From 058ce481fcc8dbbfef882035f8da3d962b225d92 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 20 Dec 2021 09:51:48 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=A7=E8=A1=8C=E6=9C=AA=E6=94=B6=E5=88=B0?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E7=9A=84=E6=8A=A5=E5=91=8A=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiScenarioReportService.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index b2b1260239..0d961705e0 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -107,15 +107,13 @@ public class ApiScenarioReportService { example.createCriteria().andReportIdEqualTo(dto.getReportId()); List requestResults = apiScenarioReportResultMapper.selectByExample(example); - ApiScenarioReport scenarioReport = null; - if (CollectionUtils.isNotEmpty(requestResults)) { - if (StringUtils.equals(dto.getRunMode(), ApiRunMode.SCENARIO_PLAN.name())) { - scenarioReport = updatePlanCase(requestResults, dto); - } else if (StringUtils.equalsAny(dto.getRunMode(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.JENKINS_SCENARIO_PLAN.name())) { - scenarioReport = updateSchedulePlanCase(requestResults, dto); - } else { - scenarioReport = updateScenario(requestResults, dto); - } + ApiScenarioReport scenarioReport; + if (StringUtils.equals(dto.getRunMode(), ApiRunMode.SCENARIO_PLAN.name())) { + scenarioReport = updatePlanCase(requestResults, dto); + } else if (StringUtils.equalsAny(dto.getRunMode(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.JENKINS_SCENARIO_PLAN.name())) { + scenarioReport = updateSchedulePlanCase(requestResults, dto); + } else { + scenarioReport = updateScenario(requestResults, dto); } // 串行队列 SerialBlockingQueueUtil.offer(dto, scenarioReport != null ? scenarioReport : SerialBlockingQueueUtil.END_SIGN); @@ -270,7 +268,7 @@ public class ApiScenarioReportService { apiScenarioMapper.updateByPrimaryKey(scenario); } } - ApiScenarioReport report = editReport(dto.getReportType(), dto.getReportId(), errorSize > 0 ? "Error" : "Success", dto.getRunMode()); + ApiScenarioReport report = editReport(dto.getReportType(), dto.getReportId(), errorSize > 0 || requestResults.isEmpty() ? "Error" : "Success", dto.getRunMode()); return report; } @@ -282,7 +280,7 @@ public class ApiScenarioReportService { Map planScenarioReportMap = new HashMap<>(); long errorSize = requestResults.stream().filter(requestResult -> StringUtils.equalsIgnoreCase(requestResult.getStatus(), "Error")).count(); - ApiScenarioReport report = editReport(dto.getReportType(), dto.getReportId(), errorSize > 0 ? "Error" : "Success", dto.getRunMode()); + ApiScenarioReport report = editReport(dto.getReportType(), dto.getReportId(), errorSize > 0 || requestResults.isEmpty() ? "Error" : "Success", dto.getRunMode()); if (report != null) { if (StringUtils.isNotEmpty(dto.getTestPlanReportId()) && !testPlanReportIdList.contains(dto.getTestPlanReportId())) { testPlanReportIdList.add(dto.getTestPlanReportId()); @@ -360,7 +358,7 @@ public class ApiScenarioReportService { public ApiScenarioReport updateScenario(List requestResults, ResultDTO dto) { long errorSize = requestResults.stream().filter(requestResult -> StringUtils.equalsIgnoreCase(requestResult.getStatus(), "Error")).count(); // 更新报告状态 - ApiScenarioReport report = editReport(dto.getReportType(), dto.getReportId(), errorSize > 0 ? "Error" : "Success", dto.getRunMode()); + ApiScenarioReport report = editReport(dto.getReportType(), dto.getReportId(), errorSize > 0 || requestResults.isEmpty() ? "Error" : "Success", dto.getRunMode()); // 更新场景状态 ApiScenarioWithBLOBs scenario = apiScenarioMapper.selectByPrimaryKey(dto.getTestId()); if (scenario == null) {