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 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;
}
}
}

View File

@ -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<TestPlanStatisticsResponse> childrenResponse = new ArrayList<>();
if (!CollectionUtils.isEmpty(children)) {
List<String> 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();