diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java index e95773964c..7b51694d27 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java @@ -111,5 +111,5 @@ public interface ExtTestPlanMapper { List selectTestPlanConfigByTestPlanIds(@Param("testPlanIds") List testPlanIds); - List selectIdAndGroupIdByProjectId(String projectId); + List selectIdAndGroupIdByProjectId(@Param("projectId") String projectId, @Param("selectArchived") boolean selectArchived); } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml index bd9cdf7955..6e0d74f63e 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml @@ -940,8 +940,13 @@ diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanManagementService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanManagementService.java index 1690ab2a0f..d7a7d255e4 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanManagementService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanManagementService.java @@ -144,12 +144,12 @@ public class TestPlanManagementService { * @param statusConditionList 状态列表 * @return 测试计划ID列表 */ - public TestPlanCalculationDTO selectTestPlanIdByProjectIdUnionConditions(String projectId, String dataType, List statusConditionList, List passedConditionList) { + public TestPlanCalculationDTO selectTestPlanIdByProjectIdUnionConditions(boolean selectArchived, String projectId, String dataType, List statusConditionList, List passedConditionList) { if (CollectionUtils.isEmpty(statusConditionList) && CollectionUtils.isEmpty(passedConditionList)) { return new TestPlanCalculationDTO(); } boolean selectPassed = CollectionUtils.isNotEmpty(passedConditionList) && CollectionUtils.size(passedConditionList) == 1; - List testPlanList = extTestPlanMapper.selectIdAndGroupIdByProjectId(projectId); + List testPlanList = extTestPlanMapper.selectIdAndGroupIdByProjectId(projectId, selectArchived); Map> testPlanGroupIdMap = new HashMap<>(); List noGroupPlanIdList = new ArrayList<>(); Map> 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 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 completePlanOrGroupIds = calculationDTO.getCompletedTestPlanIds(); List underwayPlanOrGroupIds = calculationDTO.getUnderwayTestPlanIds(); diff --git a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanControllerTests.java b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanControllerTests.java index 82653f9b0e..2bef294f06 100644 --- a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanControllerTests.java +++ b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanControllerTests.java @@ -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); } }