Pārlūkot izejas kodu

定时任务-同步任务-调整为通过配置文件使其本地不执行定时任务

LHB 1 mēnesi atpakaļ
vecāks
revīzija
7159107e2b

+ 7 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeSynchronousRecordServiceImpl.java

@@ -16,6 +16,7 @@ import org.springblade.manager.mapper.*;
 import org.springblade.manager.service.WbsTreeSynchronousRecordService;
 import org.springblade.manager.vo.WbsTreeSynchronousRecordVo;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
@@ -225,12 +226,18 @@ public class WbsTreeSynchronousRecordServiceImpl extends ServiceImpl<WbsTreeSync
         return returnData;
     }
 
+    // 读取配置并设置默认值
+    @Value("${scheduler.enabled:true}")
+    private boolean schedulerEnabled;
     /**
      * 同步节点表单
      * 定时检查同步任务,状态为1的数据如果最后更新时间与当前时间超过10分钟,则修改状态为1
      */
     @Scheduled(fixedDelay = 10000)
     public void syncInit() {
+        // 本地环境跳过执行(可添加日志输出)
+        if (!schedulerEnabled) return;
+
         List<WbsTreeSynchronousRecord> wbsTreeSynchronousRecords = baseMapper.selectList(new QueryWrapper<WbsTreeSynchronousRecord>().lambda()
                 .in(WbsTreeSynchronousRecord::getStatus, 0, 1)
                 .eq(WbsTreeSynchronousRecord::getIsDeleted, 0)