From 1b997c6b026dc7a897f0b248413054d006af8028 Mon Sep 17 00:00:00 2001
From: xyc <jc_xiong@hotmail.com>
Date: 星期六, 03 十月 2026 21:23:15 +0800
Subject: [PATCH] fix(holiday): 快报累计正文单位由亿人次改为万人次
---
traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayBulletinService.java | 54 +++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 43 insertions(+), 11 deletions(-)
diff --git a/traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayBulletinService.java b/traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayBulletinService.java
index e6ef8ac..f99c55d 100644
--- a/traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayBulletinService.java
+++ b/traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayBulletinService.java
@@ -24,12 +24,14 @@
import java.io.FileInputStream;
import java.io.InputStream;
import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.nio.file.Files;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.function.Function;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
@@ -76,8 +78,6 @@
}
String currentTotal = formatNumber(current.getTotalPersonFlow());
- String cumulativeTotalYi = formatNumber(currentCumulative.getTotalPersonFlow() == null
- ? null : HolidayNumberUtils.divide(currentCumulative.getTotalPersonFlow(), BigDecimal.valueOf(10000)));
String ringRatioClause = previousDay == null ? "" : "锛岀幆姣�" + ratioPhrase(
current.getTotalPersonFlow(), previousDay.getTotalPersonFlow());
String paragraph1 = String.format("%d鏈�%d鏃ワ紙鍋囨湡绗�%d澶╋級锛屽叏鐪佸叏绀句細璺ㄥ尯鍩熶汉鍛樻祦鍔ㄩ噺%s涓囦汉娆�%s锛屾瘮2025骞村悓鏈�%s锛屾瘮2024骞村悓鏈�%s銆�",
@@ -85,12 +85,7 @@
ringRatioClause,
ratioPhrase(current.getTotalPersonFlow(), previousYear == null ? null : previousYear.getTotalPersonFlow()),
ratioPhrase(current.getTotalPersonFlow(), twoYearsAgo == null ? null : twoYearsAgo.getTotalPersonFlow()));
- String paragraph2 = String.format("鍋囨湡浠ユ潵锛屽叏鐪佸叏绀句細璺ㄥ尯鍩熶汉鍛樻祦鍔ㄩ噺绱%s浜夸汉娆★紝姣�2025骞村悓鏈�%s锛屾瘮2024骞村悓鏈�%s銆�",
- cumulativeTotalYi,
- ratioPhrase(currentCumulative.getTotalPersonFlow(),
- previousYearCumulative == null ? null : previousYearCumulative.getTotalPersonFlow()),
- ratioPhrase(currentCumulative.getTotalPersonFlow(),
- twoYearsAgoCumulative == null ? null : twoYearsAgoCumulative.getTotalPersonFlow()));
+ String paragraph2 = cumulativeParagraph(currentCumulative, previousYearCumulative, twoYearsAgoCumulative);
File template = resolveTemplateFile();
if (!template.exists() || !template.isFile()) {
@@ -130,6 +125,10 @@
if (table == null) {
throw new IllegalArgumentException("蹇姤妯℃澘涓壘涓嶅埌鏁版嵁琛�");
}
+ DailyMetrics previousYearCivilCumulative = comparableCumulative(
+ current, previousYear, DailyMetrics::getCivilAviation);
+ DailyMetrics twoYearsAgoCivilCumulative = comparableCumulative(
+ current, twoYearsAgo, DailyMetrics::getCivilAviation);
writeTableRow(table, 2, new String[]{
number(current.getNonBusinessPersonFlow()),
ratio(current.getNonBusinessPersonFlow(), previousDay == null ? null : previousDay.getNonBusinessPersonFlow()),
@@ -173,8 +172,8 @@
previousYear == null ? null : previousYear.getCivilAviation(),
twoYearsAgo == null ? null : twoYearsAgo.getCivilAviation(),
currentCumulative.getCivilAviation(),
- previousYearCumulative == null ? null : previousYearCumulative.getCivilAviation(),
- twoYearsAgoCumulative == null ? null : twoYearsAgoCumulative.getCivilAviation()));
+ previousYearCivilCumulative == null ? null : previousYearCivilCumulative.getCivilAviation(),
+ twoYearsAgoCivilCumulative == null ? null : twoYearsAgoCivilCumulative.getCivilAviation()));
writeTableRow(table, 7, transportRow(current.getWater(),
previousDay == null ? null : previousDay.getWater(),
previousYear == null ? null : previousYear.getWater(),
@@ -250,7 +249,10 @@
Element pPr = firstChildElement(templateParagraph, "pPr");
if (pPr != null) paragraph.appendChild(pPr.cloneNode(true));
}
+ Element templateRun = templateParagraph == null ? null : firstChildElement(templateParagraph, "r");
+ Element rPr = templateRun == null ? null : firstChildElement(templateRun, "rPr");
Element run = createElement("r");
+ if (rPr != null) run.appendChild(rPr.cloneNode(true));
Element t = createElement("t");
t.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
t.setTextContent(text == null ? "" : text);
@@ -328,9 +330,39 @@
return (percent.signum() > 0 ? "澧為暱" : "涓嬮檷") + HolidayNumberUtils.format1(percent.abs()) + "%";
}
+ private DailyMetrics comparableCumulative(DailyMetrics current, DailyMetrics comparisonYear,
+ Function<DailyMetrics, BigDecimal> selector) {
+ if (current == null || comparisonYear == null) return null;
+ int coveredDay = 0;
+ for (int day = current.getDayIndex(); day >= 1; day--) {
+ DailyMetrics metrics = statService.dailyMetrics(current.getYear(), current.getHolidayType(), day);
+ if (metrics != null && selector.apply(metrics) != null) {
+ coveredDay = day;
+ break;
+ }
+ }
+ if (coveredDay == 0) return null;
+ return statService.cumulativeMetrics(comparisonYear.getYear(), current.getHolidayType(), coveredDay);
+ }
+
+ private String cumulativeParagraph(DailyMetrics currentCumulative,
+ DailyMetrics previousYearCumulative,
+ DailyMetrics twoYearsAgoCumulative) {
+ BigDecimal total = currentCumulative == null ? null : currentCumulative.getTotalPersonFlow();
+ return String.format("鍋囨湡浠ユ潵锛屽叏鐪佸叏绀句細璺ㄥ尯鍩熶汉鍛樻祦鍔ㄩ噺绱%s涓囦汉娆★紝姣�2025骞村悓鏈�%s锛屾瘮2024骞村悓鏈�%s銆�",
+ formatNumber(total),
+ ratioPhrase(total, previousYearCumulative == null ? null : previousYearCumulative.getTotalPersonFlow()),
+ ratioPhrase(total, twoYearsAgoCumulative == null ? null : twoYearsAgoCumulative.getTotalPersonFlow()));
+ }
+
private String ratio(BigDecimal current, BigDecimal base) {
if (current == null || base == null || base.abs().compareTo(EPSILON) < 0) return "鈥�";
- return ratioPhrase(current, base);
+ BigDecimal ratio = HolidayNumberUtils.divide(current, base);
+ if (ratio == null) return "鈥�";
+ BigDecimal percent = HolidayNumberUtils.multiply(ratio.subtract(BigDecimal.ONE), BigDecimal.valueOf(100));
+ if (percent == null) return "鈥�";
+ BigDecimal rounded = percent.setScale(1, RoundingMode.HALF_UP);
+ return rounded.signum() == 0 ? "0%" : rounded.toPlainString() + "%";
}
private String number(BigDecimal value) {
--
Gitblit v1.9.1