From 259db33b22095891f436b9ed5a81a21496b11c4c Mon Sep 17 00:00:00 2001
From: zhizhijie <zhizhijie@users.noreply.gitee.com>
Date: 星期一, 12 十月 2026 23:41:55 +0800
Subject: [PATCH] feat(汇总大表): 缺数清单加导出前弹窗并在生成件附《数据缺失清单》页(待验收)
---
traffic-audit-server/src/main/java/com/trafficaudit/reportexport/service/ReportExportService.java | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 105 insertions(+), 0 deletions(-)
diff --git a/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/service/ReportExportService.java b/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/service/ReportExportService.java
index 59ceab0..358a446 100644
--- a/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/service/ReportExportService.java
+++ b/traffic-audit-server/src/main/java/com/trafficaudit/reportexport/service/ReportExportService.java
@@ -42,8 +42,12 @@
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@@ -3781,6 +3785,7 @@
log.info("姹囨�诲伐浣滅翱鍏紡閲嶇畻瀹屾垚锛氭垚鍔� {} 鏍硷紝澶辫触 {} 鏍硷紙澶辫触鏍间繚鐣欐瘝鐗堟棫缂撳瓨鍊硷紝鎵撳紑鏃舵寜 fullCalcOnLoad 閲嶇畻锛�", recalc[0], recalc[1]);
if (!wb.getCTWorkbook().isSetCalcPr()) wb.getCTWorkbook().addNewCalcPr();
wb.getCTWorkbook().getCalcPr().setFullCalcOnLoad(true); // 杩樺師/鏀瑰啓鍏紡鍚庢墦寮�鍗抽噸绠�
+ appendMissingDataSheet(wb, effPeriod, dbProblems); // 2026-10-12锛氱己鏁�/浣撴缁撴灉鍐欒繘鐢熸垚浠讹紙鐢ㄦ埛瑕佹眰锛�
reportProgress(progress, 95, "鍐欏嚭鏂囦欢");
return toBytes(wb);
} finally {
@@ -3788,6 +3793,106 @@
}
}
+ /**
+ * 鐢熸垚浠躲�婃暟鎹己澶辨竻鍗曘�嬮〉锛�2026-10-12锛岀敤鎴疯姹傦級銆�
+ *
+ * <p>鎶婃湰娆″鍑虹殑銆岀己鏁版竻鍗曘�嶄笌銆岃揣杩愬熀鏁颁綋妫�銆嶇粨鏋滄樉寮忓啓杩涗骇鐗╋細鐢ㄦ埛鎷垮埌鏂囦欢鍗冲彲鐪嬪埌鏈姤琛ㄦ湡
+ * 鏈夊摢浜涙暟娌″埌銆佸摢浜涙暟涓嶅悎鐞嗭紝涓嶅繀缈诲鍑烘棩蹇椼�傚彧璇绘彁绀洪〉锛屼笉鍙備笌鏈〃璁$畻銆�
+ */
+ private void appendMissingDataSheet(XSSFWorkbook wb, String period, List<String> problems) {
+ String sheetName = "鏁版嵁缂哄け娓呭崟";
+ int old = wb.getSheetIndex(sheetName);
+ if (old >= 0) wb.removeSheetAt(old); // 姣嶇増鐢便�屽綋鏈熶骇鐗┿�嶆淳鐢熸椂鍙兘宸插甫鏈〉锛屽厛绉婚櫎閬垮厤閲嶅悕
+ XSSFSheet sh = wb.createSheet(sheetName);
+
+ CellStyle titleStyle = wb.createCellStyle();
+ Font titleFont = wb.createFont();
+ titleFont.setBold(true);
+ titleFont.setFontHeightInPoints((short) 14);
+ titleStyle.setFont(titleFont);
+
+ CellStyle metaStyle = wb.createCellStyle();
+ Font metaFont = wb.createFont();
+ metaFont.setFontHeightInPoints((short) 10);
+ metaFont.setColor(IndexedColors.GREY_50_PERCENT.getIndex());
+ metaStyle.setFont(metaFont);
+
+ CellStyle sectionStyle = wb.createCellStyle();
+ Font sectionFont = wb.createFont();
+ sectionFont.setBold(true);
+ sectionStyle.setFont(sectionFont);
+
+ CellStyle bodyStyle = wb.createCellStyle();
+ bodyStyle.setWrapText(true);
+ bodyStyle.setVerticalAlignment(VerticalAlignment.TOP);
+
+ List<String> missing = new ArrayList<>();
+ List<String> check = new ArrayList<>();
+ List<String> other = new ArrayList<>();
+ if (problems != null) {
+ for (String p : problems) {
+ if (p == null || p.trim().isEmpty()) continue;
+ if (p.startsWith("缂烘暟")) missing.add(p);
+ else if (p.startsWith("璐ц繍浣撴")) check.add(p);
+ else other.add(p);
+ }
+ }
+
+ int r = 0;
+ Row tRow = sh.createRow(r++);
+ Cell tCell = tRow.createCell(0);
+ tCell.setCellValue("鏁版嵁缂哄け娓呭崟");
+ tCell.setCellStyle(titleStyle);
+
+ Row mRow = sh.createRow(r++);
+ Cell mCell = mRow.createCell(0);
+ mCell.setCellValue("鎶ヨ〃鏈� " + period + "銆�鐢熸垚鏃堕棿 "
+ + new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm").format(new java.util.Date())
+ + "銆�鍏� " + (missing.size() + check.size() + other.size()) + " 鏉�");
+ mCell.setCellStyle(metaStyle);
+
+ Row nRow = sh.createRow(r++);
+ Cell nCell = nRow.createCell(0);
+ nCell.setCellValue("鏈〉鐢辩▼搴忚嚜鍔ㄧ敓鎴愶紙鍙鎻愮ず锛夛細涓�銆佺己鏁版竻鍗曪紳璇ユ湁鐨勬暟娌℃湁锛涗簩銆佹暟鎹綋妫�锛濇暟鍊间笉鍚堢悊锛堝瑙勪笅涓鸿礋锛夈�備笉鍙備笌鏈〃璁$畻銆�");
+ nCell.setCellStyle(metaStyle);
+
+ r++;
+ r = writeProblemSection(sh, r, "涓�銆佺己鏁版竻鍗曪紙璇ユ湁鐨勬暟娌℃湁锛�", missing, sectionStyle, bodyStyle);
+ r = writeProblemSection(sh, r, "浜屻�佹暟鎹綋妫�锛堟暟鍊间笉鍚堢悊锛�", check, sectionStyle, bodyStyle);
+ if (!other.isEmpty()) {
+ r = writeProblemSection(sh, r, "涓夈�佸叾瀹冩彁绀�", other, sectionStyle, bodyStyle);
+ }
+
+ sh.setColumnWidth(0, 6 * 256);
+ sh.setColumnWidth(1, 120 * 256);
+ sh.createFreezePane(0, 3);
+ }
+
+ /** 鍐欎竴涓竻鍗曞垎鍖猴紙鏍囬 + 閫愭潯锛夛紝杩斿洖涓嬩竴涓彲鍐欒鍙� */
+ private int writeProblemSection(XSSFSheet sh, int rowIdx, String title, List<String> lines,
+ CellStyle sectionStyle, CellStyle bodyStyle) {
+ Row hr = sh.createRow(rowIdx++);
+ Cell hc = hr.createCell(0);
+ hc.setCellValue(title);
+ hc.setCellStyle(sectionStyle);
+ sh.addMergedRegion(new CellRangeAddress(rowIdx - 1, rowIdx - 1, 0, 1));
+ if (lines.isEmpty()) {
+ Row er = sh.createRow(rowIdx++);
+ er.createCell(0).setCellValue("鈥�");
+ er.createCell(1).setCellValue("鏃�");
+ return rowIdx;
+ }
+ int i = 1;
+ for (String line : lines) {
+ Row row = sh.createRow(rowIdx++);
+ row.createCell(0).setCellValue(i++);
+ Cell c = row.createCell(1);
+ c.setCellValue(line);
+ c.setCellStyle(bodyStyle);
+ }
+ return rowIdx;
+ }
+
/** 瀵煎嚭杩涘害鍥炶皟锛堝紓姝ュ鍑轰换鍔$敤锛夛細鍥炶皟鑷韩寮傚父涓嶅奖鍝嶅鍑� */
private static void reportProgress(java.util.function.BiConsumer<Integer, String> progress, int percent, String step) {
if (progress == null) return;
--
Gitblit v1.9.1