|
@@ -164,7 +164,7 @@ async function replaceRations(userID,data,compilation) {
|
|
|
let recodes = [];
|
|
let recodes = [];
|
|
|
for(let recode of data.nodeInfo){
|
|
for(let recode of data.nodeInfo){
|
|
|
let stdRation = await searchDao.getRationItem(userID,compilation._id,data.libIDs,recode.newCode, null);
|
|
let stdRation = await searchDao.getRationItem(userID,compilation._id,data.libIDs,recode.newCode, null);
|
|
|
- let newRecode = await replaceRation(recode,stdRation,data.defaultLibID,data.projectID,data.calQuantity,compilation);
|
|
|
|
|
|
|
+ let newRecode = await replaceRation(recode,stdRation,data.defaultLibID,data.projectID,data.calQuantity,compilation,data.cleanzmhs);
|
|
|
if(newRecode){
|
|
if(newRecode){
|
|
|
recodes.push(newRecode);
|
|
recodes.push(newRecode);
|
|
|
}else {
|
|
}else {
|
|
@@ -186,20 +186,20 @@ async function getDefaultProgramID(data) {
|
|
|
return programID;
|
|
return programID;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function replaceRation(nodeInfo,stdRation,defaultLibID,projectID,calQuantity,compilation) {
|
|
|
|
|
|
|
+async function replaceRation(nodeInfo,stdRation,defaultLibID,projectID,calQuantity,compilation,cleanzmhs) {
|
|
|
if(nodeInfo.newCode == null||nodeInfo.newCode ==""){//说明是删除编号,则要变成一条空定额
|
|
if(nodeInfo.newCode == null||nodeInfo.newCode ==""){//说明是删除编号,则要变成一条空定额
|
|
|
await deleRationSubRecode(projectID,nodeInfo.ID);//删除定额下挂的各种数据,如定额工料机等
|
|
await deleRationSubRecode(projectID,nodeInfo.ID);//删除定额下挂的各种数据,如定额工料机等
|
|
|
return await setEmptyRation(projectID,nodeInfo.ID);
|
|
return await setEmptyRation(projectID,nodeInfo.ID);
|
|
|
}else if(stdRation){
|
|
}else if(stdRation){
|
|
|
- await deleRationSubRecode(projectID,nodeInfo.ID);//删除定额下挂的各种数据,如定额工料机等
|
|
|
|
|
- let newRation = await updateRation(stdRation,defaultLibID,nodeInfo.ID,nodeInfo.billsItemID,projectID,calQuantity);//生成并插入新的定额
|
|
|
|
|
- return await addRationSubList(stdRation,newRation,nodeInfo.needInstall,compilation);
|
|
|
|
|
|
|
+ await deleRationSubRecode(projectID,nodeInfo.ID,cleanzmhs);//删除定额下挂的各种数据,如定额工料机等
|
|
|
|
|
+ let newRation = await updateRation(stdRation,defaultLibID,nodeInfo.ID,nodeInfo.billsItemID,projectID,calQuantity,cleanzmhs);//生成并插入新的定额
|
|
|
|
|
+ return await addRationSubList(stdRation,newRation,nodeInfo.needInstall,compilation,cleanzmhs);
|
|
|
}else {
|
|
}else {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function addRationSubList(stdRation,newRation,needInstall,compilation) {
|
|
|
|
|
|
|
+async function addRationSubList(stdRation,newRation,needInstall,compilation,cleanzmhs=false) {
|
|
|
let startTime = +new Date();
|
|
let startTime = +new Date();
|
|
|
let ration_gljs = await addRationGLJ(stdRation,newRation,compilation);
|
|
let ration_gljs = await addRationGLJ(stdRation,newRation,compilation);
|
|
|
let addRationGLJTime = +new Date();
|
|
let addRationGLJTime = +new Date();
|
|
@@ -208,13 +208,16 @@ async function addRationSubList(stdRation,newRation,needInstall,compilation) {
|
|
|
let addRationCoeTime = +new Date();
|
|
let addRationCoeTime = +new Date();
|
|
|
console.log("添加定额coe时间-----"+(addRationCoeTime - addRationGLJTime));
|
|
console.log("添加定额coe时间-----"+(addRationCoeTime - addRationGLJTime));
|
|
|
let ration_installations = [];
|
|
let ration_installations = [];
|
|
|
- if(needInstall && stdRation.type == 'std'){//只有标准的定额才有安装增加费,补充的定额没有安装增加费
|
|
|
|
|
- ration_installations = await addRationInstallFee(stdRation,newRation);
|
|
|
|
|
|
|
+ let ration_template = [];
|
|
|
|
|
+ if(cleanzmhs == false){//清除子目换算即cleanzmh==true时 模板子目、安装增加费不用恢复成标准的
|
|
|
|
|
+ if(needInstall && stdRation.type == 'std'){//只有标准的定额才有安装增加费,补充的定额没有安装增加费
|
|
|
|
|
+ ration_installations = await addRationInstallFee(stdRation,newRation);
|
|
|
|
|
+ }
|
|
|
|
|
+ let addRationInstallFeeTime = +new Date();
|
|
|
|
|
+ console.log("添加定额install时间-----"+(addRationInstallFeeTime - addRationCoeTime));
|
|
|
|
|
+ //添加定额模板子目
|
|
|
|
|
+ ration_template = await addRationTemplate(stdRation,newRation);
|
|
|
}
|
|
}
|
|
|
- let addRationInstallFeeTime = +new Date();
|
|
|
|
|
- console.log("添加定额install时间-----"+(addRationInstallFeeTime - addRationCoeTime));
|
|
|
|
|
- //添加定额模板子目
|
|
|
|
|
- let ration_template = await addRationTemplate(stdRation,newRation);
|
|
|
|
|
return {ration:newRation,ration_gljs:ration_gljs,ration_coes:ration_coes,ration_installations:ration_installations,ration_templates:ration_template?[ration_template]:[]};
|
|
return {ration:newRation,ration_gljs:ration_gljs,ration_coes:ration_coes,ration_installations:ration_installations,ration_templates:ration_template?[ration_template]:[]};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -468,18 +471,23 @@ async function addRationGLJ(std,newRation,compilation) {
|
|
|
return rationGLJShowList;
|
|
return rationGLJShowList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function deleRationSubRecode(projectID,rationID) {//删除挂在定额下的数据,如工程量明细,定额工料机等
|
|
|
|
|
|
|
+async function deleRationSubRecode(projectID,rationID,cleanzmhs=false) {//删除挂在定额下的数据,如工程量明细,定额工料机等
|
|
|
let delete_query={projectID: projectID, rationID: rationID};
|
|
let delete_query={projectID: projectID, rationID: rationID};
|
|
|
//删除工程量明细
|
|
//删除工程量明细
|
|
|
- await deleteSubListByQuery(delete_query) ;
|
|
|
|
|
|
|
+ await deleteSubListByQuery(delete_query,cleanzmhs) ;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function deleteSubListByQuery(delete_query) {
|
|
|
|
|
- await quantity_detail.deleteByQuery(delete_query) ;//删除工程量明细
|
|
|
|
|
|
|
+async function deleteSubListByQuery(delete_query,cleanzmhs=false) {
|
|
|
|
|
+ if(cleanzmhs == false){//清空子目换算即cleanzmh==true时不需要清空工程量明细、模板关联子目、安装增加费
|
|
|
|
|
+ await quantity_detail.deleteByQuery(delete_query) ;//删除工程量明细
|
|
|
|
|
+ await rationInstallationModel.deleteMany(delete_query);//删除安装增加费
|
|
|
|
|
+ await rationTemplateModel.deleteMany(delete_query);//删除模板关联子目
|
|
|
|
|
+ }
|
|
|
|
|
+ //to do稳定土也要删除
|
|
|
|
|
+
|
|
|
await ration_coe.deleteMany(delete_query);//删除附注条件
|
|
await ration_coe.deleteMany(delete_query);//删除附注条件
|
|
|
await ration_glj.deleteMany(delete_query);//删除定额工料机
|
|
await ration_glj.deleteMany(delete_query);//删除定额工料机
|
|
|
- await rationInstallationModel.deleteMany(delete_query);//删除安装增加费
|
|
|
|
|
- await rationTemplateModel.deleteMany(delete_query);//删除模板关联子目
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function updateCoeAdjust(data,compilation) {
|
|
async function updateCoeAdjust(data,compilation) {
|
|
@@ -516,7 +524,7 @@ async function updateCoeAdjust(data,compilation) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-async function updateRation(std,defaultLibID,rationID,billsItemID,projectID,calQuantity) {
|
|
|
|
|
|
|
+async function updateRation(std,defaultLibID,rationID,billsItemID,projectID,calQuantity,cleanzmh=false) {
|
|
|
// insertNewRation
|
|
// insertNewRation
|
|
|
let ration ={};
|
|
let ration ={};
|
|
|
ration.code = std.code;
|
|
ration.code = std.code;
|
|
@@ -546,16 +554,17 @@ async function updateRation(std,defaultLibID,rationID,billsItemID,projectID,cal
|
|
|
else if(std.rationRepId === defaultLibID && ration.from === 'cpt') {
|
|
else if(std.rationRepId === defaultLibID && ration.from === 'cpt') {
|
|
|
ration.prefix = '补';
|
|
ration.prefix = '补';
|
|
|
}
|
|
}
|
|
|
- if(std.feeType == undefined || std.feeType == null || std.feeType ==''){//定额取费专业为空的情况下,取项目属性中的定额取费专业ID
|
|
|
|
|
- ration.programID = await getProgramForProject(projectID);
|
|
|
|
|
- }else {
|
|
|
|
|
- ration.programID = std.feeType;
|
|
|
|
|
- }
|
|
|
|
|
ration.rationAssList = createRationAss(std);//生成辅助定额
|
|
ration.rationAssList = createRationAss(std);//生成辅助定额
|
|
|
- if(calQuantity){
|
|
|
|
|
- await CalculateQuantity(ration,billsItemID,projectID);
|
|
|
|
|
|
|
+ if(cleanzmh==false){//如果是清空子目换算,即cleanzmh==true 保留定额工程量、工程量表达式、含量(分解系数)、取费专业(取费类别)
|
|
|
|
|
+ if(std.feeType == undefined || std.feeType == null || std.feeType ==''){//定额取费专业为空的情况下,取项目属性中的定额取费专业ID
|
|
|
|
|
+ ration.programID = await getProgramForProject(projectID);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ ration.programID = std.feeType;
|
|
|
|
|
+ }
|
|
|
|
|
+ if( calQuantity){
|
|
|
|
|
+ await CalculateQuantity(ration,billsItemID,projectID);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
let unsetObject = {
|
|
let unsetObject = {
|
|
|
"marketUnitFee":1,
|
|
"marketUnitFee":1,
|
|
|
'marketTotalFee':1,
|
|
'marketTotalFee':1,
|