From 1c4760c373b5950634ecd3418beea451a2f14a0b Mon Sep 17 00:00:00 2001 From: limin-fit2 Date: Fri, 18 Feb 2022 11:53:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E9=BC=A0=E6=A0=87=E6=82=AC=E5=81=9C=E5=9C=A8=E5=BC=80=E5=85=B3?= =?UTF-8?q?=E4=B8=8A=E6=9C=AA=E5=B1=95=E7=A4=BA=E4=B8=8B=E6=AC=A1=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E6=97=B6=E9=97=B4=E5=92=8C=E8=BF=90=E8=A1=8C=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1010303 --user=李敏 鼠标悬停在开关上未展示下次执行时间和运行规则 https://www.tapd.cn/55049933/s/1105634 --- .../track/controller/TestPlanController.java | 5 +++++ .../java/io/metersphere/track/dto/ScheduleDTO.java | 14 ++++++++++++++ .../metersphere/track/service/TestPlanService.java | 12 ++++++++++++ .../track/plan/components/TestPlanList.vue | 4 +++- 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 backend/src/main/java/io/metersphere/track/dto/ScheduleDTO.java 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' }