From ae47753f77690615762a77bde38a34e9ff0fa4ae Mon Sep 17 00:00:00 2001
From: zhizhijie <zhizhijie@users.noreply.gitee.com>
Date: 星期一, 12 十月 2026 17:12:24 +0800
Subject: [PATCH] feat(汇总大表): 缺数清单可见且缺数期不沿用上一期旧值(排名页按源侧留空)(待验收)

---
 traffic-audit-server/src/main/java/com/trafficaudit/reportexport/controller/ReportExportController.java |   76 +++++++++++++++++++++++++++++++++++++
 1 files changed, 75 insertions(+), 1 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 b955d53..db32034 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
@@ -1,13 +1,17 @@
 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;
 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 +28,12 @@
 
     @Resource
     private ReportExportService reportService;
+    @Resource
+    private FreightReadinessCheck freightReadinessCheck;
+    @Resource
+    private SummaryMissingDataCheck missingDataCheck;
+    @Resource
+    private ReportExportTaskService exportTaskService;
     @Resource
     private OperationLogService operationLogService;
 
@@ -85,12 +95,77 @@
     }
 
     /** 鐢熸垚_閬撹矾杩愯緭閲忔眹鎬昏〃.xlsx锛堟眹鎬诲伐浣滅翱 P0-P1 楠ㄦ灦锛氭暣鏈鍒舵瘝鐗堬紝椤电/鍏紡/2025 缂撳瓨淇濈暀锛� */
+    /** 璐ц繍鍙e緞瀵煎嚭鍓嶄綋妫�锛圔4锛夛細鍙杩斿洖鍛戒腑鐨勯棶棰樻竻鍗曘�� */
+    @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,
                                                         @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 绉掞紝璧板紓姝ュ彲閬垮厤鐐瑰嚮鍚庨暱鏃堕棿鏃犲搷搴旓紱鍚屾姤琛ㄦ湡缁撴灉鐩存帴澶嶇敤锛堣惤鐩樹繚瀛樸�佽繘绋嬮噸鍚悗浠嶆湁鏁堬紱鏈熼棿鏈夊鍏ュ垯鑷姩澶辨晥锛夛紝
+     * 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 + 宸℃父鍑虹鏈堟姤锛� */
@@ -308,4 +383,3 @@
             .body(data);
     }
 }
-

--
Gitblit v1.9.1