From 9ec03c4c952a088cb60758bda8b20621493ba5f4 Mon Sep 17 00:00:00 2001 From: slhafzjw Date: Mon, 9 Feb 2026 21:01:22 +0800 Subject: [PATCH] fix(ActionScheduler): include previous tick in trigger scan and tighten next execution filtering --- .../action/dispatcher/scheduler/ActionScheduler.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Partner-Main/src/main/java/work/slhaf/partner/module/modules/action/dispatcher/scheduler/ActionScheduler.kt b/Partner-Main/src/main/java/work/slhaf/partner/module/modules/action/dispatcher/scheduler/ActionScheduler.kt index 6dcded0e..102ee506 100644 --- a/Partner-Main/src/main/java/work/slhaf/partner/module/modules/action/dispatcher/scheduler/ActionScheduler.kt +++ b/Partner-Main/src/main/java/work/slhaf/partner/module/modules/action/dispatcher/scheduler/ActionScheduler.kt @@ -136,7 +136,7 @@ class ActionScheduler : AgentRunningSubModule, Void>() fun collectToTrigger(tick: Int, previousTick: Int, triggerHour: Int): Set? { if (tick > previousTick) { val toTrigger = mutableSetOf() - for (i in (previousTick + 1)..tick) { + for (i in previousTick..tick) { val bucket = wheel[i] if (bucket.isNotEmpty()) { toTrigger.addAll(bucket) @@ -193,13 +193,15 @@ class ActionScheduler : AgentRunningSubModule, Void>() onTrigger(it) log.debug("Executing action at hour {} tick {}", launchingHour, tick) } + + // 休眠一秒 + delay(1000) + if (shouldBreak) { log.debug("Wheel stopped at tick {}", tick) break } - // 休眠一秒 - delay(1000) } } @@ -253,7 +255,7 @@ class ActionScheduler : AgentRunningSubModule, Void>() ) { val runLoading = { for (actionData in source) { - val latestExecutingTime = + val nextExecutingTime = parseToZonedDateTime( actionData.scheduleType, actionData.scheduleContent, @@ -263,7 +265,7 @@ class ActionScheduler : AgentRunningSubModule, Void>() continue } - load(latestExecutingTime, actionData) + load(nextExecutingTime, actionData) } } @@ -341,7 +343,7 @@ class ActionScheduler : AgentRunningSubModule, Void>() } catch (_: Exception) { return null } - if (executionTime.isBefore(now) || executionTime.dayOfYear != now.dayOfYear) + if (executionTime.plusSeconds(1).isBefore(now) || executionTime.dayOfMonth != now.dayOfMonth) null else executionTime