|
|
@@ -56,14 +56,30 @@ async function calculateQuantity(query,noNeedCal=null,refreshRationName = false)
|
|
|
return null;
|
|
|
}
|
|
|
if(impactRation._doc.hasOwnProperty("rationAssList")&&impactRation.rationAssList.length>0){
|
|
|
+ prepareAss(impactRation.rationAssList);
|
|
|
+ let temTimes = [];
|
|
|
+ let thirdRationCodes=[];
|
|
|
for(let i=0;i<impactRation.rationAssList.length;i++){
|
|
|
let times = calculateTimes(impactRation.rationAssList[i]);
|
|
|
if(times!=0){
|
|
|
+ let thirdRationCode = impactRation.rationAssList[i].thirdRationCode;
|
|
|
+ if(thirdRationCode && thirdRationCode !=''){
|
|
|
+ temTimes.push(times);
|
|
|
+ thirdRationCodes.push(thirdRationCode)
|
|
|
+ }
|
|
|
assRation = await std_ration_lib_ration_items.findOne({rationRepId:impactRation.libID,code:impactRation.rationAssList[i].assistCode});
|
|
|
assList.push({times:times,assRation:assRation});
|
|
|
adjustState.push({index:stateSeq.ass,content:impactRation.rationAssList[i].name+" "+impactRation.rationAssList[i].actualValue+" : +"+impactRation.rationAssList[i].assistCode+"x"+times});
|
|
|
}
|
|
|
}
|
|
|
+ if(temTimes.length == 2 &&thirdRationCodes[0] == thirdRationCodes[1] ){ //说明有第三定额
|
|
|
+ let times_t = temTimes[0] * temTimes[1];
|
|
|
+ let tration = await std_ration_lib_ration_items.findOne({rationRepId:impactRation.libID,code:thirdRationCodes[0]});
|
|
|
+ if(tration){
|
|
|
+ assList.push({times:times_t,assRation:tration});
|
|
|
+ adjustState.push({index:stateSeq.ass,content:"+"+thirdRationCodes[0]+"x"+times_t});
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
for(let glj of gljList){//先把混凝土,砂浆,配合比有自定义消耗的挑出来
|
|
|
if(gljUtil.isConcreteType(glj.type)) await getMixRatioMap(glj,gljList,coeList,assList,mixRatioMap);
|
|
|
@@ -96,12 +112,26 @@ async function calculateQuantity(query,noNeedCal=null,refreshRationName = false)
|
|
|
|
|
|
function generateRationName(ration,gljList) {
|
|
|
let caption = ration.caption ? ration.caption:ration.name;
|
|
|
- if(ration.rationAssList && ration.rationAssList.length > 0){
|
|
|
- let ass = ration.rationAssList[0];
|
|
|
- if( ass.isAdjust == 1 && ass.actualValue != null && ass.actualValue != undefined ){
|
|
|
- caption = caption.replace('%s',ass.actualValue);
|
|
|
- }else {
|
|
|
- caption = caption.replace('%s',ass.stdValue);//没勾选的时候要恢复成标准值
|
|
|
+ let replaceList = [];
|
|
|
+ if(ration.rationAssList && ration.rationAssList.length > 0){//这里要处理第三定额和多辅助定额的情况
|
|
|
+ let isThird = ration.rationAssList.length == 2 && ration.rationAssList[0].thirdRationCode&&ration.rationAssList[0].thirdRationCode!='';//说明有第三定额的情况
|
|
|
+ let adjustMatch = "",notAdjust="";
|
|
|
+ for(let ass of ration.rationAssList){
|
|
|
+ let tem = "";
|
|
|
+ if( ass.isAdjust == 1 && ass.actualValue != null && ass.actualValue != undefined ){
|
|
|
+ tem = ass.actualValue;
|
|
|
+ adjustMatch = tem;
|
|
|
+ }else {
|
|
|
+ tem = ass.stdValue;
|
|
|
+ notAdjust = tem;
|
|
|
+ }
|
|
|
+ if(isThird) replaceList.push(tem);
|
|
|
+ }
|
|
|
+ if(replaceList.length == 0){
|
|
|
+ adjustMatch!=""?replaceList.push(adjustMatch):replaceList.push(notAdjust);
|
|
|
+ }
|
|
|
+ for(let r of replaceList){
|
|
|
+ caption = caption.replace('%s',r);
|
|
|
}
|
|
|
}
|
|
|
let reNameList = [];
|
|
|
@@ -348,6 +378,22 @@ function getContent(coes) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+function prepareAss(assList) {//处理辅助定额,支持多个辅助定额的情况
|
|
|
+ for(let a of assList){
|
|
|
+ if(a.groupList && a.groupList.length > 1){//组里有多个定额的情况
|
|
|
+ let newList = _.sortByAll(a.groupList,['param']);//先按参数排序
|
|
|
+ for(let n of newList){
|
|
|
+ if(a.actualValue > n.stdValue && a.actualValue <= parseFloat(n.param)){//落在中间,则用组里的这条定额
|
|
|
+ a._doc.param = n.param;
|
|
|
+ a._doc.paramName = n.paramName;
|
|
|
+ a._doc.assistCode = n.assistCode;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function calculateTimes(ass){
|
|
|
if(ass.isAdjust == 0) return 0;//打勾辅助定额才计算
|
|
|
let times =(ass.actualValue-ass.stdValue)/ass.stepValue;
|
|
|
@@ -360,6 +406,8 @@ function calculateTimes(ass){
|
|
|
times = _.round(times,ass.decimal);
|
|
|
}else if (ass.carryBit=='进一'){
|
|
|
times =_.ceil(times,ass.decimal);
|
|
|
+ }else if(ass.carryBit == '舍一'){
|
|
|
+ times = _.floor(times,ass.decimal);
|
|
|
}
|
|
|
if(r){
|
|
|
times=times*-1;
|