Explorar o código

优化清单规则、定额库打开速度

zhongzewei %!s(int64=6) %!d(string=hai) anos
pai
achega
1dddbe7455

+ 2 - 2
modules/bills_lib/models/bills_lib_interfaces.js

@@ -1791,7 +1791,7 @@ billsLibDao.prototype.deleteBills = function(delData, callback){
 
 billsLibDao.prototype.getJobContent = function(gJobData, callback){
     let billsLibId = gJobData.billsLibId;
-    JobContent.find({billsLibId: billsLibId, deleted: false}, '-_id').sort({code: 1}).exec(function(err, result){
+    JobContent.find({billsLibId: billsLibId, deleted: false}, '-_id').lean().sort({code: 1}).exec(function(err, result){
         if(err){
             callback(1, 'Error', null);
         }
@@ -2249,7 +2249,7 @@ billsLibDao.prototype.edUpdateJob = function(data, callback){
 //----------------------ItemCharacter---------------------
 billsLibDao.prototype.getItemCharacter = function(gdata, callback){
     let billsLibId = gdata.billsLibId;
-    ItemCharacter.find({billsLibId: billsLibId, deleted: false}, '-_id').sort({code: 1}).exec(function(err, result){
+    ItemCharacter.find({billsLibId: billsLibId, deleted: false}, '-_id').lean().sort({code: 1}).exec(function(err, result){
         if(err){
             callback(1, 'Error', null);
         }

+ 3 - 3
modules/complementary_glj_lib/models/gljModel.js

@@ -79,13 +79,13 @@ class GljDao {
                    for(let i = 0, len = findCount; i < len; i++){
                        let tempStdGlj;
                        if(i === 0){
-                           tempStdGlj = await stdGljModel.find({repositoryId: stdGljLibId, deleted: null, ID: {$gte: flag}}).sort({ID: 1}).limit(500);
+                           tempStdGlj = await stdGljModel.find({repositoryId: stdGljLibId, deleted: null, ID: {$gte: flag}}).lean().sort({ID: 1}).limit(500);
                            if(tempStdGlj.length > 0){
                                flag = tempStdGlj[tempStdGlj.length - 1].ID;
                            }
                        }
                        else {
-                           tempStdGlj = await stdGljModel.find({repositoryId: stdGljLibId, deleted: null, ID: {$gt: flag}}).sort({ID: 1}).limit(500);
+                           tempStdGlj = await stdGljModel.find({repositoryId: stdGljLibId, deleted: null, ID: {$gt: flag}}).lean().sort({ID: 1}).limit(500);
                            if(tempStdGlj.length > 0){
                                flag = tempStdGlj[tempStdGlj.length - 1].ID;
                            }
@@ -104,7 +104,7 @@ class GljDao {
 
             },
             function (cb) {
-                complementaryGljModel.find({userId: userId, compilationId: compilationId}, function (err, complementaryGljs) {
+                complementaryGljModel.find({userId: userId, compilationId: compilationId}, '-_id', {lean: true}, function (err, complementaryGljs) {
                     if(err){
                         cb(err);
                     }

+ 2 - 2
modules/complementary_ration_lib/models/sectionTreeModel.js

@@ -57,9 +57,9 @@ class SectionTreeDao {
         try {
             let treeData;
             if (type === rationLibType.complementary) {
-                treeData = await compleRationSectionTreeModel.find({userId: userId, compilationId: compilationId, $or: [{deleteInfo: null}, {'deleteInfo.deleted': false}]});
+                treeData = await compleRationSectionTreeModel.find({userId: userId, compilationId: compilationId, $or: [{deleteInfo: null}, {'deleteInfo.deleted': false}]}).lean();
             } else {
-                treeData = await stdSectionTreeModel.find({rationRepId: rationRepId});
+                treeData = await stdSectionTreeModel.find({rationRepId: rationRepId}).lean();
             }
             callback(0, treeData);
         } catch (err) {

+ 2 - 2
modules/pm/models/project_model.js

@@ -66,7 +66,7 @@ ProjectsDAO.prototype.getUserProjects = async function (userId, compilation, cal
                 'compilation': compilation,
                 'deleteInfo': null
             }, {'userID': userId, 'compilation': compilation, 'deleteInfo.deleted': {'$in': [null, false]}}]
-        }, '-_id');
+        }, '-_id', {lean: true});
         let projIDs= [];
         for(let project of projects){
             if(project.projType === projectType.project){
@@ -78,7 +78,7 @@ ProjectsDAO.prototype.getUserProjects = async function (userId, compilation, cal
         for(let proj of projects){
             let summaryProj = summaryInfo[proj.ID];
             if(summaryProj){
-                proj._doc.totalCost = summaryProj.totalCost;
+                proj.totalCost = summaryProj.totalCost;
             }
         }
         callback(0, '', projects);

+ 1 - 1
modules/std_billsGuidance_lib/facade/facades.js

@@ -40,7 +40,7 @@ async function getLibWithBills(libID){
     if(!billsLib){
         throw '引用的清单规则库不存在!';
     }
-    let bills = await stdBillsModel.find({billsLibId: billsLib.billsLibId}, '-_id');
+    let bills = await stdBillsModel.find({billsLibId: billsLib.billsLibId}, '-_id').lean();
     //return {guidanceLib: guidanceLib[0], bills};
     return {bills};
 }