|
|
@@ -244,28 +244,34 @@ function getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, custo
|
|
|
rptTplDataFacade.prepareProjectData(user_id, prj_id, filter, function (err, msg, rawDataObj) {
|
|
|
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, 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);
|
|
|
- }
|
|
|
- if (pageRst) {
|
|
|
- // fsUtil.writeObjToFile(pageRst, "D:/GitHome/ConstructionCost/tmp/testBuiltPageResult.jsp");
|
|
|
- cb(null, pageRst);
|
|
|
- } else {
|
|
|
- cb('Have errors while on going...', null);
|
|
|
+ try {
|
|
|
+ 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, 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);
|
|
|
+ }
|
|
|
+ if (pageRst) {
|
|
|
+ // fsUtil.writeObjToFile(pageRst, "D:/GitHome/ConstructionCost/tmp/testBuiltPageResult.jsp");
|
|
|
+ cb(null, pageRst);
|
|
|
+ } else {
|
|
|
+ cb('Have errors while on going...', null);
|
|
|
+ }
|
|
|
+ } catch (ex) {
|
|
|
+ console.log("报表数据异常: userId " + user_id + ", project id: " + prj_id);
|
|
|
+ console.log(ex);
|
|
|
+ cb('Exception occurs while on going...', null);
|
|
|
}
|
|
|
};
|
|
|
//*/
|
|
|
@@ -372,6 +378,18 @@ module.exports = {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ getMultiReportsEx: function (req, res) {
|
|
|
+ //原则说明:把所有报表模板集中获取,统一filter,只读一次数据!(有空再整)
|
|
|
+ let params = JSON.parse(req.body.params),
|
|
|
+ prj_id = params.prj_id,
|
|
|
+ rpt_ids = params.rpt_ids.split(','),
|
|
|
+ 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;
|
|
|
+ },
|
|
|
|
|
|
getReportAllPagesSvg: function (req, res) {
|
|
|
let params = JSON.parse(req.body.params),
|
|
|
@@ -578,22 +596,17 @@ module.exports = {
|
|
|
let r_name = rpt_names[idx];
|
|
|
parallelFunctions.push((function (rpt_id, rpt_name) {
|
|
|
return function (cb) {
|
|
|
- try {
|
|
|
- getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, customizeCfg, dftOption, JV.OUTPUT_TYPE_PDF, function (err, pageRst) {
|
|
|
- if(err){
|
|
|
- cb(err);
|
|
|
- }
|
|
|
- else{
|
|
|
- rpt_pdf_util.export_pdf_file(pageRst, pageSize, rpt_name, function(uuidName){
|
|
|
- let fileRst = {uuid: uuidName, reportName: rpt_name};
|
|
|
- cb(err, fileRst);
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- } catch (ex) {
|
|
|
- console.log(ex);
|
|
|
- cb("Occurs exception while creating PDF file!");
|
|
|
- }
|
|
|
+ getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, customizeCfg, dftOption, JV.OUTPUT_TYPE_PDF, function (err, pageRst) {
|
|
|
+ if(err){
|
|
|
+ cb(err);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ rpt_pdf_util.export_pdf_file(pageRst, pageSize, rpt_name, function(uuidName){
|
|
|
+ let fileRst = {uuid: uuidName, reportName: rpt_name};
|
|
|
+ cb(err, fileRst);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
})(parseInt(r_id), r_name));
|
|
|
}
|