| 
					
				 | 
			
			
				@@ -5,7 +5,14 @@ import mongoose from 'mongoose'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import async_c from 'async'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import UnitPriceFileModel from "../../glj/models/unit_price_file_model"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import UnitPriceFiles from '../../glj/models/schemas/unit_price_file'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import {defaultDecimal, billsQuantityDecimal, basicInformation, projectFeature,displaySetting} from './project_property_template'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    defaultDecimal, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    billsQuantityDecimal, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    basicInformation, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    projectFeature, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    displaySetting, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    calcOptions 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} from './project_property_template'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import fixedFlag from '../../common/const/bills_fixed'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 let FeeRateFiles = mongoose.model('fee_rate_file'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 let counter = require("../../../public/counter/counter.js"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -30,25 +37,36 @@ let fileType = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     feeRateFile: 'FeeRateFile' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-let ProjectsDAO = function(){}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+let ProjectsDAO = function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-ProjectsDAO.prototype.getUserProjects = async function(userId, compilation, callback){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ProjectsDAO.prototype.getUserProjects = async function (userId, compilation, callback) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        let projects = await Projects.find({'$or': [{'userID': userId, 'compilation': compilation, 'deleteInfo': null}, {'userID': userId, 'compilation': compilation, 'deleteInfo.deleted': {'$in': [null, false]}}]}, '-_id'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for(let i = 0 , len = projects.length; i < len; i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let projects = await Projects.find({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            '$or': [{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                'userID': userId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                'compilation': compilation, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                'deleteInfo': null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }, {'userID': userId, 'compilation': compilation, 'deleteInfo.deleted': {'$in': [null, false]}}] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, '-_id'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (let i = 0, len = projects.length; i < len; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let proj = projects[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            let engineeringCost = await BillsModel.find({projectID: proj.ID, 'flags.flag': fixedFlag.ENGINEERINGCOST, 'fees.totalFee': {$exists:  true}}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let engineeringCost = await BillsModel.find({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                projectID: proj.ID, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                'flags.flag': fixedFlag.ENGINEERINGCOST, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                'fees.totalFee': {$exists: true} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             proj._doc.engineeringCost = engineeringCost.length > 0 ? engineeringCost[0].fees[0].totalFee : 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         callback(0, '', projects); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    catch (err){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    catch (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         callback(1, 'Error', null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 ProjectsDAO.prototype.getUserProject = function (userId, ProjId, callback) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Projects.findOne({userID: userId, ID: ProjId}, '-_id', function(err, template){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    Projects.findOne({userID: userId, ID: ProjId}, '-_id', function (err, template) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             callback(1, '找不到标段数据', null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -57,22 +75,22 @@ ProjectsDAO.prototype.getUserProject = function (userId, ProjId, callback) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-ProjectsDAO.prototype.updateUserProjects = async function(userId, compilationId, datas, callback){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ProjectsDAO.prototype.updateUserProjects = async function (userId, compilationId, datas, callback) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let data, project, updateLength = 0, hasError = false, deleteInfo = null, i, newProject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let updateAll = function (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (!err){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                updateLength += 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (updateLength === datas.length) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    callback(0, '', datas); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                hasError = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                console.log(err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                callback(1, '提交数据出错.', null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            updateLength += 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (updateLength === datas.length) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                callback(0, '', datas); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if (datas){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for (i = 0; i < datas.length && !hasError; i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            hasError = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            console.log(err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            callback(1, '提交数据出错.', null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (datas) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (i = 0; i < datas.length && !hasError; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             data = datas[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (data.updateData.name !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 data.updateData.name = data.updateData.name.trim(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -103,7 +121,7 @@ ProjectsDAO.prototype.updateUserProjects = async function(userId, compilationId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     data.updateData.property.unitPriceFile.id = addResult.id; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(data.updateData.projType === projectType.tender){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (data.updateData.projType === projectType.tender) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     //小数位数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     data.updateData.property.decimal = defaultDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     //清单工程量精度 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -114,10 +132,13 @@ ProjectsDAO.prototype.updateUserProjects = async function(userId, compilationId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     //工程特征 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     data.updateData.property.projectFeature = projectFeature; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     //呈现选项 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		    data.updateData.property.displaySetting = displaySetting; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    data.updateData.property.displaySetting = displaySetting; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     data.updateData.property.billsCalcMode = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		    data.updateData.property.zanguCalcMode = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    data.updateData.property.zanguCalcMode = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //计算选项 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    data.updateData.property.calcOptions = calcOptions 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 newProject = new Projects(data.updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 查找同级是否存在同名数据 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -126,9 +147,9 @@ ProjectsDAO.prototype.updateUserProjects = async function(userId, compilationId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     callback(1, '同级目录已存在相同名称数据.', null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(data.updateData.projType==='Tender'){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    let  feeRateFileID = await feeRateFacade.newFeeRateFile(userId, data.updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    newProject.property.feeFile = feeRateFileID?feeRateFileID:-1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (data.updateData.projType === 'Tender') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    let feeRateFileID = await feeRateFacade.newFeeRateFile(userId, data.updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    newProject.property.feeFile = feeRateFileID ? feeRateFileID : -1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // 新建人工系数文件 CSL, 2017.10.13 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     let lcFile = await labourCoeFacade.newProjectLabourCoe(data.updateData); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -153,22 +174,28 @@ ProjectsDAO.prototype.updateUserProjects = async function(userId, compilationId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 data.updateData['deleteInfo'] = deleteInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //Projects.update({userID: userId, ID: data.updateData.ID}, data.updateData, updateAll); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //update 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                try{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if(data.updateData.projType === projectType.project){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (data.updateData.projType === projectType.project) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         let engineerings = await Projects.find({userID: userId, ParentID: data.updateData.ID}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         let isExist = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if(engineerings.length > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            for(let j = 0, jLen = engineerings.length; j < jLen; j++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (engineerings.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            for (let j = 0, jLen = engineerings.length; j < jLen; j++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 let e_tenders = await Projects.find({userID: userId, ParentID: engineerings[j].ID}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                if(e_tenders.length > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if (e_tenders.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     isExist = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if(isExist){//fake 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            await UnitPriceFiles.update({user_id: userId, root_project_id: data.updateData.ID}, {$set: {deleteInfo: deleteInfo}}, {multi: true}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            await FeeRateFiles.update({userID: userId, rootProjectID: data.updateData.ID}, {$set: {deleteInfo: deleteInfo}}, {multi: true}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (isExist) {//fake 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            await UnitPriceFiles.update({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                user_id: userId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                root_project_id: data.updateData.ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            }, {$set: {deleteInfo: deleteInfo}}, {multi: true}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            await FeeRateFiles.update({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                userID: userId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                rootProjectID: data.updateData.ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            }, {$set: {deleteInfo: deleteInfo}}, {multi: true}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             await Projects.update({userID: userId, ID: data.updateData.ID}, data.updateData, updateAll); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         else {//true 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -178,9 +205,9 @@ ProjectsDAO.prototype.updateUserProjects = async function(userId, compilationId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             await Projects.remove({userID: userId, ID: data.updateData.ID}, updateAll); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    else if(data.updateData.projType === projectType.engineering){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    else if (data.updateData.projType === projectType.engineering) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         let tenders = await Projects.find({userID: userId, ParentID: data.updateData.ID}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if(tenders.length > 0){//fake 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (tenders.length > 0) {//fake 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             await Projects.update({userID: userId, ID: data.updateData.ID}, data.updateData, updateAll); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         else {//true 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -188,15 +215,15 @@ ProjectsDAO.prototype.updateUserProjects = async function(userId, compilationId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             await Projects.remove({userID: userId, ID: data.updateData.ID}, updateAll); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    else if(data.updateData.projType === projectType.tender){//fake 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    else if (data.updateData.projType === projectType.tender) {//fake 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         await Projects.update({userID: userId, ID: data.updateData.ID}, data.updateData, updateAll); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    else if(data.updateData.projType === projectType.folder){//true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    else if (data.updateData.projType === projectType.folder) {//true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         await Projects.remove({userID: userId, ID: data.updateData.ID}, updateAll); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     else throw '未知文件类型,删除失败!'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                catch (error){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                catch (error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     callback(1, error, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -208,29 +235,38 @@ ProjectsDAO.prototype.updateUserProjects = async function(userId, compilationId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-ProjectsDAO.prototype.udpateUserFiles = async function (userId, datas, callback){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ProjectsDAO.prototype.udpateUserFiles = async function (userId, datas, callback) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let updateType = {update: 'update', delete: 'delete'}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let deleteInfo = Object.create(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     deleteInfo.deleted = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     deleteInfo.deleteBy = userId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     deleteInfo.deleteDateTime = new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    try{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for(let i = 0, len = datas.length; i < len; i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (let i = 0, len = datas.length; i < len; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let data = datas[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(data.updateType === updateType.update && data.fileType === fileType.unitPriceFile){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (data.updateType === updateType.update && data.fileType === fileType.unitPriceFile) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 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}}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await Projects.update({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    userID: userId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    'property.unitPriceFile.id': data.updateData.id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }, {$set: {'property.unitPriceFile.name': data.updateData.name}}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            else if(data.updateType === updateType.update && data.fileType === fileType.feeRateFile){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (data.updateType === updateType.update && data.fileType === fileType.feeRateFile) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await FeeRateFiles.update({userID: userId, ID: data.updateData.ID}, data.updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                await Projects.update({userID: userId, 'property.feeFile.id': data.updateData.ID}, {$set: {'property.feeFile.name': data.updateData.name}}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await Projects.update({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    userID: userId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    'property.feeFile.id': data.updateData.ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }, {$set: {'property.feeFile.name': data.updateData.name}}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            else if(data.updateType === updateType.delete && data.fileType === fileType.unitPriceFile){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            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 Projects.update({userID: userId, 'property.feeFile.id': data.updateData.id}, {$set: {'property.feeFile.name': data.updateData.name}}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await Projects.update({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    userID: userId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    'property.feeFile.id': data.updateData.id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }, {$set: {'property.feeFile.name': data.updateData.name}}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            else if(data.updateType === updateType.delete && data.fileType === fileType.feeRateFile){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (data.updateType === updateType.delete && data.fileType === fileType.feeRateFile) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 data.updateData.deleteInfo = deleteInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await FeeRateFiles.update({userID: userId, ID: data.updateData.ID}, data.updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -238,7 +274,7 @@ ProjectsDAO.prototype.udpateUserFiles = async function (userId, datas, callback) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         callback(false, '删除成功', null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    catch(error){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    catch (error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         callback(true, '删除失败', null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -246,7 +282,7 @@ ProjectsDAO.prototype.udpateUserFiles = async function (userId, datas, callback) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 ProjectsDAO.prototype.copyUserProjects = function (userId, datas, callback) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let data, project, updateLength = 0, hasError = false, deleteInfo = null, tempType = 1, i; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let updateAll = function (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (!err){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             updateLength += 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (updateLength === datas.length) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 callback(0, '', datas); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -281,7 +317,7 @@ ProjectsDAO.prototype.copyUserProjects = function (userId, datas, callback) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-ProjectsDAO.prototype.rename = async function (userId, compilationId, data, callback){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ProjectsDAO.prototype.rename = async function (userId, compilationId, data, callback) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (data.id === undefined || data.id === '') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             throw '数据错误!'; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -296,8 +332,8 @@ ProjectsDAO.prototype.rename = async function (userId, compilationId, data, call 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             throw '同级目录已存在相同名称数据'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Projects.update({userID: userId, ID: data.id}, {name: data.newName}, function(err){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (err){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Projects.update({userID: userId, ID: data.id}, {name: data.newName}, function (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 throw '项目不存在'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -308,10 +344,10 @@ ProjectsDAO.prototype.rename = async function (userId, compilationId, data, call 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     callback(0, ''); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-ProjectsDAO.prototype.beforeOpenProject = function (userId, projectId, updateData, callback){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ProjectsDAO.prototype.beforeOpenProject = function (userId, projectId, updateData, callback) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     updateData['recentDateTime'] = new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Projects.update({userID: userId, ID: projectId}, updateData, function(err){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (err){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    Projects.update({userID: userId, ID: projectId}, updateData, function (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             callback(1, '项目不存在.'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             callback(0, ''); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -344,28 +380,28 @@ ProjectsDAO.prototype.getProject = function (key, callback) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-ProjectsDAO.prototype.getProjectsByIds = async function (userId, compilationId, ids){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ProjectsDAO.prototype.getProjectsByIds = async function (userId, compilationId, ids) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return await Projects.find({userID: userId, compilation: compilationId, ID: {$in: ids}}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-ProjectsDAO.prototype.getGCFiles = async function (fileType, userID){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ProjectsDAO.prototype.getGCFiles = async function (fileType, userID) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let rst; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if(fileType === 'UnitPriceFile'){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (fileType === 'UnitPriceFile') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let unitPriceFileModel = new UnitPriceFileModel(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         rst = await unitPriceFileModel.getGCUnitPriceFiles(userID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    else if(fileType === 'FeeRateFile'){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    else if (fileType === 'FeeRateFile') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         rst = await feeRateFacade.getGCFeeRateFiles(userID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let isExist = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for(let type in projectType){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(projectType[type] === fileType) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (let type in projectType) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (projectType[type] === fileType) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 isExist = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if(!isExist) throw '不存在此项目类型!'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!isExist) throw '不存在此项目类型!'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         rst = await Projects.find({userID: userID, projType: fileType, 'deleteInfo.deleted': true}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return rst; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -373,55 +409,55 @@ ProjectsDAO.prototype.getGCFiles = async function (fileType, userID){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 ProjectsDAO.prototype.getFirstNodeID = async function (userID, pid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let nodes = await Projects.find({userID: userID, ParentID: pid, deleteInfo: null}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if(nodes.length === 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (nodes.length === 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return -1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let prefix = 'ID_'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let chain = Object.create(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for(let i = 0, len = nodes.length; i < len; i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (let i = 0, len = nodes.length; i < len; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let nodeDoc = nodes[i]._doc; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let node = Object.create(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             node.ID = nodeDoc.ID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             node.NextSiblingID = nodeDoc.NextSiblingID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             chain[prefix + node.ID] = node; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for(let i =0, len = nodes.length; i < len; i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (let i = 0, len = nodes.length; i < len; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let nodeDoc = nodes[i]._doc; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let next = nodeDoc.NextSiblingID > 0 ? chain[prefix + nodeDoc.NextSiblingID] : null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             chain[prefix + nodeDoc.ID].next = next; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(next){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (next) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 next.pre = chain[prefix + nodeDoc.ID] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for(let node in chain){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (let node in chain) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let pre = chain[node].pre || null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(!pre){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!pre) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 return chain[node].ID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-ProjectsDAO.prototype.recGC = async function(userID, datas, callback){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ProjectsDAO.prototype.recGC = async function (userID, datas, callback) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let functions = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let updateDatas = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for(let i = 0, len = datas.length; i < len; i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if(datas[i].findData.ParentID !== undefined && datas[i].findData.NextSiblingID === -1 && !datas[i].findData.deleteInfo){//维护项目管理树 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    for (let i = 0, len = datas.length; i < len; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (datas[i].findData.ParentID !== undefined && datas[i].findData.NextSiblingID === -1 && !datas[i].findData.deleteInfo) {//维护项目管理树 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let findNode = await Projects.find(datas[i].findData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(findNode.length > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (findNode.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 datas[i].findData = Object.create(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 datas[i].findData.ID = findNode[0].ID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 updateDatas.push(datas[i]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(datas[i].updateType === projectType.project && datas[i].updateData.NextSiblingID === undefined){//则为待查询NextSiblingID,前端无法查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            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 projPid = projData[0].ParentID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(projPid !== -1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (projPid !== -1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     let projFolder = await Projects.find({userID: userID, ID: projPid}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if(projFolder.length === 0){//文件夹已不存在 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (projFolder.length === 0) {//文件夹已不存在 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         projPid = -1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         datas[i].updateData.ParentID = -1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -432,45 +468,50 @@ ProjectsDAO.prototype.recGC = async function(userID, datas, callback){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             updateDatas.push(datas[i]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for(let i = 0, len = updateDatas.length; i < len; i ++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        functions.push((function(data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    for (let i = 0, len = updateDatas.length; i < len; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        functions.push((function (data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 return function (cb) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if(data.updateType === fileType.unitPriceFile){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (data.updateType === fileType.unitPriceFile) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         UnitPriceFiles.update({id: parseInt(data.findData.id)}, data.updateData, function (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            if(err) cb(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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                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){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    else if (data.updateType === fileType.feeRateFile) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         FeeRateFiles.update(data.findData, data.updateData, function (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            if(err) cb(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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                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){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             Projects.update(data.findData, data.updateData, function (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                if(err)cb(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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (err) callback(err, 'fail', null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         else callback(0, 'success', null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -481,12 +522,18 @@ ProjectsDAO.prototype.recGC = async function(userID, datas, callback){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @param {Object} data 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @return {Boolean} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-ProjectsDAO.prototype.isExist = async function(userId, compilationId, name, parentID) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ProjectsDAO.prototype.isExist = async function (userId, compilationId, name, parentID) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     parentID = parseInt(parentID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if (name === '' || isNaN(parentID)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    let condition = {userID: userId, compilation: compilationId, ParentID: parentID, name: name, "$or":[{deleteInfo: null}, {"deleteInfo.deleted": false}]}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let condition = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        userID: userId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        compilation: compilationId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ParentID: parentID, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        name: name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        "$or": [{deleteInfo: null}, {"deleteInfo.deleted": false}] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let count = await Projects.count(condition); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return count > 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -497,7 +544,7 @@ ProjectsDAO.prototype.isExist = async function(userId, compilationId, name, pare 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @param {Number} projectId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @return {Promise} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-ProjectsDAO.prototype.getTenderByProjectId = async function(projectId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ProjectsDAO.prototype.getTenderByProjectId = async function (projectId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let result = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // 首先获取对应的单位工程id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let engineeringData = await Projects.find({ParentID: projectId}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -506,7 +553,7 @@ ProjectsDAO.prototype.getTenderByProjectId = async function(projectId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let engineeringIdList = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for(let tmp of engineeringData) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    for (let tmp of engineeringData) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         engineeringIdList.push(tmp.ID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -516,7 +563,7 @@ ProjectsDAO.prototype.getTenderByProjectId = async function(projectId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for(let tmp of tenderData) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    for (let tmp of tenderData) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         result.push(tmp.ID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -529,7 +576,7 @@ ProjectsDAO.prototype.getTenderByProjectId = async function(projectId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @param {Number} unitPriceFileId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @return {Promise} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-ProjectsDAO.prototype.getTenderByUnitPriceFileId = async function(unitPriceFileId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ProjectsDAO.prototype.getTenderByUnitPriceFileId = async function (unitPriceFileId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let result = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     unitPriceFileId = parseInt(unitPriceFileId); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -549,7 +596,7 @@ ProjectsDAO.prototype.getTenderByUnitPriceFileId = async function(unitPriceFileI 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @param {Number} projectId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @return {Promise} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-ProjectsDAO.prototype.getUnitPriceFileId = async function(projectId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ProjectsDAO.prototype.getUnitPriceFileId = async function (projectId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let result = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let projectData = await Projects.findOne({ID: projectId}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if (projectData === null) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -566,12 +613,12 @@ ProjectsDAO.prototype.getUnitPriceFileId = async function(projectId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @param {Number} userId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @return {Promise} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-ProjectsDAO.prototype.getUserProjectData = async function(userId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ProjectsDAO.prototype.getUserProjectData = async function (userId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let projectList = await Projects.find({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         '$or': [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             {'userID': userId, 'deleteInfo': null, projType: 'Project'}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             {'userID': userId, 'deleteInfo.deleted': {'$in': [null, false]}, projType: 'Project'} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }, {_id: 0, name: 1, ID: 1}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return projectList; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -584,7 +631,7 @@ ProjectsDAO.prototype.getUserProjectData = async function(userId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @param {Object} changeInfo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @return {Promise} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-ProjectsDAO.prototype.changeUnitPriceFileInfo = async function(projectId, changeInfo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ProjectsDAO.prototype.changeUnitPriceFileInfo = async function (projectId, changeInfo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     projectId = parseInt(projectId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if (isNaN(projectId) || projectId <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return false; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -594,8 +641,27 @@ ProjectsDAO.prototype.changeUnitPriceFileInfo = async function(projectId, change 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return result.ok === 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-module.exports ={ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    project: new ProjectsDAO(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * 更新项目属性 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @param {Number} projectId - 项目id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @param {Object} propertyData - 项目属性数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @return {Promise} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return result.ok === 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+module.exports ={    project: new ProjectsDAO(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     projType: projectType, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     fileType: fileType 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 |