|
@@ -2,11 +2,13 @@
|
|
|
* Created by Tony on 2017/10/18.
|
|
|
*/
|
|
|
let test = require('tape');
|
|
|
+import JpcEx from "../../../modules/reports/rpt_component/jpc_ex";
|
|
|
import JV from "../../../modules/reports/rpt_component/jpc_value_define";
|
|
|
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();
|
|
|
let consts = require('../../../modules/main/models/project_consts');
|
|
|
let projectConsts = consts.projectConst;
|
|
@@ -26,7 +28,8 @@ fileUtils.getGlobbedFiles('../../../modules/reports/models/*.js').forEach(functi
|
|
|
//暂时引入其它模块的model
|
|
|
require('../../../modules/fee_rates/models/fee_rates');
|
|
|
// 引入人工系数模块
|
|
|
-require('../../../modules/main/models/labour_coe');
|
|
|
+require('../../../modules/main/models/labour_coe_model');
|
|
|
+require('../../../modules/main/models/calc_program_model');
|
|
|
|
|
|
let fsUtil = require("../../../public/fsUtil");
|
|
|
|
|
@@ -35,9 +38,7 @@ let projectDataMdl = require('../../../modules/main/models/project');
|
|
|
let demoPrjId = - 1;
|
|
|
let demoRptId = 226, pagesize = "A4";
|
|
|
|
|
|
-demoPrjId = 469; //QA: 1号教学楼建筑工程
|
|
|
-// demoPrjId = 491; //QA: 2号教学楼建筑工程
|
|
|
-// demoPrjId = 492; //QA: 3号教学楼建筑工程
|
|
|
+demoPrjId = 610; //QA: 建筑工程
|
|
|
let userId_Leng = 1142; //小冷User Id
|
|
|
|
|
|
let rptTplFacade = require("../../../modules/reports/facade/rpt_template_facade");
|
|
@@ -45,66 +46,90 @@ let rptTplDataFacade = require("../../../modules/reports/facade/rpt_tpl_data_fac
|
|
|
|
|
|
import rptDataExtractor from "../../../modules/reports/util/rpt_construct_data_util";
|
|
|
|
|
|
-// test('测试 - 获取project数据: ', function (t) {
|
|
|
-// projectDataMdl.getData(demoPrjId, function (err, message, result) {
|
|
|
-// if (!err) {
|
|
|
-// fsUtil.wirteObjToFile(result, "D:/GitHome/ConstructionCost/tmp/ProjectDataFullObject.js");
|
|
|
-// t.pass('pass succeeded!');
|
|
|
-// t.end();
|
|
|
-// } else {
|
|
|
-// //callback(req, res, err, message, null);
|
|
|
-// t.pass('pass failed!');
|
|
|
-// t.end();
|
|
|
-// }
|
|
|
-// });
|
|
|
-// });
|
|
|
+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('测试 - 获取project部分数据: ', function (t) {
|
|
|
-// let filter = [];
|
|
|
-// filter.push(projectConsts.BILLS);
|
|
|
-// filter.push(projectConsts.RATION);
|
|
|
-// filter.push(projectConsts.RATION_GLJ);
|
|
|
-// filter.push(projectConsts.FEERATE);
|
|
|
-// prjMdl.project.getUserProject(userId_Leng, demoPrjId, function(err, msg, prjObj){
|
|
|
-// if (!err) {
|
|
|
-// projectDataMdl.getFilterData(demoPrjId, filter, function (results) {
|
|
|
-// if (results) {
|
|
|
-// // let newData = [];
|
|
|
-// // for (let item of results) {
|
|
|
-// // newData.push(JSON.stringify(item));
|
|
|
-// // }
|
|
|
-// // fsUtil.writeArrayToFile(newData, "D:/GitHome/ConstructionCost/tmp/getProjectData_partial.js");
|
|
|
-// fsUtil.wirteObjToFile(prjObj, "D:/GitHome/ConstructionCost/tmp/getProjectObjectNew.js");
|
|
|
-// fsUtil.wirteObjToFile(results, "D:/GitHome/ConstructionCost/tmp/getProjectData_partialNew.js");
|
|
|
-// t.pass('pass succeeded!');
|
|
|
-// t.end();
|
|
|
-// } else {
|
|
|
-// //callback(req, res, err, message, null);
|
|
|
-// t.pass('get project data failed!');
|
|
|
-// t.end();
|
|
|
-// }
|
|
|
-// });
|
|
|
-// } else {
|
|
|
-// t.pass('get project failed!');
|
|
|
-// t.end();
|
|
|
-// }
|
|
|
-// });
|
|
|
-// });
|
|
|
+/*/
|
|
|
+test('测试 - 获取project数据: ', function (t) {
|
|
|
+ projectDataMdl.getData(demoPrjId, function (err, message, result) {
|
|
|
+ if (!err) {
|
|
|
+ fsUtil.wirteObjToFile(result, "D:/GitHome/ConstructionCost/tmp/ProjectDataFullObject.js");
|
|
|
+ t.pass('pass succeeded!');
|
|
|
+ t.end();
|
|
|
+ } else {
|
|
|
+ //callback(req, res, err, message, null);
|
|
|
+ t.pass('pass failed!');
|
|
|
+ t.end();
|
|
|
+ }
|
|
|
+ });
|
|
|
+});
|
|
|
+//*/
|
|
|
+/*/
|
|
|
+test('测试 - 获取project部分数据: ', function (t) {
|
|
|
+ let filter = [];
|
|
|
+ filter.push(projectConsts.BILLS);
|
|
|
+ filter.push(projectConsts.RATION);
|
|
|
+ filter.push(projectConsts.RATION_GLJ);
|
|
|
+ filter.push(projectConsts.FEERATE);
|
|
|
+ prjMdl.project.getUserProject(userId_Leng, demoPrjId, function(err, msg, prjObj){
|
|
|
+ if (!err) {
|
|
|
+ projectDataMdl.getFilterData(demoPrjId, filter, function (results) {
|
|
|
+ if (results) {
|
|
|
+ // let newData = [];
|
|
|
+ // for (let item of results) {
|
|
|
+ // newData.push(JSON.stringify(item));
|
|
|
+ // }
|
|
|
+ // fsUtil.writeArrayToFile(newData, "D:/GitHome/ConstructionCost/tmp/getProjectData_partial.js");
|
|
|
+ fsUtil.wirteObjToFile(prjObj, "D:/GitHome/ConstructionCost/tmp/getProjectObjectNew.js");
|
|
|
+ fsUtil.wirteObjToFile(results, "D:/GitHome/ConstructionCost/tmp/getProjectData_partialNew.js");
|
|
|
+ t.pass('pass succeeded!');
|
|
|
+ t.end();
|
|
|
+ } else {
|
|
|
+ //callback(req, res, err, message, null);
|
|
|
+ t.pass('get project data failed!');
|
|
|
+ t.end();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ t.pass('get project failed!');
|
|
|
+ t.end();
|
|
|
+ }
|
|
|
+ });
|
|
|
+});
|
|
|
+//*/
|
|
|
|
|
|
+//*
|
|
|
test('测试 - 测试模板啦: ', function (t) {
|
|
|
- rptTplFacade.getRptTemplate(demoRptId).then(function(tpl) {
|
|
|
+ rptTplFacade.getRptTemplate(demoRptId).then(function(rptTpl) {
|
|
|
let rptDataUtil = new rptDataExtractor();
|
|
|
- rptDataUtil.initialize(tpl);
|
|
|
+ rptDataUtil.initialize(rptTpl._doc);
|
|
|
let filter = rptDataUtil.getDataRequestFilter();
|
|
|
console.log(filter);
|
|
|
//正常应该根据报表模板定义的数据类型来请求数据
|
|
|
rptTplDataFacade.prepareProjectData(userId_Leng, demoPrjId, filter, function (err, msg, rawDataObj) {
|
|
|
if (!err) {
|
|
|
- rptDataUtil.assembleData(rawDataObj);
|
|
|
+ let tplData = rptDataUtil.assembleData(rawDataObj);
|
|
|
+ // fsUtil.wirteObjToFile(rawDataObj, "D:/GitHome/ConstructionCost/tmp/rptTplRawDataObject.js");
|
|
|
+ //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.wirteObjToFile(pageRst, "D:/GitHome/ConstructionCost/tmp/testBuiltPageResult.js");
|
|
|
+ } else {
|
|
|
+ console.log("oh! no pages were created!")
|
|
|
+ }
|
|
|
+
|
|
|
t.pass('pass succeeded!');
|
|
|
t.end();
|
|
|
- //fsUtil.wirteObjToFile(rawDataObj, "D:/GitHome/ConstructionCost/tmp/rptTplRawDataObject1.js");
|
|
|
- //准备执行公式需要的对象
|
|
|
} else {
|
|
|
console.log(msg);
|
|
|
t.pass('pass with error!');
|
|
@@ -113,6 +138,7 @@ test('测试 - 测试模板啦: ', function (t) {
|
|
|
})
|
|
|
});
|
|
|
});
|
|
|
+//*/
|
|
|
|
|
|
test('close the connection', function (t) {
|
|
|
setTimeout(function () {
|