|
@@ -66,7 +66,8 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
|
|
|
}
|
|
|
gljList = sortRationGLJ(gljList);
|
|
|
for(let i =0;i<gljList.length;i++ ){
|
|
|
- let r = await calculateQuantityPerGLJ(gljList[i],i,coeList,assList,adjustState,noNeedCal);
|
|
|
+ let isLast = i == gljList.length -1;
|
|
|
+ let r = await calculateQuantityPerGLJ(gljList[i],isLast,coeList,assList,adjustState,noNeedCal);
|
|
|
result.glj_result.push(r);
|
|
|
}
|
|
|
|
|
@@ -136,7 +137,7 @@ function sortRationGLJ(list) {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
-async function calculateQuantityPerGLJ(glj,index,coeList,assList,adjustState,noNeedCal) {
|
|
|
+async function calculateQuantityPerGLJ(glj,isLast,coeList,assList,adjustState,noNeedCal) {
|
|
|
let decimalObject =await decimal_facade.getProjectDecimal(glj.projectID);
|
|
|
let decimal = (decimalObject&&decimalObject.glj&&decimalObject.glj.quantity)?decimalObject.glj.quantity:3;
|
|
|
let quantity = scMathUtil.roundTo(parseFloat(glj.quantity),-decimal);
|
|
@@ -166,7 +167,7 @@ async function calculateQuantityPerGLJ(glj,index,coeList,assList,adjustState,noN
|
|
|
}
|
|
|
result.doc.quantity =scMathUtil.roundToString(quantity,decimal);
|
|
|
}
|
|
|
- generateAdjustState(glj,coeList,adjustState,index,result.doc.quantity);
|
|
|
+ generateAdjustState(glj,coeList,adjustState,isLast,result.doc.quantity);
|
|
|
return result;
|
|
|
}catch (err){
|
|
|
throw err;
|
|
@@ -198,7 +199,7 @@ async function calculateAss(quantity,assList,glj) {
|
|
|
return scMathUtil.roundTo(quantity,-6);
|
|
|
}
|
|
|
|
|
|
-function generateAdjustState(glj,coeList,adjustState,index,quantity) {
|
|
|
+function generateAdjustState(glj,coeList,adjustState,isLast,quantity) {
|
|
|
//替换工料机 and 添加工料机
|
|
|
if(glj._doc.createType=='replace'&&glj.rcode!=glj.code){
|
|
|
adjustState.push({index:stateSeq.replace,content:glj.rcode+'换'+glj.code});
|
|
@@ -208,17 +209,21 @@ function generateAdjustState(glj,coeList,adjustState,index,quantity) {
|
|
|
displayQuantity = glj.customQuantity;
|
|
|
}
|
|
|
displayQuantity = displayQuantity&&displayQuantity!=""?parseFloat(displayQuantity):0;
|
|
|
- adjustState.push({index:stateSeq.add,content:'添'+glj.code+'量'+ displayQuantity});
|
|
|
+ adjustState.push({index:stateSeq.add,content:'添'+glj.code+'量'+ displayQuantity,type:"添"+glj.code});
|
|
|
}
|
|
|
// to do
|
|
|
|
|
|
//标准附注条件调整 + 自定义乘系数
|
|
|
- if(0==index){
|
|
|
+ if(isLast){//最后一个工料机的时候才生成,生成一次就可以了
|
|
|
for(let i=0;i<coeList.length;i++){
|
|
|
if(coeList[i].isAdjust==1){
|
|
|
if(i==coeList.length-1){
|
|
|
adjustState.push({index:stateSeq.cusCoe,content:getContent(coeList[i].coes)});//自定义乘系数要去掉倍数为1的
|
|
|
}else {
|
|
|
+ for(let c of coeList[i].coes){
|
|
|
+ if(c.coeType=='单个工料机') _.remove(adjustState,{'type':"添"+c.gljCode});//如果是单个工料机子目换算类型自动添加的,去掉前面手动生成的调整状态
|
|
|
+ if(c.coeType=='替换人材机') _.remove(adjustState,{'content':c.gljCode+'换'+c.replaceCode});//如果是替换人材机子目换算类型自动添加的,去掉前面手动生成的调整状态
|
|
|
+ }
|
|
|
adjustState.push({index:stateSeq.coe,content:"调 : "+coeList[i].content});//coeList[i].content
|
|
|
}
|
|
|
}
|
|
@@ -304,7 +309,9 @@ function everyCoe(quantity,coe,glj) {
|
|
|
let coeQuantity = quantity;
|
|
|
if(coe.isAdjust==1){
|
|
|
for(let i=0;i<coe.coes.length;i++){
|
|
|
- if(coe.coes[i].gljCode==glj.code){//if(coe.coes[i].coeType=='单个工料机'&&coe.coes[i].gljCode==glj.code)
|
|
|
+ if(coe.coes[i].coeType=='单个工料机' &&coe.coes[i].gljCode==glj.code){//if(coe.coes[i].coeType=='单个工料机'&&coe.coes[i].gljCode==glj.code)
|
|
|
+ coeQuantity = getCalculateResult(coeQuantity,coe.coes[i]);
|
|
|
+ }else if(coe.coes[i].coeType== "替换人材机" && glj.rcode == coe.coes[i].gljCode && glj.code == coe.coes[i].replaceCode){
|
|
|
coeQuantity = getCalculateResult(coeQuantity,coe.coes[i]);
|
|
|
} else if(coe.coes[i].coeType=='定额'){
|
|
|
coeQuantity = getCalculateResult(coeQuantity,coe.coes[i]);
|