From 19c53e94b055372d7a44751e32aa6185e6135b8a Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 12 Apr 2022 11:39:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20UI=E6=8A=A5=E5=91=8A=E6=97=A0=E7=BB=93?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/ApiScenarioReportBaseInfoDTO.java | 1 + .../api/dto/UiScenarioReportBaseInfoDTO.java | 11 ++++++ .../ApiScenarioReportResultService.java | 3 +- .../ApiScenarioReportStructureService.java | 35 +++++++++---------- 4 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/api/dto/UiScenarioReportBaseInfoDTO.java diff --git a/backend/src/main/java/io/metersphere/api/dto/ApiScenarioReportBaseInfoDTO.java b/backend/src/main/java/io/metersphere/api/dto/ApiScenarioReportBaseInfoDTO.java index 3d2335b75d..1aa1448608 100644 --- a/backend/src/main/java/io/metersphere/api/dto/ApiScenarioReportBaseInfoDTO.java +++ b/backend/src/main/java/io/metersphere/api/dto/ApiScenarioReportBaseInfoDTO.java @@ -17,4 +17,5 @@ public class ApiScenarioReportBaseInfoDTO { private String rspCode; private long rspTime; private String uiImg; + private Boolean isNotStep; } diff --git a/backend/src/main/java/io/metersphere/api/dto/UiScenarioReportBaseInfoDTO.java b/backend/src/main/java/io/metersphere/api/dto/UiScenarioReportBaseInfoDTO.java new file mode 100644 index 0000000000..762f59c77b --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/dto/UiScenarioReportBaseInfoDTO.java @@ -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; +} diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportResultService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportResultService.java index a1b0d24baf..04c833c256 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportResultService.java @@ -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; diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportStructureService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportStructureService.java index 968534e851..e193ba3705 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportStructureService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportStructureService.java @@ -506,20 +506,16 @@ public class ApiScenarioReportStructureService { private ApiScenarioReportDTO getReport(String reportId,boolean selectContent) { List reportResults = null; - ApiScenarioReport report = scenarioReportMapper.selectByPrimaryKey(reportId); - if (report.getReportType() != null && report.getReportType().startsWith("UI")) { + if(selectContent){ ApiScenarioReportResultExample example = new ApiScenarioReportResultExample(); example.createCriteria().andReportIdEqualTo(reportId); reportResults = reportResultMapper.selectByExampleWithBLOBs(example); - removeUiResultIfNotStep(reportResults); - }else if(selectContent){ - ApiScenarioReportResultExample example = new ApiScenarioReportResultExample(); - example.createCriteria().andReportIdEqualTo(reportId); - reportResults = reportResultMapper.selectByExampleWithBLOBs(example); - }else { + } else { reportResults = this.selectBaseInfoResultByReportId(reportId); } + removeUiResultIfNotStep(reportResults, reportId); + ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample(); structureExample.createCriteria().andReportIdEqualTo(reportId); List reportStructureWithBLOBs = mapper.selectByExampleWithBLOBs(structureExample); @@ -575,16 +571,19 @@ public class ApiScenarioReportStructureService { * * @param reportResults */ - private void removeUiResultIfNotStep(List reportResults) { - if(CollectionUtils.isNotEmpty(reportResults)){ - Iterator 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"); - if (BooleanUtils.isTrue(isNoStep)) { - iterator.remove(); + private void removeUiResultIfNotStep(List reportResults, String reportId) { + ApiScenarioReport report = scenarioReportMapper.selectByPrimaryKey(reportId); + if (report.getReportType() != null && report.getReportType().startsWith("UI")) { + if(CollectionUtils.isNotEmpty(reportResults)){ + Iterator iterator = reportResults.iterator(); + while (iterator.hasNext()) { + ApiScenarioReportResultWithBLOBs item = iterator.next(); + String baseInfo = item.getBaseInfo(); + if (StringUtils.isNotBlank(baseInfo)) { + Boolean isNoStep = JSONObject.parseObject(baseInfo).getBoolean("isNotStep"); + if (BooleanUtils.isTrue(isNoStep)) { + iterator.remove(); + } } } }