feat:时间校验
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user