瀏覽代碼

时间判断修改

wangyunpeng 1 年之前
父節點
當前提交
48fbe4e7b5

+ 4 - 3
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/XxlJobService.java

@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 import org.springframework.util.StringUtils;
 
 
+import java.time.LocalTime;
 import java.util.List;
 import java.util.List;
 
 
 @Service
 @Service
@@ -30,9 +31,9 @@ public class XxlJobService {
             if (!StringUtils.hasText(publishPlan.getPublishWindowStart())) {
             if (!StringUtils.hasText(publishPlan.getPublishWindowStart())) {
                 continue;
                 continue;
             }
             }
-            String[] planTime = publishPlan.getPublishWindowStart().split(":");
-            int planHour = Integer.parseInt(planTime[0]);
-            int planMinute = Integer.parseInt(planTime[1]);
+            LocalTime time = LocalTime.parse(publishPlan.getPublishWindowStart());
+            int planHour = time.getHour();
+            int planMinute = time.getMinute();
             if (nowHour - planHour == 1 && nowMinute > planMinute) {
             if (nowHour - planHour == 1 && nowMinute > planMinute) {
                 sendFeishuPublishPlanNotPushWarn(publishPlan);
                 sendFeishuPublishPlanNotPushWarn(publishPlan);
             } else if (nowHour - planHour > 1) {
             } else if (nowHour - planHour > 1) {