fix: UI报告无结果

This commit is contained in:
chenjianxing 2022-04-12 11:39:16 +08:00 committed by zhangdahai112
parent 28d297fc08
commit 19c53e94b0
4 changed files with 31 additions and 19 deletions

View File

@ -17,4 +17,5 @@ public class ApiScenarioReportBaseInfoDTO {
private String rspCode;
private long rspTime;
private String uiImg;
private Boolean isNotStep;
}

View File

@ -0,0 +1,11 @@
package io.metersphere.api.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class UiScenarioReportBaseInfoDTO extends ApiScenarioReportBaseInfoDTO {
private Boolean isNotStep = false;
private String uiImg;
}

View File

@ -99,7 +99,8 @@ public class ApiScenarioReportResultService {
RequestResult result = JSONObject.parseObject(value.toJSONString(), RequestResult.class);
ApiScenarioReportBaseInfoDTO baseInfo = getBaseInfo(result);
baseInfo.setRspTime(result.getEndTime() - result.getStartTime());
baseInfo.setUiImg(result.getUrl());
baseInfo.setIsNotStep(value.getBooleanValue("isNotStep"));
baseInfo.setUiImg(value.getString("uiImg"));
report.setBaseInfo(JSONObject.toJSONString(baseInfo));
report.setContent(value.toJSONString().getBytes(StandardCharsets.UTF_8));
return report;

View File

@ -506,13 +506,7 @@ public class ApiScenarioReportStructureService {
private ApiScenarioReportDTO getReport(String reportId,boolean selectContent) {
List<ApiScenarioReportResultWithBLOBs> reportResults = null;
ApiScenarioReport report = scenarioReportMapper.selectByPrimaryKey(reportId);
if (report.getReportType() != null && report.getReportType().startsWith("UI")) {
ApiScenarioReportResultExample example = new ApiScenarioReportResultExample();
example.createCriteria().andReportIdEqualTo(reportId);
reportResults = reportResultMapper.selectByExampleWithBLOBs(example);
removeUiResultIfNotStep(reportResults);
}else if(selectContent){
if(selectContent){
ApiScenarioReportResultExample example = new ApiScenarioReportResultExample();
example.createCriteria().andReportIdEqualTo(reportId);
reportResults = reportResultMapper.selectByExampleWithBLOBs(example);
@ -520,6 +514,8 @@ public class ApiScenarioReportStructureService {
reportResults = this.selectBaseInfoResultByReportId(reportId);
}
removeUiResultIfNotStep(reportResults, reportId);
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
structureExample.createCriteria().andReportIdEqualTo(reportId);
List<ApiScenarioReportStructureWithBLOBs> reportStructureWithBLOBs = mapper.selectByExampleWithBLOBs(structureExample);
@ -575,14 +571,16 @@ public class ApiScenarioReportStructureService {
*
* @param reportResults
*/
private void removeUiResultIfNotStep(List<ApiScenarioReportResultWithBLOBs> reportResults) {
private void removeUiResultIfNotStep(List<ApiScenarioReportResultWithBLOBs> reportResults, String reportId) {
ApiScenarioReport report = scenarioReportMapper.selectByPrimaryKey(reportId);
if (report.getReportType() != null && report.getReportType().startsWith("UI")) {
if(CollectionUtils.isNotEmpty(reportResults)){
Iterator<ApiScenarioReportResultWithBLOBs> iterator = reportResults.iterator();
while (iterator.hasNext()) {
ApiScenarioReportResultWithBLOBs item = iterator.next();
String result = new String(item.getContent(), StandardCharsets.UTF_8);
if (StringUtils.isNotBlank(result)) {
Boolean isNoStep = JSONObject.parseObject(result).getBoolean("isNotStep");
String baseInfo = item.getBaseInfo();
if (StringUtils.isNotBlank(baseInfo)) {
Boolean isNoStep = JSONObject.parseObject(baseInfo).getBoolean("isNotStep");
if (BooleanUtils.isTrue(isNoStep)) {
iterator.remove();
}
@ -590,6 +588,7 @@ public class ApiScenarioReportStructureService {
}
}
}
}
private void countAllUnexecute(List<StepTreeDTO> stepList, AtomicLong allUnExecute) {
for (StepTreeDTO step : stepList) {