fix(接口测试): 重跑后,任务详情页面报错

--bug=1049600 --user=陈建星 【任务中心】即时任务列表-点击重跑后-查看任务详情报Duplicate key https://www.tapd.cn/55049933/s/1618318
This commit is contained in:
AgAngle 2024-11-27 10:40:34 +08:00 committed by jianxing
parent 7c8f7659dc
commit aa046e18d2
4 changed files with 12 additions and 4 deletions

View File

@ -494,7 +494,7 @@ public class ApiTestCaseBatchRunService {
private void serialRerunExecute(ExecTask execTask, String userId) {
ApiRunModeConfigDTO runModeConfig = getRunModeConfig(execTask);
List<ExecTaskItem> execTaskItems = extExecTaskItemMapper.selectIdAndResourceIdByTaskId(execTask.getId());
List<ExecTaskItem> execTaskItems = extExecTaskItemMapper.selectRerunIdAndResourceIdByTaskId(execTask.getId());
// 初始化执行队列
ExecutionQueue queue = apiBatchRunBaseService.getExecutionQueue(runModeConfig, ApiExecuteResourceType.API_CASE.name(), execTask.getId(), userId);
@ -516,7 +516,7 @@ public class ApiTestCaseBatchRunService {
*/
public void parallelRerunExecute(ExecTask execTask, String userId) {
String projectId = execTask.getProjectId();
List<ExecTaskItem> execTaskItems = extExecTaskItemMapper.selectIdAndResourceIdByTaskId(execTask.getId());
List<ExecTaskItem> execTaskItems = extExecTaskItemMapper.selectRerunIdAndResourceIdByTaskId(execTask.getId());
ApiRunModeConfigDTO runModeConfig = getRunModeConfig(execTask);
// 记录用例和任务的映射

View File

@ -464,7 +464,7 @@ public class ApiScenarioBatchRunService {
private void serialRerunExecute(ExecTask execTask, String userId) {
ApiRunModeConfigDTO runModeConfig = apiTestCaseBatchRunService.getRunModeConfig(execTask);
List<ExecTaskItem> execTaskItems = extExecTaskItemMapper.selectIdAndResourceIdByTaskId(execTask.getId());
List<ExecTaskItem> execTaskItems = extExecTaskItemMapper.selectRerunIdAndResourceIdByTaskId(execTask.getId());
// 删除重跑的步骤
deleteRerunIntegratedStepResult(execTask, execTaskItems, runModeConfig);
@ -489,7 +489,7 @@ public class ApiScenarioBatchRunService {
*/
public void parallelRerunExecute(ExecTask execTask, String userId) {
String projectId = execTask.getProjectId();
List<ExecTaskItem> execTaskItems = extExecTaskItemMapper.selectIdAndResourceIdByTaskId(execTask.getId());
List<ExecTaskItem> execTaskItems = extExecTaskItemMapper.selectRerunIdAndResourceIdByTaskId(execTask.getId());
ApiRunModeConfigDTO runModeConfig = apiTestCaseBatchRunService.getRunModeConfig(execTask);
// 删除重跑的步骤

View File

@ -72,5 +72,7 @@ public interface ExtExecTaskItemMapper {
List<ExecTaskItem> selectIdAndResourceIdByTaskId(@Param("taskId") String taskId);
List<ExecTaskItem> selectRerunIdAndResourceIdByTaskId(@Param("taskId") String taskId);
void deleteRerunTaskItem(@Param("taskId") String taskId, String userId);
}

View File

@ -333,6 +333,12 @@
where task_id = #{taskId} and deleted = false
</select>
<select id="selectRerunIdAndResourceIdByTaskId" resultType="io.metersphere.system.domain.ExecTaskItem">
select id, resource_id
from exec_task_item
where task_id = #{taskId} and rerun = true and deleted = false
</select>
<insert id="insertRerunTaskItem">
insert into exec_task_item(id, task_id, resource_id, resource_name, task_origin, status, `result`, resource_pool_id,
resource_pool_node, resource_type, project_id, organization_id, thread_id, start_time, end_time, executor, collection_id,