瀏覽代碼

code sync

TonyKang 4 年之前
父節點
當前提交
c1b65767d6
共有 2 個文件被更改,包括 38 次插入2 次删除
  1. 1 1
      modules/main/facade/project_facade.js
  2. 37 1
      modules/reports/controllers/rpt_controller.js

+ 1 - 1
modules/main/facade/project_facade.js

@@ -722,7 +722,7 @@ async function getGLJSummayDatas(projectIDs) {
     };
     return result;
   } catch (e) {
-    console.log(e);
+    console.log(e.toString());
   }
 }
 

+ 37 - 1
modules/reports/controllers/rpt_controller.js

@@ -563,7 +563,43 @@ function getSummaryComboPages(req, user_id, prjIds, billsSummaryRpt_ids, gljSumm
     });
 }
 
-function getGljSummaryReportPages(user_id, prjIds, rpt_id, pageSize, orientation, customizeCfg, option, outputType, cb) {
+async function getGljSummaryReportPages(user_id, prjIds, rpt_id, pageSize, orientation, customizeCfg, option, outputType, cb) {
+    let summaryRawDataRst = await rptTplDataFacade.getGLJSummayDatas(prjIds);
+    let rptTpl = await rptTplFacade.getRptTemplate(rpt_id);
+    let rptDataUtil = new rptDataExtractor();
+    rptDataUtil.initialize((rptTpl._doc)?rptTpl._doc:rptTpl);
+    try {
+        // fsUtil.writeObjToFile(summaryRawDataRst, "D:/GitHome/temp/gljSummaryRawDataRstRawData.jsp");
+        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;
+        //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) {
+            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);
+    }
+}
+
+function getGljSummaryReportPages_oldstyle(user_id, prjIds, rpt_id, pageSize, orientation, customizeCfg, option, outputType, cb) {
     let rptTpl = null;
     rptTplDataFacade.getGLJSummayDatas(prjIds).then(function(summaryRawDataRst) {
         rptTplFacade.getRptTemplate(rpt_id).then(function(rptTpl) {