Browse Source

perf: 优化项目管理列表速度

vian 1 year atrás
parent
commit
0522cb5ab2
3 changed files with 146 additions and 129 deletions
  1. 1 1
      modules/all_models/projects.js
  2. 7 0
      modules/pm/facade/pm_facade.js
  3. 138 128
      modules/pm/models/project_model.js

+ 1 - 1
modules/all_models/projects.js

@@ -17,7 +17,7 @@ const shareSchema = new Schema({
 const ProjectSchema = new Schema({
     "ID": { type: Number, index: true },
     "GUID": String, // 接口需要
-    "ParentID": Number,
+    "ParentID": { type: Number, index: true },
     "NextSiblingID": Number,
     "userID": String,
     "importedByInterface": { type: Boolean, default: false },

+ 7 - 0
modules/pm/facade/pm_facade.js

@@ -1384,7 +1384,10 @@ async function getSummaryInfo(projectIDs, flagFieldMapping = null) {
             [fixedFlag.TOTAL_COST]: [{ name: 'totalCost', feeField: 'common' }], // 总造价
         };
     }
+    const date6 = Date.now();
     let projects = await projectModel.find({ ID: { $in: projectIDs }, projType: projectType.project, $or: [{ deleteInfo: null }, { 'deleteInfo.deleted': false }] });
+    const date7 = Date.now();
+    console.log('date7 - date6', date7 - date6);
     for (let project of projects) {
         IDMapping[project.ID] = { totalCost: 0 };
     }
@@ -1393,6 +1396,8 @@ async function getSummaryInfo(projectIDs, flagFieldMapping = null) {
     if (projectIDs.length > 0) {
         tenders = await projectModel.find({ ParentID: { $in: projectIDs }, projType: projectType.tender, $or: [{ deleteInfo: null }, { 'deleteInfo.deleted': false }] });
     }
+    const date8 = Date.now();
+    console.log('date8 - date7', date8 - date7);
     let tenderIDs = [];
     if (tenders.length > 0) {
         for (let tender of tenders) {
@@ -1417,6 +1422,8 @@ async function getSummaryInfo(projectIDs, flagFieldMapping = null) {
             summarizeToParent(IDMapping[tender.ParentID], IDMapping[tender.ID], flagFieldMapping);
         }
     }
+    const date9 = Date.now();
+    console.log('date9 - date8', date9 - date8);
     return IDMapping;
 }
 

+ 138 - 128
modules/pm/models/project_model.js

@@ -12,7 +12,8 @@ let fileType = {
     feeRateFile: 'FeeRateFile'
 };
 //先导出后require可以解决循环引用问题
-module.exports ={    project: new ProjectsDAO(),
+module.exports = {
+    project: new ProjectsDAO(),
     projType: projectType,
     fileType: fileType
 };
@@ -64,24 +65,24 @@ ProjectsDAO.prototype.getAllUnitProjects = async function (userId, compilation,
         let projects = await Projects.find({
             '$or': [
                 {
-                'userID': userId,
-                'compilation': compilation,
-                'property.rootProjectID': rootPrjID,
-                'deleteInfo': null
-                }, 
+                    'userID': userId,
+                    'compilation': compilation,
+                    'property.rootProjectID': rootPrjID,
+                    'deleteInfo': null
+                },
                 {
-                    'userID': userId, 
-                    'compilation': compilation, 
+                    'userID': userId,
+                    'compilation': compilation,
                     'property.rootProjectID': rootPrjID,
-                    'deleteInfo.deleted': {'$in': [null, false]}
+                    'deleteInfo.deleted': { '$in': [null, false] }
                 }
             ]
-        }, '-_id', {lean: true});
-        let projIDs= [];
+        }, '-_id', { lean: true });
+        let projIDs = [];
         const allIDs = [];
-        for(let project of projects){
+        for (let project of projects) {
             allIDs.push(project.ID);
-            if(project.projType === projectType.project){
+            if (project.projType === projectType.project) {
                 projIDs.push(project.ID);
             }
         }
@@ -91,7 +92,7 @@ ProjectsDAO.prototype.getAllUnitProjects = async function (userId, compilation,
             project.shareInfo = shareMap[project.ID] || [];
         });
         // 当前费用定额未读的分享的条目数量
-        
+
         // 设置汇总字段
         let summaryInfo = await pmFacade.getSummaryInfo(projIDs);
         pmFacade.setupSummaryFields(summaryInfo, projects);
@@ -104,30 +105,39 @@ ProjectsDAO.prototype.getAllUnitProjects = async function (userId, compilation,
 
 ProjectsDAO.prototype.getUserProjects = async function (userId, compilation, callback) {
     try {//
+        const date1 = Date.now();
         let projects = await Projects.find({
             '$or': [{
                 'userID': userId,
                 'compilation': compilation,
                 'deleteInfo': null
-            }, {'userID': userId, 'compilation': compilation, 'deleteInfo.deleted': {'$in': [null, false]}}]
-        }, '-_id', {lean: true});
+            }, { 'userID': userId, 'compilation': compilation, 'deleteInfo.deleted': { '$in': [null, false] } }]
+        }, '-_id', { lean: true });
+        const date2 = Date.now();
+        console.log('date2 - date1', date2 - date1);
         await pmFacade.checkFiles(projects);
-        let projIDs= [];
+        const date3 = Date.now();
+        console.log('date3 - date2', date3 - date2);
+        let projIDs = [];
         const allIDs = [];
-        for(let project of projects){
+        for (let project of projects) {
             allIDs.push(project.ID);
-            if(project.projType === projectType.project){
+            if (project.projType === projectType.project) {
                 projIDs.push(project.ID);
             }
         }
         // 设置分享信息 
         const shareMap = await pmFacade.getShareInfoMap(allIDs);
+        const date4 = Date.now();
+        console.log('date4 - date3', date4 - date3);
         projects.forEach(project => {
             project.shareInfo = shareMap[project.ID] || [];
         });
         //设置汇总字段
         let summaryInfo = await pmFacade.getSummaryInfo(projIDs);
         pmFacade.setupSummaryFields(summaryInfo, projects);
+        const date5 = Date.now();
+        console.log('date5 - date4', date5 - date4);
         /* for(let proj of projects){
             let summaryProj = summaryInfo[proj.ID];
             if(summaryProj){
@@ -143,7 +153,7 @@ ProjectsDAO.prototype.getUserProjects = async function (userId, compilation, cal
 };
 
 ProjectsDAO.prototype.getUserProjectAsync = async function (userId, ProjId) {
-    let template = await Projects.findOne({$or: [{deleteInfo: null}, {'deleteInfo.deleted': false}], ID: ProjId}, '-_id');
+    let template = await Projects.findOne({ $or: [{ deleteInfo: null }, { 'deleteInfo.deleted': false }], ID: ProjId }, '-_id');
     if (template && userId !== template.userID) {
         template._doc.readOnly = true;
     }
@@ -151,12 +161,12 @@ ProjectsDAO.prototype.getUserProjectAsync = async function (userId, ProjId) {
 };
 
 ProjectsDAO.prototype.getUserProject = function (userId, ProjId, callback) {
-    Projects.findOne({$or: [{deleteInfo: null}, {'deleteInfo.deleted': false}], ID: ProjId}, '-_id', function (err, template) {
+    Projects.findOne({ $or: [{ deleteInfo: null }, { 'deleteInfo.deleted': false }], ID: ProjId }, '-_id', function (err, template) {
         if (err) {
             callback(1, '找不到标段数据', null);
         } else {
             //打开分享的项目,只读
-            if(template && userId !== template.userID){
+            if (template && userId !== template.userID) {
                 template._doc.readOnly = true;
             }
 
@@ -186,19 +196,19 @@ ProjectsDAO.prototype.updateUserProjects = async function (userId, compilationId
                 data.updateData.name = data.updateData.name.trim();
             }
             if (data.updateType === 'update') {
-                Projects.update({userID: userId, ID: data.updateData.ID}, data.updateData, updateAll);
+                Projects.update({ userID: userId, ID: data.updateData.ID }, data.updateData, updateAll);
             }
             else if (data.updateType === 'new') {
                 let overWrite;
-                if(compilation.overWriteUrl && compilation.overWriteUrl!=""){
-                    overWrite = require("../../.."+compilation.overWriteUrl);
+                if (compilation.overWriteUrl && compilation.overWriteUrl != "") {
+                    overWrite = require("../../.." + compilation.overWriteUrl);
                 }
                 data.updateData.GUID = uuidV1();
                 data.updateData['userID'] = userId;
                 data.updateData['compilation'] = compilationId;
                 data.updateData['createDateTime'] = new Date();
                 data.updateData['fileVer'] = await index.getVersion();
-                if(data.updateData.projType === projectType.project){
+                if (data.updateData.projType === projectType.project) {
                     //设置建设项目基本信息,多个单位工程共用
                     const fileKind = data.updateData.property.boqType;
                     if (fileKind) {
@@ -220,7 +230,7 @@ ProjectsDAO.prototype.updateUserProjects = async function (userId, compilationId
                         user_id: userId,
                         root_project_id: data.updateData.property.rootProjectID
                     };
-                    if(overWrite && overWrite.getDefalutAssistProductionFeeRate) insertData.assistProductionFeeRate = overWrite.getDefalutAssistProductionFeeRate();
+                    if (overWrite && overWrite.getDefalutAssistProductionFeeRate) insertData.assistProductionFeeRate = overWrite.getDefalutAssistProductionFeeRate();
                     let addResult = await unitPriceFileModel.add(insertData);
                     if (!addResult) {
                         callback(1, '新增单价文件失败.', null);
@@ -228,11 +238,11 @@ ProjectsDAO.prototype.updateUserProjects = async function (userId, compilationId
                     }
                     data.updateData.property.unitPriceFile.id = addResult.id;
                     //新增单价文件的同时,在项目工料机和空白的单价文件中先插入机械组成物等信息
-                    await gljFacade.addMixRatioForNew(data.updateData.ID,addResult.id,data.updateData.property.engineering_id,pmFacade.getExtendData(data.updateData.property,compilation));
+                    await gljFacade.addMixRatioForNew(data.updateData.ID, addResult.id, data.updateData.property.engineering_id, pmFacade.getExtendData(data.updateData.property, compilation));
                 }
                 if (data.updateData.projType === projectType.tender) {
                     //单价文件
-                    data.updateData.property.unitPriceFile.id=parseInt(data.updateData.property.unitPriceFile.id);
+                    data.updateData.property.unitPriceFile.id = parseInt(data.updateData.property.unitPriceFile.id);
                     //小数位数
                     data.updateData.property.decimal = overWrite && overWrite.defaultDecimal || defaultDecimal;
                     //清单工程量精度
@@ -241,7 +251,7 @@ ProjectsDAO.prototype.updateUserProjects = async function (userId, compilationId
                     //basicInformation[0]['items'][1]['value'] = data.updateData.property.engineeringName || '';
                     //data.updateData.property.basicInformation = basicInformation;
                     //工程特征
-                    if(data.updateData.property.featureLibID){
+                    if (data.updateData.property.featureLibID) {
                         const matchedConstructionProject = datas.find(item => item.updateData.projType === projectType.project);
                         let constructionProjectName = '';
                         if (matchedConstructionProject) {
@@ -283,24 +293,24 @@ ProjectsDAO.prototype.updateUserProjects = async function (userId, compilationId
                         data.updateData.property.growthPeriod = 0;
                     }
                     //安装增加费
-                    if(data.updateData.property.isInstall == true || data.updateData.property.isInstall=='true'){//判断是否安装工程
-                        await installationFacade.copyInstallationFeeFromLib(data.updateData.ID,data.updateData.property.engineering_id);
+                    if (data.updateData.property.isInstall == true || data.updateData.property.isInstall == 'true') {//判断是否安装工程
+                        await installationFacade.copyInstallationFeeFromLib(data.updateData.ID, data.updateData.property.engineering_id);
                     }
                     //锁定清单
                     data.updateData.property.lockBills = false;
                     //工料机单价调整系数
                     data.updateData.property.tenderSetting = tenderSetting;
                     //书签和批注
-                    data.updateData.property.bookmarkSetting =  bookmarkSetting;
+                    data.updateData.property.bookmarkSetting = bookmarkSetting;
                 }
 
                 newProject = new Projects(data.updateData);
-               /* // 查找同级是否存在同名数据
-                let exist = await this.isExist(userId, compilationId, data.updateData.name, data.updateData.ParentID);
-                if (exist) {
-                    callback(1, '同级目录已存在相同名称数据.', null);
-                    return;
-                }*/
+                /* // 查找同级是否存在同名数据
+                 let exist = await this.isExist(userId, compilationId, data.updateData.name, data.updateData.ParentID);
+                 if (exist) {
+                     callback(1, '同级目录已存在相同名称数据.', null);
+                     return;
+                 }*/
                 if (data.updateData.projType === 'Tender') {
                     let feeRateFileID = await feeRateFacade.newFeeRateFile(userId, data.updateData);
                     newProject.property.feeFile = feeRateFileID ? feeRateFileID : -1;
@@ -378,7 +388,7 @@ ProjectsDAO.prototype.updateUserProjects = async function (userId, compilationId
 };
 
 ProjectsDAO.prototype.udpateUserFiles = async function (userId, datas, callback) {
-    let updateType = {update: 'update', delete: 'delete'};
+    let updateType = { update: 'update', delete: 'delete' };
     let deleteInfo = Object.create(null);
     deleteInfo.deleted = true;
     deleteInfo.deleteBy = userId;
@@ -387,26 +397,26 @@ ProjectsDAO.prototype.udpateUserFiles = async function (userId, datas, callback)
         for (let i = 0, len = datas.length; i < len; i++) {
             let data = datas[i];
             if (data.updateType === updateType.update && data.fileType === fileType.unitPriceFile) {
-                await UnitPriceFiles.update({user_id: userId, id: parseInt(data.updateData.id)}, data.updateData);
+                await UnitPriceFiles.update({ user_id: userId, id: parseInt(data.updateData.id) }, data.updateData);
                 await Projects.update({
                     userID: userId,
                     'property.unitPriceFile.id': data.updateData.id
-                }, {$set: {'property.unitPriceFile.name': data.updateData.name}}, {multi: true});
+                }, { $set: { 'property.unitPriceFile.name': data.updateData.name } }, { multi: true });
             }
             else if (data.updateType === updateType.update && data.fileType === fileType.feeRateFile) {
-                await FeeRateFiles.update({ID: data.updateData.ID}, data.updateData);
+                await FeeRateFiles.update({ ID: data.updateData.ID }, data.updateData);
                 await Projects.update({
                     userID: userId,
                     'property.feeFile.id': data.updateData.ID
-                }, {$set: {'property.feeFile.name': data.updateData.name}}, {multi: true});
+                }, { $set: { 'property.feeFile.name': data.updateData.name } }, { multi: true });
             }
             else if (data.updateType === updateType.delete && data.fileType === fileType.unitPriceFile) {
                 data.updateData.deleteInfo = deleteInfo;
-                await UnitPriceFiles.update({user_id: userId, id: parseInt(data.updateData.id)}, data.updateData);
+                await UnitPriceFiles.update({ user_id: userId, id: parseInt(data.updateData.id) }, data.updateData);
             }
             else if (data.updateType === updateType.delete && data.fileType === fileType.feeRateFile) {
                 data.updateData.deleteInfo = deleteInfo;
-                await FeeRateFiles.update({ID: data.updateData.ID}, data.updateData);
+                await FeeRateFiles.update({ ID: data.updateData.ID }, data.updateData);
             }
             else throw '未知文件类型,删除失败'
         }
@@ -434,7 +444,7 @@ ProjectsDAO.prototype.copyUserProjects = function (userId, compilationId, datas,
         for (i = 0; i < datas.length && !hasError; i++) {
             data = datas[i];
             if (data.updateType === 'update') {
-                Projects.update({userID: userId, ID: data.updateData.ID}, data.updateData, updateAll)
+                Projects.update({ userID: userId, ID: data.updateData.ID }, data.updateData, updateAll)
             } else if (data.updateType === 'copy') {
                 console.log(userId);
                 data.updateData['userID'] = userId;
@@ -468,13 +478,13 @@ ProjectsDAO.prototype.rename = async function (userId, compilationId, data, call
         }
         data.newName = data.newName.trim();
         //重名前端控制
-       /* // 查找同级是否存在同名数据
-        let exist = await this.isExist(userId, compilationId, data.newName, data.parentID);
-        if (exist) {
-            throw '同级目录已存在相同名称数据';
-        }*/
+        /* // 查找同级是否存在同名数据
+         let exist = await this.isExist(userId, compilationId, data.newName, data.parentID);
+         if (exist) {
+             throw '同级目录已存在相同名称数据';
+         }*/
 
-        Projects.update({userID: userId, ID: data.id}, {name: data.newName}, function (err) {
+        Projects.update({ userID: userId, ID: data.id }, { name: data.newName }, function (err) {
             if (err) {
                 throw '项目不存在';
             }
@@ -488,7 +498,7 @@ ProjectsDAO.prototype.rename = async function (userId, compilationId, data, call
 
 ProjectsDAO.prototype.beforeOpenProject = function (userId, projectId, updateData, callback) {
     updateData['recentDateTime'] = new Date();
-    Projects.update({userID: userId, ID: projectId}, updateData, function (err) {
+    Projects.update({ userID: userId, ID: projectId }, updateData, function (err) {
         if (err) {
             callback(1, '项目不存在.');
         } else {
@@ -502,7 +512,7 @@ ProjectsDAO.prototype.getNewProjectID = function (count, callback) {
         console.log(result);
         let highID = result.sequence_value;
         if (!err) {
-            callback(0, '', {lowID: highID - count + 1, highID: highID});
+            callback(0, '', { lowID: highID - count + 1, highID: highID });
         } else {
             callback(1, '获取主键失败', null);
         }
@@ -511,7 +521,7 @@ ProjectsDAO.prototype.getNewProjectID = function (count, callback) {
 
 ProjectsDAO.prototype.getProject = function (key, callback) {
     if (callback) {
-        Projects.findOne({'_id': key}, function (err, result) {
+        Projects.findOne({ '_id': key }, function (err, result) {
             if (err) {
                 callback(1, '查找标段失败');
             } else {
@@ -519,12 +529,12 @@ ProjectsDAO.prototype.getProject = function (key, callback) {
             }
         });
     } else {
-        return Projects.findOne({$or: [{deleteInfo: null}, {'deleteInfo.deleted': false}], 'ID': key}).exec();
+        return Projects.findOne({ $or: [{ deleteInfo: null }, { 'deleteInfo.deleted': false }], 'ID': key }).exec();
     }
 };
 
 ProjectsDAO.prototype.getProjectsByIds = async function (userId, compilationId, ids) {
-    return await Projects.find({userID: userId, compilation: compilationId, ID: {$in: ids}}, '-_id -property');
+    return await Projects.find({ userID: userId, compilation: compilationId, ID: { $in: ids } }, '-_id -property');
 };
 
 ProjectsDAO.prototype.getGCFiles = async function (fileType, userID) {
@@ -546,13 +556,13 @@ ProjectsDAO.prototype.getGCFiles = async function (fileType, userID) {
         }
         if (!isExist) throw '不存在此项目类型!';
         rst = await Projects.find(
-            {userID: userID, projType: fileType, 'deleteInfo.deleted': true, '$or': [{'deleteInfo.completeDeleted': false}, {'deleteInfo.completeDeleted': null}]});
+            { userID: userID, projType: fileType, 'deleteInfo.deleted': true, '$or': [{ 'deleteInfo.completeDeleted': false }, { 'deleteInfo.completeDeleted': null }] });
     }
     return rst;
 };
 
 ProjectsDAO.prototype.getFirstNodeID = async function (userID, compilationId, pid) {
-    let nodes = await Projects.find({userID: userID, compilation: compilationId, ParentID: pid, deleteInfo: null});
+    let nodes = await Projects.find({ userID: userID, compilation: compilationId, ParentID: pid, deleteInfo: null });
     if (nodes.length === 0) {
         return -1;
     }
@@ -596,10 +606,10 @@ ProjectsDAO.prototype.recGC = async function (userID, compilationId, datas, call
             }
         } else {
             if (datas[i].updateType === projectType.project && datas[i].updateData.NextSiblingID === undefined) {//则为待查询NextSiblingID,前端无法查询
-                let projData = await Projects.find({userID: userID, ID: datas[i].findData.ID});//建设项目原本可能属于某文件夹、文件夹的存在需要判断
+                let projData = await Projects.find({ userID: userID, ID: datas[i].findData.ID });//建设项目原本可能属于某文件夹、文件夹的存在需要判断
                 let projPid = projData[0].ParentID;
                 if (projPid !== -1) {
-                    let projFolder = await Projects.find({userID: userID, ID: projPid});
+                    let projFolder = await Projects.find({ userID: userID, ID: projPid });
                     if (projFolder.length === 0) {//文件夹已不存在
                         projPid = -1;
                         datas[i].updateData.ParentID = -1;
@@ -613,43 +623,43 @@ ProjectsDAO.prototype.recGC = async function (userID, compilationId, datas, call
     }
     for (let i = 0, len = updateDatas.length; i < len; i++) {
         functions.push((function (data) {
-                return function (cb) {
-                    if (data.updateType === fileType.unitPriceFile) {
-                        UnitPriceFiles.update({id: parseInt(data.findData.id)}, data.updateData, function (err) {
-                            if (err) cb(err);
-                            else {
-                                Projects.update({
-                                    userID: userID,
-                                    'property.unitPriceFile.id': data.findData.id
-                                }, {$set: {'property.unitPriceFile.name': data.updateData.name}}, function (err) {
-                                    if (err) cb(err);
-                                    else cb(false);
-                                });
-                            }
-                        })
-                    } else if (data.updateType === fileType.feeRateFile) {
-                        FeeRateFiles.update(data.findData, data.updateData, function (err) {
-                            if (err) cb(err);
-                            else {
-                                Projects.update({
-                                    userID: userID,
-                                    'property.feeFile.id': data.findData.ID
-                                }, {$set: {'property.feeFile.name': data.updateData.name}}, function (err) {
-                                    if (err) cb(err);
-                                    else cb(false);
-                                });
-                            }
-                        });
-                    } else {
-                        if (data) {
-                            Projects.update(data.findData, data.updateData, function (err) {
+            return function (cb) {
+                if (data.updateType === fileType.unitPriceFile) {
+                    UnitPriceFiles.update({ id: parseInt(data.findData.id) }, data.updateData, function (err) {
+                        if (err) cb(err);
+                        else {
+                            Projects.update({
+                                userID: userID,
+                                'property.unitPriceFile.id': data.findData.id
+                            }, { $set: { 'property.unitPriceFile.name': data.updateData.name } }, function (err) {
+                                if (err) cb(err);
+                                else cb(false);
+                            });
+                        }
+                    })
+                } else if (data.updateType === fileType.feeRateFile) {
+                    FeeRateFiles.update(data.findData, data.updateData, function (err) {
+                        if (err) cb(err);
+                        else {
+                            Projects.update({
+                                userID: userID,
+                                'property.feeFile.id': data.findData.ID
+                            }, { $set: { 'property.feeFile.name': data.updateData.name } }, function (err) {
                                 if (err) cb(err);
                                 else cb(false);
                             });
                         }
+                    });
+                } else {
+                    if (data) {
+                        Projects.update(data.findData, data.updateData, function (err) {
+                            if (err) cb(err);
+                            else cb(false);
+                        });
                     }
                 }
-            })(updateDatas[i]));
+            }
+        })(updateDatas[i]));
     }
     async_c.parallel(functions, function (err, results) {
         if (err) callback(err, 'fail', null);
@@ -673,7 +683,7 @@ ProjectsDAO.prototype.isExist = async function (userId, compilationId, name, par
         compilation: compilationId,
         ParentID: parentID,
         name: name,
-        "$or": [{deleteInfo: null}, {"deleteInfo.deleted": false}]
+        "$or": [{ deleteInfo: null }, { "deleteInfo.deleted": false }]
     };
     let count = await Projects.count(condition);
     return count > 0;
@@ -688,7 +698,7 @@ ProjectsDAO.prototype.isExist = async function (userId, compilationId, name, par
 ProjectsDAO.prototype.getTenderByProjectId = async function (projectId) {
     let result = [];
     // 首先获取对应的单位工程id
-    let engineeringData = await Projects.find({ParentID: projectId});
+    let engineeringData = await Projects.find({ ParentID: projectId });
     if (engineeringData.length <= 0) {
         return result;
     }
@@ -699,7 +709,7 @@ ProjectsDAO.prototype.getTenderByProjectId = async function (projectId) {
     }
 
     // 查找对应的单位工程id
-    let tenderData = await Projects.find({ParentID: {$in: engineeringIdList},deleteInfo: null});
+    let tenderData = await Projects.find({ ParentID: { $in: engineeringIdList }, deleteInfo: null });
     if (tenderData.length <= 0) {
         return result;
     }
@@ -726,8 +736,8 @@ ProjectsDAO.prototype.getTenderByUnitPriceFileId = async function (unitPriceFile
     }
 
     //let condition = {projType: 'Tender', "property.unitPriceFile.id": unitPriceFileId};
-    let condition = {"property.unitPriceFile.id": unitPriceFileId,deleteInfo:null};
-    result = await Projects.find(condition,['ID','name','property']);
+    let condition = { "property.unitPriceFile.id": unitPriceFileId, deleteInfo: null };
+    result = await Projects.find(condition, ['ID', 'name', 'property']);
 
     return result;
 };
@@ -740,7 +750,7 @@ ProjectsDAO.prototype.getTenderByUnitPriceFileId = async function (unitPriceFile
  */
 ProjectsDAO.prototype.getProjectProperty = async function (projectId) {
     let result = null;
-    let projectData = await Projects.findOne({ID: projectId},['property']);
+    let projectData = await Projects.findOne({ ID: projectId }, ['property']);
     if (projectData === null) {
         return result;
     }
@@ -753,13 +763,13 @@ ProjectsDAO.prototype.getProjectProperty = async function (projectId) {
  * @paraconsolem {Number} userId
  * @return {Promise}
  */
-ProjectsDAO.prototype.getUserProjectData = async function (userId,compilation) {
+ProjectsDAO.prototype.getUserProjectData = async function (userId, compilation) {
     let projectList = await Projects.find({
         '$or': [
-            {'userID': userId, 'compilation': compilation, 'deleteInfo': null, projType: 'Project'},
-            {'userID': userId, 'compilation': compilation,'deleteInfo.deleted': {'$in': [null, false]}, projType: 'Project'}
+            { 'userID': userId, 'compilation': compilation, 'deleteInfo': null, projType: 'Project' },
+            { 'userID': userId, 'compilation': compilation, 'deleteInfo.deleted': { '$in': [null, false] }, projType: 'Project' }
         ]
-    }, {_id: 0, name: 1, ID: 1, NextSiblingID: 1, ParentID: 1});
+    }, { _id: 0, name: 1, ID: 1, NextSiblingID: 1, ParentID: 1 });
 
     return projectList;
 };
@@ -776,7 +786,7 @@ ProjectsDAO.prototype.changeUnitPriceFileInfo = async function (projectId, chang
     if (isNaN(projectId) || projectId <= 0) {
         return false;
     }
-    let result = await Projects.update({ID: projectId}, {"property.unitPriceFile": changeInfo});
+    let result = await Projects.update({ ID: projectId }, { "property.unitPriceFile": changeInfo });
 
     return result.ok === 1;
 };
@@ -789,30 +799,30 @@ ProjectsDAO.prototype.changeUnitPriceFileInfo = async function (projectId, chang
  * @param {Object} propertyData - 项目属性数据
  * @return {Promise}
  */
-ProjectsDAO.prototype.updateProjectProperty = async function(projectId, propertyData) {
+ProjectsDAO.prototype.updateProjectProperty = async function (projectId, propertyData) {
     projectId = parseInt(projectId);
     if (isNaN(projectId) || projectId <= 0 || propertyData.property === undefined || propertyData.data === undefined) {
         return false;
     }
     const updateData = {};
     updateData["property." + propertyData.property] = propertyData.data;
-    let result = await Projects.update({ID: projectId}, updateData);
+    let result = await Projects.update({ ID: projectId }, updateData);
 
     return result.ok === 1;
 };
 
 // CSL, 2018-01-11 获取指定ID节点(如单项工程、建设项目)下所有单位工程的各项汇总金额,用于报表计算汇总。
 ProjectsDAO.prototype.getSummaryFees = async function (ID) {
-    async function getProject(ID){
-        return await Projects.findOne({'ID': ID, deleteInfo: null}, need);
+    async function getProject(ID) {
+        return await Projects.findOne({ 'ID': ID, deleteInfo: null }, need);
     };
-    async function getChildrenDocs(IDs){
-        return await Projects.find({'ParentID': {"$in":IDs}, deleteInfo: null}, need);
+    async function getChildrenDocs(IDs) {
+        return await Projects.find({ 'ParentID': { "$in": IDs }, deleteInfo: null }, need);
     };
-    async function getEgrIDs(ID){
-        let _docs = await Projects.find({'ParentID': ID, deleteInfo: null}, ['ID', '-_id']);
+    async function getEgrIDs(ID) {
+        let _docs = await Projects.find({ 'ParentID': ID, deleteInfo: null }, ['ID', '-_id']);
         let arr = [];
-        for (let doc of _docs){
+        for (let doc of _docs) {
             arr.push(doc.ID);
         };
         return arr;
@@ -823,26 +833,26 @@ ProjectsDAO.prototype.getSummaryFees = async function (ID) {
     let _doc = await getProject(ID);
     if (!_doc) return _doc;
 
-    if (_doc.projType.sameText('Engineering')){
+    if (_doc.projType.sameText('Engineering')) {
         return await getChildrenDocs([ID]);
     }
-    else if (_doc.projType.sameText('Project')){
+    else if (_doc.projType.sameText('Project')) {
         let eIDs = await getEgrIDs(ID);
         return await getChildrenDocs(eIDs);
     }
-    else{
+    else {
         return _doc;
     };
 };
 
-ProjectsDAO.prototype.updateUnitFileToProject=async function(projectID,unitFile){
-    return await Projects.findOneAndUpdate({'ID':projectID},{'property.unitPriceFile':unitFile});
+ProjectsDAO.prototype.updateUnitFileToProject = async function (projectID, unitFile) {
+    return await Projects.findOneAndUpdate({ 'ID': projectID }, { 'property.unitPriceFile': unitFile });
 }
 
 ProjectsDAO.prototype.getBasicInfo = async function (projectID) {
     //获取建设项目
     let constructionProject = await pmFacade.getConstructionProject(projectID);
-    if(!constructionProject || !constructionProject.property || !constructionProject.property.basicInformation){
+    if (!constructionProject || !constructionProject.property || !constructionProject.property.basicInformation) {
         return null;
     }
     return constructionProject.property.basicInformation;
@@ -851,14 +861,14 @@ ProjectsDAO.prototype.getBasicInfo = async function (projectID) {
 //恢复默认系统设置
 ProjectsDAO.prototype.defaultSettings = async function (userID, compilation, projectID) {
     const compilationId = compilation._id;
-    let project = await Projects.findOne({ID: projectID});
-    if(!project){
+    let project = await Projects.findOne({ ID: projectID });
+    if (!project) {
         return false;
     }
     let cloneProperty = _.cloneDeep(project.property);
     let overWrite;
-    if(compilation.overWriteUrl && compilation.overWriteUrl!=""){
-        overWrite = require("../../.."+compilation.overWriteUrl);
+    if (compilation.overWriteUrl && compilation.overWriteUrl != "") {
+        overWrite = require("../../.." + compilation.overWriteUrl);
     }
     //关于计算
     let defaultCalcMode = overWrite && overWrite.defaultCalcMode || ((project.property.valuationType !== ValuationType.BOQ) ? 2 : 1);
@@ -872,12 +882,12 @@ ProjectsDAO.prototype.defaultSettings = async function (userID, compilation, pro
     //呈现选项
     cloneProperty.displaySetting = displaySetting;
     //列设置
-    let stdColLib = await mainColLibModel.findOne({ID: project.property.colLibID});
-    if(stdColLib){
-        await projSettingModel.update({projectID: projectID}, {$set: {main_tree_col: stdColLib.main_tree_col}});
+    let stdColLib = await mainColLibModel.findOne({ ID: project.property.colLibID });
+    if (stdColLib) {
+        await projSettingModel.update({ projectID: projectID }, { $set: { main_tree_col: stdColLib.main_tree_col } });
     }
     //系统选项
-    await optionModel.update({user_id: userID, compilation_id: compilationId}, {$set: {options: optionSetting}});
-    await Projects.update({ID: projectID}, {$set: {property: cloneProperty}});
+    await optionModel.update({ user_id: userID, compilation_id: compilationId }, { $set: { options: optionSetting } });
+    await Projects.update({ ID: projectID }, { $set: { property: cloneProperty } });
     return true;
 };