|
|
@@ -78,7 +78,7 @@ async function addNewRation(data,compilation) {
|
|
|
if(data.brUpdate.length>0){
|
|
|
await updateSerialNo(data.brUpdate);
|
|
|
}
|
|
|
- let newRation =await insertNewRation(data.newData,data.defaultLibID,stdRation,data.calQuantity);
|
|
|
+ let newRation =await insertNewRation(data.newData,data.defaultLibID,stdRation,data.calQuantity,data.programArray);
|
|
|
let addRationGLJTime = +new Date();
|
|
|
console.log("插入新定额时间-------------------------------"+(addRationGLJTime - stdRationTime));
|
|
|
if(stdRation){
|
|
|
@@ -292,7 +292,18 @@ async function updateSerialNo(serialNoUpdate){
|
|
|
await ration_model.model.bulkWrite(tasks);
|
|
|
}
|
|
|
|
|
|
-async function insertNewRation(newData,defaultLibID,std,calQuantity) {//插入新的定额
|
|
|
+function getProgramID(programArray,feeType) {
|
|
|
+ if (programArray) {
|
|
|
+ let p = _.find(programArray, { "name": feeType });
|
|
|
+ if (p) {
|
|
|
+ return p.ID;
|
|
|
+ } else {
|
|
|
+ return null//programArray[0].ID; 20201013 - 匹配不上返回空的取费类别
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+async function insertNewRation(newData,defaultLibID,std,calQuantity,programArray) {//插入新的定额
|
|
|
let startTime = +new Date();
|
|
|
if(std){
|
|
|
newData.code = std.code;
|
|
|
@@ -314,12 +325,16 @@ async function insertNewRation(newData,defaultLibID,std,calQuantity) {//插入
|
|
|
} else if(newData.from === 'cpt') {
|
|
|
newData.prefix = '补';
|
|
|
}
|
|
|
- if(std.feeType == undefined || std.feeType == null || std.feeType ==''){//定额取费专业为空的情况下,取项目属性中的定额取费专业ID
|
|
|
+ /* if(std.feeType == undefined || std.feeType == null || std.feeType ==''){//定额取费专业为空的情况下,取项目属性中的定额取费专业ID
|
|
|
newData.programID = await getProgramForProject(newData.projectID);
|
|
|
}else {
|
|
|
newData.programID = std.feeType;
|
|
|
- }
|
|
|
- newData.rationAssList =await createRationAss(std);
|
|
|
+ } */
|
|
|
+ //后台定额库中的取费类别改为文本,识别不到文本,则默认为第一个取费类别。
|
|
|
+ newData.programID = getProgramID(programArray,std.feeType);
|
|
|
+
|
|
|
+
|
|
|
+ newData.rationAssList =await createRationAss(std);
|
|
|
// calculate ration Quantity
|
|
|
}
|
|
|
if(calQuantity){
|
|
|
@@ -338,7 +353,7 @@ async function replaceRations(userID,data,compilation) {
|
|
|
let recodes = [];
|
|
|
for(let recode of data.nodeInfo){
|
|
|
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,data.cleanzmhs);
|
|
|
+ let newRecode = await replaceRation(recode,stdRation,data.defaultLibID,data.projectID,data.calQuantity,compilation,data.cleanzmhs,data.programArray);
|
|
|
if(newRecode){
|
|
|
recodes.push(newRecode);
|
|
|
}else {
|
|
|
@@ -360,13 +375,13 @@ async function getDefaultProgramID(data) {
|
|
|
return programID;
|
|
|
}
|
|
|
|
|
|
-async function replaceRation(nodeInfo,stdRation,defaultLibID,projectID,calQuantity,compilation,cleanzmhs) {
|
|
|
+async function replaceRation(nodeInfo,stdRation,defaultLibID,projectID,calQuantity,compilation,cleanzmhs,programArray) {
|
|
|
if(nodeInfo.newCode == null||nodeInfo.newCode ==""){//说明是删除编号,则要变成一条空定额
|
|
|
await deleRationSubRecode(projectID,nodeInfo.ID);//删除定额下挂的各种数据,如定额工料机等
|
|
|
return await setEmptyRation(projectID,nodeInfo.ID);
|
|
|
}else if(stdRation){
|
|
|
await deleRationSubRecode(projectID,nodeInfo.ID,cleanzmhs);//删除定额下挂的各种数据,如定额工料机等
|
|
|
- let newRation = await updateRation(stdRation,defaultLibID,nodeInfo.ID,nodeInfo.billsItemID,projectID,calQuantity,cleanzmhs);//生成并插入新的定额
|
|
|
+ let newRation = await updateRation(stdRation,defaultLibID,nodeInfo.ID,nodeInfo.billsItemID,projectID,calQuantity,cleanzmhs,programArray);//生成并插入新的定额
|
|
|
return await addRationSubList(stdRation,newRation,nodeInfo.needInstall,compilation,cleanzmhs);
|
|
|
}else {
|
|
|
return null;
|
|
|
@@ -1049,7 +1064,7 @@ async function updateCoeAdjust(data,compilation) {
|
|
|
|
|
|
|
|
|
|
|
|
-async function updateRation(std,defaultLibID,rationID,billsItemID,projectID,calQuantity,cleanzmh=false) {
|
|
|
+async function updateRation(std,defaultLibID,rationID,billsItemID,projectID,calQuantity,cleanzmh=false,programArray) {
|
|
|
// insertNewRation
|
|
|
let ration ={};
|
|
|
ration.code = std.code;
|
|
|
@@ -1080,11 +1095,12 @@ async function updateRation(std,defaultLibID,rationID,billsItemID,projectID,cal
|
|
|
}
|
|
|
ration.rationAssList =await createRationAss(std);//生成辅助定额
|
|
|
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(std.feeType == undefined || std.feeType == null || std.feeType ==''){//定额取费专业为空的情况下,取项目属性中的定额取费专业ID
|
|
|
+ // ration.programID = await getProgramForProject(projectID);
|
|
|
+ // }else {
|
|
|
+ // ration.programID = std.feeType;
|
|
|
+ // }
|
|
|
+ ration.programID = getProgramID(programArray,std.feeType);
|
|
|
if( calQuantity){
|
|
|
await CalculateQuantity(ration,billsItemID,projectID);
|
|
|
}
|