Browse Source

汇总表导出Excel问题

MaiXinRong 11 months ago
parent
commit
5c8406a856
4 changed files with 21 additions and 20 deletions
  1. 1 0
      app/extend/context.js
  2. 5 20
      app/service/jpc_report.js
  3. 5 0
      app/service/report.js
  4. 10 0
      app/service/rpt_gather_memory.js

+ 1 - 0
app/extend/context.js

@@ -10,6 +10,7 @@
 
 const moment = require('moment');
 const messageType = require('../const/message_type');
+const path = require('path');
 
 module.exports = {
     moment,

+ 5 - 20
app/service/jpc_report.js

@@ -12,8 +12,10 @@ const rptDataExtractor = require('../reports/util/rpt_calculation_data_util');
 const RPT_DEF_PROPERTIES = require('../const/report_defined_properties');
 const needCustomTables = [
     'mem_custom_select',
-    'mem_gather_stage_bills', 'mem_gather_deal_bills', 'mem_gather_stage_pay', 'mem_gather_tender_info',
-    'mem_stage_sum_bills', 'mem_stage_sum_pay',
+    'mem_gather_stage_bills', 'mem_gather_deal_bills', 'mem_gather_stage_pay', 'mem_gather_tender_info', 'mem_gather_stage_pos',
+    'mem_gather_change', 'mem_gather_change_bills', 'mem_gather_stage_change', 'mem_gather_advance_pay',
+    'mem_gather_stage_jgcl', 'mem_gather_stage_yjcl', 'mem_gather_stage_bonus', 'mem_gather_stage_other', 'mem_gather_stage_safe_prod', 'mem_gather_stage_temp_land',
+    'mem_stage_sum_bills', 'mem_stage_sum_pos', 'mem_stage_sum_pay',
     'mem_jh_gather_im_change', 'mem_jh_im_change', 'mem_jh_gather_stage_bills_compare',
     'mem_material_sum_gl',
 ];
@@ -96,12 +98,9 @@ module.exports = app => {
             const rptDataUtil = new rptDataExtractor();
             const filterTables = [];
             const memFieldKeys = {};
-            let customSelect = {};
-            let customDefine = {};
             for (const rptTpl of rptTpls) {
                 rptDataUtil.initialize(rptTpl);
                 const filter = rptDataUtil.getDataRequestFilter();
-                // console.log(filter);
                 for (const table of filter.tables) {
                     if (filterTables.indexOf(table) < 0 && needCustomTables.indexOf(table) < 0) {
                         filterTables.push(table);
@@ -119,22 +118,8 @@ module.exports = app => {
                         }
                     }
                 }
-
-                // 输出报表的时候要把客户选择的数据的参数加进来
-                let finCustomSelect = {};
-                if (rptTpl[JV.NODE_CUSTOM_DEFINE]) {
-                    finCustomSelect = rptTpl[JV.NODE_CUSTOM_DEFINE] && rptTpl[JV.NODE_CUSTOM_DEFINE][JV.NODE_CUS_AUDIT_SELECT].enable
-                        ? await ctx.service.rptCustomDefine.getCustomDefine(params.tender_id, params.stage_id, rptTpl.id)
-                        : await ctx.service.rptCustomDefine.getCustomDefine(params.tender_id, -1, rptTpl.id);
-                }
-                if (finCustomSelect) {
-                    customDefine = rptTpl[JV.NODE_CUSTOM_DEFINE];
-                    customSelect = finCustomSelect;
-                }
-
             }
-            const rawDataObj = await ctx.service.report.getReportData(rptTpls[0].source_type, params, filterTables, memFieldKeys, customDefine, customSelect);
-            // const rawDataObj = await ctx.service.report.getReportData(rptTpls[0].source_type, params, filterTables, memFieldKeys, {}, {});
+            const rawDataObj = await ctx.service.report.getReportData(rptTpls[0].source_type, params, filterTables, memFieldKeys, {}, {});
             try {
                 const rptPageRstArray = [];
                 // 2. 一个一个模板创建数据

+ 5 - 0
app/service/report.js

@@ -70,6 +70,10 @@ module.exports = app => {
             return result;
         }
 
+        clearReportCache() {
+            this.ctx.service.rptGatherMemory.clearCache();
+        }
+
         async tender(params, sourceFilters, memFieldKeys, customDefine, customSelect) {
             const [filters, specFilters] = this.getFilter(sourceFilters);
             const service = this.ctx.service;
@@ -620,6 +624,7 @@ module.exports = app => {
         }
 
         async getReportData(source_type, params, sourceFilters, memFieldKeys, customDefine, customSelect) {
+            this.clearReportCache();
             const sourceType = sourceTypeConst.sourceTypeData.find(x => { return x.id === source_type; });
             if (!sourceType && !this[sourceType.key]) return {};
 

+ 10 - 0
app/service/rpt_gather_memory.js

@@ -269,11 +269,21 @@ module.exports = app => {
          */
         constructor(ctx) {
             super(ctx);
+            this.clearCache();
+        }
+
+        clearCache() {
             this.resultTree = null;
             this.resultPos = null;
             this.resultTenderInfo = [];
             this.resultDealPay = [];
             this.resultDealBills = [];
+            this.resultStageJgcl = [];
+            this.resultStageYjcl = [];
+            this.resultStageBonus = [];
+            this.resultStageOther = [];
+            this.resultStageSafeProd = [];
+            this.resultStageTempLand = [];
         }
 
         _checkFieldsExistReg(source, regStr) {