From 67db945bbfd7ae08335652c30537a68e443deb78 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期日, 15 三月 2026 16:22:52 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/utils/holiday/HolidayUtil.java |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/utils/holiday/HolidayUtil.java b/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/utils/holiday/HolidayUtil.java
index 2060c2a..20cab47 100644
--- a/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/utils/holiday/HolidayUtil.java
+++ b/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/utils/holiday/HolidayUtil.java
@@ -10,7 +10,10 @@
 import org.springframework.data.redis.core.RedisTemplate;
 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;
 
 
@@ -66,14 +69,15 @@
         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;
             }
         }
@@ -98,17 +102,30 @@
         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