Bläddra i källkod

先发布编办后设置补充模板数据的补救相关

zhongzewei 6 år sedan
förälder
incheckning
81d38615ec
1 ändrade filer med 19 tillägg och 1 borttagningar
  1. 19 1
      modules/pm/facade/pm_facade.js

+ 19 - 1
modules/pm/facade/pm_facade.js

@@ -25,7 +25,8 @@ module.exports={
     isFirst: isFirst,
     getShareInfo: getShareInfo,
     prepareInitialData: prepareInitialData,
-    changeFile:changeFile
+    changeFile:changeFile,
+    copyForSectionError: copyForSectionError,
 };
 
 
@@ -903,6 +904,23 @@ async function updateUsedList(userId, compilation) {
 async function copyCompleRationSection(userId, compilationId) {
     await sectionTreeDao.copyDataFromTemplate(userId, compilationId);
 }
+
+/*
+ * 解决问题:
+ * 发布了编办之后,才设置了人材机库模板,导致已登录的用户不存在人材机库的分类树
+ * 为该编办下,人材机分类模板为空的用户,拷贝模板数据
+ * */
+async function copyForSectionError(compilation) {
+    let users = await userModel.find({}, '_id');
+    for (let user of users) {
+        let userId = user._id.toString();
+        let existCount = await compleGljSectionModel.find({userId}).count();
+        if (existCount === 0) {
+            await copyCompleGljSection(userId, compilation);
+        }
+    }
+}
+
 //拷贝补充人材机分类树
 async function copyCompleGljSection(userId, compilationId) {
     let templateData = await compleGljSectionTModel.find({compilationId: compilationId});