feat(测试跟踪): 已完成的测试计划报告第一次展示时记录统计数据
--story=1007420 --user=宋天阳 【中金】【测试计划报告查询慢】查看测试计划执行报告,个别报告查询慢 https://www.tapd.cn/55049933/s/1202814
This commit is contained in:
parent
71bdf13387
commit
3928bde3c3
|
@ -0,0 +1,15 @@
|
||||||
|
package io.metersphere.track.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class TestPlanReportBuildResultDTO {
|
||||||
|
private TestPlanSimpleReportDTO testPlanSimpleReportDTO;
|
||||||
|
/**
|
||||||
|
* 判断testPlanReportContent中,APIBaseInfo字段是否改变。
|
||||||
|
* 如果改变过,则需要更新testPlanReportContent数据
|
||||||
|
*/
|
||||||
|
private boolean apiBaseInfoChanged = false;
|
||||||
|
}
|
|
@ -466,16 +466,33 @@ public class TestPlanReportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestPlanReportContentWithBLOBs updateReport(TestPlanReport testPlanReport, TestPlanReportContentWithBLOBs reportContent) {
|
public TestPlanReportContentWithBLOBs updateReport(TestPlanReport testPlanReport, TestPlanReportContentWithBLOBs reportContent) {
|
||||||
if (testPlanReport == null) {
|
if (testPlanReport == null || reportContent == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
TestPlanService testPlanService = CommonBeanFactory.getBean(TestPlanService.class);
|
TestPlanService testPlanService = CommonBeanFactory.getBean(TestPlanService.class);
|
||||||
TestPlanSimpleReportDTO reportDTO = testPlanService.buildPlanReport(testPlanReport, reportContent);
|
TestPlanReportBuildResultDTO reportBuildResult = testPlanService.buildPlanReport(testPlanReport, reportContent);
|
||||||
|
TestPlanSimpleReportDTO reportDTO = reportBuildResult.getTestPlanSimpleReportDTO();
|
||||||
reportDTO.setStartTime(testPlanReport.getStartTime());
|
reportDTO.setStartTime(testPlanReport.getStartTime());
|
||||||
reportContent = parseReportDaoToReportContent(testPlanReport.getStatus(), reportDTO, reportContent);
|
reportContent = parseReportDaoToReportContent(testPlanReport.getStatus(), reportDTO, reportContent);
|
||||||
|
this.updatePassRateAndApiBaseInfoFromReportContent(testPlanReport.getStatus(), reportDTO, reportContent, reportBuildResult.isApiBaseInfoChanged());
|
||||||
return reportContent;
|
return reportContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updatePassRateAndApiBaseInfoFromReportContent(String status, TestPlanSimpleReportDTO reportDTO, TestPlanReportContentWithBLOBs reportContent, boolean apiBaseInfoChanged) {
|
||||||
|
// 如果报告已结束,则更新测试计划报告通过率字段 passRate
|
||||||
|
if (!StringUtils.equalsIgnoreCase(status, "running") && (Double.compare(reportContent.getPassRate(), reportDTO.getPassRate()) != 0 || apiBaseInfoChanged)) {
|
||||||
|
TestPlanReportContentExample contentExample = new TestPlanReportContentExample();
|
||||||
|
contentExample.createCriteria().andTestPlanReportIdEqualTo(reportContent.getTestPlanReportId());
|
||||||
|
TestPlanReportContentWithBLOBs content = new TestPlanReportContentWithBLOBs();
|
||||||
|
content.setPassRate(reportDTO.getPassRate());
|
||||||
|
if (apiBaseInfoChanged) {
|
||||||
|
content.setApiBaseCount(reportContent.getApiBaseCount());
|
||||||
|
}
|
||||||
|
testPlanReportContentMapper.updateByExampleSelective(content, contentExample);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public TestPlanReport finishedTestPlanReport(String testPlanReportId, String status) {
|
public TestPlanReport finishedTestPlanReport(String testPlanReportId, String status) {
|
||||||
TestPlanReport testPlanReport = this.getTestPlanReport(testPlanReportId);
|
TestPlanReport testPlanReport = this.getTestPlanReport(testPlanReportId);
|
||||||
if (testPlanReport != null && StringUtils.equalsIgnoreCase(testPlanReport.getStatus(), "stopped")) {
|
if (testPlanReport != null && StringUtils.equalsIgnoreCase(testPlanReport.getStatus(), "stopped")) {
|
||||||
|
@ -670,14 +687,6 @@ public class TestPlanReportService {
|
||||||
testPlanReportContentWithBLOBs.setUnExecuteScenarios(JSONObject.toJSONString(reportDTO.getUnExecuteScenarios()));
|
testPlanReportContentWithBLOBs.setUnExecuteScenarios(JSONObject.toJSONString(reportDTO.getUnExecuteScenarios()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果报告已结束,则更新测试计划报告通过率字段 passRate
|
|
||||||
if (!StringUtils.equalsIgnoreCase(testPlanReportStatus, "running")) {
|
|
||||||
TestPlanReportContentExample contentExample = new TestPlanReportContentExample();
|
|
||||||
contentExample.createCriteria().andTestPlanReportIdEqualTo(testPlanReportId);
|
|
||||||
TestPlanReportContentWithBLOBs content = new TestPlanReportContentWithBLOBs();
|
|
||||||
content.setPassRate(reportDTO.getPassRate());
|
|
||||||
testPlanReportContentMapper.updateByExampleSelective(content, contentExample);
|
|
||||||
}
|
|
||||||
return testPlanReportContentWithBLOBs;
|
return testPlanReportContentWithBLOBs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1682,7 +1682,14 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestPlanSimpleReportDTO buildPlanReport(TestPlanReport testPlanReport, TestPlanReportContentWithBLOBs testPlanReportContentWithBLOBs) {
|
/**
|
||||||
|
* @param testPlanReport 测试计划报告
|
||||||
|
* @param testPlanReportContentWithBLOBs 测试计划报告内容
|
||||||
|
* @param isReportContenChanged 测试计划报告是否已经修改过
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public TestPlanReportBuildResultDTO buildPlanReport(TestPlanReport testPlanReport, TestPlanReportContentWithBLOBs testPlanReportContentWithBLOBs) {
|
||||||
|
TestPlanReportBuildResultDTO returnDTO = new TestPlanReportBuildResultDTO();
|
||||||
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(testPlanReport.getTestPlanId());
|
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(testPlanReport.getTestPlanId());
|
||||||
if (testPlan != null) {
|
if (testPlan != null) {
|
||||||
String reportConfig = testPlan.getReportConfig();
|
String reportConfig = testPlan.getReportConfig();
|
||||||
|
@ -1691,13 +1698,31 @@ public class TestPlanService {
|
||||||
config = JSONObject.parseObject(reportConfig);
|
config = JSONObject.parseObject(reportConfig);
|
||||||
}
|
}
|
||||||
TestPlanExecuteReportDTO testPlanExecuteReportDTO = testPlanReportService.genTestPlanExecuteReportDTOByTestPlanReportContent(testPlanReportContentWithBLOBs);
|
TestPlanExecuteReportDTO testPlanExecuteReportDTO = testPlanReportService.genTestPlanExecuteReportDTOByTestPlanReportContent(testPlanReportContentWithBLOBs);
|
||||||
TestPlanSimpleReportDTO report = getReport(testPlanReport.getTestPlanId(), testPlanExecuteReportDTO);
|
TestPlanSimpleReportDTO report = null;
|
||||||
|
if (StringUtils.isEmpty(testPlanReportContentWithBLOBs.getApiBaseCount())) {
|
||||||
|
report = getReport(testPlanReport.getTestPlanId(), testPlanExecuteReportDTO);
|
||||||
|
testPlanReportContentWithBLOBs.setApiBaseCount(JSONObject.toJSONString(report));
|
||||||
|
returnDTO.setApiBaseInfoChanged(true);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
report = JSONObject.parseObject(testPlanReportContentWithBLOBs.getApiBaseCount(), TestPlanSimpleReportDTO.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.info("解析接口统计数据出错!数据:" + testPlanReportContentWithBLOBs.getApiBaseCount(), e);
|
||||||
|
}
|
||||||
|
if (report == null) {
|
||||||
|
report = getReport(testPlanReport.getTestPlanId(), testPlanExecuteReportDTO);
|
||||||
|
testPlanReportContentWithBLOBs.setApiBaseCount(JSONObject.toJSONString(report));
|
||||||
|
returnDTO.setApiBaseInfoChanged(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
buildFunctionalReport(report, config, testPlanReport.getTestPlanId());
|
buildFunctionalReport(report, config, testPlanReport.getTestPlanId());
|
||||||
buildApiReport(report, config, testPlanExecuteReportDTO);
|
buildApiReport(report, config, testPlanExecuteReportDTO);
|
||||||
buildLoadReport(report, config, testPlanExecuteReportDTO.getTestPlanLoadCaseIdAndReportIdMap(), false);
|
buildLoadReport(report, config, testPlanExecuteReportDTO.getTestPlanLoadCaseIdAndReportIdMap(), false);
|
||||||
return report;
|
returnDTO.setTestPlanSimpleReportDTO(report);
|
||||||
|
return returnDTO;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
returnDTO.setTestPlanSimpleReportDTO(new TestPlanSimpleReportDTO());
|
||||||
|
return returnDTO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue