fix(测试计划): 修复无法正常显示已归档测试计划状态的问题

This commit is contained in:
Jianguo-Genius 2024-07-17 17:31:28 +08:00 committed by Craftsman
parent 10ba0cc6c6
commit 5e2ef1d10a
2 changed files with 18 additions and 7 deletions

View File

@ -8,6 +8,7 @@ import io.metersphere.system.dto.request.schedule.BaseScheduleConfigRequest;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;
/** /**
* 测试计划统计详情 * 测试计划统计详情
@ -66,17 +67,20 @@ public class TestPlanStatisticsResponse {
/** /**
* 计算测试计划状态 * 计算测试计划状态
* 非未归档的开始计算
* 未开始执行进度0% * 未开始执行进度0%
* 进行中执行进度不到100% * 进行中执行进度不到100%
* 已完成执行进度100% * 已完成执行进度100%
*/ */
public void calculateStatus() { public void calculateStatus() {
if (this.successCount == 0 && errorCount == 0 && fakeErrorCount == 0 && blockCount == 0) { if (!StringUtils.equalsIgnoreCase(this.status, TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED)) {
this.status = TestPlanConstants.TEST_PLAN_SHOW_STATUS_PREPARED; if (this.successCount == 0 && errorCount == 0 && fakeErrorCount == 0 && blockCount == 0) {
} else if (this.pendingCount == 0) { this.status = TestPlanConstants.TEST_PLAN_SHOW_STATUS_PREPARED;
this.status = TestPlanConstants.TEST_PLAN_SHOW_STATUS_COMPLETED; } else if (this.pendingCount == 0) {
} else { this.status = TestPlanConstants.TEST_PLAN_SHOW_STATUS_COMPLETED;
this.status = TestPlanConstants.TEST_PLAN_SHOW_STATUS_UNDERWAY; } else {
this.status = TestPlanConstants.TEST_PLAN_SHOW_STATUS_UNDERWAY;
}
} }
} }

View File

@ -7,6 +7,7 @@ import io.metersphere.plan.mapper.*;
import io.metersphere.sdk.constants.ExecStatus; import io.metersphere.sdk.constants.ExecStatus;
import io.metersphere.sdk.constants.ResultStatus; import io.metersphere.sdk.constants.ResultStatus;
import io.metersphere.sdk.constants.ScheduleResourceType; import io.metersphere.sdk.constants.ScheduleResourceType;
import io.metersphere.sdk.constants.TestPlanConstants;
import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.JSON;
import io.metersphere.system.domain.Schedule; import io.metersphere.system.domain.Schedule;
import io.metersphere.system.domain.ScheduleExample; import io.metersphere.system.domain.ScheduleExample;
@ -131,11 +132,15 @@ public class TestPlanStatisticsService {
groupTestPlanMap.forEach((rootPlan, children) -> { groupTestPlanMap.forEach((rootPlan, children) -> {
TestPlanStatisticsResponse rootResponse = this.genTestPlanStatisticsResponse(rootPlan, planConfigMap, planFunctionalCaseMap, planApiCaseMap, planApiScenarioMap, scheduleMap); TestPlanStatisticsResponse rootResponse = this.genTestPlanStatisticsResponse(rootPlan, planConfigMap, planFunctionalCaseMap, planApiCaseMap, planApiScenarioMap, scheduleMap);
rootResponse.setStatus(rootPlan.getStatus());
List<TestPlanStatisticsResponse> childrenResponse = new ArrayList<>(); List<TestPlanStatisticsResponse> childrenResponse = new ArrayList<>();
if (!CollectionUtils.isEmpty(children)) { if (!CollectionUtils.isEmpty(children)) {
List<String> childStatus = new ArrayList<>(); List<String> childStatus = new ArrayList<>();
children.forEach(child -> { children.forEach(child -> {
TestPlanStatisticsResponse childResponse = this.genTestPlanStatisticsResponse(child, planConfigMap, planFunctionalCaseMap, planApiCaseMap, planApiScenarioMap, scheduleMap); TestPlanStatisticsResponse childResponse = this.genTestPlanStatisticsResponse(child, planConfigMap, planFunctionalCaseMap, planApiCaseMap, planApiScenarioMap, scheduleMap);
childResponse.setStatus(child.getStatus());
childResponse.calculateStatus(); childResponse.calculateStatus();
childStatus.add(childResponse.getStatus()); childStatus.add(childResponse.getStatus());
//添加到rootResponse中 //添加到rootResponse中
@ -145,7 +150,9 @@ public class TestPlanStatisticsService {
rootResponse.calculateCaseTotal(); rootResponse.calculateCaseTotal();
rootResponse.calculatePassRate(); rootResponse.calculatePassRate();
rootResponse.calculateExecuteRate(); rootResponse.calculateExecuteRate();
rootResponse.setStatus(testPlanBaseUtilsService.calculateStatusByChildren(childStatus)); if (!StringUtils.equalsIgnoreCase(rootResponse.getStatus(), TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED)) {
rootResponse.setStatus(testPlanBaseUtilsService.calculateStatusByChildren(childStatus));
}
} else { } else {
rootResponse.calculateCaseTotal(); rootResponse.calculateCaseTotal();
rootResponse.calculatePassRate(); rootResponse.calculatePassRate();