fix(测试计划): 修复脑图保存根节点更新父节点更新错误问题

This commit is contained in:
guoyuqi 2024-06-19 16:00:28 +08:00 committed by 刘瑞斌
parent f1961d933e
commit 2f31cf385a
3 changed files with 75 additions and 23 deletions

View File

@ -663,13 +663,8 @@ public class FunctionalCaseMinderService {
//更新附属表信息
FunctionalCaseBlob functionalCaseBlob = updateBlob(functionalCaseChangeRequest, caseId, caseBlobMapper);
//更新自定义字段
List<FunctionalCaseCustomField> functionalCaseCustomFields = updateCustomFields(functionalCaseChangeRequest, oldCaseCustomFieldMap, caseId, caseCustomFieldMapper);
//更新用例等级
FunctionalCaseCustomField customField = new FunctionalCaseCustomField();
customField.setCaseId(caseId);
customField.setFieldId(defaultCustomFieldValueMap.get("priorityFieldId").toString());
customField.setValue("P"+(functionalCaseChangeRequest.getPriority()-1));
caseCustomFieldMapper.updateByPrimaryKeySelective(customField);
String fieldId = defaultCustomFieldValueMap.get("priorityFieldId").toString();
List<FunctionalCaseCustomField> functionalCaseCustomFields = updateCustomFields(functionalCaseChangeRequest, oldCaseCustomFieldMap, caseId, fieldId, caseCustomFieldMapper);
//日志
FunctionalCaseHistoryLogDTO historyLogDTO = new FunctionalCaseHistoryLogDTO(functionalCase, functionalCaseBlob, oldCaseCustomFieldMap.get(caseId), new ArrayList<>(), new ArrayList<>());
FunctionalCaseHistoryLogDTO old = new FunctionalCaseHistoryLogDTO(oldCaseMap.get(caseId), oldBlobMap.get(caseId), new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
@ -1010,13 +1005,18 @@ public class FunctionalCaseMinderService {
return functionalCaseBlob;
}
private List<FunctionalCaseCustomField> updateCustomFields(FunctionalCaseChangeRequest functionalCaseChangeRequest, Map<String, List<FunctionalCaseCustomField>> caseCustomFieldMap, String caseId, FunctionalCaseCustomFieldMapper caseCustomFieldMapper) {
private List<FunctionalCaseCustomField> updateCustomFields(FunctionalCaseChangeRequest functionalCaseChangeRequest, Map<String, List<FunctionalCaseCustomField>> caseCustomFieldMap, String caseId,String fieldId, FunctionalCaseCustomFieldMapper caseCustomFieldMapper) {
List<FunctionalCaseCustomField> total = new ArrayList<>();
List<FunctionalCaseCustomField> functionalCaseCustomFields = caseCustomFieldMap.get(caseId);
if (CollectionUtils.isEmpty(functionalCaseCustomFields)) {
functionalCaseCustomFields = new ArrayList<>();
}
List<CaseCustomFieldDTO> customFields = functionalCaseChangeRequest.getCustomFields();
//更新用例等级
CaseCustomFieldDTO customFieldDTO = new CaseCustomFieldDTO();
customFieldDTO.setFieldId(fieldId);
customFieldDTO.setValue("P"+(functionalCaseChangeRequest.getPriority()-1));
customFields.add(customFieldDTO);
if (CollectionUtils.isNotEmpty(customFields)) {
customFields = customFields.stream().distinct().collect(Collectors.toList());
List<String> fieldIds = customFields.stream().map(CaseCustomFieldDTO::getFieldId).collect(Collectors.toList());

View File

@ -1078,5 +1078,62 @@
]
}
]
},
{
"projectId":"",
"type":"JENKINS_TASK_MANAGEMENT",
"name":"",
"messageTaskTypeDTOList":[
{
"taskType":"JENKINS_TASK",
"taskTypeName":"",
"messageTaskDetailDTOList":[
{
"event":"EXECUTE_SUCCESSFUL",
"eventName":"",
"receivers":[
{
"id": "",
"name": ""
}
],
"projectRobotConfigList":[
{
"robotId":"",
"enable":"",
"template":"",
"defaultTemplate":"",
"useDefaultTemplate":true,
"subject":"",
"defaultSubject":"",
"useDefaultSubject":true
}
]
},
{
"event":"EXECUTE_FAILED",
"eventName":"",
"receivers":[
{
"id": "",
"name": ""
}
],
"projectRobotConfigList":[
{
"robotId":"",
"enable":"",
"template":"",
"defaultTemplate":"",
"useDefaultTemplate":true,
"subject":"",
"defaultSubject":"",
"useDefaultSubject":true
}
]
}
]
}
]
}
]

