From 8c94232e63a6f28682e629dbfa92873d3cbf964a Mon Sep 17 00:00:00 2001 From: aijinhui <aijinhui> Date: 星期五, 22 九月 2023 11:11:39 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java | 69 +++++++++++++++++++++++++++++++++- 1 files changed, 66 insertions(+), 3 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index a7e0212..85bdae2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -4,6 +4,8 @@ import java.util.stream.Collectors; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.common.core.domain.HealthVo; +import com.ruoyi.common.core.domain.TreeDeptWell; import com.ruoyi.common.core.domain.TreeSelectWell; import org.springframework.stereotype.Service; import com.ruoyi.common.annotation.DataScope; @@ -358,10 +360,71 @@ } @Override - public List<TreeSelectWell> wellTree(List<SysDept> depts) { - List<SysDept> deptTrees = buildDeptTree(depts); - return deptTrees.stream().map(TreeSelectWell::new).collect(Collectors.toList()); + public List<SysDept> allByUser(List<Long> deptList) { + QueryWrapper<SysDept> queryWrapper = new QueryWrapper(); + queryWrapper.in("dept_id",deptList); + return deptMapper.selectList(queryWrapper); } + @Override + public List<TreeDeptWell> wellTree(List<TreeDeptWell> depts) { + List<TreeDeptWell> deptTrees = buildDeptWellTree(depts); + return deptTrees; +// return deptTrees.stream().map(TreeSelectWell::new).collect(Collectors.toList()); + } + @Override + public List<TreeDeptWell> buildDeptWellTree(List<TreeDeptWell> depts) + { + List<TreeDeptWell> returnList = new ArrayList<TreeDeptWell>(); + List<Long> tempList = depts.stream().map(TreeDeptWell::getDeptId).collect(Collectors.toList()); + for (TreeDeptWell dept : depts) + { + // 濡傛灉鏄《绾ц妭鐐�, 閬嶅巻璇ョ埗鑺傜偣鐨勬墍鏈夊瓙鑺傜偣 + if (!tempList.contains(dept.getParentId())) + { + recursionFnWell(depts, dept); + returnList.add(dept); + } + } + if (returnList.isEmpty()) + { + returnList = depts; + } + return returnList; + } + + 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)) + { + recursionFnWell(list, tChild); + } + } + } + + private List<TreeDeptWell> getChildListWell(List<TreeDeptWell> list, TreeDeptWell t) + { + List<TreeDeptWell> tlist = new ArrayList<TreeDeptWell>(); + Iterator<TreeDeptWell> it = list.iterator(); + while (it.hasNext()) + { + TreeDeptWell n = (TreeDeptWell) it.next(); + if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) + { + tlist.add(n); + } + } + return tlist; + } + + private boolean hasChildWell(List<TreeDeptWell> list, TreeDeptWell t) + { + return getChildListWell(list, t).size() > 0; + } } -- Gitblit v1.9.3