|  | @@ -13,6 +13,7 @@ const rpt_xl_util = require('../reports/util/rpt_excel_util');
 | 
	
		
			
				|  |  |  const rptDataExtractor = require('../reports/util/rpt_calculation_data_util');
 | 
	
		
			
				|  |  |  const fsUtil = require('../public/js/fsUtil');
 | 
	
		
			
				|  |  |  const fs = require('fs');
 | 
	
		
			
				|  |  | +const rptCronJob = require('../reports/util/rpt_tmp_file_sweep');
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  module.exports = app => {
 | 
	
		
			
				|  |  |      class ReportController extends app.BaseController {
 | 
	
	
		
			
				|  | @@ -40,6 +41,10 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                  const roleList = await ctx.service.signatureRole.getSignatureRolesByTenderId(tender.id);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  // console.log(maxStageAmt[0].maxAmt);
 | 
	
		
			
				|  |  | +                // if ((stage === null || stage === undefined) && stageList.length > 0) {
 | 
	
		
			
				|  |  | +                //     await ctx.service.stage.checkStage(stageList[stageList.length - 1].id);
 | 
	
		
			
				|  |  | +                //     stage = ctx.stage;
 | 
	
		
			
				|  |  | +                // }
 | 
	
		
			
				|  |  |                  if (stage !== null && stage !== undefined) {
 | 
	
		
			
				|  |  |                      stage_id = stage.id;
 | 
	
		
			
				|  |  |                      stage_order = stage.order;
 | 
	
	
		
			
				|  | @@ -73,6 +78,17 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                  };
 | 
	
		
			
				|  |  |                  await this.layout('report/index.ejs', renderData, 'report/rpt_all_popup.ejs');
 | 
	
		
			
				|  |  |                  // await this.layout('report/index.ejs', renderData);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                // 在这里启动一个cron job,删除临时创建的excel文件
 | 
	
		
			
				|  |  | +                if (!rptCronJob.started) {
 | 
	
		
			
				|  |  | +                    try {
 | 
	
		
			
				|  |  | +                        // console.log('rptCronJob.started: ' + rptCronJob.started);
 | 
	
		
			
				|  |  | +                        rptCronJob.started = true;
 | 
	
		
			
				|  |  | +                        rptCronJob.createJob(null, this.app.baseDir + '/app/public/download');
 | 
	
		
			
				|  |  | +                    } catch (ex) {
 | 
	
		
			
				|  |  | +                        rptCronJob.started = false;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              } catch (err) {
 | 
	
		
			
				|  |  |                  this.log(err);
 | 
	
		
			
				|  |  |                  console.log(err);
 | 
	
	
		
			
				|  | @@ -288,6 +304,14 @@ module.exports = app => {
 | 
	
		
			
				|  |  |      return ReportController;
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +async function checkStg(ctx, params) {
 | 
	
		
			
				|  |  | +    if (ctx.stage === null || ctx.stage === undefined || parseInt(ctx.stage.id) !== parseInt(params.stage_id)) {
 | 
	
		
			
				|  |  | +        await ctx.service.stage.checkStage(params.stage_id);
 | 
	
		
			
				|  |  | +        if (ctx.stage) {
 | 
	
		
			
				|  |  | +            params.stage_order = ctx.stage.curOrder;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  async function getReportData(ctx, params, filters) {
 | 
	
		
			
				|  |  |      const rst = {};
 | 
	
		
			
				|  |  |      const runnableRst = [];
 | 
	
	
		
			
				|  | @@ -314,6 +338,7 @@ async function getReportData(ctx, params, filters) {
 | 
	
		
			
				|  |  |                      runnableKey.push('stage_bills');
 | 
	
		
			
				|  |  |                      break;
 | 
	
		
			
				|  |  |                  case 'stage_bills_final':
 | 
	
		
			
				|  |  | +                    await checkStg(ctx, params);
 | 
	
		
			
				|  |  |                      runnableRst.push(ctx.service.stageBillsFinal.getFinalDataEx(params.tender_id, params.stage_order));
 | 
	
		
			
				|  |  |                      runnableKey.push('stage_bills_final');
 | 
	
		
			
				|  |  |                      break;
 | 
	
	
		
			
				|  | @@ -322,9 +347,8 @@ async function getReportData(ctx, params, filters) {
 | 
	
		
			
				|  |  |                      runnableKey.push('stage');
 | 
	
		
			
				|  |  |                      break;
 | 
	
		
			
				|  |  |                  case 'stage_pay':
 | 
	
		
			
				|  |  | +                    await checkStg(ctx, params);
 | 
	
		
			
				|  |  |                      runnableRst.push(ctx.service.stagePay.getAuditorStageData(params.stage_id, params.stage_times, params.stage_order));
 | 
	
		
			
				|  |  | -                    // console.log('params:');
 | 
	
		
			
				|  |  | -                    // console.log(params);
 | 
	
		
			
				|  |  |                      runnableKey.push('stage_pay');
 | 
	
		
			
				|  |  |                      break;
 | 
	
		
			
				|  |  |                  case 'mem_stage_im_zl':
 | 
	
	
		
			
				|  | @@ -336,15 +360,9 @@ async function getReportData(ctx, params, filters) {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    // console.log('before query, runnableKey');
 | 
	
		
			
				|  |  | -    // console.log(runnableKey);
 | 
	
		
			
				|  |  |      const queryRst = await Promise.all(runnableRst);
 | 
	
		
			
				|  |  | -    // console.log('after query');
 | 
	
		
			
				|  |  |      for (let idx = 0; idx < runnableKey.length; idx++) {
 | 
	
		
			
				|  |  |          rst[runnableKey[idx]] = queryRst[idx];
 | 
	
		
			
				|  |  | -        // console.log(runnableKey[idx]);
 | 
	
		
			
				|  |  | -        // if (rst[runnableKey[idx]] instanceof Array) console.log('is Array')
 | 
	
		
			
				|  |  | -        // else console.log('is not Array');
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      for (const filter of filters) {
 | 
	
		
			
				|  |  |          switch (filter) {
 |