From 79eaf8080123013de2f4d4daf5e5dbcabd98bfa2 Mon Sep 17 00:00:00 2001 From: AgAngle <1323481023@qq.com> Date: Tue, 22 Oct 2024 11:02:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=89=A7=E8=A1=8C=EF=BC=8C?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=88=9D=E5=A7=8B=E5=8C=96=E4=B8=8E=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E7=9A=84=E5=85=B3=E8=81=94=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plan/service/TestPlanExecuteService.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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 61f8c4e568..3868636753 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 @@ -1,6 +1,8 @@ package io.metersphere.plan.service; import com.esotericsoftware.minlog.Log; +import io.metersphere.api.domain.ApiReportRelateTask; +import io.metersphere.api.mapper.ApiReportRelateTaskMapper; import io.metersphere.api.service.ApiBatchRunBaseService; import io.metersphere.api.service.ApiCommonService; import io.metersphere.plan.domain.*; @@ -70,6 +72,8 @@ public class TestPlanExecuteService { private ExtTestPlanApiScenarioMapper extTestPlanApiScenarioMapper; @Resource private ApiBatchRunBaseService apiBatchRunBaseService; + @Resource + private ApiReportRelateTaskMapper apiReportRelateTaskMapper; // 停止测试计划的执行 public void stopTestPlanRunning(String testPlanReportId) { @@ -243,7 +247,7 @@ public class TestPlanExecuteService { extTestPlanApiScenarioMapper.countByPlanIds(childPlanIds); } // 初始化任务 - ExecTask execTask = initExecTask(executionQueue.getTaskId(), caseTotal, testPlan.getName(), project, executionQueue.getCreateUser(), executionQueue.getExecutionSource()); + ExecTask execTask = initExecTask(executionQueue.getTaskId(), caseTotal, testPlan.getName(), project, executionQueue.getCreateUser(), executionQueue.getExecutionSource(), executionQueue.getPrepareReportId()); // 预生成计划组报告 Map reportMap = testPlanReportService.genReportByExecution(executionQueue.getPrepareReportId(), execTask.getId(), genReportRequest, executionQueue.getCreateUser()); @@ -299,7 +303,7 @@ public class TestPlanExecuteService { Integer caseTotal = extTestPlanApiCaseMapper.countByPlanIds(List.of(testPlan.getId())) + extTestPlanApiScenarioMapper.countByPlanIds(List.of(testPlan.getId())); // 初始化任务 - ExecTask execTask = initExecTask(executionQueue.getTaskId(), caseTotal, testPlan.getName(), project, executionQueue.getCreateUser(), executionQueue.getExecutionSource()); + ExecTask execTask = initExecTask(executionQueue.getTaskId(), caseTotal, testPlan.getName(), project, executionQueue.getCreateUser(), executionQueue.getExecutionSource(), executionQueue.getPrepareReportId()); Map reportMap = testPlanReportService.genReportByExecution(executionQueue.getPrepareReportId(), execTask.getId(), genReportRequest, executionQueue.getCreateUser()); executionQueue.setPrepareReportId(reportMap.get(executionQueue.getSourceID())); @@ -309,7 +313,7 @@ public class TestPlanExecuteService { } } - private ExecTask initExecTask(String taskId, int caseSize, String name, Project project, String userId, String triggerMode) { + private ExecTask initExecTask(String taskId, int caseSize, String name, Project project, String userId, String triggerMode, String reportId) { ExecTask execTask = apiCommonService.newExecTask(project.getId(), userId); execTask.setId(taskId); execTask.setCaseCount(Long.valueOf(caseSize)); @@ -318,6 +322,12 @@ public class TestPlanExecuteService { execTask.setTriggerMode(triggerMode); execTask.setTaskType(ExecTaskType.TEST_PLAN.name()); baseTaskHubService.insertExecTask(execTask); + + // 创建报告和任务的关联关系 + ApiReportRelateTask apiReportRelateTask = new ApiReportRelateTask(); + apiReportRelateTask.setReportId(reportId); + apiReportRelateTask.setTaskResourceId(taskId); + apiReportRelateTaskMapper.insertSelective(apiReportRelateTask); return execTask; }