refactor: 测试计划关联接口用例,批量执行过程中前端显示加载状态
测试计划关联接口用例,批量执行过程中建议前端显示加载状态
This commit is contained in:
parent
c504b51625
commit
65427d18ca
|
@ -459,6 +459,8 @@ public class ApiAutomationService {
|
|||
ids = this.getAllScenarioIdsByFontedSelect(
|
||||
request.getModuleIds(), request.getName(), request.getProjectId(), request.getFilters(), request.getUnSelectIds());
|
||||
}
|
||||
//检查是否有正在执行中的情景
|
||||
this.checkScenarioIsRunnng(ids);
|
||||
List<ApiScenarioWithBLOBs> apiScenarios = extApiScenarioMapper.selectIds(ids);
|
||||
|
||||
String runMode = ApiRunMode.SCENARIO.name();
|
||||
|
@ -475,6 +477,15 @@ public class ApiAutomationService {
|
|||
return request.getId();
|
||||
}
|
||||
|
||||
public void checkScenarioIsRunnng(List<String> ids) {
|
||||
List<ApiScenarioReport> lastReportStatusByIds = apiReportService.selectLastReportByIds(ids);
|
||||
for (ApiScenarioReport report : lastReportStatusByIds) {
|
||||
if(StringUtils.equals(report.getStatus(),APITestStatus.Running.name())){
|
||||
MSException.throwException(report.getName()+" Is Running!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取前台查询条件查询的所有(未经分页筛选)数据ID
|
||||
*
|
||||
|
|
|
@ -415,4 +415,12 @@ public class ApiScenarioReportService {
|
|||
public List<ApiDataCountResult> countByProjectIdGroupByExecuteResult(String projectId) {
|
||||
return extApiScenarioReportMapper.countByProjectIdGroupByExecuteResult(projectId);
|
||||
}
|
||||
|
||||
public List<ApiScenarioReport> selectLastReportByIds(List<String> ids) {
|
||||
if(!ids.isEmpty()){
|
||||
return extApiScenarioReportMapper.selectLastReportByIds(ids);
|
||||
}else {
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ApiDataCountResult> countByProjectIdGroupByExecuteResult(String projectId);
|
||||
|
||||
List<ApiScenarioReport> selectLastReportByIds(@Param("scenarioIdList") List<String> ids);
|
||||
}
|
|
@ -194,4 +194,26 @@
|
|||
WHERE acr.project_id = #{projectId} AND ar.trigger_mode = 'SCHEDULE'
|
||||
GROUP BY groupField;
|
||||
</select>
|
||||
<select id="selectLastReportByIds" resultType="io.metersphere.base.domain.ApiScenarioReport">
|
||||
SELECT report.* FROM api_scenario_report report
|
||||
INNER JOIN (
|
||||
SELECT a.id,a.createTime,a.scenario_id FROM
|
||||
(
|
||||
SELECT id AS id,create_time AS createTime, scenario_id AS scenario_id FROM api_scenario_report
|
||||
WHERE scenario_id in
|
||||
<foreach collection="scenarioIdList" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
UNION
|
||||
SELECT report.id AS id,report.create_time AS createTime,planScenario.api_scenario_id AS scenario_id FROM api_scenario_report report
|
||||
INNER JOIN test_plan_api_scenario planScenario ON report.scenario_id = planScenario.id
|
||||
WHERE planScenario.api_scenario_id in
|
||||
<foreach collection="scenarioIdList" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
ORDER BY createTime DESC
|
||||
) a GROUP BY a.scenario_id
|
||||
) orderData ON orderData.id = report.id;
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue