dept_full_name
This commit is contained in:
parent
ff815314ca
commit
2e1dba94ed
|
|
@ -351,11 +351,8 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
String oldAncestors = oldDept.getAncestors();
|
||||
dept.setAncestors(newAncestors);
|
||||
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
||||
String newDeptFullNames = newParentDept.getDeptFullName() + "/" + dept.getDeptName();
|
||||
String oldDeptFullNames = oldDept.getDeptFullName();
|
||||
dept.setDeptFullName(newDeptFullNames);
|
||||
updateDeptChildrenFullName(dept.getDeptId(), newDeptFullNames, oldDeptFullNames);
|
||||
}
|
||||
updateDeptChildrenFullName(dept, newParentDept);
|
||||
int result = deptMapper.updateDept(dept);
|
||||
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
|
||||
&& !StringUtils.equals("0", dept.getAncestors()))
|
||||
|
|
@ -409,15 +406,34 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
}
|
||||
}
|
||||
|
||||
public void updateDeptChildrenFullName(Long deptId, String newFullNames, String oldFullNames)
|
||||
public void updateDeptChildrenFullName(SysDept dept, SysDept newParentDept)
|
||||
{
|
||||
List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
|
||||
for (SysDept child : children)
|
||||
{
|
||||
child.setDeptFullName(child.getDeptFullName().replaceFirst(oldFullNames, newFullNames));
|
||||
if (Objects.isNull(newParentDept)) {
|
||||
dept.setDeptFullName(dept.getDeptName());
|
||||
} else {
|
||||
dept.setDeptFullName(newParentDept.getDeptFullName() + "/" + dept.getDeptName());
|
||||
}
|
||||
if (children.size() > 0)
|
||||
{
|
||||
List<SysDept> children = deptMapper.selectChildrenDeptById(dept.getDeptId());
|
||||
List<SysDept> fullDeptList = deptMapper.selectDeptList(new SysDept());
|
||||
for (SysDept innerDept : fullDeptList) {
|
||||
if (innerDept.getDeptId().equals(dept.getDeptId())) {
|
||||
innerDept.setDeptName(dept.getDeptName());
|
||||
}
|
||||
}
|
||||
for (SysDept child : children) {
|
||||
if (child.getDeptId().equals(dept.getDeptId())) {
|
||||
child.setDeptName(dept.getDeptName());
|
||||
}
|
||||
}
|
||||
for (SysDept child : children) {
|
||||
String deptAncestors = child.getAncestors();
|
||||
deptAncestors = deptAncestors.replaceFirst("0,", "").replaceAll(",", "/");
|
||||
for (SysDept innerDept : fullDeptList) {
|
||||
deptAncestors = deptAncestors.replace(String.valueOf(innerDept.getDeptId()), innerDept.getDeptName());
|
||||
}
|
||||
child.setDeptFullName(deptAncestors + "/" + child.getDeptName());
|
||||
}
|
||||
if (children.size() > 0) {
|
||||
deptMapper.updateDeptChildrenFullName(children);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue