fix(工作台): 待办计划列表筛选有误
--bug=1048995 --user=宋昌昌 【工作台】待办-测试计划列表-状态-筛选显示计划错误 https://www.tapd.cn/55049933/s/1617098
This commit is contained in:
parent
5ffda82781
commit
d4f300266a
|
@ -111,7 +111,7 @@
|
|||
functional_case.tags,
|
||||
test_plan_functional_case.execute_user as executeUser,
|
||||
test_plan_functional_case.last_exec_time as lastExecTime,
|
||||
test_plan_functional_case.last_exec_result as lastExecResult,
|
||||
if(test_plan_functional_case.last_exec_result = '', 'PENDING', test_plan_functional_case.last_exec_result) as lastExecResult,
|
||||
test_plan_functional_case.test_plan_id as testPlanId,
|
||||
test_plan_functional_case.id,
|
||||
project.name as projectName,
|
||||
|
|
|
@ -26,6 +26,7 @@ import io.metersphere.system.utils.Pager;
|
|||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -324,14 +325,52 @@ public class TestPlanManagementService {
|
|||
* @return 已办计划ID集合
|
||||
*/
|
||||
private List<String> getDoneIds(String projectId) {
|
||||
List<String> completePlanOrGroupIds = selectTestPlanIdByProjectIdAndStatus(projectId, List.of((TestPlanConstants.TEST_PLAN_SHOW_STATUS_COMPLETED)));
|
||||
if (CollectionUtils.isEmpty(completePlanOrGroupIds)) {
|
||||
List<String> doneIds = new ArrayList<>();
|
||||
// 筛选出已完成/进行中的计划或计划组
|
||||
List<String> completePlanOrGroupIds = selectTestPlanIdByProjectIdAndStatus(projectId, List.of(TestPlanConstants.TEST_PLAN_SHOW_STATUS_COMPLETED));
|
||||
List<String> underwayPlanOrGroupIds = selectTestPlanIdByProjectIdAndStatus(projectId, List.of(TestPlanConstants.TEST_PLAN_SHOW_STATUS_UNDERWAY));
|
||||
if (CollectionUtils.isEmpty(completePlanOrGroupIds) && CollectionUtils.isEmpty(underwayPlanOrGroupIds)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<TestPlanStatisticsResponse> completePlanOrGroupWithStatistics = testPlanStatisticsService.calculateRate(completePlanOrGroupIds);
|
||||
return completePlanOrGroupWithStatistics.stream()
|
||||
.filter(plan -> plan.getPassRate() >= plan.getPassThreshold())
|
||||
.map(TestPlanStatisticsResponse::getId).collect(Collectors.toList());
|
||||
TestPlanExample example = new TestPlanExample();
|
||||
example.createCriteria().andIdIn(ListUtils.union(completePlanOrGroupIds, underwayPlanOrGroupIds));
|
||||
List<TestPlan> allPlans = testPlanMapper.selectByExample(example);
|
||||
// 筛选出已完成且阈值达标的计划ID集合, 计划组除外
|
||||
List<String> calculateIds = new ArrayList<>();
|
||||
List<String> groupPlanIds = new ArrayList<>();
|
||||
allPlans.forEach(plan -> {
|
||||
if (completePlanOrGroupIds.contains(plan.getId())) {
|
||||
if (StringUtils.equals(plan.getType(), TestPlanConstants.TEST_PLAN_TYPE_PLAN)) {
|
||||
// 已完成的计划, 待计算通过率比对
|
||||
calculateIds.add(plan.getId());
|
||||
} else {
|
||||
// 已完成的计划组, 待获取下级子计划
|
||||
groupPlanIds.add(plan.getId());
|
||||
}
|
||||
} else {
|
||||
// 进行中的状态, 直接获取计划组下的子计划
|
||||
if (StringUtils.equals(plan.getType(), TestPlanConstants.TEST_PLAN_TYPE_GROUP)) {
|
||||
groupPlanIds.add(plan.getId());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 处理计划组下级子计划
|
||||
List<TestPlan> childPlans = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(groupPlanIds)) {
|
||||
example.clear();
|
||||
example.createCriteria().andGroupIdIn(groupPlanIds);
|
||||
childPlans = testPlanMapper.selectByExample(example);
|
||||
}
|
||||
calculateIds.addAll(childPlans.stream().map(TestPlan::getId).toList());
|
||||
List<TestPlanStatisticsResponse> calcPlans = testPlanStatisticsService.calculateRate(calculateIds);
|
||||
calcPlans.forEach(plan -> {
|
||||
// 筛选出已完成的计划 && 子计划且通过率达到阈值
|
||||
if (plan.getPassRate() >= plan.getPassThreshold() && StringUtils.equals(plan.getStatus(), TestPlanConstants.TEST_PLAN_SHOW_STATUS_COMPLETED)) {
|
||||
doneIds.add(plan.getId());
|
||||
}
|
||||
});
|
||||
return doneIds;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,10 @@ import org.apache.commons.collections4.CollectionUtils;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -167,17 +170,17 @@ public class TestPlanStatisticsService {
|
|||
|
||||
private Map<String, Long> countApiScenarioExecResultMap(List<TestPlanApiScenario> apiScenarios) {
|
||||
return CollectionUtils.isEmpty(apiScenarios) ? new HashMap<>(16) : apiScenarios.stream().collect(
|
||||
Collectors.groupingBy(apiScenario -> Optional.ofNullable(apiScenario.getLastExecResult()).orElse(ExecStatus.PENDING.name()), Collectors.counting()));
|
||||
Collectors.groupingBy(apiScenario -> StringUtils.isEmpty(apiScenario.getLastExecResult()) ? ExecStatus.PENDING.name() : apiScenario.getLastExecResult(), Collectors.counting()));
|
||||
}
|
||||
|
||||
private Map<String, Long> countApiTestCaseExecResultMap(List<TestPlanApiCase> apiCases) {
|
||||
return CollectionUtils.isEmpty(apiCases) ? new HashMap<>(16) : apiCases.stream().collect(
|
||||
Collectors.groupingBy(apiCase -> Optional.ofNullable(apiCase.getLastExecResult()).orElse(ExecStatus.PENDING.name()), Collectors.counting()));
|
||||
Collectors.groupingBy(apiCase -> StringUtils.isEmpty(apiCase.getLastExecResult()) ? ExecStatus.PENDING.name() : apiCase.getLastExecResult(), Collectors.counting()));
|
||||
}
|
||||
|
||||
private Map<String, Long> countFunctionalCaseExecResultMap(List<TestPlanFunctionalCase> functionalCases) {
|
||||
return CollectionUtils.isEmpty(functionalCases) ? new HashMap<>(16) : functionalCases.stream().collect(
|
||||
Collectors.groupingBy(functionalCase -> Optional.ofNullable(functionalCase.getLastExecResult()).orElse(ExecStatus.PENDING.name()), Collectors.counting()));
|
||||
Collectors.groupingBy(functionalCase -> StringUtils.isEmpty(functionalCase.getLastExecResult()) ? ExecStatus.PENDING.name() : functionalCase.getLastExecResult(), Collectors.counting()));
|
||||
}
|
||||
|
||||
private TestPlanStatisticsResponse genTestPlanStatisticsResponse(TestPlan child,
|
||||
|
|
Loading…
Reference in New Issue