Parcourir la source

项目工料机market_price调价后处理

TonyKang il y a 5 ans
Parent
commit
a71e507a51

+ 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;
                 }
+                // 备注:养护新增调价,处理上与建筑同步
             }
         }
         //还有汇总的...

+ 1 - 1
public/gljUtil.js

@@ -33,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) {

+ 19 - 7
test/unit/reports/test_rpt_test_template.js

@@ -50,7 +50,7 @@ let demoPrjId = - 1;
 // let demoRptId = 74; //22
 // let demoRptId = 83; //02 预算
 // let demoRptId = 84; //02 清单
-let demoRptId = 108;
+let demoRptId = 63;
 
 let pagesize = "A4";
 //288: 11-2表(新)
@@ -74,7 +74,7 @@ let userId_Leng = "5c3ffa9aa0a92732f41216e0"; //小冷User Id (养护的)
 // demoPrjId = 2580; //PROD:
 // demoPrjId = 815; //PROD:
 // demoPrjId = 20690;
-demoPrjId = 21767;
+demoPrjId = 22554;
 // demoPrjId = 738; //UAT:
 // demoPrjId = 670; //UAT: 清单项目
 //*/
@@ -95,9 +95,21 @@ const rpt_pdf_util = require("../../../modules/reports/util/rpt_pdf_util");
 
 let fs = require('fs');
 //设置Date Format函数
-fs.readFile(__dirname.slice(0, __dirname.length - 18) + '/public/web/date_util.js', 'utf8', 'r', function (err, data) {
-    eval(data);
-});
+Date.prototype.Format = function (fmt) {
+    var o = {
+        "M+": this.getMonth() + 1, //月份
+        "d+": this.getDate(), //日
+        "h+": this.getHours(), //小时
+        "m+": this.getMinutes(), //分
+        "s+": this.getSeconds(), //秒
+        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
+        "S": this.getMilliseconds() //毫秒
+    };
+    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
+    for (var k in o)
+        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
+    return fmt;
+};
 
 test('测试 - 测试模板啦: ', function (t) {
     // console.log(new Date());
@@ -118,9 +130,9 @@ test('测试 - 测试模板啦: ', function (t) {
                 try {
                     let dt = new Date();
                     console.log('取完项目数据时间:' + (dt));
-                    fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/YangHuCost/tmp/rptTplRawDataObject_测试模板.jsp");
+                    // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/YangHuCost/tmp/rptTplRawDataObject_测试模板.jsp");
                     let tplData = rptDataUtil.assembleData(rawDataObj);
-                    // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/YangHuCost/tmp/rptTplRawDataAfterCacl_测试模板.jsp");
+                    fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/YangHuCost/tmp/rptTplRawDataAfterCacl_测试模板.jsp");
                     // fsUtil.writeObjToFile(tplData, "D:/GitHome/YangHuCost/tmp/rptTplAssembledData_测试模板.jsp");
                     //it's time to build the report!!!
                     let printCom = JpcEx.createNew();