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): 观测站速度/拥挤度走势图横轴改用系统配置假期天数
---
traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayTrendService.java | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
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;
}
}
}
--
Gitblit v1.9.1