fix: 删除测试时停止任务
This commit is contained in:
parent
c20e4c4e8c
commit
9d5164ed9f
|
@ -7,6 +7,7 @@ import io.metersphere.base.mapper.ScheduleMapper;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.commons.utils.SessionUtils;
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
|
import io.metersphere.job.sechedule.ApiTestJob;
|
||||||
import io.metersphere.job.sechedule.ScheduleManager;
|
import io.metersphere.job.sechedule.ScheduleManager;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.quartz.JobKey;
|
import org.quartz.JobKey;
|
||||||
|
@ -52,12 +53,15 @@ public class ScheduleService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int deleteSchedule(String scheduleId) {
|
public int deleteSchedule(String scheduleId) {
|
||||||
|
Schedule schedule = scheduleMapper.selectByPrimaryKey(scheduleId);
|
||||||
|
removeJob(schedule.getResourceId());
|
||||||
return scheduleMapper.deleteByPrimaryKey(scheduleId);
|
return scheduleMapper.deleteByPrimaryKey(scheduleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int deleteByResourceId(String resourceId) {
|
public int deleteByResourceId(String resourceId) {
|
||||||
ScheduleExample scheduleExample = new ScheduleExample();
|
ScheduleExample scheduleExample = new ScheduleExample();
|
||||||
scheduleExample.createCriteria().andResourceIdEqualTo(resourceId);
|
scheduleExample.createCriteria().andResourceIdEqualTo(resourceId);
|
||||||
|
removeJob(resourceId);
|
||||||
return scheduleMapper.deleteByExample(scheduleExample);
|
return scheduleMapper.deleteByExample(scheduleExample);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,6 +103,10 @@ public class ScheduleService {
|
||||||
return schedule;
|
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) {
|
public void addOrUpdateCronJob(Schedule request, JobKey jobKey, TriggerKey triggerKey, Class clazz) {
|
||||||
Boolean enable = request.getEnable();
|
Boolean enable = request.getEnable();
|
||||||
String cronExpression = request.getValue();
|
String cronExpression = request.getValue();
|
||||||
|
|
Loading…
Reference in New Issue