From 9d5164ed9f0b8d7aea70efd7759f99f6f679445c Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Thu, 23 Jul 2020 10:11:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=97=B6=E5=81=9C=E6=AD=A2=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/metersphere/service/ScheduleService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/src/main/java/io/metersphere/service/ScheduleService.java b/backend/src/main/java/io/metersphere/service/ScheduleService.java index ede5772f98..13c41490ba 100644 --- a/backend/src/main/java/io/metersphere/service/ScheduleService.java +++ b/backend/src/main/java/io/metersphere/service/ScheduleService.java @@ -7,6 +7,7 @@ import io.metersphere.base.mapper.ScheduleMapper; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.job.sechedule.ApiTestJob; import io.metersphere.job.sechedule.ScheduleManager; import org.apache.commons.lang3.StringUtils; import org.quartz.JobKey; @@ -52,12 +53,15 @@ public class ScheduleService { } public int deleteSchedule(String scheduleId) { + Schedule schedule = scheduleMapper.selectByPrimaryKey(scheduleId); + removeJob(schedule.getResourceId()); return scheduleMapper.deleteByPrimaryKey(scheduleId); } public int deleteByResourceId(String resourceId) { ScheduleExample scheduleExample = new ScheduleExample(); scheduleExample.createCriteria().andResourceIdEqualTo(resourceId); + removeJob(resourceId); return scheduleMapper.deleteByExample(scheduleExample); } @@ -99,6 +103,10 @@ public class ScheduleService { return schedule; } + public void removeJob(String resourceId) { + scheduleManager.removeJob(ApiTestJob.getJobKey(resourceId), ApiTestJob.getTriggerKey(resourceId)); + } + public void addOrUpdateCronJob(Schedule request, JobKey jobKey, TriggerKey triggerKey, Class clazz) { Boolean enable = request.getEnable(); String cronExpression = request.getValue();