fix: 优化逻辑

This commit is contained in:
tangwei 2026-06-25 17:29:13 +08:00
parent a3eac3a4ad
commit 0c11fade58

View File

@ -258,10 +258,11 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateEngInfo(Map<String, Object> engInfoPatch, String source) throws JsonMappingException {
if (engInfoPatch == null || engInfoPatch.isEmpty()) {
Map<String, Object> filteredPatch = filterEngInfoPatchFields(engInfoPatch);
if (filteredPatch.isEmpty()) {
return false;
}
String stcd = toTextValue(engInfoPatch.get("stcd"));
String stcd = toTextValue(filteredPatch.get("stcd"));
if (!StringUtils.hasText(stcd)) {
return false;
}
@ -270,9 +271,9 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
return false;
}
SdEngInfoBH after = BeanUtil.copyProperties(before, SdEngInfoBH.class);
objectMapper.updateValue(after, engInfoPatch);
objectMapper.updateValue(after, filteredPatch);
fillRelatedNameFields(after);
boolean result = updateEngInfoByPatch(stcd, after, engInfoPatch);
boolean result = updateEngInfoByPatch(stcd, after, filteredPatch);
if (result) {
msOperationLogService.recordEngUpdateLog(before, after, source);
}
@ -431,6 +432,26 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
return value == null ? null : String.valueOf(value);
}
private Map<String, Object> filterEngInfoPatchFields(Map<String, Object> engInfoPatch) {
Map<String, Object> filteredPatch = new LinkedHashMap<>();
if (engInfoPatch == null || engInfoPatch.isEmpty()) {
return filteredPatch;
}
Set<String> validFieldNames = new HashSet<>();
for (Field field : SdEngInfoBH.class.getDeclaredFields()) {
if ("serialVersionUID".equals(field.getName())) {
continue;
}
validFieldNames.add(field.getName());
}
for (Map.Entry<String, Object> entry : engInfoPatch.entrySet()) {
if (validFieldNames.contains(entry.getKey())) {
filteredPatch.put(entry.getKey(), entry.getValue());
}
}
return filteredPatch;
}
private boolean isLinkedNameFieldPatched(String fieldName, Map<String, Object> engInfoPatch) {
for (Map.Entry<String, String> entry : ENG_CODE_NAME_FIELD_MAP.entrySet()) {
if (entry.getValue().equals(fieldName) && engInfoPatch.containsKey(entry.getKey())) {