From d2132c6e48db6307a317db24d0c40e33df74c0e0 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期日, 15 三月 2026 15:51:56 +0800
Subject: [PATCH] 修改bug
---
xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/utils/holiday/HolidayUtil.java | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/utils/holiday/HolidayUtil.java b/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/utils/holiday/HolidayUtil.java
index 947c385..3e5f7fe 100644
--- a/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/utils/holiday/HolidayUtil.java
+++ b/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/utils/holiday/HolidayUtil.java
@@ -10,7 +10,10 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import java.time.Duration;
import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
import java.util.concurrent.TimeUnit;
@@ -64,18 +67,31 @@
for (int i = 0; i < parse.size(); i++) {
JSONObject jsonObject1 = parse.getJSONObject(i);
String daytype = jsonObject1.get("daytype").toString();
+
+ long secondsToExactEndOfDay = getSecondsToExactEndOfDay();
if (daytype.equals("0")) {
- redisService.setCacheObject(CacheConstants.IS_DAY + now, "0", 1l, TimeUnit.DAYS);
+ redisService.setCacheObject(CacheConstants.IS_DAY + now, "0", secondsToExactEndOfDay, TimeUnit.SECONDS);
return 0;
} else if (daytype.equals("1")) {
- redisService.setCacheObject(CacheConstants.IS_DAY + now, "1", 1l, TimeUnit.DAYS);
+ redisService.setCacheObject(CacheConstants.IS_DAY + now, "1", secondsToExactEndOfDay, TimeUnit.SECONDS);
return 1;
} else if (daytype.equals("2")) {
- redisService.setCacheObject(CacheConstants.IS_DAY + now, "0", 1l, TimeUnit.DAYS);
+ redisService.setCacheObject(CacheConstants.IS_DAY + now, "2", secondsToExactEndOfDay, TimeUnit.SECONDS);
return 0;
}
}
return 0;
}
+ public static long getSecondsToExactEndOfDay() {
+ LocalDateTime now = LocalDateTime.now();
+
+ // 精确到23:59:59(不包含毫秒/纳秒)
+ LocalDateTime endOfDay = LocalDateTime.of(
+ LocalDate.now(),
+ LocalTime.of(23, 59, 59)
+ );
+
+ return Duration.between(now, endOfDay).getSeconds();
+ }
}
--
Gitblit v1.7.1