Przeglądaj źródła

重庆2018 A.0.1 表

TonyKang 6 lat temu
rodzic
commit
c2afd411b6

+ 5 - 0
modules/reports/controllers/rpt_controller.js

@@ -242,6 +242,8 @@ function getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, custo
                 }
             }
             if (economicRst.length > 0) {
+                // economicRst.push('ProjectInfoFields');
+                // economicRst.push('ProjectFeatureFields');
                 promiseArr[2] = pm_facade.getIndexReportData(prj_id, economicRst);
             }
             rptTplDataFacade.prepareProjectData(user_id, prj_id, filter, function (err, msg, rawDataObj) {
@@ -303,6 +305,9 @@ function getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, custo
                         if (promiseArr[2] !== null) {
                             promiseArr[2].then(function (rst) {
                                 let ecoFieldsRst = (rst._doc)?rst._doc:rst;
+                                // fsUtil.writeObjToFile(ecoFieldsRst, "D:/GitHome/ConstructionCost/tmp/testEcoFieldsResult.jsp");
+                                rawDataObj.prjData.push({moduleName: 'ProjectInfoFields', data: ecoFieldsRst.ProjectInfoFields});
+                                rawDataObj.prjData.push({moduleName: 'ProjectFeatureFields', data: ecoFieldsRst.ProjectFeatureFields});
                                 rawDataObj.prjData.push({moduleName: 'ProjectCostFields', data: ecoFieldsRst.ProjectCostFields});
                                 rawDataObj.prjData.push({moduleName: 'ProjectEcoFields', data: ecoFieldsRst.ProjectEcoFields});
                                 rawDataObj.prjData.push({moduleName: 'ProjectLabMaterialFields', data: ecoFieldsRst.ProjectLabMaterialFields});

+ 2 - 1
test/unit/reports/test_rpt_test_template.js

@@ -50,7 +50,8 @@ let demoPrjId = - 1;
 // let demoRptId = 710; //qa 01
 // let demoRptId = 931; //qa 内蒙古2017 【扉-1】招标工程量清单扉页
 // let demoRptId = 957; //qa 内蒙古2017 12-4
-let demoRptId = 1006; //qa 重庆2018 A03
+// let demoRptId = 1006; //qa 重庆2018 A03
+let demoRptId = 1007; //qa 重庆2018 A01
 // let demoRptId = 475; //计日工
 // let demoRptId = 551; //表05
 let pagesize = "A4";

+ 0 - 104
test/unit/reports/test_tpl_11.js

@@ -1,104 +0,0 @@
-/**
- * Created by Tony on 2018/5/11.
- */
-
-let test = require('tape');
-import JpcEx from "../../../modules/reports/rpt_component/jpc_ex";
-import JV from "../../../modules/reports/rpt_component/jpc_value_define";
-let config = require("../../../config/config.js");
-config.setupDb(process.env.NODE_ENV);
-let mongoose = require("mongoose");
-let fileUtils = require("../../../modules/common/fileUtils");
-let path = require('path');
-let dbm = require("../../../config/db/db_manager");
-let rpt_cfg = require('./rpt_cfg');
-dbm.connect(process.env.NODE_ENV);
-
-//统一引用models
-fileUtils.getGlobbedFiles('../../../modules/all_models/*.js').forEach(function(modelPath) {
-    require(path.resolve(modelPath));
-});
-
-//config.setupCache();
-let cfgCacheUtil = require("../../../config/cacheCfg");
-cfgCacheUtil.setupDftCache();
-
-let fsUtil = require("../../../public/fsUtil");
-
-let demoPrjId = - 1;
-//let demoRptId = 247, pagesize = "A4";
-let demoRptId = 281, pagesize = "A4"; //281: 11-2
-
-// let userId_Leng = "59cdf14a0034a1000ba52b97"; //小冷User Id 换成_id了 QQ号
-let userId_Leng = "5acac1e885bf55000bd055ba"; //小冷User Id2
-// demoPrjId = 720; //QA: DW3
-//demoPrjId = 1626; //QA:
-demoPrjId = 2260; //QA:
-//*/
-let userId_Dft = userId_Leng;
-/*/
- let userId_Dft = "595328da1934dc327cad08eb";
- //*/
-
-let rptTplFacade = require("../../../modules/reports/facade/rpt_template_facade");
-let rptTplDataFacade = require("../../../modules/reports/facade/rpt_tpl_data_facade");
-
-import rptDataExtractor from "../../../modules/reports/util/rpt_construct_data_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);
-});
-
-test('测试 - 测试模板: 表-11 ', function (t) {
-    rptTplFacade.getRptTemplate(demoRptId).then(function(rptTpl) {
-        let rptDataUtil = new rptDataExtractor();
-        rptDataUtil.initialize(rptTpl._doc);
-        let filter = rptDataUtil.getDataRequestFilter();
-        console.log(filter);
-        //正常应该根据报表模板定义的数据类型来请求数据
-        rptTplDataFacade.prepareProjectData(userId_Dft, demoPrjId, filter, function (err, msg, rawDataObj) {
-            if (!err) {
-                try {
-                    // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/ConstructionCost/tmp/rptTplRawDataObject_建筑11表.jsp");
-                    let tplData = rptDataUtil.assembleData(rawDataObj);
-                    // fsUtil.writeObjToFile(tplData, "D:/GitHome/ConstructionCost/tmp/rptTplAssembledData_建筑11表.jsp");
-                    //it's time to build the report!!!
-                    let printCom = JpcEx.createNew();
-                    rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = pagesize;
-                    let defProperties = rpt_cfg;
-                    let dftOption = JV.PAGING_OPTION_NORMAL;
-                    printCom.initialize(rptTpl);
-                    printCom.analyzeData(rptTpl, tplData, defProperties, dftOption);
-                    let maxPages = printCom.totalPages;
-                    let pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties);
-                    if (pageRst) {
-                        // fsUtil.writeObjToFile(pageRst, "D:/GitHome/ConstructionCost/tmp/testBuiltPageResult_建筑11表.jsp");
-                    } else {
-                        console.log("oh! no pages were created!");
-                    }
-                } catch (ex) {
-                    console.log(ex);
-                    t.pass('pass with exception!');
-                    t.end();
-                }
-
-                t.pass('pass succeeded!');
-                t.end();
-            } else {
-                console.log(msg);
-                t.pass('pass with error!');
-                t.end();
-            }
-        })
-    });
-});
-
-test('close the connection', function (t) {
-    setTimeout(function () {
-        mongoose.disconnect();
-        t.pass('closing db connection');
-        t.end();
-    }, 1000);
-});

+ 140 - 0
test/unit/reports/test_tpl_project_fields.js

@@ -0,0 +1,140 @@
+/**
+ * Created by Tony on 2018/6/12.
+ * 专门测试项目技术经济指标类型表
+ */
+
+let test = require('tape');
+import JpcEx from "../../../modules/reports/rpt_component/jpc_ex";
+import JV from "../../../modules/reports/rpt_component/jpc_value_define";
+let config = require("../../../config/config.js");
+config.setupDb(process.env.NODE_ENV);
+let mongoose = require("mongoose");
+let fileUtils = require("../../../modules/common/fileUtils");
+let path = require('path');
+let dbm = require("../../../config/db/db_manager");
+let rpt_cfg = require('./rpt_cfg');
+dbm.connect(process.env.NODE_ENV);
+
+//统一引用models
+fileUtils.getGlobbedFiles('../../../modules/all_models/*.js').forEach(function(modelPath) {
+    require(path.resolve(modelPath));
+});
+
+//config.setupCache();
+let cfgCacheUtil = require("../../../config/cacheCfg");
+cfgCacheUtil.setupDftCache();
+
+let fsUtil = require("../../../public/fsUtil");
+let pm_facade = require('../../../modules/pm/facade/pm_facade');
+
+let demoPrjId = - 1;
+// let demoRptId = 1006; //qa 重庆2018 A03
+let demoRptId = 1007; //qa 重庆2018 A01
+let pagesize = "A4";
+
+
+// let userId_Leng = "59cdf14a0034a1000ba52b97"; //小冷User Id 换成_id了 QQ号
+let userId_Leng = "5acac1e885bf55000bd055ba"; //小冷User Id2
+let userId_me = "5b6a60b1c4ba33000dd417c0"; //我的
+// let userId_HaiZhu = "5b5a66c4a3c23e000dccdd77"; //海珠user id
+demoPrjId = 8522; //
+//*/
+let userId_Dft = userId_Leng;
+// let userId_Dft = "5a025c4c15074d134c2b9689";
+/*/
+ let userId_Dft = "595328da1934dc327cad08eb";
+ //*/
+
+let rptTplFacade = require("../../../modules/reports/facade/rpt_template_facade");
+let rptTplDataFacade = require("../../../modules/reports/facade/rpt_tpl_data_facade");
+
+import rptDataExtractor from "../../../modules/reports/util/rpt_construct_data_util";
+import rpt_xl_util from "../../../modules/reports/util/rpt_excel_util";
+import rpt_pdf_util from "../../../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);
+});
+
+test('测试 - : ', function (t) {
+    rptTplFacade.getRptTemplate(demoRptId).then(function(rptTpl) {
+        let rptDataUtil = new rptDataExtractor();
+        rptDataUtil.initialize(rptTpl._doc);
+        let promiseArr = [null, null, null];
+        let summaryRst = [], economicRst = [];
+        let filter = rptDataUtil.getDataRequestFilter(summaryRst, economicRst);
+        // console.log(filter);
+        if (economicRst.length > 0) {
+            // economicRst.push('ProjectInfoFields');
+            // economicRst.push('ProjectFeatureFields');
+            promiseArr[2] = pm_facade.getIndexReportData(demoPrjId, economicRst);
+        }
+        //正常应该根据报表模板定义的数据类型来请求数据
+        rptTplDataFacade.prepareProjectData(userId_Dft, demoPrjId, filter, function (err, msg, rawDataObj) {
+            if (!err) {
+                try {
+                    promiseArr[2].then(function (rst) {
+                        let ecoFieldsRst = (rst._doc)?rst._doc:rst;
+                        // fsUtil.writeObjToFile(ecoFieldsRst, "D:/GitHome/ConstructionCost/tmp/testEcoFieldsResult.jsp");
+                        rawDataObj.prjData.push({moduleName: 'ProjectInfoFields', data: ecoFieldsRst.ProjectInfoFields});
+                        rawDataObj.prjData.push({moduleName: 'ProjectFeatureFields', data: ecoFieldsRst.ProjectFeatureFields});
+                        rawDataObj.prjData.push({moduleName: 'ProjectCostFields', data: ecoFieldsRst.ProjectCostFields});
+                        rawDataObj.prjData.push({moduleName: 'ProjectEcoFields', data: ecoFieldsRst.ProjectEcoFields});
+                        rawDataObj.prjData.push({moduleName: 'ProjectLabMaterialFields', data: ecoFieldsRst.ProjectLabMaterialFields});
+                        rawDataObj.prjData.push({moduleName: 'ProjectQtyFields', data: ecoFieldsRst.ProjectQtyFields});
+
+                        // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/ConstructionCost/tmp/rptTplRawDataObject_系统指标.jsp");
+                        let tplData = rptDataUtil.assembleData(rawDataObj);
+                        // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/ConstructionCost/tmp/rptTplRawDataAfterCacl_系统指标.jsp");
+                        // fsUtil.writeObjToFile(tplData, "D:/GitHome/ConstructionCost/tmp/rptTplAssembledData_系统指标.jsp");
+                        //it's time to build the report!!!
+                        let printCom = JpcEx.createNew();
+                        rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = pagesize;
+                        let defProperties = rpt_cfg;
+                        let dftOption = JV.PAGING_OPTION_NORMAL;
+                        printCom.initialize(rptTpl);
+                        printCom.analyzeData(rptTpl, tplData, defProperties, dftOption, JV.OUTPUT_TYPE_EXCEL);
+                        let maxPages = printCom.totalPages;
+                        let customizeCfg = {"fillZero": true};
+                        let pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties, customizeCfg);
+                        if (pageRst) {
+                            // fsUtil.writeObjToFile(pageRst, "D:/GitHome/ConstructionCost/tmp/testBuiltPageResult_系统指标.jsp");
+                            // rpt_xl_util.exportExcel(pageRst, pagesize, "local_test_rpt_excel", true, null, null, function(uuidName){
+                            //     console.log("excel uuid: " + uuidName);
+                            // });
+                            // rpt_pdf_util.export_pdf_file(pageRst, pagesize, 'local_test_rpt_pdf', function(uuidName){
+                            //     console.log("pdf uuid: " + uuidName);
+                            // });
+                        } else {
+                            console.log("oh! no pages were created!");
+                        }
+                    });
+                } catch (ex) {
+                    console.log(ex);
+                    t.pass('pass with exception!');
+                    t.end();
+                }
+
+                t.pass('pass succeeded!');
+                t.end();
+            } else {
+                console.log(msg);
+                t.pass('pass with error!');
+                t.end();
+            }
+        })
+    });
+});
+
+test('close the connection', function (t) {
+    setTimeout(function () {
+        mongoose.disconnect();
+        t.pass('closing db connection');
+        t.end();
+    }, 1000);
+    // mongoose.disconnect();
+    // t.pass('closing db connection');
+    // t.end();
+});