diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index fbd9904977..4964958aef 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -459,6 +459,8 @@ public class ApiAutomationService { ids = this.getAllScenarioIdsByFontedSelect( request.getModuleIds(), request.getName(), request.getProjectId(), request.getFilters(), request.getUnSelectIds()); } + //检查是否有正在执行中的情景 + this.checkScenarioIsRunnng(ids); List apiScenarios = extApiScenarioMapper.selectIds(ids); String runMode = ApiRunMode.SCENARIO.name(); @@ -475,6 +477,15 @@ public class ApiAutomationService { return request.getId(); } + public void checkScenarioIsRunnng(List ids) { + List lastReportStatusByIds = apiReportService.selectLastReportByIds(ids); + for (ApiScenarioReport report : lastReportStatusByIds) { + if(StringUtils.equals(report.getStatus(),APITestStatus.Running.name())){ + MSException.throwException(report.getName()+" Is Running!"); + } + } + } + /** * 获取前台查询条件查询的所有(未经分页筛选)数据ID * diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index 6c945f5d2e..7469f8a987 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -415,4 +415,12 @@ public class ApiScenarioReportService { public List countByProjectIdGroupByExecuteResult(String projectId) { return extApiScenarioReportMapper.countByProjectIdGroupByExecuteResult(projectId); } + + public List selectLastReportByIds(List ids) { + if(!ids.isEmpty()){ + return extApiScenarioReportMapper.selectLastReportByIds(ids); + }else { + return new ArrayList<>(0); + } + } } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.java index 425ec646de..8fd7e161be 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.java @@ -3,6 +3,7 @@ package io.metersphere.base.mapper.ext; import io.metersphere.api.dto.QueryAPIReportRequest; import io.metersphere.api.dto.automation.APIScenarioReportResult; import io.metersphere.api.dto.datacount.ApiDataCountResult; +import io.metersphere.base.domain.ApiScenarioReport; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -20,4 +21,6 @@ public interface ExtApiScenarioReportMapper { long countByProjectIdAndCreateAndByScheduleInThisWeek(@Param("projectId") String projectId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp); List countByProjectIdGroupByExecuteResult(String projectId); + + List selectLastReportByIds(@Param("scenarioIdList") List ids); } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml index 8acd2c9948..5a552d03e3 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml @@ -194,4 +194,26 @@ WHERE acr.project_id = #{projectId} AND ar.trigger_mode = 'SCHEDULE' GROUP BY groupField; + + \ No newline at end of file