fix(测试计划): 修改工作台已归档的通过、未通过测试计划查询方式

This commit is contained in:
Jianguo-Genius 2024-12-20 14:59:38 +08:00 committed by Craftsman
parent 4641e9c3e7
commit 89857c2fff
4 changed files with 17 additions and 11 deletions

View File

@ -111,5 +111,5 @@ public interface ExtTestPlanMapper {
List<TestPlanConfig> selectTestPlanConfigByTestPlanIds(@Param("testPlanIds") List<String> testPlanIds);
List<TestPlan> selectIdAndGroupIdByProjectId(String projectId);
List<TestPlan> selectIdAndGroupIdByProjectId(@Param("projectId") String projectId, @Param("selectArchived") boolean selectArchived);
}

View File

@ -940,8 +940,13 @@
<select id="selectIdAndGroupIdByProjectId" resultType="io.metersphere.plan.domain.TestPlan">
SELECT id, group_id, type
FROM test_plan
WHERE project_id = #{0}
AND status != 'ARCHIVED'
WHERE project_id = #{projectId}
<if test="selectArchived == false">
AND status != 'ARCHIVED'
</if>
<if test="selectArchived == true">
AND status = 'ARCHIVED'
</if>
</select>
<sql id="queryMyFollowGroupByTableRequest">

View File

@ -144,12 +144,12 @@ public class TestPlanManagementService {
* @param statusConditionList 状态列表
* @return 测试计划ID列表
*/
public TestPlanCalculationDTO selectTestPlanIdByProjectIdUnionConditions(String projectId, String dataType, List<String> statusConditionList, List<String> passedConditionList) {
public TestPlanCalculationDTO selectTestPlanIdByProjectIdUnionConditions(boolean selectArchived, String projectId, String dataType, List<String> statusConditionList, List<String> passedConditionList) {
if (CollectionUtils.isEmpty(statusConditionList) && CollectionUtils.isEmpty(passedConditionList)) {
return new TestPlanCalculationDTO();
}
boolean selectPassed = CollectionUtils.isNotEmpty(passedConditionList) && CollectionUtils.size(passedConditionList) == 1;
List<TestPlan> testPlanList = extTestPlanMapper.selectIdAndGroupIdByProjectId(projectId);
List<TestPlan> testPlanList = extTestPlanMapper.selectIdAndGroupIdByProjectId(projectId, selectArchived);
Map<String, List<String>> testPlanGroupIdMap = new HashMap<>();
List<String> noGroupPlanIdList = new ArrayList<>();
Map<String, List<String>> noGroupPlanIdMap = new HashMap<>();
@ -342,7 +342,7 @@ public class TestPlanManagementService {
item.setValue(defaultStatusList);
//目前未归档的测试计划只有3中类型所以这里判断如果是3个的话等于直接查询未归档
if (statusList.size() < 3) {
TestPlanCalculationDTO calculationDTO = this.selectTestPlanIdByProjectIdUnionConditions(request.getProjectId(), request.getType(), statusList, null);
TestPlanCalculationDTO calculationDTO = this.selectTestPlanIdByProjectIdUnionConditions(false, request.getProjectId(), request.getType(), statusList, null);
request.setCombineInnerIds(calculationDTO.getConditionInnerId());
request.setIncludeItemTestPlanIds(calculationDTO.getConditionItemPlanId());
request.setCombineOperator(item.getOperator());
@ -364,9 +364,10 @@ public class TestPlanManagementService {
} else if (request.getFilter() != null && request.getFilter().containsKey("archivedPassed")) {
passedSelectParam = request.getFilter().get("archivedPassed");
request.getFilter().put("status", new ArrayList<>() {{
statusSelectParam = new ArrayList<>() {{
this.add(TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED);
}});
}};
request.getFilter().put("status", statusSelectParam);
}
if (request.getFilter() == null || !request.getFilter().containsKey("status")) {
@ -387,7 +388,7 @@ public class TestPlanManagementService {
boolean selectPassed = CollectionUtils.isNotEmpty(passedSelectParam) && CollectionUtils.size(passedSelectParam) == 1;
if (selectStatus || selectPassed) {
TestPlanCalculationDTO calculationDTO = this.selectTestPlanIdByProjectIdUnionConditions(request.getProjectId(), request.getType(),
TestPlanCalculationDTO calculationDTO = this.selectTestPlanIdByProjectIdUnionConditions(selectArchived, request.getProjectId(), request.getType(),
selectStatus ? statusSelectParam : null,
selectPassed ? passedSelectParam : null);
request.setInnerIds(calculationDTO.getConditionInnerId());
@ -515,7 +516,7 @@ public class TestPlanManagementService {
List<String> statusList = new ArrayList<>();
statusList.add(TestPlanConstants.TEST_PLAN_SHOW_STATUS_COMPLETED);
statusList.add(TestPlanConstants.TEST_PLAN_SHOW_STATUS_UNDERWAY);
TestPlanCalculationDTO calculationDTO = this.selectTestPlanIdByProjectIdUnionConditions(request.getProjectId(), "ALL", statusList, null);
TestPlanCalculationDTO calculationDTO = this.selectTestPlanIdByProjectIdUnionConditions(false, request.getProjectId(), "ALL", statusList, null);
List<String> completePlanOrGroupIds = calculationDTO.getCompletedTestPlanIds();
List<String> underwayPlanOrGroupIds = calculationDTO.getUnderwayTestPlanIds();

View File

@ -2813,7 +2813,7 @@ public class TestPlanControllerTests extends BaseTest {
Assertions.assertEquals(1, underwayTestPlanIds.size());
Assertions.assertEquals("test3", underwayTestPlanIds.getFirst());
testPlanManagementService.selectTestPlanIdByProjectIdUnionConditions(null, null, null, null);
testPlanManagementService.selectTestPlanIdByProjectIdUnionConditions(false, null, null, null, null);
}
}