|
@@ -108,6 +108,9 @@ const overHeightLibModel = mongoose.model('std_over_height_lib');
|
|
|
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();
|
|
|
let counter = require('../../../public/counter/counter');
|
|
@@ -699,6 +702,13 @@ async function copyProject(userID, compilationID,data,newProjectID = null, delay
|
|
|
if(originalProperty.unitPriceFile){
|
|
|
copyTasks.push(copyUnitPriceFile(newProjectID,originalProperty.rootProjectID,userID,originalProperty.unitPriceFile.id,unitPriceFileID,newUnitName));
|
|
|
}
|
|
|
+ //复制设备购置
|
|
|
+
|
|
|
+ copyTasks.push(copyEquipment(newProjectID,originalID));
|
|
|
+
|
|
|
+ // 复制费用汇总
|
|
|
+ copyTasks.push(copyGatherFee(newProjectID, originalID));
|
|
|
+
|
|
|
await Promise.all(copyTasks);
|
|
|
// 最后再处理项目数据
|
|
|
// 可能会有最后再在外层方法插入项目数据的需求,如拷贝例题,暂时先不在这里插入项目数据
|
|
@@ -817,6 +827,27 @@ async function copyProjectGLJ(gljList) {
|
|
|
await insertMany(gljList,gljListModel);
|
|
|
}
|
|
|
|
|
|
+async function copyEquipment(newProjectID,oldProjectID){//复制设备购置费
|
|
|
+ let result = null;
|
|
|
+ const equipments = await equipmentPurchaseModel.findOne({projectID:oldProjectID}, '-_id').lean();
|
|
|
+ if(equipments){
|
|
|
+ equipments.projectID = newProjectID;
|
|
|
+ result = await equipmentPurchaseModel.create(equipments);
|
|
|
+ }
|
|
|
+ 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');
|
|
@@ -2462,6 +2493,7 @@ async function exportMainData(userID,projectID) {
|
|
|
result['compilationID'] = project.compilation;
|
|
|
result['from'] = "construction";
|
|
|
result.projects.push(project);
|
|
|
+ tenderIDs.push(project.ID);
|
|
|
let subProjects = await projectModel.find({"$or": [{'ParentID':projectID}, {"property.rootProjectID": projectID}]});
|
|
|
for(let s of subProjects){
|
|
|
if(!s.deleteInfo || !s.deleteInfo.deleted){
|
|
@@ -2509,6 +2541,7 @@ async function exportTenderData(data){
|
|
|
let result = {};
|
|
|
let projectSetting = await projectSettingModel.findOne({"projectID": data.projectID}, '-_id');
|
|
|
if(projectSetting) result['projSetting'] = projectSetting;
|
|
|
+ result.projectID = data.projectID;
|
|
|
result.bills = await billsModel.find({"projectID": data.projectID});
|
|
|
result.rations = await rationModel.find({'$or': [{projectID: data.projectID, deleteInfo: null}, {projectID: data.projectID, 'deleteInfo.deleted': {$in: [null, false]}}]});
|
|
|
result.projectGLJs = await gljListModel.find({'project_id':data.projectID});
|
|
@@ -2523,6 +2556,8 @@ async function exportTenderData(data){
|
|
|
result.evaluateList = await evaluateListModel.find({projectID:data.projectID}, '-_id').lean();
|
|
|
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));
|
|
|
}
|
|
@@ -2767,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=[]
|
|
|
+ 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] = 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);
|
|
@@ -2785,6 +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(tnewGatherFees) newGatherFees.push(tnewGatherFees);
|
|
|
}
|
|
|
|
|
|
if(newProjectSettings.length > 0) await insertMany(newProjectSettings,projectSettingModel)
|
|
@@ -2802,6 +2839,8 @@ async function importProjects(data,req,updateData) {
|
|
|
if(contractorList.length > 0) await insertMany(contractorList,contractorListModel);
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -2815,9 +2854,9 @@ 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;
|
|
|
+ let newProjectSetting =null,newCalcProgramsFile = null,newLabourCoe = null,newEquipments = null, newGatherFees = null;
|
|
|
let billsIDMap = {},projectGLJIDMap={},rationIDMap = {};
|
|
|
- let newProjectID = projectIDMap[data.projSetting.projectID];
|
|
|
+ let newProjectID = projectIDMap[data.projectID];
|
|
|
//生成安装增加费设置
|
|
|
if(data.installationFees && data.installationFees.length > 0){
|
|
|
for(let ins of data.installationFees){
|
|
@@ -2897,7 +2936,21 @@ async function handleEachProject(data,projectIDMap,labourCoeFileIDMap,calcProgra
|
|
|
delete newLabourCoe._id;
|
|
|
}
|
|
|
|
|
|
- return [newProjectSetting,bills,rations,installationFees,projectGLJs,rationGLJs,rationCoes,quantityDetails,rationInstallations,rationTemplates,evaluateList,bidList,contractorList,newCalcProgramsFile,newLabourCoe]
|
|
|
+ if(data.equipments){
|
|
|
+ data.equipments.projectID = newProjectID;
|
|
|
+ newEquipments = data.equipments;
|
|
|
+ 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,newGatherFees]
|
|
|
|
|
|
}
|
|
|
function setMaterialList(datas,newProjectID,projectGLJIDMap){
|