From b8d71cbe9f9137d244408b9562b28af66adc5718 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Tue, 18 Jan 2022 10:44:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=9C=BA=E6=99=AF=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1):=20=E4=BF=AE=E5=A4=8D=E5=86=85=E5=90=AB?= =?UTF-8?q?=E5=85=B6=E5=AE=83=E5=9C=BA=E6=99=AF=E7=9A=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E6=8A=A5=E5=91=8A=E5=86=85=E7=9A=84=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复内含其它场景的接口场景报告内的统计错误 --- .../ApiScenarioReportStructureService.java | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) 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 f2c1ea7edd..67114ecfd9 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportStructureService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportStructureService.java @@ -147,7 +147,15 @@ public class ApiScenarioReportStructureService { isError.set(isError.longValue() + 1); } } else if (CollectionUtils.isNotEmpty(step.getChildren())) { - scenarioCalculate(step.getChildren(), isError, isErrorReport); + AtomicLong isChildrenError = new AtomicLong(); + AtomicLong isChildrenErrorReport = new AtomicLong(); + stepChildrenErrorCalculate(step.getChildren(), isChildrenError,isChildrenErrorReport); + if (isChildrenError.longValue() > 0) { + isError.set(isError.longValue() + 1); + } + if(isChildrenErrorReport.longValue() > 0){ + isErrorReport.set(isErrorReport.longValue() + 1); + } } } } @@ -182,7 +190,6 @@ public class ApiScenarioReportStructureService { private void calculateStep(List dtoList, AtomicLong stepError, AtomicLong stepTotal, AtomicLong stepErrorCode) { for (StepTreeDTO step : dtoList) { // 失败结果数量 -// stepErrorCalculate(step.getChildren(), stepError); scenarioCalculate(step.getChildren(), stepError, stepErrorCode); if (CollectionUtils.isNotEmpty(step.getChildren())) { stepTotal.set((stepTotal.longValue() + step.getChildren().size())); @@ -296,27 +303,17 @@ public class ApiScenarioReportStructureService { return reportDTO; } - private void stepErrorCalculate(List dtoList, AtomicLong isError) { + private void stepChildrenErrorCalculate(List dtoList, AtomicLong isError, AtomicLong isErrorReport) { for (StepTreeDTO step : dtoList) { if (step.getValue() != null && step.getValue().getError() > 0) { - isError.set(isError.longValue() + 1); - } else if (CollectionUtils.isNotEmpty(step.getChildren())) { - AtomicLong isChildrenError = new AtomicLong(); - stepChildrenErrorCalculate(step.getChildren(), isChildrenError); - if (isChildrenError.longValue() > 0) { + if (StringUtils.isNotEmpty(step.getErrorCode())) { + isErrorReport.set(isErrorReport.longValue() + 1); + } else if (step.getValue().getError() > 0) { isError.set(isError.longValue() + 1); } - } - } - } - - private void stepChildrenErrorCalculate(List dtoList, AtomicLong isError) { - for (StepTreeDTO step : dtoList) { - if (step.getValue() != null && step.getValue().getError() > 0) { - isError.set(isError.longValue() + 1); break; } else if (CollectionUtils.isNotEmpty(step.getChildren())) { - stepChildrenErrorCalculate(step.getChildren(), isError); + stepChildrenErrorCalculate(step.getChildren(), isError, isErrorReport); } } }