diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java index bc0144fe91..cd10aee076 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java @@ -287,4 +287,9 @@ public class TestPlanController { public long countByScheduleEnableTotal(@RequestBody QueryTestPlanRequest request) { return testPlanService.countScheduleEnableTotal(request); } + + @PostMapping(value = "/update/scheduleByEnable") + public ScheduleDTO updateTestPlanBySchedule(@RequestBody ScheduleInfoRequest request) { + return testPlanService.updateTestPlanBySchedule(request); + } } diff --git a/backend/src/main/java/io/metersphere/track/dto/ScheduleDTO.java b/backend/src/main/java/io/metersphere/track/dto/ScheduleDTO.java new file mode 100644 index 0000000000..2854880862 --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/dto/ScheduleDTO.java @@ -0,0 +1,14 @@ +package io.metersphere.track.dto; + +import io.metersphere.base.domain.Schedule; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ScheduleDTO extends Schedule { + /** + * 定时任务下一次执行时间 + */ + private Long scheduleExecuteTime; +} diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index abcd5616fa..ef890173da 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -2039,4 +2039,16 @@ public class TestPlanService { Date time1 = trigger.getFireTimeAfter(time0); return time1.getTime(); } + + public ScheduleDTO updateTestPlanBySchedule(ScheduleInfoRequest request) { + ScheduleDTO scheduleDTO = new ScheduleDTO(); + Schedule schedule = scheduleService.getSchedule(request.getTaskID()); + schedule.setEnable(request.isEnable()); + apiAutomationService.updateSchedule(schedule); + BeanUtils.copyBean(scheduleDTO, schedule); + if (schedule.getEnable() != null && schedule.getEnable()) { + scheduleDTO.setScheduleExecuteTime(getNextTriggerTime(schedule.getValue())); + } + return scheduleDTO; + } } diff --git a/frontend/src/business/components/track/plan/components/TestPlanList.vue b/frontend/src/business/components/track/plan/components/TestPlanList.vue index 302ae18b67..313bb164fb 100644 --- a/frontend/src/business/components/track/plan/components/TestPlanList.vue +++ b/frontend/src/business/components/track/plan/components/TestPlanList.vue @@ -628,9 +628,11 @@ export default { cancelButtonText: this.$t('commons.cancel'), type: 'warning', }).then(() => { - this.result = this.$post('/test/plan/schedule/updateEnableByPrimyKey', param, () => { + this.result = this.$post('/test/plan/update/scheduleByEnable', param, response => { if (row.scheduleOpen) { row.scheduleStatus = 'OPEN' + row.scheduleCorn = response.data.value; + row.scheduleExecuteTime = response.data.scheduleExecuteTime; } else { row.scheduleStatus = 'SHUT' }