From e958585c9e80b984d6dcd5dc8247cc73ed87a70e Mon Sep 17 00:00:00 2001
From: xyc <jc_xiong@hotmail.com>
Date: 星期四, 08 十月 2026 10:43:38 +0800
Subject: [PATCH] fix(holiday): 观测站速度/拥挤度走势图横轴改用系统配置假期天数

---
 HANDOFF.md                                                                                            |   13 ++++++
 traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayTrendChartService.java     |    8 +++
 traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayTrendService.java          |   25 ++++++++----
 traffic-audit-server/src/test/java/com/trafficaudit/holiday/service/HolidayTrendChartServiceTest.java |   24 ++++++++++++
 4 files changed, 60 insertions(+), 10 deletions(-)

diff --git a/HANDOFF.md b/HANDOFF.md
index 5227497..de79350 100644
--- a/HANDOFF.md
+++ b/HANDOFF.md
@@ -4,7 +4,18 @@
 > **姣忓ぉ缁撴潫鏃�**锛氭妸褰撳ぉ杩涘睍銆佽俯杩囩殑鍧戙�佹柊闇�姹傘�佹湭瀹屾垚浜嬮」鏇存柊鍒版湰鏂囦欢锛岀劧鍚庡彲浠ユ斁蹇冨紑鏂板璇濄��
 > **鍗忎綔绾﹀畾锛�2026-08-31锛�**锛氳銆屾彁浜ゃ��= 鏈湴 commit + 鎺ㄩ�佸埌杩滅 git锛坥rigin main锛孏itblit锛夛紝涓嶅啀鍙仛鏈湴 commit銆�
 
