mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-11-30 11:08:38 +08:00
refactor(系统设置): 优化初始定时任务
This commit is contained in:
parent
1db33454a0
commit
b828dfec49
@ -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<Schedule> schedules) {
|
||||
List<String> 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(),
|
||||
|
Loading…
Reference in New Issue
Block a user