Browse Source

拷贝工程允许人工系数、计算程序、费率、单价文件为空

zhongzewei 7 years ago
parent
commit
be91d4895b
2 changed files with 33 additions and 9 deletions
  1. 9 1
      modules/all_models/std_glj.js
  2. 24 8
      modules/pm/facade/pm_facade.js

+ 9 - 1
modules/all_models/std_glj.js

@@ -8,7 +8,11 @@ const Schema = mongoose.Schema;
 const std_gljComponent = new Schema(
     {
         ID: Number,
-        consumeAmt: Number
+        consumeAmt: Number,
+        consumeAmtProperties: {
+            type: Schema.Types.Mixed,
+            default: {}
+        }
     },
     {_id: false},
     {versionKey: false}
@@ -22,6 +26,10 @@ const std_glj = new Schema({
     name: String,
     specs: String,
     basePrice: Number,
+    basePriceProperties: {
+        type: Schema.Types.Mixed,
+        default: {}
+    },
     gljClass: Number,
     gljType: Number,
     model: Number,// 机型

+ 24 - 8
modules/pm/facade/pm_facade.js

@@ -81,10 +81,18 @@ async function copyProject(userID, compilationID,data) {
 
     //更新项目的属性;
     projectMap['copy'].document.ID = newProjectID;
-    projectMap['copy'].document.property.calcProgramFile.ID = calcProgramFileID;
-    projectMap['copy'].document.property.labourCoeFile.ID = labourCoeFileID;
-    projectMap['copy'].document.property.feeFile.id = feeRateFileID;
-    projectMap['copy'].document.property.unitPriceFile.id = unitPriceFileID;
+    if(projectMap['copy'].document.property.calcProgramFile){
+        projectMap['copy'].document.property.calcProgramFile.ID = calcProgramFileID;
+    }
+    if(projectMap['copy'].document.property.labourCoeFile){
+        projectMap['copy'].document.property.labourCoeFile.ID = labourCoeFileID;
+    }
+    if(projectMap['copy'].document.property.feeFile){
+        projectMap['copy'].document.property.feeFile.id = feeRateFileID;
+    }
+    if(projectMap['copy'].document.property.unitPriceFile){
+        projectMap['copy'].document.property.unitPriceFile.id = unitPriceFileID;
+    }
     projectMap['copy'].document.userID = userID;
     projectMap['copy'].document.compilation = compilationID;
     projectMap['copy'].document.createDateTime = new Date();
@@ -104,16 +112,24 @@ async function copyProject(userID, compilationID,data) {
         copyBills(newProjectID,billMap),
         copyRations(newProjectID,billMap.uuidMaping,rationMap,projectGLJMap.IDMap),
         copyProjectGLJ(projectGLJMap.datas),
-        commonCopy(newProjectID,originalProperty.calcProgramFile.ID,calcProgramFileID,calcProgramsModel),
-        commonCopy(newProjectID,originalProperty.labourCoeFile.ID,labourCoeFileID,labourCoesModel),
-        copyFeeRate(originalProperty.rootProjectID,userID,originalProperty.feeFile.id,feeRateFileID,newFeeName),
-        copyUnitPriceFile(newProjectID,originalProperty.rootProjectID,userID,originalProperty.unitPriceFile.id,unitPriceFileID,newUnitName),
         copyInstallFee(originalID,newProjectID),
         copyRationSubList(originalID,newProjectID,billMap.uuidMaping,rationMap.uuidMaping,projectGLJMap.IDMap,rationGLJModel),
         copyRationSubList(originalID,newProjectID,billMap.uuidMaping,rationMap.uuidMaping,projectGLJMap.IDMap,rationCoeModel),
         copyRationSubList(originalID,newProjectID,billMap.uuidMaping,rationMap.uuidMaping,projectGLJMap.IDMap,quantityDetailModel),
         copyRationSubList(originalID,newProjectID,billMap.uuidMaping,rationMap.uuidMaping,projectGLJMap.IDMap,rationInstallationModel)
     ];
+    if(originalProperty.calcProgramFile){
+        copyTasks.push(commonCopy(newProjectID,originalProperty.calcProgramFile.ID,calcProgramFileID,calcProgramsModel));
+    }
+    if(originalProperty.labourCoeFile){
+        copyTasks.push(commonCopy(newProjectID,originalProperty.labourCoeFile.ID,labourCoeFileID,labourCoesModel));
+    }
+    if(originalProperty.feeFile){
+        copyTasks.push(copyFeeRate(originalProperty.rootProjectID,userID,originalProperty.feeFile.id,feeRateFileID,newFeeName));
+    }
+    if(originalProperty.unitPriceFile){
+        copyTasks.push(copyUnitPriceFile(newProjectID,originalProperty.rootProjectID,userID,originalProperty.unitPriceFile.id,unitPriceFileID,newUnitName));
+    }
     let p = await Promise.all(copyTasks);
     return p[0];
 }