| | |
| | | package com.trafficaudit.reportexport.controller; |
| | | |
| | | import com.trafficaudit.common.Result; |
| | | import com.trafficaudit.reportexport.calc.FreightReadinessCheck; |
| | | import com.trafficaudit.reportexport.calc.SummaryMissingDataCheck; |
| | | import com.trafficaudit.reportexport.service.ReportExportService; |
| | | import com.trafficaudit.reportexport.service.ReportExportTaskService; |
| | | import com.trafficaudit.system.service.OperationLogService; |
| | |
| | | |
| | | @Resource |
| | | private ReportExportService reportService; |
| | | @Resource |
| | | private FreightReadinessCheck freightReadinessCheck; |
| | | @Resource |
| | | private SummaryMissingDataCheck missingDataCheck; |
| | | @Resource |
| | | private ReportExportTaskService exportTaskService; |
| | | @Resource |
| | |
| | | } |
| | | |
| | | /** 生成_道路运输量汇总表.xlsx(汇总工作簿 P0-P1 骨架:整本复制母版,页签/公式/2025 缓存保留) */ |
| | | /** 货运口径导出前体检(B4):只读返回命中的问题清单。 */ |
| | | @GetMapping("/summaryWorkbook/freightCheck") |
| | | public Result<java.util.List<String>> freightCheck(@RequestParam("period") String period) { |
| | | return Result.ok(freightReadinessCheck.check(period)); |
| | | } |
| | | |
| | | /** 汇总大表缺数清单(只读):列出目标期出表会缺的月份/市州/来源(与 freightCheck 互补)。 */ |
| | | @GetMapping("/summaryWorkbook/missing") |
| | | public Result<java.util.List<String>> missingCheck(@RequestParam("period") String period) { |
| | | return Result.ok(missingDataCheck.check(period)); |
| | | } |
| | | |
| | | /** 汇总大表按月扩列(Step 1,只做版式、数据留空):返回下一月版式 xlsx。 */ |
| | | @GetMapping("/export/summaryWorkbook/expand") |
| | | public ResponseEntity<byte[]> expandSummaryWorkbook(@RequestParam("period") String period, |
| | | @RequestParam(value = "titlesOnly", defaultValue = "false") boolean titlesOnly) throws Exception { |
| | | if (titlesOnly) { |
| | | byte[] titled = reportService.fixSummaryTitles(period); |
| | | return buildResponse(titled, String.format("标题修正_道路运输量汇总表_%s.xlsx", period)); |
| | | } |
| | | byte[] data = reportService.expandSummaryWorkbook(period); |
| | | return buildResponse(data, String.format("扩列_道路运输量汇总表_%s_待确认.xlsx", period)); |
| | | } |
| | | |
| | | @GetMapping("/export/summaryWorkbook") |
| | | public ResponseEntity<byte[]> exportSummaryWorkbook(@RequestParam("period") String period, |
| | | @RequestParam(value = "mode", defaultValue = "month") String mode, |
| | |
| | | return buildResponse(reportService.exportWycSplit(period, mode), String.format("生成_网约车客运量拆分表_%s.xlsx", period)); |
| | | } |
| | | |
| | | /** 生成_能运汇总表.xlsx(H204,全省 + 各市州 sheet) */ |
| | | @GetMapping("/export/energySummary") |
| | | public ResponseEntity<byte[]> exportEnergySummary(@RequestParam("period") String period) throws Exception { |
| | | logExport("生成_能运汇总表.xlsx", period); |
| | | return buildResponse(reportService.exportEnergySummary(period), "生成_能运汇总表.xlsx"); |
| | | /** 季度汇总测试版:所选季度 15 字段,插入到汇总表 B/C 列之间 */ |
| | | @GetMapping("/export/energyQuarterSummary") |
| | | public ResponseEntity<byte[]> exportEnergyQuarterSummary(@RequestParam("period") String period) throws Exception { |
| | | String fileName = "生成_" + energyPeriodCn(period) + "能运汇总表.xlsx"; |
| | | logExport(fileName, period); |
| | | return buildResponse(reportService.exportEnergyQuarterSummary(period), fileName); |
| | | } |
| | | |
| | | /** 领导版:10 字段简表,当前季度 + 去年同期 */ |
| | | @GetMapping("/export/energyLeader") |
| | | public ResponseEntity<byte[]> exportEnergyLeader(@RequestParam("period") String period) throws Exception { |
| | | String fileName = "生成_" + energyPeriodCn(period) + "能耗汇总表(领导版).xlsx"; |
| | | logExport(fileName, period); |
| | | return buildResponse(reportService.exportEnergyLeader(period), fileName); |
| | | } |
| | | /** 生成_城市公交客运量分市州明细.xlsx(城市客运第1步,公交) */ |
| | | @GetMapping("/export/cityBusDetail") |
| | |
| | | .body(data); |
| | | } |
| | | |
| | | /** 报表期 yyyy-MM -> 中文年月(2025-06 -> 2025年6月) */ |
| | | private String energyPeriodCn(String period) { |
| | | if (period == null || period.length() < 7) return period == null ? "" : period; |
| | | int year = Integer.parseInt(period.substring(0, 4)); |
| | | int month = Integer.parseInt(period.substring(5, 7)); |
| | | return year + "年" + month + "月"; |
| | | } |
| | | |
| | | private ResponseEntity<byte[]> buildResponse(byte[] data, String fileName) throws Exception { |
| | | String encoded = URLEncoder.encode(fileName, "UTF-8").replace("+", "%20"); |
| | | String type = fileName.toLowerCase().endsWith(".xls") |