From 3b3652e3418ccfbbd21d9f7a2d8769d09c4f18f9 Mon Sep 17 00:00:00 2001
From: zhizhijie <zhizhijie@users.noreply.gitee.com>
Date: 星期一, 12 十月 2026 13:08:54 +0800
Subject: [PATCH] fix(汇总大表): 扩列公式克隆修正(值列相对右移、同比列重写)并落盘 9 月母版 待验收
---
traffic-audit-server/src/main/java/com/trafficaudit/reportexport/service/ReportExportService.java | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 49 insertions(+), 5 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 a93160b..fff7842 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
@@ -35,6 +35,7 @@
import com.trafficaudit.reportexport.calc.PaxCalc;
import com.trafficaudit.reportexport.calc.SummaryWorkbookFiller;
import com.trafficaudit.reportexport.calc.FreightReadinessCheck;
+import com.trafficaudit.reportexport.calc.SummaryMissingDataCheck;
import com.trafficaudit.reportexport.layout.SummaryLayoutExpander;
import com.trafficaudit.reportexport.calc.WycSplitCalc;
import lombok.extern.slf4j.Slf4j;
@@ -107,6 +108,8 @@
private SummaryLayoutExpander summaryLayoutExpander;
@Resource
private FreightReadinessCheck freightReadinessCheck;
+ @Resource
+ private SummaryMissingDataCheck missingDataCheck;
@Resource
private WycSplitCalc wycSplitCalc;
@Resource
@@ -3641,14 +3644,54 @@
if (month >= 12) {
throw new RuntimeException("鎵╁垪锛�12 鏈堜箣鍚庨渶鏂板紑涓�鏈紝璺ㄥ勾瑙勫垯鍙﹁澶勭悊");
}
- File mother = resolveSummaryMother(period, "month");
- if (mother == null) {
- throw new RuntimeException("鏈壘鍒版眹鎬昏〃姣嶇増锛坉ocs/鐢熸垚姹囨�诲ぇ琛級锛�" + year + "骞�" + month + "鏈堥亾璺繍杈撻噺姹囨�昏〃.xlsx");
+ // 2026-10-12锛氭墿鍒椾互銆屽綋鏈熶骇鐗┿�嶄负搴曪紙浜х墿鍚綋鏈熷垪鐨勫�间笌鍏紡锛涙瘝鐗堢殑褰撴湡鍒楁槸绌虹殑锛�
+ // 鐩存帴鎷挎瘝鐗堟墿鍒椾細鎶婂綋鏈熸暟鎹涪鎴愮┖娲烇紝瀵艰嚧绱婕忔湀锛夈�備骇鐗╁彇鑷鍑鸿惤鐩樼紦瀛橈紱缂轰骇鐗╂椂鍥為��姣嶇増骞跺憡璀︺��
+ File source = resolveLatestProduct(period);
+ boolean fromProduct = source != null;
+ if (source == null) {
+ source = resolveSummaryMother(period, "month");
+ if (source != null) {
+ log.warn("姹囨�诲ぇ琛ㄦ墿鍒楋細鏈壘鍒� {} 鐨勪骇鐗╃紦瀛橈紝鍥為��鐢ㄦ瘝鐗堟墿鍒椻�斺�斿巻鍙插垪閲岀己灏戝綋鏈熸暟鎹紝绱鍙兘婕忔湀", period);
+ }
}
- try (InputStream in = new FileInputStream(mother)) {
+ if (source == null) {
+ throw new RuntimeException("鏈壘鍒版眹鎬昏〃姣嶇増鎴栦骇鐗╋紙docs/鐢熸垚姹囨�诲ぇ琛級锛�" + year + "骞�" + month + "鏈堥亾璺繍杈撻噺姹囨�昏〃.xlsx");
+ }
+ try (InputStream in = new FileInputStream(source)) {
byte[] out = summaryLayoutExpander.expand(org.apache.poi.util.IOUtils.toByteArray(in), year, month + 1);
- log.info("姹囨�诲ぇ琛ㄦ墿鍒楀畬鎴愶細{}骞磠}鏈堟瘝鐗� -> {}骞磠}鏈堢増寮忥紙鍙仛鐗堝紡銆佹暟鎹暀绌猴級", year, month, year, month + 1);
+ log.info("姹囨�诲ぇ琛ㄦ墿鍒楀畬鎴愶細{}{} -> {}骞磠}鏈堢増寮忥紙鍙仛鐗堝紡銆佸綋鏈熷垪鐣欑┖锛�",
+ fromProduct ? "浜х墿" : "姣嶇増", source.getName(), year, month + 1);
return out;
+ }
+ }
+
+ /** 鍙栬鏈熴�屾渶鏂颁骇鐗┿�嶏細瀵煎嚭钀界洏缂撳瓨 _cache/summaryWorkbook_<period>_month_v*.xlsx锛堟寜淇敼鏃堕棿鍙栨渶鏂帮級 */
+ private File resolveLatestProduct(String period) {
+ try {
+ String rel = summaryTemplateDir;
+ while (rel != null && rel.startsWith("./")) rel = rel.substring(2);
+ String[] roots = {
+ summaryTemplateDir,
+ System.getProperty("user.dir") + "/" + rel,
+ System.getProperty("user.dir") + "/../" + rel
+ };
+ String prefix = "summaryWorkbook_" + period + "_month_";
+ for (String root : roots) {
+ if (root == null || root.trim().isEmpty()) continue;
+ File dir = new File(root, "_cache");
+ if (!dir.isDirectory()) continue;
+ File[] files = dir.listFiles((d, name) -> name.startsWith(prefix) && name.endsWith(".xlsx"));
+ if (files == null || files.length == 0) continue;
+ File latest = files[0];
+ for (File f : files) {
+ if (f.lastModified() > latest.lastModified()) latest = f;
+ }
+ return latest;
+ }
+ return null;
+ } catch (Exception e) {
+ log.warn("姹囨�诲ぇ琛ㄦ墿鍒楋細鏌ユ壘浜х墿缂撳瓨澶辫触锛堝拷鐣ワ級锛歿}", e.getMessage());
+ return null;
}
}
@@ -3711,6 +3754,7 @@
List<String> dbProblems = new ArrayList<>();
String effPeriod = String.format("%04d-%02d", year, effMonth);
dbProblems.addAll(freightReadinessCheck.check(effPeriod)); // B4锛氳揣杩愬彛寰勫鍑哄墠浣撴锛�6 鏉¤鍒欙級
+ dbProblems.addAll(missingDataCheck.check(effPeriod)); // 缂烘暟娓呭崟锛堣鏈夌殑鏁版病鏈夛級
reportProgress(progress, 22, "鍥炲~褰撴湀鏁版嵁");
int dbFilled = summaryWorkbookFiller.fillMonthlyLedger(wb, effPeriod, year, effMonth, dbProblems);
int yoyFilled = summaryWorkbookFiller.ensureMonthYoyFormulas(wb, year, effMonth);
--
Gitblit v1.9.1