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-itinerary-boot/src/main/java/com/xiaopeng/itinerary/utils/holiday/HolidayUtil.java |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/utils/holiday/HolidayUtil.java b/xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/utils/holiday/HolidayUtil.java
index 5af8fb0..cb0d6d8 100644
--- a/xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/utils/holiday/HolidayUtil.java
+++ b/xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/utils/holiday/HolidayUtil.java
@@ -8,7 +8,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,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();
     }
     /**
      * 2非工作日  0工作日  1节假日 3调休日
@@ -96,17 +111,19 @@
         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;
     }
+
 }

--
Gitblit v1.7.1