Browse Source

Merge branch '1.0.0_online' of http://192.168.1.41:3000/SmartCost/ConstructionCost into 1.0.0_online

zhongzewei 6 years ago
parent
commit
205887b036

+ 3 - 341
modules/reports/controllers/rpt_controller.js

@@ -11,347 +11,6 @@ let Template = mongoose.model('rpt_templates');
 let rptTplDataFacade = require("../facade/rpt_tpl_data_facade");
 let fsUtil = require("../../../public/fsUtil");
 let pm_facade = require('../../../modules/pm/facade/pm_facade');
-let dummyDataObj = {
-    ProjectCostFields: [{
-        "name": "分部分项工程费",
-        "cost": 728819,
-        "unitCost": 728819,
-        "per": 70.08
-    }, {
-        "name": "技术措施费",
-        "cost": 36807.79,
-        "unitCost": 36807.79,
-        "per": 3.54
-    }, {
-        "name": "安全文明施工费",
-        "cost": 62312.37,
-        "unitCost": 62312.37,
-        "per": 5.99
-    }, {
-        "name": "建设工程竣工档案编制费",
-        "cost": 6867.95,
-        "unitCost": 6867.95,
-        "per": 0.66
-    }, {
-        "name": "其他组织措施费",
-        "cost": 36056.75,
-        "unitCost": 36056.75,
-        "per": 3.47
-    }, {
-        "name": "暂列金额",
-        "cost": 0,
-        "unitCost": 0,
-        "per": 0
-    }, {
-        "name": "专业工程暂估价",
-        "cost": 0,
-        "unitCost": 0,
-        "per": 0
-    }, {
-        "name": "计日工",
-        "cost": 0,
-        "unitCost": 0,
-        "per": 0
-    }, {
-        "name": "总承包服务费",
-        "cost": 0,
-        "unitCost": 0,
-        "per": 0
-    }, {
-        "name": "索赔与现场签证",
-        "cost": 0,
-        "unitCost": 0,
-        "per": 0
-    }, {
-        "name": "规费",
-        "cost": 64387.06,
-        "unitCost": 64387.06,
-        "per": 6.19
-    }, {
-        "name": "税金",
-        "cost": 104748.1,
-        "unitCost": 104748.1,
-        "per": 10.07
-    }, {
-        "name": "工程造价",
-        "cost": 1039999.02,
-        "unitCost": 1039999.02,
-        "per": 100
-    }
-    ],
-    ProjectEcoFields: [{
-        "name": "土石方工程",
-        "cost": 31477.97,
-        "unitCost": 29.338,
-        "per": 0.84
-    }, {
-        "name": "地基处理与边坡支护工程",
-        "cost": 0,
-        "unitCost": 0,
-        "per": 0
-    }, {
-        "name": "桩基工程",
-        "cost": 0,
-        "unitCost": 0,
-        "per": 0
-    }, {
-        "name": "砌筑工程",
-        "cost": 312217.05,
-        "unitCost": 290.995,
-        "per": 8.32
-    }, {
-        "name": "混凝土及钢筋混凝土工程",
-        "cost": 2301974.32,
-        "unitCost": 2145.503,
-        "per": 61.34
-    }, {
-        "name": "金属结构工程",
-        "cost": 0,
-        "unitCost": 0,
-        "per": 0
-    }, {
-        "name": "木结构工程",
-        "cost": 0,
-        "unitCost": 0,
-        "per": 0
-    }, {
-        "name": "门窗工程",
-        "cost": 0,
-        "unitCost": 0,
-        "per": 0
-    }, {
-        "name": "屋面及防水工程",
-        "cost": 0,
-        "unitCost": 0,
-        "per": 0
-    }, {
-        "name": "保温、防腐、隔热工程",
-        "cost": 0,
-        "unitCost": 0,
-        "per": 0
-    }, {
-        "name": "楼地面装饰工程",
-        "cost": 0,
-        "unitCost": 0,
-        "per": 0
-    }, {
-        "name": "其他工程",
-        "cost": 0,
-        "unitCost": 0,
-        "per": 0
-    }
-    ],
-    ProjectLabMaterialFields: [{
-        "name": "综合用工",
-        "unit": "工日",
-        "unitPrice": 118.62,
-        "quantity": 5248.2,
-        "unitIndex": 489.147
-    }, {
-        "name": "土石方用工",
-        "unit": "工日",
-        "unitPrice": 100,
-        "quantity": 176.71,
-        "unitIndex": 16.47
-    }, {
-        "name": "钢材",
-        "unit": "t",
-        "unitPrice": 3079.64,
-        "quantity": 1.68,
-        "unitIndex": 0.157
-    }, {
-        "name": "水泥",
-        "unit": "t",
-        "unitPrice": 0,
-        "quantity": 0,
-        "unitIndex": 0
-    }, {
-        "name": "商品混凝土",
-        "unit": "m3",
-        "unitPrice": 403,
-        "quantity": 484.59,
-        "unitIndex": 45.165
-    }, {
-        "name": "锯材",
-        "unit": "m3",
-        "unitPrice": 0,
-        "quantity": 0,
-        "unitIndex": 0
-    }, {
-        "name": "砂",
-        "unit": "t",
-        "unitPrice": 0,
-        "quantity": 0,
-        "unitIndex": 0
-    }, {
-        "name": "石子",
-        "unit": "t",
-        "unitPrice": 0,
-        "quantity": 0,
-        "unitIndex": 0
-    }, {
-        "name": "标砖",
-        "unit": "千块",
-        "unitPrice": 4,
-        "quantity": 11.06,
-        "unitIndex": 1.031
-    }, {
-        "name": "砌块",
-        "unit": "m3",
-        "unitPrice": 0,
-        "quantity": 0,
-        "unitIndex": 0
-    }, {
-        "name": "门",
-        "unit": "m2",
-        "unitPrice": 0,
-        "quantity": 0,
-        "unitIndex": 0
-    }, {
-        "name": "窗",
-        "unit": "m2",
-        "unitPrice": 0,
-        "quantity": 0,
-        "unitIndex": 0
-    }, {
-        "name": "保温材料",
-        "unit": "",
-        "unitPrice": 0,
-        "quantity": 0,
-        "unitIndex": 0
-    }, {
-        "name": "防水材料",
-        "unit": "",
-        "unitPrice": 0,
-        "quantity": 0,
-        "unitIndex": 0
-    }, {
-        "name": "其它材料",
-        "unit": "",
-        "unitPrice": 0,
-        "quantity": 0,
-        "unitIndex": 0
-    }
-    ],
-    ProjectQtyFields: [{
-        "name": "挖土石方量",
-        "quantityIndexUnit": "m3",
-        "quantity": 0
-    }, {
-        "name": "基础混凝土",
-        "quantityIndexUnit": "m3",
-        "quantity": 0
-    }, {
-        "name": "混凝土桩",
-        "quantityIndexUnit": "m3",
-        "quantity": 0
-    }, {
-        "name": "混凝土柱",
-        "quantityIndexUnit": "m3",
-        "quantity": 0
-    }, {
-        "name": "混凝土梁",
-        "quantityIndexUnit": "m3",
-        "quantity": 0
-    }, {
-        "name": "混凝土有梁板",
-        "quantityIndexUnit": "m3",
-        "quantity": 0
-    }, {
-        "name": "混凝土平板",
-        "quantityIndexUnit": "m3",
-        "quantity": 0
-    }, {
-        "name": "混凝土楼梯",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }, {
-        "name": "混凝土墙",
-        "quantityIndexUnit": "m3",
-        "quantity": 0
-    }, {
-        "name": "屋架",
-        "quantityIndexUnit": "m3",
-        "quantity": 0
-    }, {
-        "name": "砌体",
-        "quantityIndexUnit": "m3",
-        "quantity": 0
-    }, {
-        "name": "楼地面",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }, {
-        "name": "隔热、保温",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }, {
-        "name": "天棚装饰",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }, {
-        "name": "内墙装饰",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }, {
-        "name": "外墙装饰",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }, {
-        "name": "防水",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }, {
-        "name": "门",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }, {
-        "name": "窗",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }, {
-        "name": "钢材",
-        "quantityIndexUnit": "t",
-        "quantity": 0
-    }, {
-        "name": "阳台雨蓬挑檐",
-        "quantityIndexUnit": "m3",
-        "quantity": 0
-    }, {
-        "name": "屋面防水",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }, {
-        "name": "基础模板",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }, {
-        "name": "梁模板",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }, {
-        "name": "柱模板",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }, {
-        "name": "墙模板",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }, {
-        "name": "平板模板",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }, {
-        "name": "楼梯模板",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }, {
-        "name": "其他模板",
-        "quantityIndexUnit": "m2",
-        "quantity": 0
-    }
-    ]
-};
 
 import rptTplFacade from "../facade/rpt_template_facade";
 import demoTemplateFacade from "../facade/rpt_tpl_data_demo_facade";
