From 752e00503f672ddfe2066afb6c235721a3a912b5 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 19 十一月 2024 10:25:55 +0800
Subject: [PATCH] 2024.11.19 各项修正

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/ScheduleVo.kt |   49 +++++++++++++++++++++++++------------------------
 1 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/ScheduleVo.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/ScheduleVo.kt
index b147a6c..1c24fd6 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/ScheduleVo.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/ScheduleVo.kt
@@ -77,16 +77,17 @@
         }
 
         fun toScheduleVoList(schedule: EnvironmentalSchedule, option: ScheduleOption): List<ScheduleVo> {
-            val sT = LocalDateTime.ofInstant(option.startTime.toInstant(), ZoneId.systemDefault()).toLocalDate()
+            var sT = LocalDateTime.ofInstant(option.startTime.toInstant(), ZoneId.systemDefault()).toLocalDate()
             val eT = LocalDateTime.ofInstant(option.endTime.toInstant(), ZoneId.systemDefault()).toLocalDate()
+                .plusDays(1)
             val dateList = mutableListOf<Date>()
             when (schedule.scPeriodType.toInt()) {
                 // 姣忔棩
                 0 -> {
                     do {
                         dateList.add(Date.from(sT.atTime(0, 0, 0).atZone(ZoneId.systemDefault()).toInstant()))
-                        sT.plusDays(1)
-                    } while (sT.isAfter(eT))
+                        sT = sT.plusDays(1)
+                    } while (sT.isBefore(eT))
                 }
                 // 姣忓懆
                 1 -> {
@@ -95,30 +96,30 @@
                         if (weekList.contains(sT.dayOfWeek.value.toString())) {
                             dateList.add(Date.from(sT.atTime(0, 0, 0).atZone(ZoneId.systemDefault()).toInstant()))
                         }
-                        sT.plusDays(1)
-                    } while (sT.isAfter(eT))
+                        sT = sT.plusDays(1)
+                    } while (sT.isBefore(eT))
                 }
                 // 姣忔湀
                 2 -> {
                     val dayList = schedule.scEveryMonth.split(";")
-//                    do {
-//                        if (dayList.contains(sT.dayOfMonth.toString())) {
-//                            dateList.add(Date.from(sT.atTime(0, 0, 0).atZone(ZoneId.systemDefault()).toInstant()))
-//                        }
-//                        sT.plusDays(1)
-//                    } while (sT.isAfter(eT))
-                    var diffDays: Int? = null
-                    var mostRecentSchedule: Date? = null
-                    dayList.forEach {
-                        val diff = abs(it.toInt() - sT.dayOfMonth)
-                        if (diffDays == null || diff < diffDays!!) {
-                            mostRecentSchedule = Date.from(sT.withDayOfMonth(it.toInt()).atTime(0, 0, 0).atZone(ZoneId
-                                .systemDefault())
-                                .toInstant())
-                            diffDays = diff
+                    do {
+                        if (dayList.contains(sT.dayOfMonth.toString())) {
+                            dateList.add(Date.from(sT.atTime(0, 0, 0).atZone(ZoneId.systemDefault()).toInstant()))
                         }
-                    }
-                    mostRecentSchedule?.let { dateList.add(it) }
+                        sT = sT.plusDays(1)
+                    } while (sT.isBefore(eT))
+//                    var diffDays: Int? = null
+//                    var mostRecentSchedule: Date? = null
+//                    dayList.forEach {
+//                        val diff = abs(it.toInt() - sT.dayOfMonth)
+//                        if (diffDays == null || diff < diffDays!!) {
+//                            mostRecentSchedule = Date.from(sT.withDayOfMonth(it.toInt()).atTime(0, 0, 0).atZone(ZoneId
+//                                .systemDefault())
+//                                .toInstant())
+//                            diffDays = diff
+//                        }
+//                    }
+//                    mostRecentSchedule?.let { dateList.add(it) }
                 }
                 // 姣忓勾
                 3 -> {
@@ -128,8 +129,8 @@
                         if (dayList.contains(timeFormat)) {
                             dateList.add(Date.from(sT.atTime(0, 0, 0).atZone(ZoneId.systemDefault()).toInstant()))
                         }
-                        sT.plusDays(1)
-                    } while (sT.isAfter(eT))
+                        sT = sT.plusDays(1)
+                    } while (sT.isBefore(eT))
                 }
                 // 鍥哄畾鏃ユ湡
                 4 -> {

--
Gitblit v1.9.3