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();