From 35d098a89613c96179391178b7f8143dec393ada Mon Sep 17 00:00:00 2001
From: zhizhijie <zhizhijie@users.noreply.gitee.com>
Date: 星期日, 20 九月 2026 15:52:36 +0800
Subject: [PATCH] feat(报表): 汇总大表导出异步化 + 结果缓存 + 进度弹窗
---
traffic-audit-server/src/main/java/com/trafficaudit/reportexport/controller/ReportExportController.java | 84 ++++++++++++++++++++++++++++++++++++++++--
1 files changed, 80 insertions(+), 4 deletions(-)
diff --git a/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/controller/ReportExportController.java b/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/controller/ReportExportController.java
index 9594638..f4e8e8a 100644
--- a/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/controller/ReportExportController.java
+++ b/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/controller/ReportExportController.java
@@ -2,12 +2,14 @@
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;
@@ -24,6 +26,8 @@
@Resource
private ReportExportService reportService;
+ @Resource
+ private ReportExportTaskService exportTaskService;
@Resource
private OperationLogService operationLogService;
@@ -84,6 +88,64 @@
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锛圚204锛屽叏鐪� + 鍚勫競宸� sheet锛� */
@GetMapping("/export/energySummary")
public ResponseEntity<byte[]> exportEnergySummary(@RequestParam("period") String period) throws Exception {
@@ -138,6 +200,22 @@
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,
@@ -151,7 +229,7 @@
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锛堝煄甯傚杩愬悇甯傚窞鏄庣粏琛╛妯℃澘搴曠锛� */
@@ -159,7 +237,7 @@
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锛堝煄甯傛眹鎬籣妯℃澘搴曠锛� */
@@ -275,5 +353,3 @@
.body(data);
}
}
-
-
--
Gitblit v1.9.1