| | |
| | | |
| | | import com.trafficaudit.common.Result; |
| | | import com.trafficaudit.reportexport.service.ReportExportService; |
| | | import com.trafficaudit.reportexport.service.ReportExportTaskService; |
| | | import com.trafficaudit.system.service.OperationLogService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | |
| | | @Resource |
| | | private ReportExportService reportService; |
| | | @Resource |
| | | private ReportExportTaskService exportTaskService; |
| | | @Resource |
| | | private OperationLogService operationLogService; |
| | | |
| | |
| | | return buildResponse(reportService.exportPassengerMidAnalysis(period, mode), "生成_公路旅客中口径分析.xlsx"); |
| | | } |
| | | |
| | | /** 生成_道路运输量汇总表.xlsx(汇总工作簿 P0-P1 骨架:整本复制母版,页签/公式/2025 缓存保留) */ |
| | | @GetMapping("/export/summaryWorkbook") |
| | | public ResponseEntity<byte[]> exportSummaryWorkbook(@RequestParam("period") String period, |
| | | @RequestParam(value = "mode", defaultValue = "month") String mode, |
| | | @RequestParam(value = "toMonth", required = false) Integer toMonth) throws Exception { |
| | | logExport("道路运输量汇总表.xlsx", period); |
| | | return buildResponse(reportService.exportSummaryWorkbook(period, mode, toMonth), String.format("生成_道路运输量汇总表_%s.xlsx", period)); |
| | | } |
| | | |
| | | /** |
| | | * 汇总大表异步导出:立即返回任务号,前端轮询进度、完成后再下载文件。 |
| | | * 生成一次约 10~20 秒,走异步可避免点击后长时间无响应;同报表期 10 分钟内的结果直接复用(期间有导入则自动失效), |
| | | * refresh=true 可强制重新生成。 |
| | | */ |
| | | @GetMapping("/exportTask/summaryWorkbook") |
| | | public Result<java.util.Map<String, Object>> submitSummaryWorkbookTask(@RequestParam("period") String period, |
| | | @RequestParam(value = "mode", defaultValue = "month") String mode, |
| | | @RequestParam(value = "toMonth", required = false) Integer toMonth, |
| | | @RequestParam(value = "refresh", defaultValue = "false") boolean refresh) { |
| | | ReportExportTaskService.Task task = exportTaskService.submit( |
| | | ReportExportTaskService.TYPE_SUMMARY_WORKBOOK, period, mode, toMonth, refresh); |
| | | if (!task.isFromCache()) { |
| | | logExport("道路运输量汇总表.xlsx", period); |
| | | } |
| | | return Result.ok(task.toView()); |
| | | } |
| | | |
| | | /** 查询异步导出任务进度(结果保留 30 分钟) */ |
| | | @GetMapping("/exportTask/{taskId}") |
| | | public Result<java.util.Map<String, Object>> exportTaskStatus(@PathVariable("taskId") String taskId) { |
| | | ReportExportTaskService.Task task = exportTaskService.get(taskId); |
| | | if (task == null) { |
| | | return Result.error("导出任务不存在或已过期(生成结果保留 30 分钟)"); |
| | | } |
| | | return Result.ok(task.toView()); |
| | | } |
| | | |
| | | /** 下载异步导出任务已生成的文件 */ |
| | | @GetMapping("/exportTask/{taskId}/file") |
| | | public ResponseEntity<byte[]> exportTaskFile(@PathVariable("taskId") String taskId) throws Exception { |
| | | ReportExportTaskService.Task task = exportTaskService.get(taskId); |
| | | if (task == null) { |
| | | throw new RuntimeException("导出任务不存在或已过期(生成结果保留 30 分钟)"); |
| | | } |
| | | if (!task.isDone()) { |
| | | throw new RuntimeException("导出任务尚未完成(当前状态:" + task.getStatus() + "),请稍后再试"); |
| | | } |
| | | return buildResponse(task.getData(), task.getFileName()); |
| | | } |
| | | |
| | | /** 生成_网约车客运量拆分表.xlsx(月度:订单附件1 + 全省 pin + 巡游出租月报) */ |
| | | @GetMapping("/export/wycSplit") |
| | | public ResponseEntity<byte[]> exportWycSplit(@RequestParam("period") String period, |
| | | @RequestParam(value = "mode", defaultValue = "month") String mode) throws Exception { |
| | | logExport("生成_网约车客运量拆分表.xlsx", period); |
| | | 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 { |
| | |
| | | return buildResponse(reportService.investCounty(period, mode), "生成_经济强县交通物流基础设施投资统计报表.xls"); |
| | | } |
| | | |
| | | /** 生成_X月客运站投资明细表.xlsx(投资模块明细表1:客运站场) */ |
| | | @GetMapping("/export/investPassengerDetail") |
| | | public ResponseEntity<byte[]> exportInvestPassengerDetail(@RequestParam("period") String period, |
| | | @RequestParam(value = "mode", defaultValue = "month") String mode) throws Exception { |
| | | logExport("生成_X月客运站投资明细表.xlsx", period); |
| | | return buildResponse(reportService.exportInvestPassengerDetail(period, mode), "生成_客运站投资明细表.xlsx"); |
| | | } |
| | | |
| | | /** 生成_X月物流站场投资明细.xls(投资模块明细表2:物流园区) */ |
| | | @GetMapping("/export/investLogisticsDetail") |
| | | public ResponseEntity<byte[]> exportInvestLogisticsDetail(@RequestParam("period") String period, |
| | | @RequestParam(value = "mode", defaultValue = "month") String mode) throws Exception { |
| | | logExport("生成_X月物流站场投资明细.xls", period); |
| | | return buildResponse(reportService.exportInvestLogisticsDetail(period, mode), "生成_物流站场投资明细.xls"); |
| | | } |
| | | |
| | | /** 生成_轨道轮渡客运量分市州明细.xlsx(城市客运,轨道/轮渡取自公交源文件) */ |
| | | @GetMapping("/export/cityRailFerryDetail") |
| | | public ResponseEntity<byte[]> exportCityRailFerryDetail(@RequestParam("period") String period, |
| | |
| | | public ResponseEntity<byte[]> exportCityPassengerCitySum(@RequestParam("period") String period, |
| | | @RequestParam(value = "mode", defaultValue = "month") String mode) throws Exception { |
| | | logExport("生成_城市客运客运量分市州累计.xlsx", period); |
| | | return buildResponse(reportService.exportCityPassengerCitySum("导入模板_城市分市州.xlsx", period, mode), "生成_城市客运客运量分市州累计.xlsx"); |
| | | return buildResponse(reportService.exportCityPassengerCitySum("生成_城市客运客运量分市州累计.xlsx", period, mode), "生成_城市客运客运量分市州累计.xlsx"); |
| | | } |
| | | |
| | | /** 生成_城市客运各市州明细表.xlsx(城市客运各市州明细表_模板底稿) */ |
| | |
| | | public ResponseEntity<byte[]> exportCityPassengerDetailSum(@RequestParam("period") String period, |
| | | @RequestParam(value = "mode", defaultValue = "month") String mode) throws Exception { |
| | | logExport("生成_城市客运各市州明细表.xlsx", period); |
| | | return buildResponse(reportService.exportCityPassengerCitySum("导入模板_城市客运各市州明细表.xlsx", period, mode), "生成_城市客运各市州明细表.xlsx"); |
| | | return buildResponse(reportService.exportCityPassengerCitySum("生成_城市客运各市州明细表.xlsx", period, mode), "生成_城市客运各市州明细表.xlsx"); |
| | | } |
| | | |
| | | /** 生成_城市客运汇总.xlsx(城市汇总_模板底稿) */ |
| | |
| | | .body(data); |
| | | } |
| | | } |
| | | |
| | | |