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);