|
|
@@ -66,7 +66,7 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
|
|
|
}
|
|
|
}
|
|
|
for(let glj of gljList){//先把混凝土,砂浆,配合比有自定义消耗的挑出来
|
|
|
- if(gljUtil.isConcreteType(glj.type)&& !noCustomQuantiyt(glj)) await getMixRatioMap(glj,mixRatioMap);
|
|
|
+ if(gljUtil.isConcreteType(glj.type)&& !noCustomQuantiyt(glj)) await getMixRatioMap(glj,gljList,coeList,assList,mixRatioMap);
|
|
|
}
|
|
|
|
|
|
gljList = sortRationGLJ(gljList);
|
|
|
@@ -140,11 +140,11 @@ function sortRationGLJ(list) {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
-function sortBeforeCalc(list) {
|
|
|
- list = _.sortByAll(list, [function (item) {
|
|
|
- return gljUtil.isConcreteType(item.type)?1:2;
|
|
|
- }]);
|
|
|
- return list;
|
|
|
+async function calcWhenNoCustomQuantiyt(decimal,glj,gljList,coeList,assList) {
|
|
|
+ let quantity = glj.rationItemQuantity ? scMathUtil.roundTo(parseFloat(glj.rationItemQuantity),-decimal):0;
|
|
|
+ quantity =scMathUtil.roundTo(await calculateAss(quantity,assList,glj),-decimal);
|
|
|
+ quantity = calculateQuantityByCoes(quantity,coeList,glj,gljList,decimal);
|
|
|
+ return quantity;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -164,9 +164,11 @@ async function calculateQuantityPerGLJ(glj,gljList,coeList,assList,adjustState,m
|
|
|
try {
|
|
|
if(noNeedCal==null){//计算顺序:辅助定额,附注条件,自定义消耗(如果有就不用前计算两项),自定义乘系数
|
|
|
if(noCustomQuantiyt(glj)){
|
|
|
- quantity =scMathUtil.roundTo(parseFloat(glj.rationItemQuantity),-decimal);
|
|
|
- quantity =scMathUtil.roundTo(await calculateAss(quantity,assList,glj),-decimal);
|
|
|
- quantity = calculateQuantityByCoes(quantity,coeList,glj,gljList,decimal);
|
|
|
+ quantity = await calcWhenNoCustomQuantiyt(decimal,glj,gljList,coeList,assList);
|
|
|
+ let mIndex = gljUtil.getIndex(glj);
|
|
|
+ if(mixRatioMap[mIndex]){//组成物
|
|
|
+ quantity = calcQuantityForMix(quantity,mixRatioMap[mIndex],decimal);
|
|
|
+ }
|
|
|
}else {//对于有自定义消耗量的,并且是混凝土,浆砂,配合比 这三种类型,其组成物的消耗量要跟据自定义消耗量做相应的换算
|
|
|
quantity = glj.customQuantity;
|
|
|
result.doc.customQuantity = glj.customQuantity;
|
|
|
@@ -176,6 +178,7 @@ async function calculateQuantityPerGLJ(glj,gljList,coeList,assList,adjustState,m
|
|
|
quantity = scMathUtil.roundToString(quantity,decimal);
|
|
|
quantity = calculateQuantityByCustomerCoes(quantity,customerCoe,glj,decimal);
|
|
|
}
|
|
|
+ if(quantity < 0) quantity = 0;
|
|
|
result.doc.quantity =scMathUtil.roundToString(quantity,decimal);
|
|
|
//2019-01-03 需求修改中间过程的价格不参与计算
|
|
|
//glj.quantity = quantity;//这里保存中间过程计算出来的消耗量,后面处理“+*”操作符时要用到
|
|
|
@@ -187,16 +190,32 @@ async function calculateQuantityPerGLJ(glj,gljList,coeList,assList,adjustState,m
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-async function getMixRatioMap(glj,mixRatioMap) {//生成组成物对应的父工料机的映射表
|
|
|
+function calcQuantityForMix(quantity,plist,decimal) {
|
|
|
+ for(let pglj of plist){
|
|
|
+ let consumption = scMathUtil.roundForObj(pglj.consumption,decimal);
|
|
|
+ let customQuantity = scMathUtil.roundForObj(pglj.customQuantity,decimal);
|
|
|
+ let temQuantity = scMathUtil.roundForObj(consumption * pglj.assCoeQuantity,6);
|
|
|
+ let pcustomQuantity = scMathUtil.roundForObj(consumption * customQuantity,6);
|
|
|
+ quantity = scMathUtil.roundForObj(quantity - temQuantity,6);
|
|
|
+ quantity = scMathUtil.roundForObj(quantity + pcustomQuantity,decimal);
|
|
|
+ }
|
|
|
+ return quantity;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+async function getMixRatioMap(glj,gljList,coeList,assList,mixRatioMap) {//生成组成物对应的父工料机的映射表
|
|
|
+ let decimalObject = await decimal_facade.getProjectDecimal(glj.projectID);
|
|
|
+ let decimal = (decimalObject&&decimalObject.glj&&decimalObject.glj.quantity)?decimalObject.glj.quantity:3;
|
|
|
+ let assCoeQuantity = await calcWhenNoCustomQuantiyt(decimal,glj,gljList,coeList,assList);//计算要用父工料机经过辅助子目换算后的量
|
|
|
let unitPriceFileId = await ProjectModel.getUnitPriceFileId(glj.projectID);
|
|
|
let connect_key = gljUtil.getIndex(glj);
|
|
|
let mixList = await mixRatioModel.find({"unit_price_file_id":unitPriceFileId,'connect_key':connect_key})
|
|
|
for(let m of mixList){
|
|
|
let mkey = gljUtil.getIndex(m);
|
|
|
if(mixRatioMap[mkey]){
|
|
|
- mixRatioMap[mkey].push({customQuantity:glj.customQuantity,rationItemQuantity:glj.rationItemQuantity,consumption:m.consumption});
|
|
|
+ mixRatioMap[mkey].push({customQuantity:glj.customQuantity,assCoeQuantity:assCoeQuantity,consumption:m.consumption});
|
|
|
}else {
|
|
|
- mixRatioMap[mkey] = [{customQuantity:glj.customQuantity,rationItemQuantity:glj.rationItemQuantity,consumption:m.consumption}];
|
|
|
+ mixRatioMap[mkey] = [{customQuantity:glj.customQuantity,assCoeQuantity:assCoeQuantity,consumption:m.consumption}];
|
|
|
}
|
|
|
}
|
|
|
}
|