fix(测试跟踪): 解决测试计划报告分享&导出的报告没有运行模式和资源池信息问题
--bug=1020879 --user=张勇 【测试跟踪】测试计划报告分享&导出的报告没有运行模式和资源池信息 https://www.tapd.cn/55049933/s/1316035
This commit is contained in:
parent
0d9b8a6dd8
commit
eb4134eea7
|
@ -1,5 +1,6 @@
|
||||||
package io.metersphere.controller;
|
package io.metersphere.controller;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import io.metersphere.dto.TestPlanCaseDTO;
|
import io.metersphere.dto.TestPlanCaseDTO;
|
||||||
import io.metersphere.plan.dto.TestPlanSimpleReportDTO;
|
import io.metersphere.plan.dto.TestPlanSimpleReportDTO;
|
||||||
import io.metersphere.plan.service.TestPlanReportService;
|
import io.metersphere.plan.service.TestPlanReportService;
|
||||||
|
@ -44,7 +45,7 @@ public class ShareController {
|
||||||
|
|
||||||
@GetMapping("/report/export/{shareId}/{planId}/{lang}")
|
@GetMapping("/report/export/{shareId}/{planId}/{lang}")
|
||||||
public void exportHtmlReport(@PathVariable String shareId, @PathVariable String planId,
|
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);
|
shareInfoService.validate(shareId, planId);
|
||||||
testPlanService.exportPlanReport(planId, lang, response);
|
testPlanService.exportPlanReport(planId, lang, response);
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,7 +252,7 @@ public class TestPlanController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/report/export/{planId}/{lang}")
|
@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);
|
testPlanService.exportPlanReport(planId, lang, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ public class TestPlanController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/report/db/export/{reportId}/{lang}")
|
@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);
|
testPlanService.exportPlanDbReport(reportId, lang, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ public class TestPlanSimpleReportDTO extends TestPlanReportContent {
|
||||||
* projectEnvMap: <项目,运行环境>
|
* projectEnvMap: <项目,运行环境>
|
||||||
*/
|
*/
|
||||||
private String runMode;
|
private String runMode;
|
||||||
|
private String resourcePool;
|
||||||
private String envGroupName;
|
private String envGroupName;
|
||||||
private Map<String, List<String>> projectEnvMap;
|
private Map<String, List<String>> projectEnvMap;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package io.metersphere.plan.service;
|
package io.metersphere.plan.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.*;
|
import io.metersphere.base.mapper.*;
|
||||||
import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
|
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.SqlSession;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.mybatis.spring.SqlSessionUtils;
|
import org.mybatis.spring.SqlSessionUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -1044,6 +1046,16 @@ public class TestPlanReportService {
|
||||||
testPlanReportDTO.setId(reportId);
|
testPlanReportDTO.setId(reportId);
|
||||||
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(testPlanReportContent.getTestPlanReportId());
|
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(testPlanReportContent.getTestPlanReportId());
|
||||||
testPlanReportDTO.setName(testPlanReport.getName());
|
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;
|
return testPlanReportDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1385,15 +1385,22 @@ public class TestPlanService {
|
||||||
return report;
|
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);
|
TestPlanSimpleReportDTO report = buildPlanReport(planId, true);
|
||||||
report.setLang(lang);
|
report.setLang(lang);
|
||||||
|
TestPlanExtReportDTO extReport = getExtReport(planId);
|
||||||
|
if(extReport != null) {
|
||||||
|
BeanUtils.copyBean(report, extReport);
|
||||||
|
}
|
||||||
render(report, response);
|
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);
|
TestPlanSimpleReportDTO report = testPlanReportService.getReport(reportId);
|
||||||
|
TestPlanExtReportDTO extReport = getExtReportByReportId(reportId);
|
||||||
|
if(extReport != null) {
|
||||||
|
BeanUtils.copyBean(report, extReport);
|
||||||
|
}
|
||||||
Set<String> serviceIdSet = DiscoveryUtil.getServiceIdSet();
|
Set<String> serviceIdSet = DiscoveryUtil.getServiceIdSet();
|
||||||
if (serviceIdSet.contains(MicroServiceName.API_TEST)) {
|
if (serviceIdSet.contains(MicroServiceName.API_TEST)) {
|
||||||
report.setApiAllCases(planTestPlanApiCaseService.buildResponse(report.getApiAllCases()));
|
report.setApiAllCases(planTestPlanApiCaseService.buildResponse(report.getApiAllCases()));
|
||||||
|
@ -2009,4 +2016,28 @@ public class TestPlanService {
|
||||||
TestResourcePool testResourcePool = testResourcePoolMapper.selectByPrimaryKey(actuator);
|
TestResourcePool testResourcePool = testResourcePoolMapper.selectByPrimaryKey(actuator);
|
||||||
testPlanExtReportDTO.setResourcePool(testResourcePool == null ? null : testResourcePool.getName());
|
testPlanExtReportDTO.setResourcePool(testResourcePool == null ? null : testResourcePool.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TestPlanExtReportDTO getExtReportByReportId(String reportId) throws JsonProcessingException {
|
||||||
|
TestPlanExtReportDTO testPlanExtReportDTO = new TestPlanExtReportDTO();
|
||||||
|
Set<String> serviceIdSet = DiscoveryUtil.getServiceIdSet();
|
||||||
|
if (serviceIdSet.contains(MicroServiceName.API_TEST)) {
|
||||||
|
List<ApiDefinitionExecResultWithBLOBs> 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<UiScenarioReportWithBLOBs> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,6 +139,8 @@ export default {
|
||||||
getReport() {
|
getReport() {
|
||||||
if (this.isTemplate) {
|
if (this.isTemplate) {
|
||||||
this.report = "#report";
|
this.report = "#report";
|
||||||
|
this.runMode = this.report.runMode;
|
||||||
|
this.resourcePool = this.report.resourcePool;
|
||||||
if (this.report.lang) {
|
if (this.report.lang) {
|
||||||
this.$setLang(this.report.lang);
|
this.$setLang(this.report.lang);
|
||||||
}
|
}
|
||||||
|
@ -151,6 +153,8 @@ export default {
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.report = r.data;
|
this.report = r.data;
|
||||||
|
this.runMode = r.data.runMode;
|
||||||
|
this.resourcePool = r.data.resourcePool;
|
||||||
this.report.config = this.getDefaultConfig(this.report);
|
this.report.config = this.getDefaultConfig(this.report);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue