From ceaca62fafa2c46bf14b2b1f7785518f67b71f61 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Thu, 18 Apr 2024 12:24:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=BA=E6=99=AF=E5=88=9B=E5=BB=BA=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E4=B8=8D=E5=8F=91=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1039697 --user=王孝刚 【项目管理】消息管理-设置开启和关闭定时任务,收不到通知 https://www.tapd.cn/55049933/s/1500618 --- .../definition/ApiDefinitionImportUtilService.java | 9 +++++---- .../io/metersphere/system/schedule/ScheduleService.java | 8 +++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionImportUtilService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionImportUtilService.java index c695d3537c..46b95c485f 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionImportUtilService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionImportUtilService.java @@ -62,11 +62,12 @@ import org.springframework.transaction.annotation.Transactional; import java.util.*; import java.util.stream.Collectors; +import static io.metersphere.project.utils.NodeSortUtils.DEFAULT_NODE_INTERVAL_POS; + @Service public class ApiDefinitionImportUtilService { private static final String UNPLANNED_API = "api_unplanned_request"; - public static final Long ORDER_STEP = 5000L; private final ThreadLocal currentApiOrder = new ThreadLocal<>(); private final ThreadLocal currentApiCaseOrder = new ThreadLocal<>(); private final ThreadLocal currentModuleOrder = new ThreadLocal<>(); @@ -191,7 +192,7 @@ public class ApiDefinitionImportUtilService { public Long getNextOrder(String projectId) { Long pos = extApiDefinitionMapper.getPos(projectId); - return (pos == null ? 0 : pos) + ORDER_STEP; + return (pos == null ? 0 : pos) + DEFAULT_NODE_INTERVAL_POS; } public Long getImportNextOrder(String projectId) { @@ -199,7 +200,7 @@ public class ApiDefinitionImportUtilService { if (order == null) { order = getNextOrder(projectId); } - order = order + ORDER_STEP; + order = order + DEFAULT_NODE_INTERVAL_POS; currentApiOrder.set(order); return order; } @@ -219,7 +220,7 @@ public class ApiDefinitionImportUtilService { if (order == null) { order = apiDefinitionModuleService.getNextOrder(projectId); } - order = order + ORDER_STEP; + order = order + DEFAULT_NODE_INTERVAL_POS; currentModuleOrder.set(order); return order; } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/schedule/ScheduleService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/schedule/ScheduleService.java index bd32ad566d..f181d863ba 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/schedule/ScheduleService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/schedule/ScheduleService.java @@ -16,6 +16,7 @@ import org.quartz.SchedulerException; import org.quartz.TriggerKey; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.List; @Transactional(rollbackFor = Exception.class) @@ -123,7 +124,6 @@ public class ScheduleService { schedule.setUpdateTime(System.currentTimeMillis()); schedule.setJob(clazz.getName()); scheduleMapper.updateByExampleSelective(schedule, example); - apiScheduleNoticeService.sendScheduleNotice(schedule, operator); } else { schedule = scheduleConfig.genCronSchedule(null); schedule.setJob(clazz.getName()); @@ -133,6 +133,12 @@ public class ScheduleService { schedule.setUpdateTime(System.currentTimeMillis()); scheduleMapper.insert(schedule); } + //通知 + if ((CollectionUtils.isEmpty(scheduleList) && BooleanUtils.isTrue(scheduleConfig.getEnable())) + || (CollectionUtils.isNotEmpty(scheduleList) && !scheduleList.getFirst().getEnable().equals(scheduleConfig.getEnable()))) { + apiScheduleNoticeService.sendScheduleNotice(schedule, operator); + } + JobDataMap jobDataMap = scheduleManager.getDefaultJobDataMap(schedule, scheduleConfig.getCron(), operator);