From 74dba73597b9213076e19e9f9a21643d28e458c2 Mon Sep 17 00:00:00 2001 From: AgAngle <1323481023@qq.com> Date: Mon, 21 Oct 2024 14:42:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=89=A7=E8=A1=8C=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/scenario/ApiScenarioBatchRunService.java | 8 +------- .../plan/service/PlanRunTestPlanApiCaseService.java | 4 ++-- .../plan/service/PlanRunTestPlanApiScenarioService.java | 2 +- .../plan/service/TestPlanApiCaseBatchRunService.java | 4 ++-- .../plan/service/TestPlanApiScenarioBatchRunService.java | 4 ++-- .../metersphere/plan/service/TestPlanExecuteService.java | 2 +- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioBatchRunService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioBatchRunService.java index b88c733cee..c520793a81 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioBatchRunService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioBatchRunService.java @@ -132,14 +132,8 @@ public class ApiScenarioBatchRunService { initIntegratedReportCaseRecord(reportId, subIds); // 集合报告初始化一级步骤 initApiScenarioReportStep(apiScenarios, reportId); - } else { - // 初始化任务项 - Map resourceExecTaskItemMap = execTaskItems - .stream() - .collect(Collectors.toMap(ExecTaskItem::getResourceId, ExecTaskItem::getId)); - // 非集合报告,初始化独立报告,执行时初始化步骤 - initScenarioReport(resourceExecTaskItemMap, runModeConfig, apiScenarios, userId); } + // 初始化队列项 apiBatchRunBaseService.initExecutionQueueDetails(queue.getQueueId(), execTaskItems); }); diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/PlanRunTestPlanApiCaseService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/PlanRunTestPlanApiCaseService.java index e1e1c2e2a1..9998028051 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/PlanRunTestPlanApiCaseService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/PlanRunTestPlanApiCaseService.java @@ -207,7 +207,7 @@ public class PlanRunTestPlanApiCaseService { ApiTestCase apiTestCase = apiTestCaseMapper.selectByPrimaryKey(testPlanReportApiCase.getApiCaseId()); // 独立报告,执行到当前任务时初始化报告 - String reportId = initApiReport(Map.of(apiTestCase.getId(), queueDetail.getTaskItemId()), runModeConfig, List.of(testPlanReportApiCase), Map.of(apiTestCase.getId(), apiTestCase), queue.getUserId()).get(resourceId); + String reportId = initApiReport(Map.of(testPlanReportApiCase.getId(), queueDetail.getTaskItemId()), runModeConfig, List.of(testPlanReportApiCase), Map.of(apiTestCase.getId(), apiTestCase), queue.getUserId()).get(resourceId); TaskRequestDTO taskRequest = testPlanApiCaseBatchRunService.getTaskRequestDTO(reportId, testPlanReportApiCase.getId(), apiTestCase, runModeConfig); taskRequest.getTaskInfo().setTaskId(queue.getTaskId()); taskRequest.getTaskInfo().setResourceType(ApiExecuteResourceType.PLAN_RUN_API_CASE.name()); @@ -256,7 +256,7 @@ public class PlanRunTestPlanApiCaseService { // 创建报告和任务的关联关系 ApiReportRelateTask apiReportRelateTask = new ApiReportRelateTask(); apiReportRelateTask.setReportId(apiReport.getId()); - apiReportRelateTask.setTaskResourceId(resourceExecTaskItemMap.get(apiReport.getId())); + apiReportRelateTask.setTaskResourceId(resourceExecTaskItemMap.get(testPlanReportApiCase.getId())); apiReportRelateTasks.add(apiReportRelateTask); } apiReportService.insertApiReport(apiReports, apiTestCaseRecords, apiReportRelateTasks); diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/PlanRunTestPlanApiScenarioService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/PlanRunTestPlanApiScenarioService.java index 053f335420..f9017d2d28 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/PlanRunTestPlanApiScenarioService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/PlanRunTestPlanApiScenarioService.java @@ -202,7 +202,7 @@ public class PlanRunTestPlanApiScenarioService { // 创建报告和任务的关联关系 ApiReportRelateTask apiReportRelateTask = new ApiReportRelateTask(); apiReportRelateTask.setReportId(apiScenario.getId()); - apiReportRelateTask.setTaskResourceId(resourceExecTaskItemMap.get(apiScenario.getId())); + apiReportRelateTask.setTaskResourceId(resourceExecTaskItemMap.get(testPlanReportApiScenario.getId())); apiReportRelateTasks.add(apiReportRelateTask); } apiScenarioReportService.insertApiScenarioReport(apiScenarioReports, apiScenarioRecords, apiReportRelateTasks); diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseBatchRunService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseBatchRunService.java index 545b33c6bf..5667424547 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseBatchRunService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseBatchRunService.java @@ -400,7 +400,7 @@ public class TestPlanApiCaseBatchRunService { TestPlan testPlan = testPlanMapper.selectByPrimaryKey(testPlanId); // 独立报告,执行到当前任务时初始化报告 - String reportId = initApiReport(Map.of(apiTestCase.getId(), queueDetail.getTaskItemId()), runModeConfig, List.of(BeanUtils.copyBean(new TestPlanApiCaseBatchRunDTO(), testPlanApiCase)), + String reportId = initApiReport(Map.of(testPlanApiCase.getId(), queueDetail.getTaskItemId()), runModeConfig, List.of(BeanUtils.copyBean(new TestPlanApiCaseBatchRunDTO(), testPlanApiCase)), testPlan.getProjectId(), queue.getUserId()).get(testPlanApiCase.getId()); TaskRequestDTO taskRequest = getTaskRequestDTO(reportId, testPlanApiCase.getId(), apiTestCase, runModeConfig); taskRequest.getTaskInfo().setTaskId(queue.getTaskId()); @@ -464,7 +464,7 @@ public class TestPlanApiCaseBatchRunService { // 创建报告和任务的关联关系 ApiReportRelateTask apiReportRelateTask = new ApiReportRelateTask(); apiReportRelateTask.setReportId(apiReport.getId()); - apiReportRelateTask.setTaskResourceId(resourceExecTaskItemMap.get(apiReport.getId())); + apiReportRelateTask.setTaskResourceId(resourceExecTaskItemMap.get(testPlanApiCase.getId())); apiReportRelateTasks.add(apiReportRelateTask); } apiReportService.insertApiReport(apiReports, apiTestCaseRecords, apiReportRelateTasks); diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioBatchRunService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioBatchRunService.java index f4398737b5..4d7ab7dc4d 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioBatchRunService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioBatchRunService.java @@ -308,7 +308,7 @@ public class TestPlanApiScenarioBatchRunService { private ExecTask initExecTask(int caseSize, Project project, String userId) { ExecTask execTask = apiCommonService.newExecTask(project.getId(), userId); execTask.setCaseCount(Long.valueOf(caseSize)); - execTask.setTaskName(Translator.get("api_batch_task_name")); + execTask.setTaskName(Translator.get("api_scenario_batch_task_name")); execTask.setOrganizationId(project.getOrganizationId()); execTask.setTriggerMode(TaskTriggerMode.MANUAL.name()); execTask.setTaskType(ExecTaskType.TEST_PLAN_API_SCENARIO.name()); @@ -350,7 +350,7 @@ public class TestPlanApiScenarioBatchRunService { // 创建报告和任务的关联关系 ApiReportRelateTask apiReportRelateTask = new ApiReportRelateTask(); apiReportRelateTask.setReportId(apiScenarioReport.getId()); - apiReportRelateTask.setTaskResourceId(resourceExecTaskItemMap.get(apiScenarioReport.getId())); + apiReportRelateTask.setTaskResourceId(resourceExecTaskItemMap.get(testPlanApiScenario.getId())); apiReportRelateTasks.add(apiReportRelateTask); } apiScenarioReportService.insertApiScenarioReport(apiScenarioReports, apiScenarioRecords, apiReportRelateTasks); diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanExecuteService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanExecuteService.java index 5896135140..61f8c4e568 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanExecuteService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanExecuteService.java @@ -675,7 +675,7 @@ public class TestPlanExecuteService { public void finishTaskAndSummaryTestPlanReport(String taskId, String reportId, boolean isGroupReport, boolean isStop) { TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(reportId); - if (StringUtils.isBlank(testPlanReport.getParentId()) && StringUtils.isNotBlank(taskId)) { + if (StringUtils.equals(testPlanReport.getParentId(), reportId) && StringUtils.isNotBlank(taskId)) { // 执行完成,更新任务状态 apiBatchRunBaseService.updateTaskStatus(taskId); apiBatchRunBaseService.removeRunningTaskCache(taskId);