diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java index 6c0a01a4ce..f97c3b12b0 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java @@ -1050,18 +1050,26 @@ public class FunctionalCaseMinderService { private List addCustomFields(FunctionalCaseChangeRequest functionalCaseChangeRequest, String caseId, FunctionalCaseCustomFieldMapper caseCustomFieldMapper, Map defaultValueMap) { List customFields = functionalCaseChangeRequest.getCustomFields(); List list = customFields.stream().map(CaseCustomFieldDTO::getFieldId).toList(); - List customFieldDTOs = new ArrayList<>(); + List defaultCustomFieldDTOs = new ArrayList<>(); defaultValueMap.forEach((k, v) -> { if (!list.contains(k) && !StringUtils.equalsIgnoreCase(k, "priorityFieldId")) { CaseCustomFieldDTO customFieldDTO = new CaseCustomFieldDTO(); customFieldDTO.setFieldId(k); customFieldDTO.setValue(v.toString()); + defaultCustomFieldDTOs.add(customFieldDTO); + } + }); + List customFieldDTOs = new ArrayList<>(); + customFields.forEach(t->{ + if (!StringUtils.equalsIgnoreCase(t.getFieldId(), defaultValueMap.get("priorityFieldId").toString())) { + CaseCustomFieldDTO customFieldDTO = new CaseCustomFieldDTO(); + customFieldDTO.setFieldId(t.getFieldId()); + customFieldDTO.setValue(t.getValue()); customFieldDTOs.add(customFieldDTO); } }); - customFields.addAll(customFieldDTOs); - customFields = customFields.stream().distinct().collect(Collectors.toList()); - return saveCustomField(caseId, caseCustomFieldMapper, customFields); + customFieldDTOs.addAll(defaultCustomFieldDTOs); + return saveCustomField(caseId, caseCustomFieldMapper, customFieldDTOs.stream().distinct().collect(Collectors.toList())); } private List saveCustomField(String caseId, FunctionalCaseCustomFieldMapper caseCustomFieldMapper, List customFields) {