|
|
@@ -8,6 +8,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
|
|
import org.springframework.scheduling.support.CronExpression;
|
|
|
import org.springframework.scheduling.support.CronTrigger;
|
|
|
@@ -18,7 +19,12 @@ import javax.annotation.PreDestroy;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.concurrent.ScheduledFuture;
|
|
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
|
@@ -40,6 +46,9 @@ public class InspectionScheduler {
|
|
|
|
|
|
private static final DateTimeFormatter DATETIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
+ @Value("${schedulerCfg.inspection-scheduler:disable}")
|
|
|
+ private String schedulerEnable;
|
|
|
+
|
|
|
@Autowired
|
|
|
private InspectionPlanMapper planMapper;
|
|
|
|
|
|
@@ -66,22 +75,24 @@ public class InspectionScheduler {
|
|
|
*/
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
- log.info("========== 初始化巡检调度器 ==========");
|
|
|
+ if ("enable".equals(schedulerEnable)) {
|
|
|
+ log.info("========== 初始化巡检调度器 ==========");
|
|
|
|
|
|
- // 创建任务调度器
|
|
|
- taskScheduler = new ThreadPoolTaskScheduler();
|
|
|
- taskScheduler.setPoolSize(5);
|
|
|
- taskScheduler.setThreadNamePrefix("inspection-scheduler-");
|
|
|
- taskScheduler.setWaitForTasksToCompleteOnShutdown(true);
|
|
|
- taskScheduler.setAwaitTerminationSeconds(60);
|
|
|
- taskScheduler.initialize();
|
|
|
+ // 创建任务调度器
|
|
|
+ taskScheduler = new ThreadPoolTaskScheduler();
|
|
|
+ taskScheduler.setPoolSize(5);
|
|
|
+ taskScheduler.setThreadNamePrefix("inspection-scheduler-");
|
|
|
+ taskScheduler.setWaitForTasksToCompleteOnShutdown(true);
|
|
|
+ taskScheduler.setAwaitTerminationSeconds(60);
|
|
|
+ taskScheduler.initialize();
|
|
|
|
|
|
- startTime = LocalDateTime.now();
|
|
|
+ startTime = LocalDateTime.now();
|
|
|
|
|
|
- // 加载已启用的计划
|
|
|
- loadEnabledPlans();
|
|
|
+ // 加载已启用的计划
|
|
|
+ loadEnabledPlans();
|
|
|
|
|
|
- log.info("========== 巡检调度器初始化完成,已注册 {} 个计划 ==========", scheduledTasks.size());
|
|
|
+ log.info("========== 巡检调度器初始化完成,已注册 {} 个计划 ==========", scheduledTasks.size());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|