feat:时间校验

This commit is contained in:
Zhujx
2025-09-30 15:55:13 +08:00
parent e4fa58310c
commit 820b713c95

View File

@@ -5,7 +5,6 @@ import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
@@ -21,8 +20,12 @@ public class DynamicTaskScheduler {
public void schedule(TaskConfig config, Runnable task) {
schedule(config, task, LocalDateTime.now());
}
public void schedule(TaskConfig config, Runnable task, LocalDateTime serverTime) {
LocalDateTime time = config.getExecutionTime();
if (time.isBefore(LocalDateTime.now())) return;
if (time.isBefore(serverTime)) return;
ScheduledFuture<?> future = taskScheduler.schedule(() -> {
try {