-## 鏈�鏂帮紙2026-10-08 涓婄彮鍓嶅叧鏈哄揩鐓э級
+## 鏈�鏂帮紙2026-10-08 璧板娍鍥鹃檮褰曚簩瑙傛祴绔欏浘澶╂暟淇锛�
+
+### 10-08锛氳娴嬬珯閫熷害/鎷ユ尋搴﹁蛋鍔垮浘鏀圭敤绯荤粺閰嶇疆鍋囨湡澶╂暟锛堝凡淇紝寰呴獙鏀讹級
+
+- **闇�姹傦紙鐢ㄦ埛锛�**锛氳蛋鍔垮浘鏈�鍚庝袱寮犲浘鈥滄櫘閫氬浗鐪侀亾瑙傛祴绔欏钩鍧囨満鍔ㄨ溅閫熷害鈥濃�溾�﹀钩鍧囨嫢鎸ゅ害鈥濆彧鍚粖骞存暟鎹紝妯酱澶╂暟涓嶅簲鏄浐瀹� 8 澶╋紝鑰屽簲涓虹郴缁熼厤缃殑鍋囨湡澶╂暟銆�
+- **鏀瑰姩**锛歚HolidayTrendChartService.lineChart` 鏂板鍙紶 `dayLabels` 鐨勯噸杞斤紙榛樿浠嶄负 `DAY_LABELS` 8 澶╋紝鍏朵綑 13 寮犲浘闆舵敼鍔級锛沗HolidayTrendService.observationData` 鏀逛负鎸� `configService.findHolidayDays(year, holidayType)`锛坄day_index>=1`锛夌殑澶╂暟涓庢棩鏈熺敓鎴愭暟鎹偣鍜屾í杞存爣绛撅紝鏈�鍚庝袱寮犲浘浼犲叆璇ユ爣绛俱��
+- **閰嶇疆渚濇嵁**锛歚holiday_calendar` 2026 鍗佷竴 `day_index 1..7`锛�7 澶╋紝`day_index 0` = 09-30 鐜瘮鍩烘湡锛夛紱2025 = 8 澶┿��2024 = 7 澶┿��
+- **楠岃瘉**锛歚mvn -o test` 16/16 閫氳繃锛堟柊澧炶嚜瀹氫箟妯酱鏍囩鍗曞厓娴嬭瘯锛夛紱鐪熷疄浜戝彧璇荤敓鎴愯蛋鍔垮浘锛屼笌鐢ㄦ埛宸蹭笅杞界増閫愬浘瀵规瘮锛歩mage1~13 鐨� SHA-256 瀹屽叏涓�鑷达紝浠� image14锛堥�熷害锛夈�乮mage15锛堟嫢鎸ゅ害锛夊彉鍖栵紱OCR 纭鏂板浘妯酱涓� 10鏈�1鏃10鏈�7鏃ャ�佹棤 10鏈�8鏃ャ��
+- **杈圭晫**锛氬叾浣欏浘浠嶅浐瀹� 8 澶╁彛寰勶紝鏈敼锛涙湭瀵煎叆/瑕嗙洊/閲嶅浠讳綍涓氬姟鏁版嵁銆�
+- **閲嶅惎**锛氫负璁╂寜閽笅杞界敤涓婃柊浠g爜锛屽凡鐢� `start-dev.ps1` 閲嶅惎鍚庣锛堝墠绔湭鍔級锛岄噸鍚椂闂� 2026-10-08 10:38:53锛涘彲鐩存帴鍦ㄧ郴缁熼噷閲嶆柊涓嬭浇璧板娍鍥鹃獙鏀躲��
+
+## 鍘嗗彶锛�2026-10-08 涓婄彮鍓嶅叧鏈哄揩鐓э級
 
 ### 10-08锛氳蛋鍔垮浘 `(14)` 涓庡凡楠屾敹 `(12)` 姣斿锛堝唴瀹逛竴鑷达級
 
diff --git a/traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayTrendChartService.java b/traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayTrendChartService.java
index 0f06317..eb09955 100644
--- a/traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayTrendChartService.java
+++ b/traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayTrendChartService.java
@@ -103,6 +103,12 @@
 
     public byte[] lineChart(String yAxisLabel, List<ChartSeries> series, boolean percentAxis,
                             int valueDecimals, int width, int height) {
+        return lineChart(yAxisLabel, series, percentAxis, valueDecimals, DAY_LABELS, width, height);
+    }
+
+    public byte[] lineChart(String yAxisLabel, List<ChartSeries> series, boolean percentAxis,
+                            int valueDecimals, List<String> dayLabels, int width, int height) {
+        List<String> axisLabels = (dayLabels == null || dayLabels.isEmpty()) ? DAY_LABELS : dayLabels;
         XYSeriesCollection dataset = new XYSeriesCollection();
         for (int seriesIndex = 0; seriesIndex < series.size(); seriesIndex++) {
             ChartSeries item = series.get(seriesIndex);
@@ -132,7 +138,7 @@
         plot.setRangeGridlinesVisible(false);
         plot.setDomainTickBandPaint(null);
         plot.setRangeTickBandPaint(null);
-        SymbolAxis domainAxis = new SymbolAxis(null, DAY_LABELS.toArray(new String[0]));
+        SymbolAxis domainAxis = new SymbolAxis(null, axisLabels.toArray(new String[0]));
         domainAxis.setGridBandPaint(new Color(0, 0, 0, 0));
         domainAxis.setGridBandAlternatePaint(new Color(0, 0, 0, 0));
         domainAxis.setLowerMargin(0.04);
diff --git a/traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayTrendService.java b/traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayTrendService.java
index 9960464..11793f8 100644
--- a/traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayTrendService.java
+++ b/traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayTrendService.java
@@ -15,6 +15,7 @@
 import java.io.InputStream;
 import java.math.BigDecimal;
 import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -138,12 +139,14 @@
         blocks.add(new HolidayTrendWordService.ChartBlock(
                 prefix + "鏅�氬浗鐪侀亾瑙傛祴绔欏钩鍧囨満鍔ㄨ溅閫熷害",
                 chartService.lineChart("鍏噷/灏忔椂",
-                        Collections.singletonList(series("骞冲潎閫熷害", observation.speed)), false, 1100, 590),
+                        Collections.singletonList(series("骞冲潎閫熷害", observation.speed)), false, 2,
+                        observation.labels, 1100, 590),
                 lineImageSize(5268595L, 2821305L)));
         blocks.add(new HolidayTrendWordService.ChartBlock(
                 prefix + "鏅�氬浗鐪侀亾瑙傛祴绔欏钩鍧囨嫢鎸ゅ害",
                 chartService.lineChart("鎷ユ尋搴�",
-                        Collections.singletonList(series("骞冲潎鎷ユ尋搴�", observation.congestion)), false, 1100, 590),
+                        Collections.singletonList(series("骞冲潎鎷ユ尋搴�", observation.congestion)), false, 2,
+                        observation.labels, 1100, 590),
                 lineImageSize(5268595L, 2821305L)));
 
         File template = resolveTemplateFile();
@@ -263,23 +266,27 @@
     private ObservationData observationData(int year, String holidayType) {
         List<HolidayCalendar> days = configService.findHolidayDays(year, holidayType);
         if (days.isEmpty()) {
-            return new ObservationData(nulls(), nulls());
+            return new ObservationData(nulls(), nulls(), HolidayTrendChartService.DAY_LABELS);
         }
         LocalDate start = days.get(0).getHolidayDate();
-        LocalDate end = start.plusDays(HolidayTrendChartService.DAY_LABELS.size() - 1L);
+        LocalDate end = days.get(days.size() - 1).getHolidayDate();
         List<ObservationDailyOperation> rows = observationStationFlowMapper.selectDailyOperations(start, end);
         Map<LocalDate, ObservationDailyOperation> byDate = new LinkedHashMap<>();
         for (ObservationDailyOperation row : rows) {
             byDate.put(row.getObsDate(), row);
         }
+        DateTimeFormatter labelFormat = DateTimeFormatter.ofPattern("M鏈坉鏃�");
         List<BigDecimal> speed = new ArrayList<>();
         List<BigDecimal> congestion = new ArrayList<>();
-        for (int i = 0; i < HolidayTrendChartService.DAY_LABELS.size(); i++) {
-            ObservationDailyOperation row = byDate.get(start.plusDays(i));
+        List<String> labels = new ArrayList<>();
+        for (HolidayCalendar day : days) {
+            LocalDate date = day.getHolidayDate();
+            ObservationDailyOperation row = byDate.get(date);
             speed.add(row == null ? null : row.getAverageSpeed());
             congestion.add(row == null ? null : row.getAverageCongestion());
+            labels.add(date.format(labelFormat));
         }
-        return new ObservationData(speed, congestion);
+        return new ObservationData(speed, congestion, labels);
     }
 
     private HolidayTrendChartService.ChartSeries series(String name, List<BigDecimal> values) {
@@ -441,10 +448,12 @@
     private static class ObservationData {
         private final List<BigDecimal> speed;
         private final List<BigDecimal> congestion;
+        private final List<String> labels;
 
-        private ObservationData(List<BigDecimal> speed, List<BigDecimal> congestion) {
+        private ObservationData(List<BigDecimal> speed, List<BigDecimal> congestion, List<String> labels) {
             this.speed = speed;
             this.congestion = congestion;
+            this.labels = labels;
         }
     }
 }
diff --git a/traffic-audit-server/src/test/java/com/trafficaudit/holiday/service/HolidayTrendChartServiceTest.java b/traffic-audit-server/src/test/java/com/trafficaudit/holiday/service/HolidayTrendChartServiceTest.java
index fff727d..24bffda 100644
--- a/traffic-audit-server/src/test/java/com/trafficaudit/holiday/service/HolidayTrendChartServiceTest.java
+++ b/traffic-audit-server/src/test/java/com/trafficaudit/holiday/service/HolidayTrendChartServiceTest.java
@@ -114,6 +114,30 @@
         assertFalse(java.util.Arrays.equals(twoDecimals, threeDecimals));
     }
 
+    @Test
+    void rendersLineChartWithConfiguredDayLabels() {
+        HolidayTrendChartService service = new HolidayTrendChartService();
+        HolidayTrendChartService.ChartSeries congestion = new HolidayTrendChartService.ChartSeries();
+        congestion.setName("\u5e73\u5747\u62e5\u6324\u5ea6");
+        congestion.setValues(java.util.Arrays.asList(
+                new BigDecimal("0.50"), new BigDecimal("0.48"), new BigDecimal("0.47"),
+                new BigDecimal("0.49"), new BigDecimal("0.49"), new BigDecimal("0.49"),
+                new BigDecimal("0.47")));
+        java.util.List<String> sevenDays = java.util.Arrays.asList(
+                "10\u67081\u65e5", "10\u67082\u65e5", "10\u67083\u65e5", "10\u67084\u65e5",
+                "10\u67085\u65e5", "10\u67086\u65e5", "10\u67087\u65e5");
+
+        byte[] custom = service.lineChart("\u62e5\u6324\u5ea6",
+                java.util.Collections.singletonList(congestion), false, 2, sevenDays, 1100, 590);
+        byte[] defaults = service.lineChart("\u62e5\u6324\u5ea6",
+                java.util.Collections.singletonList(congestion), false, 2, 1100, 590);
+
+        assertPng(custom);
+        assertPng(defaults);
+        assertFalse(java.util.Arrays.equals(custom, defaults),
+                "custom day labels should change the rendered axis");
+    }
+
     private void assertNoLargeLightGrayBackground(byte[] data) throws Exception {
         BufferedImage image = ImageIO.read(new ByteArrayInputStream(data));
         int matches = 0;

--
Gitblit v1.9.1