From b231e27794ec98c221dd034957f3a2e13ab67c99 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Tue, 21 May 2024 11:41:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=BD=92=E6=A1=A3=E6=9C=AA=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=B7=B2=E5=AE=8C=E6=88=90=E7=9A=84=E7=8A=B6=E6=80=81=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1040794 --user=宋昌昌 【测试计划】未开始的计划也可归档 https://www.tapd.cn/55049933/s/1517305 --- .../src/main/resources/i18n/plan.properties | 3 ++- .../main/resources/i18n/plan_en_US.properties | 3 ++- .../main/resources/i18n/plan_zh_CN.properties | 3 ++- .../main/resources/i18n/plan_zh_TW.properties | 3 ++- .../service/TestPlanBatchArchivedService.java | 27 ++++++++++--------- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/backend/framework/sdk/src/main/resources/i18n/plan.properties b/backend/framework/sdk/src/main/resources/i18n/plan.properties index 504e03d832..4c125264d3 100644 --- a/backend/framework/sdk/src/main/resources/i18n/plan.properties +++ b/backend/framework/sdk/src/main/resources/i18n/plan.properties @@ -93,4 +93,5 @@ test_plan_report_id.not_blank=测试计划报告id不能为空 test_plan_report_name.not_blank=测试计划报告名称不能为空 test_plan_not_exist=测试计划不存在 test_plan.report_id.not_blank=测试计划报告ID不能为空 -test_plan.report.share_id.not_blank=测试计划报告分享ID不能为空 \ No newline at end of file +test_plan.report.share_id.not_blank=测试计划报告分享ID不能为空 +no_plan_to_archive=没有可归档的计划/计划组 \ No newline at end of file diff --git a/backend/framework/sdk/src/main/resources/i18n/plan_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/plan_en_US.properties index c38ca73e72..94c370bc90 100644 --- a/backend/framework/sdk/src/main/resources/i18n/plan_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/plan_en_US.properties @@ -105,4 +105,5 @@ test_plan_report_name.not_blank=The test plan report name cannot be empty run_functional_case=Run functional case test_plan_not_exist=The test plan does not exist test_plan.report_id.not_blank=The test plan report ID cannot be empty -test_plan.report.share_id.not_blank=The test plan report share ID cannot be empty \ No newline at end of file +test_plan.report.share_id.not_blank=The test plan report share ID cannot be empty +no_plan_to_archive=No plans/plan groups to archive \ No newline at end of file diff --git a/backend/framework/sdk/src/main/resources/i18n/plan_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/plan_zh_CN.properties index 2ce4c9ee26..db79209a0e 100644 --- a/backend/framework/sdk/src/main/resources/i18n/plan_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/plan_zh_CN.properties @@ -105,4 +105,5 @@ test_plan_report_name.not_blank=测试计划报告名称不能为空 run_functional_case=执行功能用例 test_plan_not_exist=测试计划不存在 test_plan.report_id.not_blank=测试计划报告ID不能为空 -test_plan.report.share_id.not_blank=测试计划报告分享ID不能为空 \ No newline at end of file +test_plan.report.share_id.not_blank=测试计划报告分享ID不能为空 +no_plan_to_archive=没有可归档的计划/计划组 \ No newline at end of file diff --git a/backend/framework/sdk/src/main/resources/i18n/plan_zh_TW.properties b/backend/framework/sdk/src/main/resources/i18n/plan_zh_TW.properties index 37806f98f4..caca09659f 100644 --- a/backend/framework/sdk/src/main/resources/i18n/plan_zh_TW.properties +++ b/backend/framework/sdk/src/main/resources/i18n/plan_zh_TW.properties @@ -105,4 +105,5 @@ test_plan_report_name.not_blank=測試計劃報告名稱不能爲空 run_functional_case=執行功能用例 test_plan_not_exist=測試計劃不存在 test_plan.report_id.not_blank=測試計劃報告ID不能爲空 -test_plan.report.share_id.not_blank=測試計劃報告分享ID不能爲空 \ No newline at end of file +test_plan.report.share_id.not_blank=測試計劃報告分享ID不能爲空 +no_plan_to_archive=沒有可歸檔的計劃/計劃組 \ No newline at end of file diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanBatchArchivedService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanBatchArchivedService.java index a99619cef1..c86d565a00 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanBatchArchivedService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanBatchArchivedService.java @@ -7,7 +7,10 @@ import io.metersphere.plan.dto.request.TestPlanBatchRequest; import io.metersphere.plan.mapper.TestPlanMapper; import io.metersphere.sdk.constants.TestPlanConstants; import io.metersphere.sdk.exception.MSException; +import io.metersphere.sdk.util.Translator; import jakarta.annotation.Resource; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -24,36 +27,36 @@ public class TestPlanBatchArchivedService extends TestPlanBaseUtilsService { public void batchArchived(Map> plans, TestPlanBatchRequest request, String userId) { int affectedGroupPlanCount = batchArchivedGroup(plans, request, userId); - int affectedPlanCount = batchArchivedPlan(plans, request, userId); + int affectedPlanCount = batchArchivedPlan(plans, userId); if (affectedGroupPlanCount <= 0 && affectedPlanCount <= 0) { // 暂无可归档的计划 - throw new MSException(""); + throw new MSException(Translator.get("no_plan_to_archive")); } } /** - * 批量移动组 + * 批量归档组 * - * @param plans + * @param planGroups 计划组 */ - private int batchArchivedGroup(Map> plans, TestPlanBatchProcessRequest request, String userId) { + private int batchArchivedGroup(Map> planGroups, TestPlanBatchProcessRequest request, String userId) { //TODO 批量归档计划组 return 0; } /** - * 批量移动计划 + * 批量归档计划 * * @param plans 归档测试计划集合 */ - private int batchArchivedPlan(Map> plans, TestPlanBatchRequest request, String userId) { + private int batchArchivedPlan(Map> plans, String userId) { if (plans.containsKey(TestPlanConstants.TEST_PLAN_TYPE_PLAN)) { List testPlans = plans.get(TestPlanConstants.TEST_PLAN_TYPE_PLAN); - testPlans.forEach(testPlan -> { - testPlan.setModuleId(request.getModuleId()); - validateTestPlan(testPlan); - }); - List ids = testPlans.stream().map(TestPlan::getId).collect(Collectors.toList()); + List ids = testPlans.stream().filter(plan -> StringUtils.equals(plan.getStatus(), TestPlanConstants.TEST_PLAN_STATUS_COMPLETED)) + .map(TestPlan::getId).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(ids)) { + return 0; + } TestPlan record = new TestPlan(); record.setStatus(TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED); record.setUpdateUser(userId);