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 090def1885..c47bc4511f 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -434,7 +434,36 @@ public class ApiScenarioReportService { } } + private void counter(TestResult result) { + if (CollectionUtils.isEmpty(result.getScenarios())) { + if (StringUtils.isNotEmpty(result.getTestId())) { + List list = new LinkedList<>(); + try { + list = JSON.parseObject(result.getTestId(), List.class); + } catch (Exception e) { + list.add(result.getTestId()); + } + ApiScenarioReportExample scenarioReportExample = new ApiScenarioReportExample(); + scenarioReportExample.createCriteria().andIdIn(list); + List reportList = apiScenarioReportMapper.selectByExample(scenarioReportExample); + for (ApiScenarioReport report : reportList) { + if (report.getExecuteType().equals(ExecuteType.Marge.name())) { + Object obj = MessageCache.cache.get(report.getScenarioId()); + if (obj != null) { + ReportCounter counter = (ReportCounter) obj; + counter.setNumber(counter.getNumber() + 1); + MessageCache.cache.put(report.getScenarioId(), counter); + } + } + } + } + } + } + public ApiScenarioReport updateScenario(TestResult result) { + // 针对未正常返回结果的报告计数 + counter(result); + ApiScenarioReport lastReport = null; for (ScenarioResult item : result.getScenarios()) { // 更新报告状态 @@ -479,6 +508,7 @@ public class ApiScenarioReportService { } } } + return lastReport; }