From 468c46596d8ffe9690e8ff15805770f08ee9ee01 Mon Sep 17 00:00:00 2001
From: zhizhijie <zhizhijie@users.noreply.gitee.com>
Date: 星期一, 12 十月 2026 17:16:43 +0800
Subject: [PATCH] docs(交接): 记录10-12汇总大表缺数/母版脏格修复的下班关机交接与下一步待办
---
traffic-audit-server/src/main/java/com/trafficaudit/reportexport/service/ReportExportService.java | 138 +++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 123 insertions(+), 15 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 3465473..59ceab0 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
@@ -34,6 +34,8 @@
import com.trafficaudit.reportexport.calc.MidCalc;
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;
@@ -104,6 +106,10 @@
private SummaryWorkbookFiller summaryWorkbookFiller;
@Resource
private SummaryLayoutExpander summaryLayoutExpander;
+ @Resource
+ private FreightReadinessCheck freightReadinessCheck;
+ @Resource
+ private SummaryMissingDataCheck missingDataCheck;
@Resource
private WycSplitCalc wycSplitCalc;
@Resource
@@ -1433,10 +1439,11 @@
Map<String, ScaleSplitTransport> result = new HashMap<>();
List<ScaleSplitTransport> list = scaleSplitMapper.selectList(
new LambdaQueryWrapper<ScaleSplitTransport>()
- .eq(ScaleSplitTransport::getPeriodType, "CUMULATIVE"));
+ .eq(ScaleSplitTransport::getPeriodType, "CUMULATIVE")
+ .eq(ScaleSplitTransport::getReportPeriod, period)); // 2026-10-12锛氬彧璁ょ洰鏍囨湡锛岀己鏁扮暀绌恒�佷笉闈欓粯鍥為��涓婁竴鏈�
for (ScaleSplitTransport record : list) {
if (record.getReportPeriod() == null) continue;
- if (record.getReportPeriod().compareTo(period) > 0) continue;
+ if (!period.equals(record.getReportPeriod())) continue;
String city = RegionUtil.normalizeCityName(record.getRegionName());
if (city == null) continue;
if ("婀栧寳鐪�".equals(city)) continue;
@@ -1469,11 +1476,12 @@
private ScaleSplitTransport getProvinceCumulative(String period) {
List<ScaleSplitTransport> list = scaleSplitMapper.selectList(
new LambdaQueryWrapper<ScaleSplitTransport>()
- .eq(ScaleSplitTransport::getPeriodType, "CUMULATIVE"));
+ .eq(ScaleSplitTransport::getPeriodType, "CUMULATIVE")
+ .eq(ScaleSplitTransport::getReportPeriod, period)); // 2026-10-12锛氬悓涓婏紙鍙鐩爣鏈燂級
ScaleSplitTransport best = null;
for (ScaleSplitTransport record : list) {
if (record.getReportPeriod() == null) continue;
- if (record.getReportPeriod().compareTo(period) > 0) continue;
+ if (!period.equals(record.getReportPeriod())) continue;
String name = RegionUtil.normalizeCityName(record.getRegionName());
if (!"婀栧寳鐪�".equals(name)) continue;
if (best == null || record.getReportPeriod().compareTo(best.getReportPeriod()) > 0) best = record;
@@ -3638,14 +3646,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;
}
}
@@ -3707,6 +3755,8 @@
int effMonth = (toMonth != null && toMonth > 0 && toMonth < month) ? toMonth : month;
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);
@@ -3716,7 +3766,9 @@
reportProgress(progress, 45, "鍒锋柊鎺掑悕椤典笌璺ㄩ〉鍚堟垚椤�");
int rankRefreshed = refreshSummaryRankSheets(wb, effPeriod, "month");
int cumulativeRefreshed = refreshSummaryCumulativeSheets(wb, year, effMonth); // 鍥涘紶璺ㄩ〉鍚堟垚椤甸殢鎶ヨ〃鏈熷埛鏂�
- int widthApplied = applySummaryReferenceLayout(wb);
+ // 2026-10-12锛氬仠鐢ㄣ�屽鐢ㄥ閮ㄥ弬鐓т欢銆婄敓鎴恄閬撹矾杩愯緭閲忔眹鎬昏〃.xlsx銆嬪垪瀹姐�嶁�斺�旂増寮忎竴寰嬩互褰撴湡姣嶇増涓哄噯锛�
+ // 閬垮厤姣嶇増涓庡弬鐓т欢涓ゅ缁存姢锛堟瘝鐗堝凡骞跺叆鍙傜収浠剁殑鍒楀/闅愯棌锛夈��
+ int widthApplied = 0;
log.info("姹囨�诲伐浣滅翱鏁版嵁椹卞姩鍥炲~瀹屾垚锛氬啓鍏ュ綋鏈堝�兼牸鏁�={}锛岃ˉ鍐欏綋鏈堝悓姣斿叕寮忔牸鏁�={}锛岃ˉ鍐欏綋鏈堝悎璁″叕寮忔牸鏁�={}锛�"
+ "淇绱鍚屾瘮鍒嗘瘝鏍兼暟={}锛屽埛鏂版帓鍚嶉〉鏁板�兼牸鏁�={}锛屽埛鏂板洓椤碉紙鍩庡競姹囨��/鍩庡競鍒嗗競宸�/涓彛寰勫垎鏋�/閬撹矾杩愯緭鍛ㄨ浆閲忥級鏁板�兼牸鏁�={}锛�"
+ "鎸夈�婄敓鎴恄閬撹矾杩愯緭閲忔眹鎬昏〃銆嬪榻愬垪瀹藉垪鏁�={}锛岀己鏁版彁绀�={}",
@@ -3938,15 +3990,38 @@
int colOff = dstTitle.getColumnIndex() - sc0;
int h = rankBlockHeight(src, sr0, sc0);
int w = rankBlockWidth(src, sr0, sc0);
+ // 2026-10-12锛氭暣鍧楃己鏁帮紙婧愪晶涓�涓暟鍊奸兘娌℃湁锛屽 9 鏈堢己鈶♀憿鏃剁殑鍛ㄨ浆閲忔帓鍚嶏級鈫� 鐩爣鍧楀彧鐣欐爣棰樹笌鏍囩锛�
+ // 鏁版嵁/鎺掑悕/鍗犳瘮涓�寰嬬暀绌猴紱鍚﹀垯姣嶇増鐨� RANK/鍗犳瘮鍏紡浼氬湪绌哄潡涓婄畻鍑恒�屽叏 1 + #DIV/0!銆嶃��
+ boolean blockHasData = false;
+ for (int r = 1; r < h && !blockHasData; r++) {
+ Row sr = src.getRow(sr0 + r);
+ if (sr == null) continue;
+ for (int c = 0; c < w; c++) {
+ Cell sc0c = sr.getCell(sc0 + c);
+ if (sc0c != null && rankNumeric(sc0c, ev) != null) {
+ blockHasData = true;
+ break;
+ }
+ }
+ }
for (int r = 0; r < h; r++) {
Row srcRow = src.getRow(sr0 + r);
if (srcRow == null) continue;
Row dstRow = dst.getRow(sr0 + r + rowOff);
if (dstRow == null) dstRow = dst.createRow(sr0 + r + rowOff);
for (int c = 0; c < w; c++) {
- Cell sc = srcRow.getCell(sc0 + c);
- if (sc == null) continue;
int dc = sc0 + c + colOff;
+ Cell sc = srcRow.getCell(sc0 + c);
+ if (!blockHasData && r > 0) {
+ // 鏁村潡缂烘暟锛氬彧淇濈暀鏍囩锛堝競宸炲悕/鎸囨爣鍚嶏級锛屾暟鎹笌鎺掑悕/鍗犳瘮閲嶇畻缁撴灉涓�寰嬬暀绌�
+ if (sc == null || !isRankLabel(sc)) clearRankCell(dstRow, dc);
+ continue;
+ }
+ if (sc == null) {
+ // 2026-10-12锛氭簮渚ф暣鏍肩己澶� = 缂烘暟 鈫� 鐩爣鏍兼寜銆岀己鏁扮暀绌恒�嶆竻绌猴紙涓嶅啀娌跨敤姣嶇増涓婁竴鎶ヨ〃鏈熺殑鏃у�硷級
+ if (r > 0) clearRankCell(dstRow, dc);
+ continue;
+ }
if (r == 0) {
// 鏍囬琛岋細鍚屾鍧楁爣棰樻枃妗堛�傛瘝鐗堟爣棰樻槸 inlineStr锛孭OI 鐨� setCellValue 鍙啓 <v>銆�
// 涓嶆洿鏂� <is>锛孍xcel 浼氱户缁樉绀烘棫鏈堜唤锛屽繀椤诲厛 setBlank 娓呮帀鍐嶅啓銆�
@@ -3981,7 +4056,12 @@
continue;
}
Double v = rankNumeric(sc, ev);
- if (v == null) continue;
+ if (v == null) {
+ // 2026-10-12锛氭簮渚ф暟鍊间綅涓虹┖锛堝缂衡憽鍏ㄥ彛寰勬椂鎺掑悕琛ㄧ殑銆岃涓嬨�嶅垪锛�= 缂烘暟 鈫� 鐣欑┖锛�
+ // 婧愪晶鏄爣绛炬枃鏈紙甯傚窞鍚�/鎸囨爣鍚嶏級鏃朵笉鏄己鏁帮紝淇濈暀姣嶇増鑷甫鍐呭銆�
+ if (!isRankLabel(sc)) clearRankCell(dstRow, dc);
+ continue;
+ }
if (dcCell == null) dcCell = rankCell(dstRow, dc);
dcCell.setCellValue(v);
copied++;
@@ -3998,6 +4078,34 @@
Cell left = col > 0 ? row.getCell(col - 1) : null;
if (left != null) c.setCellStyle(left.getCellStyle());
return c;
+ }
+
+ /**
+ * 鐩爣鏍兼寜銆岀己鏁扮暀绌恒�嶆竻绌恒��
+ *
+ * <p>2026-10-12锛氳繖閲岃繛姣嶇増鑷甫鐨勬帓鍚�/鍗犳瘮鍏紡鏍间竴璧锋竻锛堢己鏁版湡涓嶆樉绀�"涓婁竴鏈熸畫鐣欏�� + 鍏� 1 鎺掑悕 + #DIV/0!"锛夛紝
+ * 涓庛�婄敓鎴恄璐ц繍閲忔帓鍚�/鍛ㄨ浆閲忔帓鍚�/涓彛寰勬帓鍚嶃�嬭繖浜涚敤鎴锋棩甯告牳瀵逛欢鐨勭┖鎬佷竴鑷达紱涓嬫湡婧愪晶鏈夋暟鏃舵寜婧愪晶閲嶅啓鍥炴潵銆�
+ * 鏂囧瓧鏍囩鏍间笉鍔ㄣ��
+ */
+ private void clearRankCell(Row dstRow, int col) {
+ Cell c = dstRow.getCell(col);
+ if (c == null) return;
+ if (c.getCellType() != CellType.STRING) c.setBlank();
+ }
+
+ /** 婧愪晶鏄惁涓烘枃瀛楁爣绛撅紙甯傚窞鍚�/鎸囨爣鍚嶏級鈥斺�旀爣绛句笉鏄己鏁帮紝涓嶆竻绌虹洰鏍囨牸 */
+ private boolean isRankLabel(Cell c) {
+ if (c.getCellType() != CellType.STRING) return false;
+ String v = c.getStringCellValue();
+ if (v == null) return false;
+ String x = v.replace(",", "").trim();
+ if (x.isEmpty()) return false;
+ try {
+ Double.parseDouble(x);
+ return false;
+ } catch (NumberFormatException ignore) {
+ return true;
+ }
}
/** 鍏紡鍐呮墍鏈� A1 寮曠敤鏁翠綋骞崇Щ锛氬垪 +dCol銆佽 +dRow锛圫UM/RANK 绛夊嚱鏁板悕鍚庢帴鎷彿涓嶄細琚尮閰嶏級 */
@@ -4513,8 +4621,8 @@
if (sh == null) return 0;
smSetTitle(sh, 0, 0, "鍩庡競瀹㈣繍瀹㈣繍閲忓垎甯傚窞1-" + month + "鏈堢疮璁℃儏鍐�");
smSetTitle(sh, 22, 0, "鍩庡競瀹㈣繍瀹㈣繍鍛ㄨ浆閲忓垎甯傚窞1-" + month + "鏈堢疮璁℃儏鍐�");
- smSetTitle(sh, 45, 0, "鍩庡競瀹㈣繍瀹㈣繍閲忓垎甯傚窞" + month + "鏈堟儏鍐�");
- smSetTitle(sh, 67, 0, "鍩庡競瀹㈣繍瀹㈣繍鍛ㄨ浆閲忓垎甯傚窞" + month + "鏈堟儏鍐�");
+ smSetTitle(sh, 44, 0, "鍩庡競瀹㈣繍瀹㈣繍閲忓垎甯傚窞" + month + "鏈堟儏鍐�"); // 0鍩�44 = Excel 绗�45琛岋紙姣嶇増閲屾爣棰樺湪 A45锛孉46 鏄�"鍗曚綅"琛岋級
+ smSetTitle(sh, 66, 0, "鍩庡競瀹㈣繍瀹㈣繍鍛ㄨ浆閲忓垎甯傚窞" + month + "鏈堟儏鍐�"); // 0鍩�66 = Excel 绗�67琛岋紙鍚屼笂锛�
int n = 0;
n += smWriteCityByRegionBlock(sh, 4, true, curCum, lastCum);
n += smWriteCityByRegionBlock(sh, 26, false, curCum, lastCum);
--
Gitblit v1.9.1