فهرست منبع

Merge branch 'master' of http://192.168.1.41:3000/SmartCost/YangHuCost

vian 5 سال پیش
والد
کامیت
1e21e5bcc7
1فایلهای تغییر یافته به همراه27 افزوده شده و 12 حذف شده
  1. 27 12
      public/web/gljUtil.js

+ 27 - 12
public/web/gljUtil.js

@@ -12,7 +12,7 @@ let gljUtil = {
         let rationGljGroup = _.groupBy(rationGLJDatas,'projectGLJID');
         let IDarray =  this.getSubdivisionAndTechBillsLeavesID(billsDatas);//分别取分部分项和技术措施项目的所有叶子清单ID
         let billIDs = IDarray[0],tech_billIDS = IDarray[1];
-
+        let materialCalcMap={};
         //养护没有分部分项消耗量这一说的所以不用管
 
         let qField = isTender==true?"tenderQuantity":"quantity";
@@ -30,6 +30,7 @@ let gljUtil = {
             pglj[qField] = result.quantity;
             quantityMap[pg_index] = pglj;
             if(pglj.code == gljUtil.getElecCode() && pglj.name == '电' && pglj.unit == "kW·h") elecIndex = pg_index;
+            if(pglj.unit_price.calcMaterial == 1) materialCalcMap[pg_index] = true;
         }
         //计算做为组成物的消耗量
         for(let pkey in mixRatioMap){
@@ -45,9 +46,25 @@ let gljUtil = {
             }
         }
 
+        //计算经过场外运输损耗后的总消耗量
+        for(let pglj of project_gljs ){
+          let offSiteTransportLossRate = this.getOffSiteTransportLossRate(pglj);
+          pglj.offSiteTransportLossRate = parseFloat(offSiteTransportLossRate);//scMathUtil.roundForObj(offSiteTransportLossRate,getDecimal("glj.unitPrice")) ;这里再取小数位数太麻烦了,暂时用保存的吧
+          offSiteTransportLossRate = offSiteTransportLossRate/100;
+          pglj.transportLossQuantity =  scMathUtil.roundForObj(pglj.quantity*offSiteTransportLossRate,q_decimal);
+          pglj.quantity = scMathUtil.roundForObj(pglj.quantity +  pglj.transportLossQuantity ,q_decimal);
+        }
         //材料计算中,工料机的消耗量
-        if(projectGLJDatas.freightList) this.setMaterialCalcQuantity(quantityMap,projectGLJDatas.freightList,q_decimal,_,scMathUtil,isTender); //运费计算中工料机的消耗量
-        if(projectGLJDatas.originalList) this.setMaterialCalcQuantity(quantityMap,projectGLJDatas.originalList,q_decimal,_,scMathUtil,isTender);//原价计算中工料机的消耗量
+
+        //材料计算中,有可能A包含B,B包含C。。。。。等情况,为避免循环计算,只多计算一次,不做再深的嵌套处理
+        // 1.先计算做为父工料机的材料计算消耗量
+        if(projectGLJDatas.freightList) this.setMaterialCalcQuantity(quantityMap,materialCalcMap,true,projectGLJDatas.freightList,q_decimal,_,scMathUtil,isTender); //运费计算中工料机的消耗量
+        if(projectGLJDatas.originalList) this.setMaterialCalcQuantity(quantityMap,materialCalcMap,true,projectGLJDatas.originalList,q_decimal,_,scMathUtil,isTender);//原价计算中工料机的消耗量
+
+        // 2.再计算做为子工料机的材料计算消耗量
+        if(projectGLJDatas.freightList) this.setMaterialCalcQuantity(quantityMap,materialCalcMap,false,projectGLJDatas.freightList,q_decimal,_,scMathUtil,isTender); //运费计算中工料机的消耗量
+        if(projectGLJDatas.originalList) this.setMaterialCalcQuantity(quantityMap,materialCalcMap,false,projectGLJDatas.originalList,q_decimal,_,scMathUtil,isTender);//原价计算中工料机的消耗量
+
 
         //因为材料计算里自采材料产生的消耗量和进行材料计算的父工料机的消耗量有关,所以材料计算中的组成物的消耗量要在上一步的组成物计算完后,再计算自采材料里组成物的消耗量,所认两个组成物计算不能合并,而且乘的值也不同
         for(let pkey in mixRatioMap){
@@ -91,16 +108,9 @@ let gljUtil = {
                 }
             }
         }
-        //计算经过场外运输损耗后的总消耗量
-        for(let pglj of project_gljs ){
-            let offSiteTransportLossRate = this.getOffSiteTransportLossRate(pglj);
-            pglj.offSiteTransportLossRate = parseFloat(offSiteTransportLossRate);//scMathUtil.roundForObj(offSiteTransportLossRate,getDecimal("glj.unitPrice")) ;这里再取小数位数太麻烦了,暂时用保存的吧
-            offSiteTransportLossRate = offSiteTransportLossRate/100;
-            pglj.transportLossQuantity =  scMathUtil.roundForObj(pglj.quantity*offSiteTransportLossRate,q_decimal);
-            pglj.quantity = scMathUtil.roundForObj(pglj.quantity +  pglj.transportLossQuantity ,q_decimal);
-        }
+        
     },
-    setMaterialCalcQuantity:function (quantityMap,calcList,q_decimal,_,scMathUtil,isTender) {
+    setMaterialCalcQuantity:function (quantityMap,materialCalcMap,isParent,calcList,q_decimal,_,scMathUtil,isTender) {
         let qField = isTender==true?"tenderQuantity":"quantity";
         for(let t of calcList){
             if(quantityMap[t.connect_key] && quantityMap[t.connect_key][qField] > 0){
@@ -110,6 +120,11 @@ let gljUtil = {
                         let rIndex = this.getIndex(rg);
                         let pglj = quantityMap[rIndex];
                         let ration = rationIDMap[rg.rationID];
+                        if(isParent == true) {//当计算做为材料计算父消耗量时,忽略子消耗量
+                          if(!materialCalcMap[rIndex]) continue
+                        }else{//当计算做为材料计算子消耗量时,忽略父消耗量
+                          if(materialCalcMap[rIndex]) continue
+                        }
                         if(pglj && ration){
                             let rg_quantity = scMathUtil.roundForObj(rg.quantity,q_decimal);
                             let r_quantity = scMathUtil.roundForObj(ration.quantity,q_decimal);