Quellcode durchsuchen

fix: 导入导出ybp时,处理费用汇总数据

vian vor 4 Jahren
Ursprung
Commit
a8633164d7
1 geänderte Dateien mit 29 neuen und 5 gelöschten Zeilen
  1. 29 5
      modules/pm/facade/pm_facade.js

+ 29 - 5
modules/pm/facade/pm_facade.js

@@ -109,6 +109,7 @@ const shareListModel = mongoose.model('share_list');
 const shareLibModel = mongoose.model('share_libs');
 let welcomeModel = mongoose.model("welcome_setting");
 let equipmentPurchaseModel = mongoose.model('equipment_purchase');
+const gaterFeeModel = mongoose.model('gather_calc_programs');
 
 
 let scMathUtil = require('../../../public/scMathUtil').getUtil();
@@ -705,6 +706,9 @@ async function copyProject(userID, compilationID,data,newProjectID = null, delay
 
     copyTasks.push(copyEquipment(newProjectID,originalID));
 
+    // 复制费用汇总
+    copyTasks.push(copyGatherFee(newProjectID, originalID));
+
     await Promise.all(copyTasks);
     // 最后再处理项目数据
     // 可能会有最后再在外层方法插入项目数据的需求,如拷贝例题,暂时先不在这里插入项目数据
@@ -833,6 +837,17 @@ async function copyEquipment(newProjectID,oldProjectID){//复制设备购置费
     return result;
 }
 
+// 复制费用汇总
+async function copyGatherFee(newProjectID, oldProjectID) {
+    let result = null;
+    const gatherItem = await gaterFeeModel.findOne({ projectID: oldProjectID }, '-_id').lean();
+    if (gatherItem) {
+        gatherItem.projectID = newProjectID;
+        result = await gaterFeeModel.create(gatherItem);
+    }
+    return result;
+}
+
 async  function commonCopy(newProjectID,oldID,newID,model) { //对于只需更新ID和projectID的文件的复制
     let result = null;
     let file = await model.findOne({"ID": oldID}, '-_id');
@@ -2542,6 +2557,7 @@ async function exportTenderData(data){
     result.bidList = await bidListModel.find({projectID:data.projectID}, '-_id').lean();
     result.contractorList = await contractorListModel.find({projectID:data.projectID}, '-_id').lean();
     result.equipments = await equipmentPurchaseModel.findOne({projectID:data.projectID},'-_id').lean();
+    result.gatherFees = await gaterFeeModel.findOne({projectID:data.projectID},'-_id').lean();
 
     return cipher.aesEncrypt(JSON.stringify(result));
 }
@@ -2786,9 +2802,9 @@ async function importProjects(data,req,updateData) {
             let [constructionProjectID,projectIDMap,labourCoeFileIDMap,calcProgramFileIDMap] = await handleMainProjectDatas(mainData,updateData,req.session.sessionUser.id);
             result.constructionProjectID = constructionProjectID;
             if(datas.length > 1 ){
-                let newProjectSettings=[],bills=[],rations=[],installationFees=[],projectGLJs=[],rationGLJs=[],rationCoes=[],quantityDetails=[],rationInstallations=[],rationTemplates=[],evaluateList=[],bidList=[],contractorList=[],newCalcProgramsFiles=[],newLabourCoes=[],newEquipments = [];
+                let newProjectSettings=[],bills=[],rations=[],installationFees=[],projectGLJs=[],rationGLJs=[],rationCoes=[],quantityDetails=[],rationInstallations=[],rationTemplates=[],evaluateList=[],bidList=[],contractorList=[],newCalcProgramsFiles=[],newLabourCoes=[],newEquipments = [],newGatherFees = [];
                 for(let i = 1;i<datas.length;i++){
-                  let [tnewProjectSetting,tbills,trations,tinstallationFees,tprojectGLJs,trationGLJs,trationCoes,tquantityDetails,trationInstallations,trationTemplates,tevaluateList,tbidList,tcontractorList,tnewCalcProgramsFile,tnewLabourCoe,tnewEquipments] = await handleEachProject(datas[i],projectIDMap,labourCoeFileIDMap,calcProgramFileIDMap)
+                  let [tnewProjectSetting,tbills,trations,tinstallationFees,tprojectGLJs,trationGLJs,trationCoes,tquantityDetails,trationInstallations,trationTemplates,tevaluateList,tbidList,tcontractorList,tnewCalcProgramsFile,tnewLabourCoe,tnewEquipments, tnewGatherFees] = await handleEachProject(datas[i],projectIDMap,labourCoeFileIDMap,calcProgramFileIDMap)
                   if(tnewProjectSetting) newProjectSettings.push(tnewProjectSetting);
                   if(tbills.length > 0) bills = bills.concat(tbills);
                   if(trations.length > 0) rations = rations.concat(trations);
@@ -2804,7 +2820,8 @@ async function importProjects(data,req,updateData) {
                   if(tcontractorList.length > 0)  contractorList = contractorList.concat(tcontractorList);
                   if(tnewCalcProgramsFile) newCalcProgramsFiles.push(tnewCalcProgramsFile);
                   if(tnewLabourCoe) newLabourCoes.push(tnewLabourCoe); 
-                  if(tnewEquipments) newEquipments.push(tnewEquipments); 
+                  if(tnewEquipments) newEquipments.push(tnewEquipments);
+                  if(tnewGatherFees) newGatherFees.push(tnewGatherFees);
                 }
 
                 if(newProjectSettings.length > 0) await insertMany(newProjectSettings,projectSettingModel)
@@ -2823,6 +2840,7 @@ async function importProjects(data,req,updateData) {
                 if(newCalcProgramsFiles.length > 0) await insertMany(newCalcProgramsFiles,calcProgramsModel);
                 if(newLabourCoes.length > 0) await insertMany(newLabourCoes,labourCoesModel); 
                 if(newEquipments.length > 0) await insertMany(newEquipments,equipmentPurchaseModel); 
+                if(newGatherFees.length > 0) await insertMany(newGatherFees,gaterFeeModel); 
 
             }
 
@@ -2836,7 +2854,7 @@ async function importProjects(data,req,updateData) {
 
 async function handleEachProject(data,projectIDMap,labourCoeFileIDMap,calcProgramFileIDMap){
     let bills = [],rations = [],projectGLJs = [],installationFees=[],rationGLJs=[],rationCoes=[],quantityDetails=[],rationInstallations=[],rationTemplates=[],evaluateList=[],bidList=[],contractorList=[];
-    let newProjectSetting =null,newCalcProgramsFile = null,newLabourCoe = null,newEquipments = null;
+    let newProjectSetting =null,newCalcProgramsFile = null,newLabourCoe = null,newEquipments = null, newGatherFees = null;
     let billsIDMap = {},projectGLJIDMap={},rationIDMap = {};
     let newProjectID = projectIDMap[data.projectID];
     //生成安装增加费设置
@@ -2924,9 +2942,15 @@ async function handleEachProject(data,projectIDMap,labourCoeFileIDMap,calcProgra
         delete newEquipments._id; 
     }
 
+    if (data.gatherFees) {
+        data.gatherFees.projectID = newProjectID;
+        newGatherFees = data.gatherFees;
+        delete newGatherFees._id;
+    }
+
 
 
-    return [newProjectSetting,bills,rations,installationFees,projectGLJs,rationGLJs,rationCoes,quantityDetails,rationInstallations,rationTemplates,evaluateList,bidList,contractorList,newCalcProgramsFile,newLabourCoe,newEquipments]
+    return [newProjectSetting,bills,rations,installationFees,projectGLJs,rationGLJs,rationCoes,quantityDetails,rationInstallations,rationTemplates,evaluateList,bidList,contractorList,newCalcProgramsFile,newLabourCoe,newEquipments,newGatherFees]
 
 }
 function setMaterialList(datas,newProjectID,projectGLJIDMap){