|
@@ -30,7 +30,7 @@ async function addNewRation(data) {
|
|
|
let startTime = +new Date();
|
|
|
if(query){
|
|
|
let searchDao = new SearchDao();
|
|
|
- stdRation = await searchDao.getRationItem(query.userID,query.rationRepId,query.code);
|
|
|
+ stdRation = await searchDao.getRationItem(query.userID,[query.rationRepId],query.code);
|
|
|
data.newData.code = query.code;
|
|
|
}
|
|
|
let stdRationTime = +new Date();
|
|
@@ -38,7 +38,7 @@ async function addNewRation(data) {
|
|
|
if(data.brUpdate.length>0){
|
|
|
await updateSerialNo(data.brUpdate);
|
|
|
}
|
|
|
- let newRation =await insertNewRation(data.newData,stdRation,data.calQuantity);
|
|
|
+ let newRation =await insertNewRation(data.newData,data.firstLibID,stdRation,data.calQuantity);
|
|
|
let addRationGLJTime = +new Date();
|
|
|
console.log("插入新定额时间-------------------------------"+(addRationGLJTime - stdRationTime));
|
|
|
if(stdRation){
|
|
@@ -68,7 +68,7 @@ async function updateSerialNo(serialNoUpdate){
|
|
|
|
|
|
}
|
|
|
|
|
|
-async function insertNewRation(newData,std,calQuantity) {//插入新的定额
|
|
|
+async function insertNewRation(newData,firstLibID,std,calQuantity) {//插入新的定额
|
|
|
let startTime = +new Date();
|
|
|
if(std){
|
|
|
newData.name = std.name;
|
|
@@ -80,7 +80,14 @@ async function insertNewRation(newData,std,calQuantity) {//插入新的定额
|
|
|
newData.comments = std.chapter.explanation;
|
|
|
newData.ruleText = std.chapter.ruleText;
|
|
|
}
|
|
|
+ newData.prefix = 0;
|
|
|
newData.from = std.type === 'complementary' ? 'cpt' : 'std';
|
|
|
+ if(firstLibID !== std.rationRepId){//借
|
|
|
+ newData.prefix = 2;
|
|
|
+ }
|
|
|
+ else if(std.rationRepId === firstLibID && newData.from === 'cpt') {
|
|
|
+ newData.prefix = 1;
|
|
|
+ }
|
|
|
newData.programID = std.feeType;
|
|
|
newData.rationAssList = createRationAss(std);
|
|
|
// calculate ration Quantity
|
|
@@ -101,8 +108,8 @@ async function replaceRations(userID,data) {
|
|
|
let searchDao = new SearchDao();
|
|
|
let recodes = [];
|
|
|
for(let recode of data.nodeInfo){
|
|
|
- let stdRation = await searchDao.getRationItem(userID,data.libID,recode.newCode);
|
|
|
- let newRecode = await replaceRation(recode,stdRation,data.projectID,data.calQuantity);
|
|
|
+ let stdRation = await searchDao.getRationItem(userID,data.libIDs,recode.newCode);
|
|
|
+ let newRecode = await replaceRation(recode,stdRation,data.firstLibID,data.projectID,data.calQuantity);
|
|
|
if(newRecode){
|
|
|
recodes.push(newRecode);
|
|
|
}else {
|
|
@@ -112,10 +119,10 @@ async function replaceRations(userID,data) {
|
|
|
return recodes;
|
|
|
}
|
|
|
|
|
|
-async function replaceRation(nodeInfo,stdRation,projectID,calQuantity) {
|
|
|
+async function replaceRation(nodeInfo,stdRation,firstLibID,projectID,calQuantity) {
|
|
|
if(stdRation){
|
|
|
await deleRationSubRecode(projectID,nodeInfo.ID);
|
|
|
- let newRation = await updateRation(stdRation,nodeInfo.ID,nodeInfo.billsItemID,projectID,calQuantity);//生成并插入新的定额
|
|
|
+ let newRation = await updateRation(stdRation,firstLibID,nodeInfo.ID,nodeInfo.billsItemID,projectID,calQuantity);//生成并插入新的定额
|
|
|
return await addRationSubList(stdRation,newRation,nodeInfo.needInstall);
|
|
|
}else {
|
|
|
return null;
|
|
@@ -291,7 +298,7 @@ async function deleRationSubRecode(projectID,rationID) {//删除挂在定额下
|
|
|
await rationInstallationModel.deleteMany(delete_query);//删除安装增加费
|
|
|
}
|
|
|
|
|
|
-async function updateRation(std,rationID,billsItemID,projectID,calQuantity) {
|
|
|
+async function updateRation(std,firstLibID,rationID,billsItemID,projectID,calQuantity) {
|
|
|
// insertNewRation
|
|
|
let ration ={};
|
|
|
ration.code = std.code;
|
|
@@ -309,6 +316,15 @@ async function updateRation(std,rationID,billsItemID,projectID,calQuantity) {
|
|
|
ration.ruleText = std.chapter.ruleText;
|
|
|
}
|
|
|
ration.from = std.type === 'complementary' ? 'cpt' : 'std';
|
|
|
+ //定额前缀 none:0, complementary:1, borrow: 2
|
|
|
+ ration.prefix = 0;
|
|
|
+ //借用优先级比补充高
|
|
|
+ if(std.rationRepId !== parseInt(firstLibID)){//借用
|
|
|
+ ration.prefix = 2;
|
|
|
+ }
|
|
|
+ else if(std.rationRepId === firstLibID && ration.from === 'cpt') {
|
|
|
+ ration.prefix = 1;
|
|
|
+ }
|
|
|
ration.programID = std.feeType;
|
|
|
ration.rationAssList = createRationAss(std);//生成辅助定额
|
|
|
if(calQuantity){
|