fix(测试计划): 修复测试计划组移除测试计划时没有自动更新状态的缺陷

This commit is contained in:
Jianguo-Genius 2024-06-24 18:17:42 +08:00 committed by 刘瑞斌
parent 255a15a825
commit c269b2382a
1 changed files with 16 additions and 0 deletions

View File

@ -320,6 +320,7 @@ public class TestPlanService extends TestPlanBaseUtilsService {
public TestPlan update(TestPlanUpdateRequest request, String userId, String requestUrl, String requestMethod) { public TestPlan update(TestPlanUpdateRequest request, String userId, String requestUrl, String requestMethod) {
this.checkTestPlanNotArchived(request.getId()); this.checkTestPlanNotArchived(request.getId());
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getId()); TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getId());
String testPlanGroup = testPlan.getGroupId();
if (!ObjectUtils.allNull(request.getName(), request.getModuleId(), request.getTags(), request.getPlannedEndTime(), request.getPlannedStartTime(), request.getDescription(), request.getGroupId())) { if (!ObjectUtils.allNull(request.getName(), request.getModuleId(), request.getTags(), request.getPlannedEndTime(), request.getPlannedStartTime(), request.getDescription(), request.getGroupId())) {
TestPlan updateTestPlan = new TestPlan(); TestPlan updateTestPlan = new TestPlan();
updateTestPlan.setId(request.getId()); updateTestPlan.setId(request.getId());
@ -364,6 +365,10 @@ public class TestPlanService extends TestPlanBaseUtilsService {
testPlanConfig.setPassThreshold(request.getPassThreshold()); testPlanConfig.setPassThreshold(request.getPassThreshold());
testPlanConfigMapper.updateByPrimaryKeySelective(testPlanConfig); testPlanConfigMapper.updateByPrimaryKeySelective(testPlanConfig);
} }
if (!StringUtils.equalsIgnoreCase(testPlanGroup, TestPlanConstants.TEST_PLAN_DEFAULT_GROUP_ID)) {
this.updateTestPlanGroupStatus(testPlanGroup);
}
testPlanLogService.saveUpdateLog(testPlan, testPlanMapper.selectByPrimaryKey(request.getId()), testPlan.getProjectId(), userId, requestUrl, requestMethod); testPlanLogService.saveUpdateLog(testPlan, testPlanMapper.selectByPrimaryKey(request.getId()), testPlan.getProjectId(), userId, requestUrl, requestMethod);
return testPlan; return testPlan;
} }
@ -824,6 +829,17 @@ public class TestPlanService extends TestPlanBaseUtilsService {
} }
public void refreshTestPlanStatus(String testPlanId) { public void refreshTestPlanStatus(String testPlanId) {
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(testPlanId);
if (StringUtils.equalsIgnoreCase(testPlan.getType(), TestPlanConstants.TEST_PLAN_TYPE_PLAN)) {
this.updateTestPlanStatus(testPlanId);
} else {
if (!StringUtils.equalsIgnoreCase(testPlan.getGroupId(), TestPlanConstants.TEST_PLAN_DEFAULT_GROUP_ID)) {
this.updateTestPlanGroupStatus(testPlan.getGroupId());
}
}
}
private void updateTestPlanStatus(String testPlanId) {
Map<String, Long> caseExecResultCount = new HashMap<>(); Map<String, Long> caseExecResultCount = new HashMap<>();
Map<String, TestPlanResourceService> beansOfType = applicationContext.getBeansOfType(TestPlanResourceService.class); Map<String, TestPlanResourceService> beansOfType = applicationContext.getBeansOfType(TestPlanResourceService.class);
beansOfType.forEach((k, v) -> { beansOfType.forEach((k, v) -> {