Browse Source

报表调价后数据merge

TonyKang 5 years atrás
parent
commit
a33f4a0840
2 changed files with 38 additions and 23 deletions
  1. 21 7
      modules/reports/util/rpt_yanghu_data_util.js
  2. 17 16
      public/gljUtil.js

+ 21 - 7
modules/reports/util/rpt_yanghu_data_util.js

@@ -146,8 +146,10 @@ class Rpt_Data_Extractor {
                             rst.push(key);
                             if (key === projectConst.RATION_GLJ && (rst.indexOf(projectConst.PROJECTGLJ) < 0)) {
                                 rst.push(projectConst.PROJECTGLJ);
+                                if (rst.indexOf(projectConst.LABOUR_COE < 0)) rst.push(projectConst.LABOUR_COE);
                             }
                             if (key === projectConst.PROJECTGLJ) {
+                                if (rst.indexOf(projectConst.LABOUR_COE < 0)) rst.push(projectConst.LABOUR_COE);
                                 if (rst.indexOf(projectConst.RATION_GLJ) < 0) rst.push(projectConst.RATION_GLJ);
                                 if (field[JV.PROP_FIELD_EXP_MAP].indexOf("'quantity'") > 0 ||
                                     field[JV.PROP_FIELD_EXP_MAP].indexOf("'subdivisionQuantity'") > 0 ||
@@ -250,7 +252,7 @@ class Rpt_Data_Extractor {
             for (let item of rawDataObj.prjData) {
                 setupFunc($PROJECT.DETAIL, item.moduleName, item);
             }
-            let projectGLJDatas = getModuleDataByKey(rawDataObj.prjData, "projectGLJ");
+            let projectGLJDatas = getModuleDataByKey(rawDataObj.prjData, projectConst.PROJECTGLJ);
             if (projectGLJDatas) {
                 //增加一个辅助对象,方便通过gljid key直接获取数据,省去循环时间
                 let gljAssitantObj = {"gljIds": {}, "componentGljIds": {}};
@@ -263,9 +265,10 @@ class Rpt_Data_Extractor {
                 }
                 //顺便做个排序(跟UI一致的排序)
             }
-            let rationGLJDatas = getModuleDataByKey(rawDataObj.prjData, "ration_glj");
-            let rationDatas = getModuleDataByKey(rawDataObj.prjData, "ration");
-            let billsDatas = getModuleDataByKey(rawDataObj.prjData, "bills");
+            let labourCoeDatas =  getModuleDataByKey(rawDataObj.prjData, projectConst.LABOUR_COE);
+            let rationGLJDatas = getModuleDataByKey(rawDataObj.prjData, projectConst.RATION_GLJ);
+            let rationDatas = getModuleDataByKey(rawDataObj.prjData, projectConst.RATION);
+            let billsDatas = getModuleDataByKey(rawDataObj.prjData, projectConst.BILLS);
             let decimal = rawDataObj.prj.property.decimal.glj.quantity;
             // let labourCoeDatas =  getModuleDataByKey(rawDataObj.prjData, "labour_coe");
             let calcOptions = rawDataObj.prj.property.calcOptions;
@@ -273,12 +276,23 @@ class Rpt_Data_Extractor {
             if (projectGLJDatas && rationGLJDatas && rationDatas && billsDatas) {
                 gljUtil.calcProjectGLJQuantity(projectGLJDatas.data, rationGLJDatas.data, rationDatas.data, billsDatas.data, decimal);
             }
-            if (projectGLJDatas && rationGLJDatas) {
+            if (projectGLJDatas && rationGLJDatas && labourCoeDatas) {
                 //考虑调价情况
+                const newAdjPriceArr = [];
                 for (const glj of projectGLJDatas.data.gljList) {
-                    glj.unit_price.market_price = gljUtil.getMarketPrice(glj, projectGLJDatas.data, calcOptions, [], rawDataObj.prj.property.decimal, false);
-                    //备注:养护没有调价,就不用_tender了
+                    newAdjPriceArr.push(gljUtil.getGLJPrice(glj, projectGLJDatas.data, calcOptions, labourCoeDatas, rawDataObj.prj.property.decimal, false, gljUtil.getTenderPriceCoe(glj, rawDataObj.prj.property), true));
+                    // glj.unit_price.market_price = gljUtil.getMarketPrice(glj, projectGLJDatas.data, calcOptions, [], rawDataObj.prj.property.decimal, false);
+                }
+                for (let gljIdx = 0; gljIdx < newAdjPriceArr.length; gljIdx++) {
+                    let newGlj = newAdjPriceArr[gljIdx];
+                    let gljItem = projectGLJDatas.data.gljList[gljIdx];
+                    let unit_price = gljItem.unit_price._doc ? gljItem.unit_price._doc : gljItem.unit_price;
+                    unit_price.org_market_price = gljItem.unit_price.marketPrice;
+                    unit_price.market_price = newGlj.marketPrice;
+                    unit_price.org_basePrice =  gljItem.unit_price.base_price;
+                    unit_price.base_price = newGlj.basePrice;
                 }
+                // 备注:养护新增调价,处理上与建筑同步
             }
         }
         //还有汇总的...

+ 17 - 16
public/gljUtil.js

@@ -10,21 +10,22 @@ let gljNodeUtil = require("./web/gljUtil");
 // eval(data + ' ; gljNodeUtil = gljUtil; ');
 
 module.exports = {
-    calcProjectGLJQuantity :calcProjectGLJQuantity,
-    getGLJPrice:getGLJPrice,
-    calcPriceDiff:calcPriceDiff,
-    getMarketPrice:getMarketPrice,
-    getBasePrice:getBasePrice,
-    getAdjustPrice:getAdjustPrice,
-    getMainType:getMainType,
-    isConcreteType:isConcreteType,
-    isCommercialConcreteType:isCommercialConcreteType,
-    getIndex:getIndex,
-    sortRationGLJ:sortRationGLJ,
-    sortProjectGLJ:sortProjectGLJ,
-    getCCSProjectGLJ:getCCSProjectGLJ,
-    getBaseCCSMixRatio:getBaseCCSMixRatio,
-    setMaterialCalcRationFee:setMaterialCalcRationFee
+  calcProjectGLJQuantity: calcProjectGLJQuantity,
+  getGLJPrice: getGLJPrice,
+  calcPriceDiff: calcPriceDiff,
+  getMarketPrice: getMarketPrice,
+  getBasePrice: getBasePrice,
+  getAdjustPrice: getAdjustPrice,
+  getMainType: getMainType,
+  isConcreteType: isConcreteType,
+  isCommercialConcreteType: isCommercialConcreteType,
+  getIndex: getIndex,
+  sortRationGLJ: sortRationGLJ,
+  sortProjectGLJ: sortProjectGLJ,
+  getCCSProjectGLJ: getCCSProjectGLJ,
+  getBaseCCSMixRatio: getBaseCCSMixRatio,
+  setMaterialCalcRationFee: setMaterialCalcRationFee,
+  getTenderPriceCoe: getTenderPriceCoe
 };
 
 function calcProjectGLJQuantity(projectGLJDatas,rationGLJDatas,rationDatas,billsDatas,q_decimal) {
@@ -32,7 +33,7 @@ function calcProjectGLJQuantity(projectGLJDatas,rationGLJDatas,rationDatas,bills
 }
 
 function getGLJPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio=false,tenderCoe, isReport) {
-    return gljNodeUtil.getGLJPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil,tenderCoe, isReport);
+    return gljNodeUtil.getGLJPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil,null,tenderCoe, isReport);
 }
 
 function setMaterialCalcRationFee(ration,ration_gljs,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,_,scMathUtil) {