This commit is contained in:
2024-10-24 10:13:48 +08:00
parent 054fa20bab
commit 0eeedf8f35
4 changed files with 11 additions and 16 deletions

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNode;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -166,8 +167,8 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
return deptList.stream()
.filter(deptVO -> deptVO.getId().equals(deptIndex))
.peek(deptFirst -> {
if (!Objects.isNull(deptFirst.getPid())){
deptFirst.setLevel(deptFirst.getPids().split(",").length - 1);
if (!Objects.isNull(deptFirst.getPid())) {
deptFirst.setLevel(deptFirst.getPids().split(StrPool.COMMA).length - 1);
}
deptFirst.setChildren(getChildren(deptFirst, deptList));
})
@@ -182,7 +183,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
}
List<String> useMonitorIds = deptTem.stream().map(Dept::getId).collect(Collectors.toList());
List<String> resultDeptId = deptTem.stream().map(item -> item.getPids().split(",")).flatMap(Arrays::stream).distinct().collect(Collectors.toList());
List<String> resultDeptId = deptTem.stream().map(item -> item.getPids().split(StrPool.COMMA)).flatMap(Arrays::stream).distinct().collect(Collectors.toList());
resultDeptId.addAll(useMonitorIds);
List<Integer> deptType = WebUtil.filterDeptType();
@@ -265,7 +266,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
@Override
public boolean selectPid(List<String> ids) {
// 判断是否有子节点
// 判断是否有子节点
List<Dept> dept = this.baseMapper.selectPid(ids, DataStateEnum.ENABLE.getCode());
// 判断是否存在绑定关系
HttpResult<Boolean> deptLineVOHttpResult = deptLineFeignClient.selectDeptBindLines(ids);
@@ -453,7 +454,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
*/
@Override
public List<DeptDTO> getDepSonDetailByDeptId(String deptId) {
List<Dept> result ;
List<Dept> result;
LambdaQueryWrapper<Dept> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(Dept::getPid, deptId).
@@ -480,7 +481,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
List<Dept> upDeptList = allDept.stream()
.filter(dept -> dept.getId().equals(deptId))
.collect(Collectors.toList());
if(CollectionUtil.isEmpty(upDeptList)){
if (CollectionUtil.isEmpty(upDeptList)) {
return new ArrayList<>();
}
upDeptList.addAll(getParentDept(upDeptList, allDept));
@@ -490,12 +491,13 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
/**
* 找出当前部门的父级部门
*
* @param upDeptList 当前部门
* @param allDept 所有部门
* @param allDept 所有部门
* @return 父级部门
*/
private List<Dept> getParentDept(List<Dept> upDeptList, List<Dept> allDept) {
if(CollectionUtil.isEmpty(upDeptList)){
if (CollectionUtil.isEmpty(upDeptList)) {
return new ArrayList<>();
} else {
List<Dept> parentDeptList = new ArrayList<>();