Przeglądaj źródła

定时任务开关

Gaokun Wang 4 miesięcy temu
rodzic
commit
bcab82da7a

+ 1 - 0
als-modules/agile-assurance/src/main/java/org/eco/als/service/impl/FaultStatisticsServiceImpl.java

@@ -141,6 +141,7 @@ public class FaultStatisticsServiceImpl extends BaseServiceImpl<FaultStatisticsM
         return this.listAs(queryWrapper, FaultStatisticsVo.class);
     }
 
+    @Transactional
     @Override
     public void getExtraStatistics() {
         int count = faultStatisticsMapper.deleteByCondition(FAULT_STATISTICS.CREATE_TIME.lt(DateUtil.date()));

+ 3 - 5
als-modules/agile-assurance/src/main/java/org/eco/als/task/FaultTask.java

@@ -3,8 +3,7 @@ package org.eco.als.task;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
 import org.eco.als.service.IFaultStatisticsService;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
@@ -17,14 +16,13 @@ import org.springframework.stereotype.Component;
  */
 @Slf4j
 @Component
-@EnableAsync
 @EnableScheduling
+@ConditionalOnProperty(prefix = "scheduling", name = "enabled", havingValue = "true")
 public class FaultTask {
     @Resource
     private IFaultStatisticsService faultStatisticsService;
 
-    @Async("TaskExecutor")
-    @Scheduled(cron = "0 */30 * * * *")
+    @Scheduled(cron = "0 */1 * * * *")
     public void faultStatisticsTask() {
         log.info("获取ZK故障信息定时任务=========开始");
         faultStatisticsService.getExtraStatistics();

+ 3 - 0
als-start/src/main/resources/application-local.yml

@@ -162,6 +162,9 @@ sms:
       #您的sdkAppId
       sdk-app-id: 您的sdkAppId
 
+--- # 定时任务配置
+scheduling:
+    enabled: false
 easy-es:
   address: 127.0.0.1:9007
   banner: false # 默认为true 打印banner 若您不期望打印banner,可配置为false

+ 3 - 0
als-start/src/main/resources/application-prod.yml

@@ -167,6 +167,9 @@ easy-es:
   banner: false # 默认为true 打印banner 若您不期望打印banner,可配置为false
   username: elk #es用户名,若无则删去此行配置
   password: #es密码,若无则删去此行配置
+--- # 定时任务配置
+scheduling:
+  enabled: true
 ## 知识图谱
 kgqa:
   ask-url: http://192.168.2.120:7074/kgqa/ask # kgqa问答接口