|
|
@@ -89,7 +89,7 @@ let progressiveModel = mongoose.model('std_progressive_lib');
|
|
|
let importLogsModel = mongoose.model("import_logs");
|
|
|
const shareListModel = mongoose.model('share_list');
|
|
|
let welcomeModel = mongoose.model("welcome_setting");
|
|
|
-
|
|
|
+let divideModel = mongoose.model("divide_setting");
|
|
|
|
|
|
let featureLibModel = mongoose.model("std_project_feature_lib");
|
|
|
let scMathUtil = require('../../../public/scMathUtil').getUtil();
|
|
|
@@ -585,6 +585,10 @@ async function copyProject(userID, compilationID, data, newProjectID = null, del
|
|
|
if(originalProperty.labourCoeFile){
|
|
|
copyTasks.push(commonCopy(newProjectID,originalProperty.labourCoeFile.ID,labourCoeFileID,labourCoesModel));
|
|
|
}
|
|
|
+ //复制分摊信息
|
|
|
+ let divide_setting = await divideModel.findOne({projectID:originalID}, '-_id').lean();
|
|
|
+ if(divide_setting) copyTasks.push(copyDivide(divide_setting,newProjectID,projectGLJMap.IDMap));
|
|
|
+
|
|
|
// 处理单价、费率文件
|
|
|
if (saveAsFile) {
|
|
|
let feeRateFileName = isSaveAs ? projectName : originalProperty.feeFile.name;
|
|
|
@@ -752,6 +756,15 @@ async function commonCopy(newProjectID,oldID,newID,model) { //对于只需更
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+async function copyDivide(divide_setting,newProjectID,projectGLJIDMap){
|
|
|
+ divide_setting.ID = uuidV1();
|
|
|
+ divide_setting.projectID = newProjectID;
|
|
|
+ for(let rg of divide_setting.ration_gljs){
|
|
|
+ rg.projectGLJID = projectGLJIDMap[rg.projectGLJID]
|
|
|
+ }
|
|
|
+ return await divideModel.create(divide_setting);
|
|
|
+}
|
|
|
+
|
|
|
async function copyFeeRate(rootProjectID,userID,originalFeeRateFileID,feeRateFileID,newName) {//复制费率和费率文件
|
|
|
let [feeRateFile,feeRate] =await feeRate_facade.getFeeRateByID(originalFeeRateFileID);
|
|
|
let newFeeRateID = uuidV1();
|
|
|
@@ -1589,17 +1602,18 @@ async function exportTenderData(data){
|
|
|
let result = {};
|
|
|
let projectSetting = await projectSettingModel.findOne({"projectID": data.projectID}, '-_id');
|
|
|
if(projectSetting) result['projSetting'] = projectSetting;
|
|
|
- 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});
|
|
|
- result.installationFees = await installationFeeModel.find({projectID:data.projectID});
|
|
|
- result.rationGLJs = await rationGLJModel.find({projectID:data.projectID});
|
|
|
- result.rationCoes = await rationCoeModel.find({projectID:data.projectID});
|
|
|
- result.quantityDetails = await quantityDetailModel.find({projectID:data.projectID});
|
|
|
- result.rationInstallations = await rationInstallationModel.find({projectID:data.projectID});
|
|
|
- result.rationTemplates = await rationTemplateModel.find({projectID:data.projectID});
|
|
|
- result.calcProgramsFile = await calcProgramsModel.findOne({projectID:data.projectID});
|
|
|
- result.labourCoes = await labourCoesModel.findOne({projectID:data.projectID});
|
|
|
+ result.bills = await billsModel.find({"projectID": data.projectID}).lean();
|
|
|
+ result.rations = await rationModel.find({'$or': [{projectID: data.projectID, deleteInfo: null}, {projectID: data.projectID, 'deleteInfo.deleted': {$in: [null, false]}}]}).lean();
|
|
|
+ result.projectGLJs = await gljListModel.find({'project_id':data.projectID}).lean();
|
|
|
+ result.installationFees = await installationFeeModel.find({projectID:data.projectID}).lean();
|
|
|
+ result.rationGLJs = await rationGLJModel.find({projectID:data.projectID}).lean();
|
|
|
+ result.rationCoes = await rationCoeModel.find({projectID:data.projectID}).lean();
|
|
|
+ result.quantityDetails = await quantityDetailModel.find({projectID:data.projectID}).lean();
|
|
|
+ result.rationInstallations = await rationInstallationModel.find({projectID:data.projectID}).lean();
|
|
|
+ result.rationTemplates = await rationTemplateModel.find({projectID:data.projectID}).lean();
|
|
|
+ result.calcProgramsFile = await calcProgramsModel.findOne({projectID:data.projectID}).lean();
|
|
|
+ result.labourCoes = await labourCoesModel.findOne({projectID:data.projectID}).lean();
|
|
|
+ result.divide_setting = await divideModel.findOne({projectID:data.projectID}, '-_id').lean();
|
|
|
|
|
|
return cipher.aesEncrypt(JSON.stringify(result));
|
|
|
}
|
|
|
@@ -1712,9 +1726,9 @@ async function importProject(data,req,updateData) {
|
|
|
let [constructionProjectID,projectIDMap,labourCoeFileIDMap,calcProgramFileIDMap] = await handleMainProjectDatas(mainData,updateData,req.session.sessionUser.id);
|
|
|
result.constructionProjectID = constructionProjectID;
|
|
|
if(datas.length > 1 ){//生成后统一次插入 2020-05-29
|
|
|
- let newProjectSettings=[],bills=[],rations=[],projectGLJs=[],rationGLJs=[],rationCoes=[],quantityDetails=[],rationInstallations=[],rationTemplates=[],newCalcProgramsFiles=[],newLabourCoes=[];
|
|
|
+ let newProjectSettings=[],bills=[],rations=[],projectGLJs=[],rationGLJs=[],rationCoes=[],quantityDetails=[],rationInstallations=[],rationTemplates=[],newCalcProgramsFiles=[],newLabourCoes=[],newDivides=[];
|
|
|
for(let i = 1;i<datas.length;i++){
|
|
|
- let [newProjectSetting,tbills,trations,tprojectGLJs,trationGLJs,trationCoes,tquantityDetails,trationInstallations,trationTemplates,newCalcProgramsFile,newLabourCoe] = await handleEachProject(datas[i],projectIDMap,labourCoeFileIDMap,calcProgramFileIDMap)
|
|
|
+ let [newProjectSetting,tbills,trations,tprojectGLJs,trationGLJs,trationCoes,tquantityDetails,trationInstallations,trationTemplates,newCalcProgramsFile,newLabourCoe,newDivide] = await handleEachProject(datas[i],projectIDMap,labourCoeFileIDMap,calcProgramFileIDMap)
|
|
|
if(newProjectSetting) newProjectSettings.push(newProjectSetting);
|
|
|
if(tbills.length > 0) bills = bills.concat(tbills);
|
|
|
if(trations.length > 0) rations = rations.concat(trations);
|
|
|
@@ -1726,6 +1740,7 @@ async function importProject(data,req,updateData) {
|
|
|
if(trationTemplates.length > 0) rationTemplates = rationTemplates.concat(trationTemplates);
|
|
|
if(newCalcProgramsFile) newCalcProgramsFiles.push(newCalcProgramsFile);
|
|
|
if(newLabourCoe) newLabourCoes.push(newLabourCoe);
|
|
|
+ if(newDivide) newDivides.push(newDivide);
|
|
|
}
|
|
|
|
|
|
if(newProjectSettings.length > 0) await insertMany(newProjectSettings,projectSettingModel);
|
|
|
@@ -1739,6 +1754,7 @@ async function importProject(data,req,updateData) {
|
|
|
if(rationTemplates.length > 0) await insertMany(rationTemplates,rationTemplateModel);
|
|
|
if(newCalcProgramsFiles.length > 0) await insertMany(newCalcProgramsFiles,calcProgramsModel);
|
|
|
if(newLabourCoes.length>0) await insertMany(newLabourCoes,labourCoesModel);
|
|
|
+ if(newDivides.length>0) await divideModel.insertMany(newDivides);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -1748,7 +1764,7 @@ async function importProject(data,req,updateData) {
|
|
|
|
|
|
async function handleEachProject(data,projectIDMap,labourCoeFileIDMap,calcProgramFileIDMap){
|
|
|
let bills = [],rations = [],projectGLJs = [],rationGLJs=[],rationCoes=[],quantityDetails=[],rationInstallations=[],rationTemplates=[];
|
|
|
- let newProjectSetting =null,newCalcProgramsFile = null,newLabourCoe = null;
|
|
|
+ let newProjectSetting =null,newCalcProgramsFile = null,newLabourCoe = null,newDivide=null;
|
|
|
let billsIDMap = {},projectGLJIDMap={},rationIDMap = {};
|
|
|
let newProjectID = projectIDMap[data.projSetting.projectID];
|
|
|
//生成新的清单;
|
|
|
@@ -1817,7 +1833,18 @@ async function handleEachProject(data,projectIDMap,labourCoeFileIDMap,calcProgra
|
|
|
newLabourCoe = data.labourCoes;
|
|
|
delete newLabourCoe._id;
|
|
|
}
|
|
|
- return [newProjectSetting,bills,rations,projectGLJs,rationGLJs,rationCoes,quantityDetails,rationInstallations,rationTemplates,newCalcProgramsFile,newLabourCoe]
|
|
|
+
|
|
|
+ if(data.divide_setting){
|
|
|
+ data.divide_setting.ID = uuidV1();
|
|
|
+ data.divide_setting.projectID = newProjectID;
|
|
|
+ for(let rg of data.divide_setting.ration_gljs){
|
|
|
+ rg.projectGLJID = projectGLJIDMap[rg.projectGLJID]
|
|
|
+ }
|
|
|
+ newDivide = data.divide_setting
|
|
|
+ delete newDivide._id;
|
|
|
+ }
|
|
|
+
|
|
|
+ return [newProjectSetting,bills,rations,projectGLJs,rationGLJs,rationCoes,quantityDetails,rationInstallations,rationTemplates,newCalcProgramsFile,newLabourCoe,newDivide]
|
|
|
|
|
|
}
|
|
|
|