diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseScheduleService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseScheduleService.java index 5ddcde7746..82e9475bf2 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseScheduleService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseScheduleService.java @@ -1,5 +1,6 @@ package io.metersphere.system.service; +import io.metersphere.sdk.constants.ScheduleResourceType; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.LogUtils; import io.metersphere.system.domain.Schedule; @@ -39,9 +40,14 @@ public class BaseScheduleService { } private void doHandleSchedule(List schedules) { + List resourceTypes = List.of(ScheduleResourceType.API_IMPORT.name(), ScheduleResourceType.API_SCENARIO.name(), ScheduleResourceType.TEST_PLAN.name(), ScheduleResourceType.BUG_SYNC.name()); schedules.forEach(schedule -> { try { if (schedule.getEnable()) { + if (resourceTypes.contains(schedule.getResourceType())) { + // 删除关闭的job + removeJob(schedule); + } LogUtils.info("初始化任务:" + JSON.toJSONString(schedule)); scheduleManager.addOrUpdateCronJob(new JobKey(schedule.getKey(), schedule.getJob()), new TriggerKey(schedule.getKey(), schedule.getJob()), Class.forName(schedule.getJob()), schedule.getValue(),