| | |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.common.core.domain.TreeDeptWell; |
| | | import com.ruoyi.common.core.domain.TreeSelectWell; |
| | | import com.ruoyi.common.core.domain.*; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.TreeSelect; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<TreeSelectWell> wellTree(List<TreeDeptWell> depts) { |
| | | public List<TreeDeptWell> wellTree(List<TreeDeptWell> depts) { |
| | | List<TreeDeptWell> deptTrees = buildDeptWellTree(depts); |
| | | return deptTrees.stream().map(TreeSelectWell::new).collect(Collectors.toList()); |
| | | return deptTrees; |
| | | // return deptTrees.stream().map(TreeSelectWell::new).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | private void recursionFnWell(List<TreeDeptWell> list, TreeDeptWell t) |
| | | { |
| | | // 得到子节点列表 |
| | | List<TreeDeptWell> childList = getChildListWell(list, t); |
| | | t.setChildren(childList); |
| | | for (TreeDeptWell tChild : childList) |
| | | { |
| | | if (hasChildWell(list, tChild)) |
| | | if(t.getId() == null){ |
| | | List<TreeDeptWell> childList = getChildListWell(list, t); |
| | | t.setChildren(childList); |
| | | for (TreeDeptWell tChild : childList) |
| | | { |
| | | recursionFnWell(list, tChild); |
| | | if (hasChildWell(list, tChild)) |
| | | { |
| | | recursionFnWell(list, tChild); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | return getChildListWell(list, t).size() > 0; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<DeptUserTree> deptUserTree(List<DeptUserTree> depts) |
| | | { |
| | | List<DeptUserTree> returnList = new ArrayList<>(); |
| | | List<Long> tempList = depts.stream().map(DeptUserTree::getDeptId).collect(Collectors.toList()); |
| | | for (DeptUserTree dept : depts) |
| | | { |
| | | // 如果是顶级节点, 遍历该父节点的所有子节点 |
| | | if (!tempList.contains(dept.getParentId())) |
| | | { |
| | | recursionFnDeptUserTree(depts, dept); |
| | | returnList.add(dept); |
| | | } |
| | | } |
| | | if (returnList.isEmpty()) |
| | | { |
| | | returnList = depts; |
| | | } |
| | | return returnList; |
| | | } |
| | | |
| | | private void recursionFnDeptUserTree(List<DeptUserTree> list, DeptUserTree t) |
| | | { |
| | | // 得到子节点列表 |
| | | if(t.getUserId()==null){ |
| | | List<DeptUserTree> childList = getChildListDeptUserTree(list, t); |
| | | t.setChildren(childList); |
| | | for (DeptUserTree tChild : childList) { |
| | | if (hasChildDeptUserTree(list, tChild)) { |
| | | recursionFnDeptUserTree(list, tChild); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private List<DeptUserTree> getChildListDeptUserTree(List<DeptUserTree> list, DeptUserTree t) |
| | | { |
| | | List<DeptUserTree> tlist = new ArrayList<>(); |
| | | Iterator<DeptUserTree> it = list.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | DeptUserTree n = (DeptUserTree) it.next(); |
| | | if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) |
| | | { |
| | | tlist.add(n); |
| | | } |
| | | } |
| | | return tlist; |
| | | } |
| | | |
| | | private boolean hasChildDeptUserTree(List<DeptUserTree> list, DeptUserTree t) |
| | | { |
| | | return getChildListDeptUserTree(list, t).size() > 0; |
| | | } |
| | | } |