From 5e2ef1d10a01fd94f2699147bd50d5b0609c9637 Mon Sep 17 00:00:00 2001 From: Jianguo-Genius Date: Wed, 17 Jul 2024 17:31:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=B7=B2=E5=BD=92=E6=A1=A3=E6=B5=8B=E8=AF=95=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E7=8A=B6=E6=80=81=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/TestPlanStatisticsResponse.java | 16 ++++++++++------ .../plan/service/TestPlanStatisticsService.java | 9 ++++++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanStatisticsResponse.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanStatisticsResponse.java index 3db8c17053..56a97139d6 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanStatisticsResponse.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanStatisticsResponse.java @@ -8,6 +8,7 @@ import io.metersphere.system.dto.request.schedule.BaseScheduleConfigRequest; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; +import org.apache.commons.lang3.StringUtils; /** * 测试计划统计详情 @@ -66,17 +67,20 @@ public class TestPlanStatisticsResponse { /** * 计算测试计划状态 + * 非未归档的开始计算: * 未开始:执行进度0% * 进行中:执行进度不到100% * 已完成:执行进度100% */ public void calculateStatus() { - if (this.successCount == 0 && errorCount == 0 && fakeErrorCount == 0 && blockCount == 0) { - this.status = TestPlanConstants.TEST_PLAN_SHOW_STATUS_PREPARED; - } else if (this.pendingCount == 0) { - this.status = TestPlanConstants.TEST_PLAN_SHOW_STATUS_COMPLETED; - } else { - this.status = TestPlanConstants.TEST_PLAN_SHOW_STATUS_UNDERWAY; + if (!StringUtils.equalsIgnoreCase(this.status, TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED)) { + if (this.successCount == 0 && errorCount == 0 && fakeErrorCount == 0 && blockCount == 0) { + this.status = TestPlanConstants.TEST_PLAN_SHOW_STATUS_PREPARED; + } else if (this.pendingCount == 0) { + this.status = TestPlanConstants.TEST_PLAN_SHOW_STATUS_COMPLETED; + } else { + this.status = TestPlanConstants.TEST_PLAN_SHOW_STATUS_UNDERWAY; + } } } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanStatisticsService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanStatisticsService.java index 04b4fa700e..b34cc059d7 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanStatisticsService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanStatisticsService.java @@ -7,6 +7,7 @@ import io.metersphere.plan.mapper.*; import io.metersphere.sdk.constants.ExecStatus; import io.metersphere.sdk.constants.ResultStatus; import io.metersphere.sdk.constants.ScheduleResourceType; +import io.metersphere.sdk.constants.TestPlanConstants; import io.metersphere.sdk.util.JSON; import io.metersphere.system.domain.Schedule; import io.metersphere.system.domain.ScheduleExample; @@ -131,11 +132,15 @@ public class TestPlanStatisticsService { groupTestPlanMap.forEach((rootPlan, children) -> { TestPlanStatisticsResponse rootResponse = this.genTestPlanStatisticsResponse(rootPlan, planConfigMap, planFunctionalCaseMap, planApiCaseMap, planApiScenarioMap, scheduleMap); + rootResponse.setStatus(rootPlan.getStatus()); + List childrenResponse = new ArrayList<>(); if (!CollectionUtils.isEmpty(children)) { List childStatus = new ArrayList<>(); children.forEach(child -> { TestPlanStatisticsResponse childResponse = this.genTestPlanStatisticsResponse(child, planConfigMap, planFunctionalCaseMap, planApiCaseMap, planApiScenarioMap, scheduleMap); + childResponse.setStatus(child.getStatus()); + childResponse.calculateStatus(); childStatus.add(childResponse.getStatus()); //添加到rootResponse中 @@ -145,7 +150,9 @@ public class TestPlanStatisticsService { rootResponse.calculateCaseTotal(); rootResponse.calculatePassRate(); rootResponse.calculateExecuteRate(); - rootResponse.setStatus(testPlanBaseUtilsService.calculateStatusByChildren(childStatus)); + if (!StringUtils.equalsIgnoreCase(rootResponse.getStatus(), TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED)) { + rootResponse.setStatus(testPlanBaseUtilsService.calculateStatusByChildren(childStatus)); + } } else { rootResponse.calculateCaseTotal(); rootResponse.calculatePassRate();