@@ -564,6 +223,9 @@ function setupCustomizeCfg(customizeCfg, rptTpl, defProperties) {
     }
 }
 function getEcoFieldsData() {
+    let dummyDataObj = null;
+    let data = fs.readFileSync('D:/Temp/demoFieldData.js', 'utf8', 'r');
+    eval('dummyDataObj = ' + data + ';');
     return dummyDataObj;
 }
 function getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, customizeCfg, option, outputType, cb) {

+ 66 - 4
modules/reports/rpt_component/jpc_flow_tab.js

@@ -821,6 +821,10 @@ JpcFlowTabSrv.prototype.createNew = function(){
     };
     JpcFlowTabResult.combinePageCells = function (rstPageCells, verticalCombinePos, horizonCombinePos) {
         // let me = this;
+        //备注:纵向合并要考虑以下因素:
+        //     如果有多个column纵向合并,需要总体考虑分割,
+        //     假如:第一列的前3个数据(1、2、3)是相同的,第二列中第2、3、4行数据相同,那么第二列只能合并2、3行的数据,不能合并到第四行
+        //     同理如此类推第三列...n列
         if (verticalCombinePos.length > 0 || horizonCombinePos.length > 1) {
             let cacheObj = {vCache:{}, hCache: {}, hCacheStr: []};
             let removeCellIds = [];
@@ -848,19 +852,56 @@ JpcFlowTabSrv.prototype.createNew = function(){
                 }
             }
             if (verticalCombinePos.length > 0) {
-                for (let vPosArr of verticalCombinePos) {
+                let preColMergePosArr = []; //见上面备注描述,纪录当前列的分割坐标集合情况
+                let private_chk_in_pre_merge = function (preIdx, newCell) {
+                    let rst = true;
+                    if (preIdx >= 0 && preIdx < preColMergePosArr.length) {
+                        for (let mergeArea of preColMergePosArr[preIdx]) {
+                            if (newCell[JV.PROP_AREA][JV.PROP_TOP] >= mergeArea[0] && newCell[JV.PROP_AREA][JV.PROP_TOP] < mergeArea[1]) {
+                                rst = (newCell[JV.PROP_AREA][JV.PROP_BOTTOM] <= mergeArea[1]);
+                                break;
+                            }
+                        }
+                    }
+                    return rst;
+                };
+                for (let vidx = 0; vidx < verticalCombinePos.length; vidx++) {
+                    let vPosArr = verticalCombinePos[vidx];
                     let pStr = "_" + vPosArr[0] + "_" + vPosArr[1];
                     //rstPageCells的结果已经是按顺序排列了,这里不用再排序
                     if (cacheObj.vCache[pStr] && cacheObj.vCache[pStr].length > 0) {
                         let preCell = rstPageCells[cacheObj.vCache[pStr][0]];
+                        if (vidx === 0) {
+                            //这里要处理下
+                            let minY = 10000, maxY = 0;
+                            for (let preCIdx = 0; preCIdx < cacheObj.vCache[pStr].length; preCIdx++) {
+                                if (minY > rstPageCells[cacheObj.vCache[pStr][preCIdx]][JV.PROP_AREA][JV.PROP_TOP]) minY = rstPageCells[cacheObj.vCache[pStr][preCIdx]][JV.PROP_AREA][JV.PROP_TOP];
+                                if (maxY < rstPageCells[cacheObj.vCache[pStr][preCIdx]][JV.PROP_AREA][JV.PROP_BOTTOM]) maxY = rstPageCells[cacheObj.vCache[pStr][preCIdx]][JV.PROP_AREA][JV.PROP_BOTTOM];
+                            }
+                            preColMergePosArr.push([[minY, maxY]]);
+                        }
+                        let dtlColMergePosArr = [];
+                        preColMergePosArr.push(dtlColMergePosArr);
                         for (let cIdx = 1; cIdx < cacheObj.vCache[pStr].length; cIdx++) {
                             if (preCell.Value === "") {
+                                dtlColMergePosArr.push([preCell[JV.PROP_AREA][JV.PROP_TOP], preCell[JV.PROP_AREA][JV.PROP_BOTTOM]]);
                                 preCell = rstPageCells[cacheObj.vCache[pStr][cIdx]];
                             } else {
                                 if (preCell.Value === rstPageCells[cacheObj.vCache[pStr][cIdx]].Value) {
+                                    let bkBottom = preCell[JV.PROP_AREA][JV.PROP_BOTTOM];
                                     preCell[JV.PROP_AREA][JV.PROP_BOTTOM] = rstPageCells[cacheObj.vCache[pStr][cIdx]][JV.PROP_AREA][JV.PROP_BOTTOM];
-                                    removeCellIds.push(cacheObj.vCache[pStr][cIdx]);
+                                    if (private_chk_in_pre_merge(vidx, preCell)) {
+                                        removeCellIds.push(cacheObj.vCache[pStr][cIdx]);
+                                        if (cIdx === cacheObj.vCache[pStr].length - 1) {
+                                            dtlColMergePosArr.push([preCell[JV.PROP_AREA][JV.PROP_TOP], preCell[JV.PROP_AREA][JV.PROP_BOTTOM]]);
+                                        }
+                                    } else {
+                                        preCell[JV.PROP_AREA][JV.PROP_BOTTOM] = bkBottom;
+                                        dtlColMergePosArr.push([preCell[JV.PROP_AREA][JV.PROP_TOP], preCell[JV.PROP_AREA][JV.PROP_BOTTOM]]);
+                                        preCell = rstPageCells[cacheObj.vCache[pStr][cIdx]];
+                                    }
                                 } else {
+                                    dtlColMergePosArr.push([preCell[JV.PROP_AREA][JV.PROP_TOP], preCell[JV.PROP_AREA][JV.PROP_BOTTOM]]);
                                     preCell = rstPageCells[cacheObj.vCache[pStr][cIdx]];
                                 }
                             }
@@ -892,8 +933,10 @@ JpcFlowTabSrv.prototype.createNew = function(){
                 }
             }
             if (removeCellIds.length > 0) {
-                //这次真的要排序了
-                removeCellIds.sort(); //默认方式即可
+                //排序,保证一定的顺序,不能用默认的方式(默认方式是针对字符串的简单排序)
+                removeCellIds.sort(function (idx1, idx2) {
+                    return parseInt(idx1) - parseInt(idx2);
+                });
                 for (let idx = removeCellIds.length - 1; idx >= 0; idx--) {
                     rstPageCells.splice(removeCellIds[idx], 1);
                 }
@@ -1099,9 +1142,28 @@ JpcFlowTabSrv.prototype.createNew = function(){
         for (let idIdx = eliminateCells.length - 1; idIdx >= 0; idIdx--) {
             rst.splice(eliminateCells[idIdx], 1);
         }
+        me.checkCombineEvent(JV.RUN_TYPE_BEFORE_COMBINE, verticalCombinePos, horizonCombinePos, rst, $CURRENT_RPT);
         me.combinePageCells(rst, verticalCombinePos, horizonCombinePos);
+        me.checkCombineEvent(JV.RUN_TYPE_AFTER_COMBINE, verticalCombinePos, horizonCombinePos, rst, $CURRENT_RPT);
         return rst;
     };
+    JpcFlowTabResult.checkCombineEvent = function ($RUN_TYPE, $VER_COMB_ARRAY, $HOR_COMB_ARRAY, $CURRENT_CELL_ITEMS, $CURRENT_RPT) {
+        if ($CURRENT_RPT.formulas) {
+            for (let execFmlIdx = 0; execFmlIdx < $CURRENT_RPT.formulas.length; execFmlIdx++) {
+                if ($CURRENT_RPT.formulas[execFmlIdx][JV.PROP_RUN_TYPE] === $RUN_TYPE) {
+                    let expression = $CURRENT_RPT.formulas[execFmlIdx][JV.PROP_EXPRESSION];
+                    if (expression) {
+                        let $ME = $CURRENT_RPT.formulas[execFmlIdx];
+                        try {
+                            eval(expression);
+                        } catch (ex) {
+                            console.log(ex);
+                        }
+                    }
+                }
+            }
+        }
+    };
     JpcFlowTabResult.outputColumn = function (rptTpl, dataObj, page, segIdx, bands, unitFactor, multiColIdx) {
         let me = this, rst = [];
         let FLOW_NODE_STR = me.isEx?JV.NODE_FLOW_INFO_EX:JV.NODE_FLOW_INFO;

+ 2 - 0
public/web/rpt_value_define.js

@@ -207,6 +207,8 @@ const JV = {
     RUN_TYPE_BEFORE_ANALYZING: "before_analyzing",
     RUN_TYPE_BEFORE_PAGING: "before_paging",
     RUN_TYPE_BEFORE_OUTPUT: "before_output",
+    RUN_TYPE_BEFORE_COMBINE: "before_combine",
+    RUN_TYPE_AFTER_COMBINE: "after_combine",
 
     PAGE_STATUS: ["EveryPage","FirstPage", "LastPage", "SegmentStart", "SegmentEnd", "Group", "CrossRowEnd", "CrossColEnd"],