From 2ed500595e8e56431d9ddefb19c30a566f416e55 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期四, 02 四月 2026 15:42:44 +0800
Subject: [PATCH] fix: 首页趋势换成周、月、年
---
src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
index 3df5ead..996cd1c 100644
--- a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
+++ b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -3635,23 +3635,26 @@
int points;
if (type == null) type = 1;
- if (type == 1) { // 鏃�
- points = 1;
- startDate = now;
- formatter = DateTimeFormatter.ofPattern("MM-dd");
- } else if (type == 2) { // 鍛�
+
+ if (type == 1) { // 鍛�
startDate = now.with(DayOfWeek.MONDAY);
points = (int) ChronoUnit.DAYS.between(startDate, now) + 1;
formatter = DateTimeFormatter.ofPattern("MM-dd");
- } else { // 鏈�
+ } else if (type == 2) { // 鏈�
startDate = now.with(TemporalAdjusters.firstDayOfMonth());
points = now.getDayOfMonth();
formatter = DateTimeFormatter.ofPattern("MM-dd");
+ } else { // 骞�
+ startDate = now.with(TemporalAdjusters.firstDayOfYear());
+ points = now.getMonthValue();
+ formatter = DateTimeFormatter.ofPattern("yyyy-MM");
}
Map<String, PlanTrendsDto> resultMap = new LinkedHashMap<>();
for (int i = 0; i < points; i++) {
- String label = startDate.plusDays(i).format(formatter);
+ String label = (type == 3)
+ ? startDate.plusMonths(i).format(formatter)
+ : startDate.plusDays(i).format(formatter);
PlanTrendsDto dto = new PlanTrendsDto();
dto.setDateStr(label);
dto.setPlannedVolume(BigDecimal.ZERO);
--
Gitblit v1.9.3