diff --git a/test-track/backend/src/main/java/io/metersphere/controller/ShareController.java b/test-track/backend/src/main/java/io/metersphere/controller/ShareController.java index b8ab035fee..1ccc779e11 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/ShareController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/ShareController.java @@ -1,5 +1,6 @@ package io.metersphere.controller; +import com.fasterxml.jackson.core.JsonProcessingException; import io.metersphere.dto.TestPlanCaseDTO; import io.metersphere.plan.dto.TestPlanSimpleReportDTO; import io.metersphere.plan.service.TestPlanReportService; @@ -44,7 +45,7 @@ public class ShareController { @GetMapping("/report/export/{shareId}/{planId}/{lang}") public void exportHtmlReport(@PathVariable String shareId, @PathVariable String planId, - @PathVariable(required = false) String lang, HttpServletResponse response) throws UnsupportedEncodingException { + @PathVariable(required = false) String lang, HttpServletResponse response) throws UnsupportedEncodingException, JsonProcessingException { shareInfoService.validate(shareId, planId); testPlanService.exportPlanReport(planId, lang, response); } diff --git a/test-track/backend/src/main/java/io/metersphere/controller/TestPlanController.java b/test-track/backend/src/main/java/io/metersphere/controller/TestPlanController.java index f36c0b2f55..71106482fe 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/TestPlanController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/TestPlanController.java @@ -252,7 +252,7 @@ public class TestPlanController { } @GetMapping("/report/export/{planId}/{lang}") - public void exportHtmlReport(@PathVariable String planId, @PathVariable(required = false) String lang, HttpServletResponse response) throws UnsupportedEncodingException { + public void exportHtmlReport(@PathVariable String planId, @PathVariable(required = false) String lang, HttpServletResponse response) throws UnsupportedEncodingException, JsonProcessingException { testPlanService.exportPlanReport(planId, lang, response); } @@ -262,7 +262,7 @@ public class TestPlanController { } @GetMapping("/report/db/export/{reportId}/{lang}") - public void exportHtmlDbReport(@PathVariable String reportId, @PathVariable(required = false) String lang, HttpServletResponse response) throws UnsupportedEncodingException { + public void exportHtmlDbReport(@PathVariable String reportId, @PathVariable(required = false) String lang, HttpServletResponse response) throws UnsupportedEncodingException, JsonProcessingException { testPlanService.exportPlanDbReport(reportId, lang, response); } diff --git a/test-track/backend/src/main/java/io/metersphere/plan/dto/TestPlanSimpleReportDTO.java b/test-track/backend/src/main/java/io/metersphere/plan/dto/TestPlanSimpleReportDTO.java index 3e66a828ab..d0ba8a349f 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/dto/TestPlanSimpleReportDTO.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/dto/TestPlanSimpleReportDTO.java @@ -28,6 +28,7 @@ public class TestPlanSimpleReportDTO extends TestPlanReportContent { * projectEnvMap: <项目,运行环境> */ private String runMode; + private String resourcePool; private String envGroupName; private Map> projectEnvMap; 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 9cbf6b5487..386f3020aa 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 @@ -1,6 +1,7 @@ package io.metersphere.plan.service; +import com.fasterxml.jackson.core.JsonProcessingException; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.ExtTestPlanMapper; @@ -37,6 +38,7 @@ import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -1044,6 +1046,16 @@ public class TestPlanReportService { testPlanReportDTO.setId(reportId); TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(testPlanReportContent.getTestPlanReportId()); testPlanReportDTO.setName(testPlanReport.getName()); + TestPlanService testPlanService = CommonBeanFactory.getBean(TestPlanService.class); + TestPlanExtReportDTO extReport = null; + try { + extReport = testPlanService.getExtReportByReportId(reportId); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + if(extReport != null) { + BeanUtils.copyBean(testPlanReportDTO, extReport); + } return testPlanReportDTO; } 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 8e826acfcb..01d18fb368 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 @@ -1385,15 +1385,22 @@ public class TestPlanService { return report; } - public void exportPlanReport(String planId, String lang, HttpServletResponse response) throws UnsupportedEncodingException { + public void exportPlanReport(String planId, String lang, HttpServletResponse response) throws UnsupportedEncodingException, JsonProcessingException { TestPlanSimpleReportDTO report = buildPlanReport(planId, true); report.setLang(lang); + TestPlanExtReportDTO extReport = getExtReport(planId); + if(extReport != null) { + BeanUtils.copyBean(report, extReport); + } render(report, response); } - public void exportPlanDbReport(String reportId, String lang, HttpServletResponse response) throws UnsupportedEncodingException { + public void exportPlanDbReport(String reportId, String lang, HttpServletResponse response) throws UnsupportedEncodingException, JsonProcessingException { TestPlanSimpleReportDTO report = testPlanReportService.getReport(reportId); - + TestPlanExtReportDTO extReport = getExtReportByReportId(reportId); + if(extReport != null) { + BeanUtils.copyBean(report, extReport); + } Set serviceIdSet = DiscoveryUtil.getServiceIdSet(); if (serviceIdSet.contains(MicroServiceName.API_TEST)) { report.setApiAllCases(planTestPlanApiCaseService.buildResponse(report.getApiAllCases())); @@ -2009,4 +2016,28 @@ public class TestPlanService { TestResourcePool testResourcePool = testResourcePoolMapper.selectByPrimaryKey(actuator); testPlanExtReportDTO.setResourcePool(testResourcePool == null ? null : testResourcePool.getName()); } + + public TestPlanExtReportDTO getExtReportByReportId(String reportId) throws JsonProcessingException { + TestPlanExtReportDTO testPlanExtReportDTO = new TestPlanExtReportDTO(); + Set serviceIdSet = DiscoveryUtil.getServiceIdSet(); + if (serviceIdSet.contains(MicroServiceName.API_TEST)) { + List apiDefinitionLists = planTestPlanApiCaseService.selectExtForPlanReport(reportId); + if(CollectionUtils.isNotEmpty(apiDefinitionLists)){ + ApiDefinitionExecResultWithBLOBs apiDefinition = apiDefinitionLists.get(0); + convertEnvConfig(apiDefinition.getEnvConfig(), testPlanExtReportDTO); + getResourcePool(apiDefinition.getActuator(), testPlanExtReportDTO); + return testPlanExtReportDTO; + } + } + if (serviceIdSet.contains(MicroServiceName.UI_TEST)) { + List apiDefinitionLists = planTestPlanUiScenarioCaseService.selectExtForPlanReport(reportId); + if(CollectionUtils.isNotEmpty(apiDefinitionLists)){ + UiScenarioReportWithBLOBs apiDefinition = apiDefinitionLists.get(0); + convertEnvConfig(apiDefinition.getEnvConfig(), testPlanExtReportDTO); + getResourcePool(apiDefinition.getActuator(), testPlanExtReportDTO); + return testPlanExtReportDTO; + } + } + return null; + } } diff --git a/test-track/frontend/src/business/plan/view/comonents/report/detail/TestPlanReportContent.vue b/test-track/frontend/src/business/plan/view/comonents/report/detail/TestPlanReportContent.vue index 48f1ca9de6..b11149d0b4 100644 --- a/test-track/frontend/src/business/plan/view/comonents/report/detail/TestPlanReportContent.vue +++ b/test-track/frontend/src/business/plan/view/comonents/report/detail/TestPlanReportContent.vue @@ -139,6 +139,8 @@ export default { getReport() { if (this.isTemplate) { this.report = "#report"; + this.runMode = this.report.runMode; + this.resourcePool = this.report.resourcePool; if (this.report.lang) { this.$setLang(this.report.lang); } @@ -151,6 +153,8 @@ export default { .then((r) => { this.loading = false; this.report = r.data; + this.runMode = r.data.runMode; + this.resourcePool = r.data.resourcePool; this.report.config = this.getDefaultConfig(this.report); }); } else {