|
|
@@ -248,7 +248,6 @@ function getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, custo
|
|
|
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);
|
|
|
@@ -344,62 +343,77 @@ function getMultiRptsCommon(user_id, prj_id, rpt_ids, pageSize, orientation, cus
|
|
|
filters.push(dtlFilter);
|
|
|
}
|
|
|
}
|
|
|
- //正常应该根据报表模板定义的数据类型来请求数据
|
|
|
- rptTplDataFacade.prepareProjectData(userId_Dft, demoPrjId, filters, function (err, msg, rawDataObj) {
|
|
|
- if (!err) {
|
|
|
- try {
|
|
|
- //1. 这里只用一份数据,根据实际应用情况,只需要保留copy三样数据: bills, ration, ration_glj, projectGLJ
|
|
|
- let savedBillsData = [], savedRationData = [], savedGljData = [];
|
|
|
- for (let dtlData of rawDataObj.prjData) {
|
|
|
- if (dtlData.moduleName === 'bills') {
|
|
|
- Object.assign(savedBillsData, dtlData.data);
|
|
|
- } else if (dtlData.moduleName === 'ration') {
|
|
|
- Object.assign(savedRationData, dtlData.data);
|
|
|
- } else if (dtlData.moduleName === 'ration_glj') {
|
|
|
- Object.assign(savedGljData, dtlData.data);
|
|
|
- } else if (dtlData.moduleName === 'projectGLJ') {
|
|
|
- //这个待定
|
|
|
- }
|
|
|
+ }
|
|
|
+ //正常应该根据报表模板定义的数据类型来请求数据
|
|
|
+ rptTplDataFacade.prepareProjectData(user_id, prj_id, filters, function (err, msg, rawDataObj) {
|
|
|
+ if (!err) {
|
|
|
+ try {
|
|
|
+ let rptPageRstArray = [];
|
|
|
+ //1. 这里只用一份数据,根据实际应用情况,只需要保留copy三样数据: bills, ration, ration_glj, projectGLJ
|
|
|
+ let savedBillsData = [], savedRationData = [], savedGljData = [], savedPrjGljData = [], savedFeeRateData = [];
|
|
|
+ for (let dtlData of rawDataObj.prjData) {
|
|
|
+ if (dtlData.moduleName === 'bills') {
|
|
|
+ Object.assign(savedBillsData, dtlData.data);
|
|
|
+ } else if (dtlData.moduleName === 'ration') {
|
|
|
+ Object.assign(savedRationData, dtlData.data);
|
|
|
+ } else if (dtlData.moduleName === 'ration_glj') {
|
|
|
+ Object.assign(savedGljData, dtlData.data);
|
|
|
+ } else if (dtlData.moduleName === 'feeRate') {
|
|
|
+ Object.assign(savedFeeRateData, dtlData.data._doc.rates);
|
|
|
+ } else if (dtlData.moduleName === 'projectGLJ') {
|
|
|
+ Object.assign(savedPrjGljData, dtlData.data.gljList);
|
|
|
}
|
|
|
- //2. 一个一个模板创建数据
|
|
|
- for (let tplIdx = 0; tplIdx < rptTpls.length; tplIdx++) {
|
|
|
- let rptTpl = (rptTpls[tplIdx]._doc)?rptTpls[tplIdx]._doc:rptTpls[tplIdx];
|
|
|
- rptDataUtil.initialize(rptTpl);
|
|
|
- let tplData = rptDataUtil.assembleData(rawDataObj);
|
|
|
- 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) {
|
|
|
- } else {
|
|
|
- }
|
|
|
- //注意:这里需要把清单、定额、工料机数据assign回去!!!
|
|
|
- for (let dtlData of rawDataObj.prjData) {
|
|
|
- if (dtlData.moduleName === 'bills' && savedBillsData.length > 0) {
|
|
|
- Object.assign(dtlData.data, savedBillsData);
|
|
|
- } else if (dtlData.moduleName === 'ration' && savedRationData.length > 0) {
|
|
|
- Object.assign(dtlData.data, savedRationData);
|
|
|
- } else if (dtlData.moduleName === 'ration_glj' && savedGljData.length > 0) {
|
|
|
- Object.assign(dtlData.data, savedGljData);
|
|
|
- } else if (dtlData.moduleName === 'projectGLJ') {
|
|
|
- //这个待定
|
|
|
- }
|
|
|
+ }
|
|
|
+ //2. 一个一个模板创建数据
|
|
|
+ for (let tplIdx = 0; tplIdx < rptTpls.length; tplIdx++) {
|
|
|
+ let rptTpl = (rptTpls[tplIdx]._doc)?rptTpls[tplIdx]._doc:rptTpls[tplIdx];
|
|
|
+ rptDataUtil.initialize(rptTpl);
|
|
|
+ let tplData = rptDataUtil.assembleData(rawDataObj);
|
|
|
+ let printCom = JpcEx.createNew();
|
|
|
+ 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;
|
|
|
+ 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, outputType);
|
|
|
+ let maxPages = printCom.totalPages;
|
|
|
+ let pageRst = null;
|
|
|
+ if (maxPages > 0) {
|
|
|
+ pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties, customizeCfg);
|
|
|
+ } else {
|
|
|
+ pageRst = printCom.outputAsPreviewPage(rptTpl, defProperties);
|
|
|
+ }
|
|
|
+ rptPageRstArray.push(pageRst);
|
|
|
+ //注意:这里需要把清单、定额、工料机数据assign回去!!!
|
|
|
+ for (let dtlData of rawDataObj.prjData) {
|
|
|
+ if (dtlData.moduleName === 'bills' && savedBillsData.length > 0) {
|
|
|
+ Object.assign(dtlData.data, savedBillsData);
|
|
|
+ } else if (dtlData.moduleName === 'ration' && savedRationData.length > 0) {
|
|
|
+ Object.assign(dtlData.data, savedRationData);
|
|
|
+ } else if (dtlData.moduleName === 'ration_glj' && savedGljData.length > 0) {
|
|
|
+ Object.assign(dtlData.data, savedGljData);
|
|
|
+ } else if (dtlData.moduleName === 'feeRate' && savedFeeRateData.length > 0) {
|
|
|
+ Object.assign(dtlData.data._doc.rates, savedFeeRateData);
|
|
|
+ } else if (dtlData.moduleName === 'projectGLJ' && savedPrjGljData.length > 0) {
|
|
|
+ Object.assign(dtlData.data.gljList, savedPrjGljData);
|
|
|
}
|
|
|
}
|
|
|
- } catch (ex) {
|
|
|
- console.log(ex);
|
|
|
- } finally {
|
|
|
}
|
|
|
- } else {
|
|
|
- //
|
|
|
+ cb(null, rptPageRstArray);
|
|
|
+ } catch (ex) {
|
|
|
+ console.log("报表数据异常(getMultiRptsCommon): userId " + user_id + ", project id: " + prj_id);
|
|
|
+ console.log(ex);
|
|
|
+ cb('Exception occurs while on going...', null);
|
|
|
+ } finally {
|
|
|
}
|
|
|
- })
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ cb('No report data were found!', null);
|
|
|
+ }
|
|
|
+ })
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -442,6 +456,88 @@ function getBillsSummaryReportPages(user_id, prjIds, rpt_id, pageSize, orientati
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+function getSummaryComboPages(user_id, prjIds, billsSummaryRpt_ids, gljSummaryRpt_ids, pageSize, orientation, customizeCfg, option, outputType, cb) {
|
|
|
+ let pageRstArr = [];
|
|
|
+ let pri_setup_rpt_tpl_data = function (rptTpl, summaryRawDataRst) {
|
|
|
+ let rptDataUtil = new rptDataExtractor();
|
|
|
+ rptDataUtil.initialize((rptTpl._doc)?rptTpl._doc:rptTpl);
|
|
|
+ try {
|
|
|
+ let tplData = rptDataUtil.assembleData(summaryRawDataRst);
|
|
|
+ let printCom = JpcEx.createNew();
|
|
|
+ if (pageSize) rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = pageSize;
|
|
|
+ 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, outputType);
|
|
|
+ let maxPages = printCom.totalPages;
|
|
|
+ let pageRst = null;
|
|
|
+ if (maxPages > 0) {
|
|
|
+ pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties, customizeCfg);
|
|
|
+ } else {
|
|
|
+ pageRst = printCom.outputAsPreviewPage(rptTpl, defProperties);
|
|
|
+ }
|
|
|
+ pageRstArr.push(pageRst);
|
|
|
+ } catch (ex) {
|
|
|
+ console.log("Summary报表数据异常: userId " + user_id + ", project ids: " + prjIds);
|
|
|
+ console.log(ex);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ let billRpts = [], gljRpts = [];
|
|
|
+ rptTplFacade.getRptTemplates(billsSummaryRpt_ids.concat(gljSummaryRpt_ids)).then(function(rptTpls) {
|
|
|
+ if (rptTpls && rptTpls.length > 0) {
|
|
|
+ for (let rptTpl of rptTpls) {
|
|
|
+ if (billsSummaryRpt_ids.indexOf(rptTpl.ID) >= 0) {
|
|
|
+ billRpts.push(rptTpl);
|
|
|
+ } else if (gljSummaryRpt_ids.indexOf(rptTpl.ID) >= 0) {
|
|
|
+ gljRpts.push(rptTpl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (billRpts.length > 0) {
|
|
|
+ rptTplDataFacade.getBudgetSummayDatas(prjIds).then(function(summaryRawDataRst) {
|
|
|
+ let savedBillsData = [];
|
|
|
+ Object.assign(savedBillsData, summaryRawDataRst.SummaryAuditDetail);
|
|
|
+ for (let idx = 0; idx < billRpts.length; idx++) {
|
|
|
+ pri_setup_rpt_tpl_data(billRpts[idx], summaryRawDataRst);
|
|
|
+ if (idx < billRpts.length - 1) {
|
|
|
+ Object.assign(summaryRawDataRst.SummaryAuditDetail, savedBillsData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (gljRpts && gljRpts.length > 0) {
|
|
|
+ rptTplDataFacade.getGLJSummayDatas(prjIds).then(function(summaryRawDataRst) {
|
|
|
+ let savedBillsData = [];
|
|
|
+ Object.assign(savedBillsData, summaryRawDataRst.SummaryAuditDetail);
|
|
|
+ for (let idx = 0; idx < gljRpts.length; idx++) {
|
|
|
+ pri_setup_rpt_tpl_data(gljRpts[idx], summaryRawDataRst);
|
|
|
+ if (idx < gljRpts.length - 1) {
|
|
|
+ Object.assign(summaryRawDataRst.SummaryAuditDetail, savedBillsData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cb(null, pageRstArr);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ cb(null, pageRstArr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if (gljRpts.length > 0) {
|
|
|
+ rptTplDataFacade.getGLJSummayDatas(prjIds).then(function(summaryRawDataRst) {
|
|
|
+ let savedBillsData = [];
|
|
|
+ Object.assign(savedBillsData, summaryRawDataRst.SummaryAuditDetail);
|
|
|
+ for (let idx = 0; idx < gljRpts.length; idx++) {
|
|
|
+ pri_setup_rpt_tpl_data(gljRpts[idx], summaryRawDataRst);
|
|
|
+ if (idx < gljRpts.length - 1) {
|
|
|
+ Object.assign(summaryRawDataRst.SummaryAuditDetail, savedBillsData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cb(null, pageRstArr);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
function getGljSummaryReportPages(user_id, prjIds, rpt_id, pageSize, orientation, customizeCfg, option, outputType, cb) {
|
|
|
let rptTpl = null;
|
|
|
rptTplDataFacade.getGLJSummayDatas(prjIds).then(function(summaryRawDataRst) {
|
|
|
@@ -497,6 +593,7 @@ module.exports = {
|
|
|
});
|
|
|
},
|
|
|
getMultiReports: function (req, res) {
|
|
|
+ //打印预览用
|
|
|
let params = JSON.parse(req.body.params),
|
|
|
prj_id = params.prj_id,
|
|
|
rpt_ids = params.rpt_ids.split(','),
|
|
|
@@ -578,6 +675,18 @@ module.exports = {
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ createSummaryReportFiles: function (req, res) {
|
|
|
+ let params = JSON.parse(req.body.params),
|
|
|
+ rpt_bill_tpl_ids = params.rpt_bill_tpl_ids,
|
|
|
+ rpt_glj_tpl_ids = params.rpt_glj_tpl_ids,
|
|
|
+ prjIds = params.prjIds,
|
|
|
+ pageSize = params.pageSize,
|
|
|
+ orientation = params.orientation,
|
|
|
+ customizeCfg = params.custCfg
|
|
|
+ ;
|
|
|
+ let user_id = req.session.sessionUser.id;
|
|
|
+ },
|
|
|
+
|
|
|
getReportAllPagesSvg: function (req, res) {
|
|
|
let params = JSON.parse(req.body.params),
|
|
|
rpt_id = params.rpt_tpl_id,
|
|
|
@@ -632,6 +741,54 @@ module.exports = {
|
|
|
})
|
|
|
},
|
|
|
|
|
|
+ createExcelFilesInOneBookEx: function (req, res) {
|
|
|
+ //采用了优化策略
|
|
|
+ let params = JSON.parse(req.body.params),
|
|
|
+ prj_id = params.prj_id,
|
|
|
+ rpt_ids = params.rpt_ids,
|
|
|
+ //--以下是汇总类数据----------
|
|
|
+ rpt_bill_tpl_ids = params.rpt_bill_tpl_ids,
|
|
|
+ rpt_glj_tpl_ids = params.rpt_glj_tpl_ids,
|
|
|
+ prjIds = params.prjIds,
|
|
|
+ //------------
|
|
|
+ rptName = params.rptName,
|
|
|
+ pageSize = params.pageSize,
|
|
|
+ orientation = params.orientation,
|
|
|
+ customizeCfg = params.custCfg,
|
|
|
+ option = params.option;
|
|
|
+ let user_id = req.session.sessionUser.id;
|
|
|
+ let dftOption = option||JV.PAGING_OPTION_NORMAL;
|
|
|
+
|
|
|
+ if (rpt_ids && rpt_ids.length > 0) {
|
|
|
+ getMultiRptsCommon(user_id, prj_id, rpt_ids, pageSize, orientation, customizeCfg, dftOption, JV.OUTPUT_TYPE_NORMAL, function (err, rptPageRstArray) {
|
|
|
+ if(err){
|
|
|
+ callback(req, res, '数据有误', null);
|
|
|
+ } else {
|
|
|
+ if ((rpt_bill_tpl_ids && rpt_bill_tpl_ids.length > 0) || (rpt_glj_tpl_ids && rpt_glj_tpl_ids.length > 0)) {
|
|
|
+ getSummaryComboPages(user_id, prjIds, rpt_bill_tpl_ids, rpt_glj_tpl_ids, pageSize, orientation, customizeCfg, option, JV.OUTPUT_TYPE_NORMAL, function (err, rptSumPageRstArray) {
|
|
|
+ rpt_xl_util.exportExcelInOneBook(rptPageRstArray.concat(rptSumPageRstArray), pageSize, rptName, function(uuidName){
|
|
|
+ let fileRst = {uuid: uuidName, reportName: rptName};
|
|
|
+ callback(req, res, err, fileRst);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ rpt_xl_util.exportExcelInOneBook(rptPageRstArray, pageSize, rptName, function(uuidName){
|
|
|
+ let fileRst = {uuid: uuidName, reportName: rptName};
|
|
|
+ callback(req, res, err, fileRst);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if ((rpt_bill_tpl_ids && rpt_bill_tpl_ids.length > 0) || (rpt_glj_tpl_ids && rpt_glj_tpl_ids.length > 0)) {
|
|
|
+ getSummaryComboPages(user_id, prjIds, rpt_bill_tpl_ids, rpt_glj_tpl_ids, pageSize, orientation, customizeCfg, option, JV.OUTPUT_TYPE_NORMAL, function (err, rptPageRstArray) {
|
|
|
+ rpt_xl_util.exportExcelInOneBook(rptPageRstArray, pageSize, rptName, function(uuidName){
|
|
|
+ let fileRst = {uuid: uuidName, reportName: rptName};
|
|
|
+ callback(req, res, err, fileRst);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
createExcelFiles: function (req, res) {
|
|
|
let params = JSON.parse(req.body.params),
|
|
|
prj_id = params.prj_id,
|
|
|
@@ -672,6 +829,76 @@ module.exports = {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
+ createExcelFilesEx: function (req, res) {
|
|
|
+ let params = JSON.parse(req.body.params),
|
|
|
+ prj_id = params.prj_id,
|
|
|
+ rpt_ids = params.rpt_ids,
|
|
|
+ //--以下是汇总类数据----------
|
|
|
+ rpt_bill_tpl_ids = params.rpt_bill_tpl_ids,
|
|
|
+ rpt_glj_tpl_ids = params.rpt_glj_tpl_ids,
|
|
|
+ prjIds = params.prjIds,
|
|
|
+ sum_rpt_names = params.sum_rpt_names,
|
|
|
+ //------------
|
|
|
+ rpt_names = params.rpt_names,
|
|
|
+ pageSize = params.pageSize,
|
|
|
+ orientation = params.orientation,
|
|
|
+ isOneSheet = params.isOneSheet,
|
|
|
+ customizeCfg = params.custCfg,
|
|
|
+ option = params.option;
|
|
|
+ let user_id = req.session.sessionUser.id;
|
|
|
+ let dftOption = option||JV.PAGING_OPTION_NORMAL;
|
|
|
+ let pri_Add_Parallel_Functions = function (parallelFunctions, rptPageRstArray, paraRptNames, err) {
|
|
|
+ for (let idx = 0; idx < rptPageRstArray.length; idx++) {
|
|
|
+ parallelFunctions.push((function (pageRst, rpt_name) {
|
|
|
+ return function (cb) {
|
|
|
+ rpt_xl_util.exportExcel(pageRst, pageSize, rpt_name, isOneSheet, null, null, function(uuidName){
|
|
|
+ let fileRst = {uuid: uuidName, reportName: rpt_name};
|
|
|
+ cb(err, fileRst);
|
|
|
+ })
|
|
|
+ };
|
|
|
+ })(rptPageRstArray[idx], paraRptNames[idx]));
|
|
|
+ }
|
|
|
+ };
|
|
|
+ let pri_Run_Parallel_Functions = function (parallelFunctions) {
|
|
|
+ async.parallel(parallelFunctions, function (err, fileRstArray) {
|
|
|
+ if (err) {
|
|
|
+ console.log('导出Excel错误(导出数据过程错误), userId: ' + user_id + ', prjId' + prj_id);
|
|
|
+ callback(req, res, '数据导出错误', null);
|
|
|
+ } else {
|
|
|
+ // console.log(err);
|
|
|
+ callback(req, res, err, fileRstArray);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ if (rpt_ids && rpt_ids.length > 0) {
|
|
|
+ getMultiRptsCommon(user_id, prj_id, rpt_ids, pageSize, orientation, customizeCfg, dftOption, JV.OUTPUT_TYPE_PDF, function (err, rptPageRstArray) {
|
|
|
+ if (err) {
|
|
|
+ console.log('导出Excel错误(生成数据过程错误), userId: ' + user_id + ', prjId' + prj_id);
|
|
|
+ callback(req, res, '数据生成错误', null);
|
|
|
+ } else {
|
|
|
+ if ((rpt_bill_tpl_ids && rpt_bill_tpl_ids.length > 0) || (rpt_glj_tpl_ids && rpt_glj_tpl_ids.length > 0)) {
|
|
|
+ getSummaryComboPages(user_id, prjIds, rpt_bill_tpl_ids, rpt_glj_tpl_ids, pageSize, orientation, customizeCfg, option, JV.OUTPUT_TYPE_NORMAL, function (err, rptSumPageRstArray) {
|
|
|
+ let parallelFunctions = [];
|
|
|
+ pri_Add_Parallel_Functions(parallelFunctions, rptPageRstArray, rpt_names, err);
|
|
|
+ pri_Add_Parallel_Functions(parallelFunctions, rptSumPageRstArray, sum_rpt_names, err);
|
|
|
+ pri_Run_Parallel_Functions(parallelFunctions);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ let parallelFunctions = [];
|
|
|
+ pri_Add_Parallel_Functions(parallelFunctions, rptPageRstArray, rpt_names, err);
|
|
|
+ pri_Run_Parallel_Functions(parallelFunctions);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if ((rpt_bill_tpl_ids && rpt_bill_tpl_ids.length > 0) || (rpt_glj_tpl_ids && rpt_glj_tpl_ids.length > 0)) {
|
|
|
+ getSummaryComboPages(user_id, prjIds, rpt_bill_tpl_ids, rpt_glj_tpl_ids, pageSize, orientation, customizeCfg, option, JV.OUTPUT_TYPE_NORMAL, function (err, rptSumPageRstArray) {
|
|
|
+ let parallelFunctions = [];
|
|
|
+ pri_Add_Parallel_Functions(parallelFunctions, rptSumPageRstArray, sum_rpt_names, err);
|
|
|
+ pri_Run_Parallel_Functions(parallelFunctions);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
getFileByUUID: function (req, res) {
|
|
|
let uuid = req.params.uuid,
|
|
|
rptName = req.params.rptName,
|
|
|
@@ -806,6 +1033,74 @@ module.exports = {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ createPdfFilesEx: function (req, res) {
|
|
|
+ let params = JSON.parse(req.body.params),
|
|
|
+ prj_id = params.prj_id,
|
|
|
+ rpt_ids = params.rpt_ids,
|
|
|
+ rpt_names = params.rpt_names,
|
|
|
+ //--以下是汇总类数据----------
|
|
|
+ rpt_bill_tpl_ids = params.rpt_bill_tpl_ids,
|
|
|
+ rpt_glj_tpl_ids = params.rpt_glj_tpl_ids,
|
|
|
+ prjIds = params.prjIds,
|
|
|
+ sum_rpt_names = params.sum_rpt_names,
|
|
|
+ //------------
|
|
|
+ pageSize = params.pageSize,
|
|
|
+ orientation = params.orientation,
|
|
|
+ customizeCfg = params.custCfg,
|
|
|
+ option = params.option;
|
|
|
+ let user_id = req.session.sessionUser.id;
|
|
|
+ let dftOption = option||JV.PAGING_OPTION_NORMAL;
|
|
|
+ let pri_Add_Parallel_Functions = function (parallelFunctions, rptPageRstArray, paraRptNames, err) {
|
|
|
+ for (let idx = 0; idx < rptPageRstArray.length; idx++) {
|
|
|
+ parallelFunctions.push((function (pageRst, rpt_name) {
|
|
|
+ return function (cb) {
|
|
|
+ rpt_pdf_util.export_pdf_file(pageRst, pageSize, rpt_name, function(uuidName){
|
|
|
+ let fileRst = {uuid: uuidName, reportName: rpt_name};
|
|
|
+ cb(err, fileRst);
|
|
|
+ })
|
|
|
+ };
|
|
|
+ })(rptPageRstArray[idx], paraRptNames[idx]));
|
|
|
+ }
|
|
|
+ };
|
|
|
+ let pri_Run_Parallel_Functions = function (parallelFunctions) {
|
|
|
+ async.parallel(parallelFunctions, function (err, fileRstArray) {
|
|
|
+ if (err) {
|
|
|
+ console.log('导出PDF错误(生成数据过程错误), userId: ' + user_id + ', prjId' + prj_id);
|
|
|
+ callback(req, res, '数据导出错误', null);
|
|
|
+ } else {
|
|
|
+ // console.log(err);
|
|
|
+ callback(req, res, err, fileRstArray);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ if (rpt_ids && rpt_ids.length > 0) {
|
|
|
+ getMultiRptsCommon(user_id, prj_id, rpt_ids, pageSize, orientation, customizeCfg, dftOption, JV.OUTPUT_TYPE_PDF, function (err, rptPageRstArray) {
|
|
|
+ if (err) {
|
|
|
+ console.log('导出Excel错误(生成数据过程错误), userId: ' + user_id + ', prjId' + prj_id);
|
|
|
+ callback(req, res, '数据生成错误', null);
|
|
|
+ } else {
|
|
|
+ if ((rpt_bill_tpl_ids && rpt_bill_tpl_ids.length > 0) || (rpt_glj_tpl_ids && rpt_glj_tpl_ids.length > 0)) {
|
|
|
+ getSummaryComboPages(user_id, prjIds, rpt_bill_tpl_ids, rpt_glj_tpl_ids, pageSize, orientation, customizeCfg, option, JV.OUTPUT_TYPE_NORMAL, function (err, rptSumPageRstArray) {
|
|
|
+ let parallelFunctions = [];
|
|
|
+ pri_Add_Parallel_Functions(parallelFunctions, rptPageRstArray, rpt_names, err);
|
|
|
+ pri_Add_Parallel_Functions(parallelFunctions, rptSumPageRstArray, sum_rpt_names, err);
|
|
|
+ pri_Run_Parallel_Functions(parallelFunctions);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ let parallelFunctions = [];
|
|
|
+ pri_Add_Parallel_Functions(parallelFunctions, rptPageRstArray, rpt_names, err);
|
|
|
+ pri_Run_Parallel_Functions(parallelFunctions);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if ((rpt_bill_tpl_ids && rpt_bill_tpl_ids.length > 0) || (rpt_glj_tpl_ids && rpt_glj_tpl_ids.length > 0)) {
|
|
|
+ getSummaryComboPages(user_id, prjIds, rpt_bill_tpl_ids, rpt_glj_tpl_ids, pageSize, orientation, customizeCfg, option, JV.OUTPUT_TYPE_NORMAL, function (err, rptSumPageRstArray) {
|
|
|
+ let parallelFunctions = [];
|
|
|
+ pri_Add_Parallel_Functions(parallelFunctions, rptSumPageRstArray, sum_rpt_names, err);
|
|
|
+ pri_Run_Parallel_Functions(parallelFunctions);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
getPDF:function (req, res) {
|
|
|
let prj_id = req.params.prj_id,
|
|
|
rpt_id = req.params.rpt_id,
|