|
|
|
@ -56,7 +56,7 @@ public class UpdateDeptTask { |
|
|
|
for (Dept dept : deptList) { |
|
|
|
List<String> ancs = new ArrayList<>(); |
|
|
|
ancs = convertAncestors(dept, deptList, ancs); |
|
|
|
ancs.add("0"); |
|
|
|
ancs.add(null); |
|
|
|
Collections.reverse(ancs); |
|
|
|
String anc = String.join(",", ancs); |
|
|
|
dept.setAncestors(anc); |
|
|
|
@ -67,6 +67,7 @@ public class UpdateDeptTask { |
|
|
|
|
|
|
|
private List<String> convertAncestors(Dept dept, List<Dept> deptList, List<String> ancs) { |
|
|
|
for (Dept tmp : deptList) { |
|
|
|
if (StringUtils.isEmpty(dept.getParentId()) || StringUtils.isEmpty(dept.getDeptId())) { return ancs; } |
|
|
|
if (dept.getParentId().equals(tmp.getDeptId()) && !dept.getDeptId().equals(tmp.getDeptId())) { |
|
|
|
ancs.add(tmp.getDeptId()); |
|
|
|
return convertAncestors(tmp, deptList, ancs); |
|
|
|
|