View File

@ -251,6 +251,7 @@ public class TestPlanCollectionMinderService {
beansOfType.forEach((k, v) -> {
v.associateCollection(request.getPlanId(), associateMap, user);
});
List<TestPlanCollection> testPlanCollections = testPlanCollectionMapper.selectByExample(new TestPlanCollectionExample());
//更新测试计划
testPlanService.refreshTestPlanStatus(request.getPlanId());
}
@ -350,6 +351,7 @@ public class TestPlanCollectionMinderService {
TestPlanCollection testPlanCollection = new TestPlanCollection();
BeanUtils.copyBean(testPlanCollection, testPlanCollectionMinderEditDTO);
testPlanCollection.setName(testPlanCollectionMinderEditDTO.getText());
testPlanCollection.setParentId(CommonConstants.DEFAULT_NULL_VALUE);
parentList.add(testPlanCollection);
}
return parentList.stream().collect(Collectors.groupingBy(TestPlanCollection::getType));
@ -358,18 +360,17 @@ public class TestPlanCollectionMinderService {
@NotNull
private static TestPlanCollection updateCollection(TestPlanCollectionMinderEditRequest request, String userId, TestPlanCollectionMinderEditDTO testPlanCollectionMinderEditDTO, Map<String, List<TestPlanCollection>> parentMap, TestPlanCollectionMapper collectionMapper) {
TestPlanCollection testPlanCollection = new TestPlanCollection();
TestPlanCollection parent = parentMap.get(testPlanCollectionMinderEditDTO.getType()).get(0);
if (StringUtils.equalsIgnoreCase(parent.getId(), testPlanCollectionMinderEditDTO.getId())) {
testPlanCollection.setParentId(parent.getParentId());
} else {
testPlanCollection.setParentId(parent.getId());
}
if (testPlanCollectionMinderEditDTO.getExtended()) {
BeanUtils.copyBean(testPlanCollection, parent);
} else {
BeanUtils.copyBean(testPlanCollection, testPlanCollectionMinderEditDTO);
}
if (StringUtils.equalsIgnoreCase(parent.getId(), testPlanCollectionMinderEditDTO.getId())) {
testPlanCollection.setParentId(parent.getParentId());
} else {
testPlanCollection.setParentId(parent.getId());
}
testPlanCollection.setName(testPlanCollectionMinderEditDTO.getText());
testPlanCollection.setTestPlanId(request.getPlanId());
testPlanCollection.setType(testPlanCollectionMinderEditDTO.getType());
@ -384,23 +385,17 @@ public class TestPlanCollectionMinderService {
@NotNull
private static TestPlanCollection addCollection(TestPlanCollectionMinderEditRequest request, String userId, TestPlanCollectionMinderEditDTO testPlanCollectionMinderEditDTO, Map<String, List<TestPlanCollection>> parentMap, TestPlanCollectionMapper collectionMapper) {
List<TestPlanCollection> testPlanCollections = parentMap.get(testPlanCollectionMinderEditDTO.getType());
TestPlanCollection parent = null;
TestPlanCollection parent = testPlanCollections.get(0);
TestPlanCollection testPlanCollection = new TestPlanCollection();
if (CollectionUtils.isNotEmpty(testPlanCollections)) {
parent = testPlanCollections.get(0);
testPlanCollection.setParentId(parent.getId());
} else {
testPlanCollection.setParentId(CommonConstants.DEFAULT_NULL_VALUE);
}
if (testPlanCollectionMinderEditDTO.getExtended() && parent!=null) {
if (testPlanCollectionMinderEditDTO.getExtended()) {
BeanUtils.copyBean(testPlanCollection, parent);
} else {
BeanUtils.copyBean(testPlanCollection, testPlanCollectionMinderEditDTO);
}
testPlanCollection.setParentId(parent.getId());
testPlanCollection.setName(testPlanCollectionMinderEditDTO.getText());
testPlanCollection.setId(IDGenerator.nextStr());
testPlanCollection.setTestPlanId(request.getPlanId());
testPlanCollection.setType(testPlanCollectionMinderEditDTO.getType());
testPlanCollection.setCreateUser(userId);
testPlanCollection.setCreateTime(System.currentTimeMillis());
testPlanCollection.setPos(testPlanCollectionMinderEditDTO.getNum());