From 9d81ed87375b92fbd43872f5d6db521437d14544 Mon Sep 17 00:00:00 2001 From: AgAngle <1323481023@qq.com> Date: Tue, 23 Jul 2024 20:03:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83=E5=BC=80=E5=90=AF=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E4=B8=8D=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1044324 --user=陈建星 【系统设置】任务中心-定时任务-测试计划-列表中手动修改测试计划组的定时任务运行规则不生效 https://www.tapd.cn/55049933/s/1552871 --- .../system/service/TaskCenterService.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/TaskCenterService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/TaskCenterService.java index 9e0dbaf634..1b0d602993 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/TaskCenterService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/TaskCenterService.java @@ -9,6 +9,7 @@ import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.constants.TaskCenterResourceType; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.util.DateUtils; +import io.metersphere.sdk.util.LogUtils; import io.metersphere.sdk.util.SubListUtils; import io.metersphere.sdk.util.Translator; import io.metersphere.system.domain.Organization; @@ -208,9 +209,9 @@ public class TaskCenterService { private static String getLogModule(String moduleType, String module) { return switch (ScheduleTagType.valueOf(moduleType)) { - case ScheduleTagType.API_IMPORT -> StringUtils.join(module, "_TIME_API_IMPORT"); - case ScheduleTagType.API_SCENARIO -> StringUtils.join(module, "_TIME_API_SCENARIO"); - case ScheduleTagType.TEST_PLAN -> StringUtils.join(module, "_TIME_TEST_PLAN"); + case API_IMPORT -> StringUtils.join(module, "_TIME_API_IMPORT"); + case API_SCENARIO -> StringUtils.join(module, "_TIME_API_SCENARIO"); + case TEST_PLAN -> StringUtils.join(module, "_TIME_TEST_PLAN"); default -> throw new MSException(Translator.get("module_type_error")); }; } @@ -227,8 +228,13 @@ public class TaskCenterService { Schedule schedule = checkScheduleExit(id); schedule.setEnable(!schedule.getEnable()); scheduleService.editSchedule(schedule); - scheduleService.addOrUpdateCronJob(schedule, new JobKey(schedule.getKey(), schedule.getJob()), - new TriggerKey(schedule.getKey(), schedule.getJob()), BaseScheduleJob.class); + try { + scheduleService.addOrUpdateCronJob(schedule, new JobKey(schedule.getKey(), schedule.getJob()), + new TriggerKey(schedule.getKey(), schedule.getJob()), Class.forName(schedule.getJob())); + } catch (ClassNotFoundException e) { + LogUtils.error(e); + throw new RuntimeException(e); + } apiScheduleNoticeService.sendScheduleNotice(schedule, userId); String logModule = getLogModule(moduleType, module); saveLog(List.of(schedule), userId, path, HttpMethodConstants.GET.name(), logModule, OperationLogType.UPDATE.name()); @@ -304,8 +310,13 @@ public class TaskCenterService { list.forEach(s -> { s.setEnable(enable); batchMapper.updateByPrimaryKeySelective(s); - scheduleService.addOrUpdateCronJob(s, new JobKey(s.getKey(), s.getJob()), - new TriggerKey(s.getKey(), s.getJob()), BaseScheduleJob.class); + try { + scheduleService.addOrUpdateCronJob(s, new JobKey(s.getKey(), s.getJob()), + new TriggerKey(s.getKey(), s.getJob()), Class.forName(s.getJob())); + } catch (ClassNotFoundException e) { + LogUtils.error(e); + throw new RuntimeException(e); + } }); sqlSession.flushStatements(); });