From 89857c2fffce9ee1b72ed3f32b47bb9ebf4a709a Mon Sep 17 00:00:00 2001 From: Jianguo-Genius Date: Fri, 20 Dec 2024 14:59:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=A5=E4=BD=9C=E5=8F=B0=E5=B7=B2=E5=BD=92?= =?UTF-8?q?=E6=A1=A3=E7=9A=84=E9=80=9A=E8=BF=87=E3=80=81=E6=9C=AA=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plan/mapper/ExtTestPlanMapper.java | 2 +- .../metersphere/plan/mapper/ExtTestPlanMapper.xml | 9 +++++++-- .../plan/service/TestPlanManagementService.java | 15 ++++++++------- .../plan/controller/TestPlanControllerTests.java | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) 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); } }