fix(测试计划): 批量归档未添加已完成的状态校验
--bug=1040794 --user=宋昌昌 【测试计划】未开始的计划也可归档 https://www.tapd.cn/55049933/s/1517305
This commit is contained in:
parent
eb0bdc72c9
commit
b231e27794
|
@ -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不能为空
|
||||
test_plan.report.share_id.not_blank=测试计划报告分享ID不能为空
|
||||
no_plan_to_archive=没有可归档的计划/计划组
|
|
@ -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
|
||||
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
|
|
@ -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不能为空
|
||||
test_plan.report.share_id.not_blank=测试计划报告分享ID不能为空
|
||||
no_plan_to_archive=没有可归档的计划/计划组
|
|
@ -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不能爲空
|
||||
test_plan.report.share_id.not_blank=測試計劃報告分享ID不能爲空
|
||||
no_plan_to_archive=沒有可歸檔的計劃/計劃組
|
|
@ -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<String, List<TestPlan>> 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<String, List<TestPlan>> plans, TestPlanBatchProcessRequest request, String userId) {
|
||||
private int batchArchivedGroup(Map<String, List<TestPlan>> planGroups, TestPlanBatchProcessRequest request, String userId) {
|
||||
//TODO 批量归档计划组
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量移动计划
|
||||
* 批量归档计划
|
||||
*
|
||||
* @param plans 归档测试计划集合
|
||||
*/
|
||||
private int batchArchivedPlan(Map<String, List<TestPlan>> plans, TestPlanBatchRequest request, String userId) {
|
||||
private int batchArchivedPlan(Map<String, List<TestPlan>> plans, String userId) {
|
||||
if (plans.containsKey(TestPlanConstants.TEST_PLAN_TYPE_PLAN)) {
|
||||
List<TestPlan> testPlans = plans.get(TestPlanConstants.TEST_PLAN_TYPE_PLAN);
|
||||
testPlans.forEach(testPlan -> {
|
||||
testPlan.setModuleId(request.getModuleId());
|
||||
validateTestPlan(testPlan);
|
||||
});
|
||||
List<String> ids = testPlans.stream().map(TestPlan::getId).collect(Collectors.toList());
|
||||
List<String> 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);
|
||||
|
|
Loading…
Reference in New Issue