|
@@ -10,6 +10,7 @@ import JV from "../rpt_component/jpc_value_define";
|
|
let Template = mongoose.model('rpt_templates');
|
|
let Template = mongoose.model('rpt_templates');
|
|
let rptTplDataFacade = require("../facade/rpt_tpl_data_facade");
|
|
let rptTplDataFacade = require("../facade/rpt_tpl_data_facade");
|
|
let fsUtil = require("../../../public/fsUtil");
|
|
let fsUtil = require("../../../public/fsUtil");
|
|
|
|
+let pm_facade = require('../../../modules/pm/facade/pm_facade');
|
|
|
|
|
|
import rptTplFacade from "../facade/rpt_template_facade";
|
|
import rptTplFacade from "../facade/rpt_template_facade";
|
|
import demoTemplateFacade from "../facade/rpt_tpl_data_demo_facade";
|
|
import demoTemplateFacade from "../facade/rpt_tpl_data_demo_facade";
|
|
@@ -218,9 +219,65 @@ function getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, custo
|
|
if (rptTpl) {
|
|
if (rptTpl) {
|
|
let rptDataUtil = new rptDataExtractor();
|
|
let rptDataUtil = new rptDataExtractor();
|
|
rptDataUtil.initialize((rptTpl._doc)?rptTpl._doc:rptTpl);
|
|
rptDataUtil.initialize((rptTpl._doc)?rptTpl._doc:rptTpl);
|
|
- let filter = rptDataUtil.getDataRequestFilter();
|
|
|
|
|
|
+ let summaryRst = [];
|
|
|
|
+ let filter = rptDataUtil.getDataRequestFilter(summaryRst);
|
|
|
|
+ let promiseArr = [null, null];
|
|
|
|
+ if (summaryRst.length > 0) {
|
|
|
|
+ if (summaryRst.indexOf(`Construct`) >= 0 || summaryRst.indexOf(`ConstructDetail`) >= 0) {
|
|
|
|
+ promiseArr[0] = pm_facade.getSummaryInfoByTender(prj_id, pm_facade.projectType.project);
|
|
|
|
+ }
|
|
|
|
+ if (summaryRst.indexOf(`Segment`) >= 0 || summaryRst.indexOf(`SegmentDetail`) >= 0) {
|
|
|
|
+ promiseArr[1] = pm_facade.getSummaryInfoByTender(prj_id, pm_facade.projectType.engineering);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
rptTplDataFacade.prepareProjectData(user_id, prj_id, filter, function (err, msg, rawDataObj) {
|
|
rptTplDataFacade.prepareProjectData(user_id, prj_id, filter, function (err, msg, rawDataObj) {
|
|
if (!err) {
|
|
if (!err) {
|
|
|
|
+ let buildPageData = function() {
|
|
|
|
+ let tplData = rptDataUtil.assembleData(rawDataObj);
|
|
|
|
+ let printCom = JpcEx.createNew();
|
|
|
|
+ if (pageSize) rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = pageSize;
|
|
|
|
+ //console.log("orientation: " + (orientation === 'null'));
|
|
|
|
+ if (orientation && (orientation !== 'null')) rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_ORIENTATION] = orientation;
|
|
|
|
+ let defProperties = rptUtil.getReportDefaultCache();
|
|
|
|
+ if (customizeCfg) setupCustomizeCfg(customizeCfg, rptTpl, defProperties);
|
|
|
|
+ let dftOption = option||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, customizeCfg);
|
|
|
|
+ if (pageRst) {
|
|
|
|
+ // fsUtil.writeObjToFile(pageRst, "D:/GitHome/ConstructionCost/tmp/testBuiltPageResult.jsp");
|
|
|
|
+ cb(null, pageRst);
|
|
|
|
+ } else {
|
|
|
|
+ cb('Have errors while on going...', null);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ //*/
|
|
|
|
+ //取汇总数据流程
|
|
|
|
+ if (promiseArr[0] !== null) {
|
|
|
|
+ promiseArr[0].then(function (rst) {
|
|
|
|
+ rawDataObj.Construct = rst.parent;
|
|
|
|
+ rawDataObj.ConstructDetail = rst.subList;
|
|
|
|
+ if (promiseArr[1] !== null) {
|
|
|
|
+ promiseArr[1].then(function (rst) {
|
|
|
|
+ rawDataObj.Segment = rst.parent;
|
|
|
|
+ rawDataObj.SegmentDetail = rst.subList;
|
|
|
|
+ buildPageData(rawDataObj, rptDataUtil, rptTpl);
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ buildPageData(rawDataObj, rptDataUtil, rptTpl);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else if (promiseArr[1] !== null) {
|
|
|
|
+ promiseArr[1].then(function (rst) {
|
|
|
|
+ rawDataObj.Segment = rst.parent;
|
|
|
|
+ rawDataObj.SegmentDetail = rst.subList;
|
|
|
|
+ buildPageData(rawDataObj, rptDataUtil, rptTpl);
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ buildPageData(rawDataObj, rptDataUtil, rptTpl);
|
|
|
|
+ }
|
|
|
|
+ /*/
|
|
let tplData = rptDataUtil.assembleData(rawDataObj);
|
|
let tplData = rptDataUtil.assembleData(rawDataObj);
|
|
let printCom = JpcEx.createNew();
|
|
let printCom = JpcEx.createNew();
|
|
if (pageSize) rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = pageSize;
|
|
if (pageSize) rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = pageSize;
|
|
@@ -239,7 +296,7 @@ function getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, custo
|
|
} else {
|
|
} else {
|
|
cb('Have errors while on going...', null);
|
|
cb('Have errors while on going...', null);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ //*/
|
|
} else {
|
|
} else {
|
|
cb('No report data were found!', null);
|
|
cb('No report data were found!', null);
|
|
}
|
|
}
|
|
@@ -250,6 +307,7 @@ function getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, custo
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
module.exports = {
|
|
module.exports = {
|
|
getReportAllPages: function (req, res) {
|
|
getReportAllPages: function (req, res) {
|
|
let params = JSON.parse(req.body.params),
|
|
let params = JSON.parse(req.body.params),
|