|
@@ -40,7 +40,7 @@ async function addNewRation(data) {
|
|
|
if(data.brUpdate.length>0){
|
|
|
await updateSerialNo(data.brUpdate);
|
|
|
}
|
|
|
- let newRation =await insertNewRation(data.newData,data.firstLibID,stdRation,data.calQuantity);
|
|
|
+ let newRation =await insertNewRation(data.newData,data.defaultLibID,stdRation,data.calQuantity);
|
|
|
let addRationGLJTime = +new Date();
|
|
|
console.log("插入新定额时间-------------------------------"+(addRationGLJTime - stdRationTime));
|
|
|
if(stdRation){
|
|
@@ -79,7 +79,7 @@ async function updateSerialNo(serialNoUpdate){
|
|
|
|
|
|
}
|
|
|
|
|
|
-async function insertNewRation(newData,firstLibID,std,calQuantity) {//插入新的定额
|
|
|
+async function insertNewRation(newData,defaultLibID,std,calQuantity) {//插入新的定额
|
|
|
let startTime = +new Date();
|
|
|
if(std){
|
|
|
newData.code = std.code;
|
|
@@ -95,10 +95,10 @@ async function insertNewRation(newData,firstLibID,std,calQuantity) {//插入新
|
|
|
}
|
|
|
newData.prefix = '';
|
|
|
newData.from = std.type === 'complementary' ? 'cpt' : 'std';
|
|
|
- if(firstLibID !== std.rationRepId){//借
|
|
|
+ if(defaultLibID !== std.rationRepId){//借
|
|
|
newData.prefix = '借';
|
|
|
}
|
|
|
- else if(std.rationRepId === firstLibID && newData.from === 'cpt') {
|
|
|
+ else if(std.rationRepId === defaultLibID && newData.from === 'cpt') {
|
|
|
newData.prefix = '补';
|
|
|
}
|
|
|
if(std.feeType == undefined || std.feeType == null || std.feeType ==''){//定额取费专业为空的情况下,取项目属性中的定额取费专业ID
|
|
@@ -114,7 +114,6 @@ async function insertNewRation(newData,firstLibID,std,calQuantity) {//插入新
|
|
|
}
|
|
|
let addRationGLJTime = +new Date();
|
|
|
console.log("计算消耗量时间-------------------------------"+(addRationGLJTime - startTime));
|
|
|
- console.log(newData);
|
|
|
let newRation = await ration_model.model.create(newData);
|
|
|
return newRation;
|
|
|
/*ration_model.model.create(newData);
|
|
@@ -126,7 +125,7 @@ async function replaceRations(userID,data) {
|
|
|
let recodes = [];
|
|
|
for(let recode of data.nodeInfo){
|
|
|
let stdRation = await searchDao.getRationItem(userID,data.libIDs,recode.newCode, null);
|
|
|
- let newRecode = await replaceRation(recode,stdRation,data.firstLibID,data.projectID,data.calQuantity);
|
|
|
+ let newRecode = await replaceRation(recode,stdRation,data.defaultLibID,data.projectID,data.calQuantity);
|
|
|
if(newRecode){
|
|
|
recodes.push(newRecode);
|
|
|
}else {
|
|
@@ -136,13 +135,13 @@ async function replaceRations(userID,data) {
|
|
|
return recodes;
|
|
|
}
|
|
|
|
|
|
-async function replaceRation(nodeInfo,stdRation,firstLibID,projectID,calQuantity) {
|
|
|
+async function replaceRation(nodeInfo,stdRation,defaultLibID,projectID,calQuantity) {
|
|
|
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);//删除定额下挂的各种数据,如定额工料机等
|
|
|
- let newRation = await updateRation(stdRation,firstLibID,nodeInfo.ID,nodeInfo.billsItemID,projectID,calQuantity);//生成并插入新的定额
|
|
|
+ let newRation = await updateRation(stdRation,defaultLibID,nodeInfo.ID,nodeInfo.billsItemID,projectID,calQuantity);//生成并插入新的定额
|
|
|
return await addRationSubList(stdRation,newRation,nodeInfo.needInstall);
|
|
|
}else {
|
|
|
return null;
|
|
@@ -341,7 +340,7 @@ async function deleRationSubRecode(projectID,rationID) {//删除挂在定额下
|
|
|
await rationInstallationModel.deleteMany(delete_query);//删除安装增加费
|
|
|
}
|
|
|
|
|
|
-async function updateRation(std,firstLibID,rationID,billsItemID,projectID,calQuantity) {
|
|
|
+async function updateRation(std,defaultLibID,rationID,billsItemID,projectID,calQuantity) {
|
|
|
// insertNewRation
|
|
|
let ration ={};
|
|
|
ration.code = std.code;
|
|
@@ -362,10 +361,10 @@ async function updateRation(std,firstLibID,rationID,billsItemID,projectID,calQu
|
|
|
//定额前缀 none:0, complementary:1, borrow: 2
|
|
|
ration.prefix = '';
|
|
|
//借用优先级比补充高
|
|
|
- if(std.rationRepId !== parseInt(firstLibID)){//借用
|
|
|
+ if(std.rationRepId !== parseInt(defaultLibID)){//借用
|
|
|
ration.prefix = '借';
|
|
|
}
|
|
|
- else if(std.rationRepId === firstLibID && ration.from === 'cpt') {
|
|
|
+ else if(std.rationRepId === defaultLibID && ration.from === 'cpt') {
|
|
|
ration.prefix = '补';
|
|
|
}
|
|
|
if(std.feeType == undefined || std.feeType == null || std.feeType ==''){//定额取费专业为空的情况下,取项目属性中的定额取费专业ID
|