组织变更

This commit is contained in:
Administrator 2025-08-08 17:51:07 +08:00
parent 3c300ea1e3
commit 6ac7e17b5f
1 changed files with 16 additions and 9 deletions

View File

@ -53,26 +53,31 @@ public class SyncDepartmentChanges implements EsbServerlessRpcRemoteInterface {
*/
List<Map<String, Object>> originalTree = getOriginalTree("0", bgsxrq);
List<Map<String, Object>> changedTree = getOriginalTree("1", bgsxrq);
log.error("SyncDepartmentChanges.originalTree:{}", originalTree);
log.error("SyncDepartmentChanges.changedTree:{}", changedTree);
// 比对并获取差异
List<Map<String, Object>> differences = findDifferences(originalTree, changedTree);
log.error("SyncDepartmentChanges.differences:{}", differences);
/**
* 需新增的部门
*/
List<Map<String, Object>> addedChanges = differences.stream().filter(map -> "added".equals(map.get("type"))).collect(Collectors.toList());
log.error("SyncDepartmentChanges.addedChanges:{}", addedChanges);
/**
* 需修改的部门
*/
List<Map<String, Object>> modifiedChanges = differences.stream().filter(map -> "modified".equals(map.get("type"))).collect(Collectors.toList());
log.error("SyncDepartmentChanges.modifiedChanges:{}", modifiedChanges);
/**
* 需删除的部门
*/
List<Map<String, Object>> deletedChanges = differences.stream().filter(map -> "deleted".equals(map.get("type"))).collect(Collectors.toList());
log.error("SyncDepartmentChanges.deletedChanges:{}", deletedChanges);
/**
@ -96,15 +101,17 @@ public class SyncDepartmentChanges implements EsbServerlessRpcRemoteInterface {
if (CollectionUtils.isNotEmpty(addedChanges)) {
for (Map<String, Object> addedChange : addedChanges) {
String changed = null!=addedChange.get("changed")?String.valueOf(addedChange.get("changed").toString()):"";
log.error("SyncDepartmentChanges111.changed:{}", changed);
// 去掉大括号并按逗号分割
String[] entries = changed.substring(1, changed.length() - 1).split(", ");
// 使用 Stream 转换为 Map
Map<String, String> map = Arrays.stream(entries)
.map(entry -> entry.split("="))
.map(entry -> entry.split("=", 2)) // 防止值里有 "="
.collect(Collectors.toMap(
entry -> entry[0], // key
entry -> entry[1] // value
arr -> arr[0], // key
arr -> arr.length > 1 ? arr[1] : "" // value处理空值
));
log.error("SyncDepartmentChanges111.map:{}", map);
addSysDept(map, apiInfo, host, form_id, layout_id);
}
}
@ -129,10 +136,10 @@ public class SyncDepartmentChanges implements EsbServerlessRpcRemoteInterface {
String[] entries = modified.substring(1, modified.length() - 1).split(", ");
// 使用 Stream 转换为 Map
Map<String, String> map = Arrays.stream(entries)
.map(entry -> entry.split("="))
.map(entry -> entry.split("=", 2)) // 防止值里有 "="
.collect(Collectors.toMap(
entry -> entry[0], // key
entry -> entry[1] // value
arr -> arr[0], // key
arr -> arr.length > 1 ? arr[1] : "" // value处理空值
));
updateSysDept(map, apiInfo, host, form_id, layout_id);
}
@ -145,10 +152,10 @@ public class SyncDepartmentChanges implements EsbServerlessRpcRemoteInterface {
String[] entries = modified.substring(1, modified.length() - 1).split(", ");
// 使用 Stream 转换为 Map
Map<String, String> map = Arrays.stream(entries)
.map(entry -> entry.split("="))
.map(entry -> entry.split("=", 2)) // 防止值里有 "="
.collect(Collectors.toMap(
entry -> entry[0], // key
entry -> entry[1] // value
arr -> arr[0], // key
arr -> arr.length > 1 ? arr[1] : "" // value处理空值
));
updateSysDept(map, apiInfo, host, form_id, layout_id);
}