diff --git a/test-track/backend/src/main/java/io/metersphere/plan/request/ui/TestPlanUiExecuteReportDTO.java b/test-track/backend/src/main/java/io/metersphere/plan/request/ui/TestPlanUiExecuteReportDTO.java new file mode 100644 index 0000000000..e7f9623ca0 --- /dev/null +++ b/test-track/backend/src/main/java/io/metersphere/plan/request/ui/TestPlanUiExecuteReportDTO.java @@ -0,0 +1,18 @@ +package io.metersphere.plan.request.ui; + +import io.metersphere.dto.TestPlanUiScenarioDTO; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.Map; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class TestPlanUiExecuteReportDTO { + private Map testPlanUiScenarioIdAndReportIdMap; + private Map uiScenarioInfoDTOMap; +} diff --git a/test-track/backend/src/main/java/io/metersphere/plan/request/ui/UiPlanReportRequest.java b/test-track/backend/src/main/java/io/metersphere/plan/request/ui/UiPlanReportRequest.java new file mode 100644 index 0000000000..f69626579e --- /dev/null +++ b/test-track/backend/src/main/java/io/metersphere/plan/request/ui/UiPlanReportRequest.java @@ -0,0 +1,12 @@ +package io.metersphere.plan.request.ui; + + +import io.metersphere.request.PlanSubReportRequest; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class UiPlanReportRequest extends PlanSubReportRequest { + private TestPlanUiExecuteReportDTO testPlanExecuteReportDTO; +} diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java index 807c641d76..bf40289df3 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java @@ -21,6 +21,8 @@ import io.metersphere.plan.request.TestPlanReportSaveRequest; import io.metersphere.plan.request.api.ApiPlanReportRequest; import io.metersphere.plan.request.api.TestPlanRunRequest; import io.metersphere.plan.request.performance.LoadPlanReportDTO; +import io.metersphere.plan.request.ui.TestPlanUiExecuteReportDTO; +import io.metersphere.plan.request.ui.UiPlanReportRequest; import io.metersphere.plan.service.remote.api.*; import io.metersphere.plan.service.remote.performance.PlanLoadTestReportService; import io.metersphere.plan.service.remote.performance.PlanTestPlanLoadCaseService; @@ -1267,6 +1269,28 @@ public class TestPlanReportService { return returnMap; } + private TestPlanUiExecuteReportDTO parseUiCaseReportMap(String reportStructStr) { + TestPlanUiExecuteReportDTO uiExecuteReportDTO = new TestPlanUiExecuteReportDTO(); + if (StringUtils.isNotEmpty(reportStructStr)) { + Map uiReportMap = new HashMap<>(); + Map uiDTOMap = new HashMap<>(); + List testPlanUiScenarioDTOList = null; + try { + testPlanUiScenarioDTOList = JSON.parseArray(reportStructStr, TestPlanUiScenarioDTO.class); + } catch (Exception ignored) { + } + if (CollectionUtils.isNotEmpty(testPlanUiScenarioDTOList)) { + for (TestPlanUiScenarioDTO dto : testPlanUiScenarioDTOList) { + uiReportMap.put(dto.getId(), dto.getReportId()); + uiDTOMap.put(dto.getId(), dto); + } + } + uiExecuteReportDTO.setTestPlanUiScenarioIdAndReportIdMap(uiReportMap); + uiExecuteReportDTO.setUiScenarioInfoDTOMap(uiDTOMap); + } + return uiExecuteReportDTO; + } + private Map parseCaseReportMap(String reportStructStr) { Map returnMap = new HashMap<>(); if (StringUtils.isNotEmpty(reportStructStr)) { @@ -1343,15 +1367,15 @@ public class TestPlanReportService { //查找UI测试报告结果 if (DiscoveryUtil.hasService(MicroServiceName.UI_TEST)) { LogUtil.info("测试计划报告【" + testPlanReportContentWithBLOBs.getTestPlanReportId() + "】开始查找UI测试报告结果"); - Map testPlanUiCaseIdAndReportIdMap = this.parseCaseReportMap(testPlanReportContentWithBLOBs.getPlanUiScenarioReportStruct()); - if (MapUtils.isNotEmpty(testPlanUiCaseIdAndReportIdMap)) { - ApiPlanReportRequest request = new ApiPlanReportRequest(); - request.setConfig(reportConfig); - request.setPlanId(testPlanId); - request.setSaveResponse(null); - request.setTestPlanExecuteReportDTO(reportDetailDTO); + TestPlanUiExecuteReportDTO uiExecuteReportDTO = this.parseUiCaseReportMap(testPlanReportContentWithBLOBs.getPlanUiScenarioReportStruct()); + if (MapUtils.isNotEmpty(uiExecuteReportDTO.getTestPlanUiScenarioIdAndReportIdMap()) + && MapUtils.isNotEmpty(uiExecuteReportDTO.getUiScenarioInfoDTOMap())) { + UiPlanReportRequest planSubReportRequest = new UiPlanReportRequest(); + planSubReportRequest.setTestPlanExecuteReportDTO(uiExecuteReportDTO); + planSubReportRequest.setConfig(reportConfig); + planSubReportRequest.setSaveResponse(false); try { - UiPlanReportDTO uiReport = planTestPlanUiScenarioCaseService.getUiReport(request); + UiPlanReportDTO uiReport = planTestPlanUiScenarioCaseService.getUiReport(planSubReportRequest); reportDetailDTO.setUiPlanReportDTO(uiReport); } catch (Exception e) { LogUtil.error("连接Ui-test查找报告结果信息失败!", e); diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java index 26e4dcaf63..e9d034ef9d 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java @@ -38,6 +38,8 @@ import io.metersphere.plan.request.function.PlanCaseRelevanceRequest; import io.metersphere.plan.request.function.QueryTestPlanCaseRequest; import io.metersphere.plan.request.performance.LoadPlanReportDTO; import io.metersphere.plan.request.ui.RunUiScenarioRequest; +import io.metersphere.plan.request.ui.TestPlanUiExecuteReportDTO; +import io.metersphere.plan.request.ui.UiPlanReportRequest; import io.metersphere.plan.service.remote.api.PlanApiAutomationService; import io.metersphere.plan.service.remote.api.PlanTestPlanApiCaseService; import io.metersphere.plan.service.remote.api.PlanTestPlanScenarioCaseService; @@ -1294,8 +1296,8 @@ public class TestPlanService { } } - public void buildUiReport(TestPlanReportDataStruct report, Map config, String planId, TestPlanCaseReportResultDTO testPlanExecuteReportDTO, boolean saveResponse) { - ApiPlanReportRequest request = new ApiPlanReportRequest(); + public void buildUiReport(TestPlanReportDataStruct report, Map config, String planId, TestPlanUiExecuteReportDTO testPlanExecuteReportDTO, boolean saveResponse) { + UiPlanReportRequest request = new UiPlanReportRequest(); request.setConfig(config); request.setPlanId(planId); request.setSaveResponse(saveResponse); diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java index e7e48f3b1b..7604ad8b40 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java @@ -9,8 +9,8 @@ import io.metersphere.commons.utils.LogUtil; import io.metersphere.dto.*; import io.metersphere.plan.constant.ApiReportStatus; import io.metersphere.plan.dto.*; -import io.metersphere.plan.request.api.ApiPlanReportRequest; import io.metersphere.plan.request.api.ApiScenarioRequest; +import io.metersphere.plan.request.ui.UiPlanReportRequest; import io.metersphere.plan.service.TestPlanService; import io.metersphere.plan.service.remote.api.PlanTestPlanScenarioCaseService; import io.metersphere.plan.service.remote.api.PlanUiScenarioReportService; @@ -45,7 +45,7 @@ public class PlanTestPlanUiScenarioCaseService extends UiTestService { return (List) microService.getForData(serviceName, BASE_URL + "/plan/exec/result/" + planId); } - public UiPlanReportDTO getUiReport(ApiPlanReportRequest request) { + public UiPlanReportDTO getUiReport(UiPlanReportRequest request) { return microService.postForData(serviceName, BASE_URL + "/plan/report", request, UiPlanReportDTO.class); }