|
@@ -31,19 +31,60 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public List<SysDept> findTree(String deptId) {
|
|
|
|
|
- SysDept sysDept = getById(deptId);
|
|
|
|
|
|
|
+ public List<SysDept> findTree(String deptId,String managementSource) {
|
|
|
|
|
+ if(null == deptId || "".equals(deptId)){
|
|
|
|
|
+ deptId = "9";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ SysDept sysDept = getById(deptId);
|
|
|
LambdaQueryWrapper<SysDept> lqw = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<SysDept> lqw = new LambdaQueryWrapper<>();
|
|
|
lqw.eq(SysDept::getDelFlag, 0);
|
|
lqw.eq(SysDept::getDelFlag, 0);
|
|
|
lqw.likeRight(SysDept::getId, deptId);
|
|
lqw.likeRight(SysDept::getId, deptId);
|
|
|
lqw.orderByDesc(SysDept::getOrderNum);
|
|
lqw.orderByDesc(SysDept::getOrderNum);
|
|
|
List<SysDept> sysDeptList = list(lqw);
|
|
List<SysDept> sysDeptList = list(lqw);
|
|
|
- Map<String, List<SysDept>> map = sysDeptList.stream().collect(Collectors.groupingBy(SysDept::getParentId));
|
|
|
|
|
- sysDeptList.forEach(i -> i.setChildren(map.getOrDefault(i.getId(), new ArrayList<>())));
|
|
|
|
|
- return map.get(sysDept.getParentId());
|
|
|
|
|
|
|
+ //判断机构来源条件 进行遍历
|
|
|
|
|
+ if(null != managementSource && !"".equals(managementSource)){
|
|
|
|
|
+ lqw.eq(SysDept::getManagementSource,managementSource);
|
|
|
|
|
+ //条件
|
|
|
|
|
+ List<SysDept> conditionList = list(lqw);
|
|
|
|
|
+ Map<String, List<SysDept>> conditionMap = conditionList.stream().collect(Collectors.groupingBy(SysDept::getParentId));
|
|
|
|
|
+ Map<String, List<SysDept>> map = conditionList.stream().collect(Collectors.groupingBy(SysDept::getParentId));
|
|
|
|
|
+ //先查第6层
|
|
|
|
|
+ conditionList.forEach(i ->
|
|
|
|
|
+ i.setChildren(map.getOrDefault(i.getId(), new ArrayList<>()))
|
|
|
|
|
+ );
|
|
|
|
|
+ List<SysDept> result = new ArrayList<>();
|
|
|
|
|
+ //再查前4层
|
|
|
|
|
+ int level = 5;
|
|
|
|
|
+ while(level > 0){
|
|
|
|
|
+ result = recursion(sysDeptList, conditionMap);
|
|
|
|
|
+ conditionMap = result.stream().collect(Collectors.groupingBy(SysDept::getParentId));
|
|
|
|
|
+ level--;
|
|
|
|
|
+ }
|
|
|
|
|
+ sysDeptList = result;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ Map<String, List<SysDept>> map = sysDeptList.stream().collect(Collectors.groupingBy(SysDept::getParentId));
|
|
|
|
|
+ sysDeptList.forEach(i -> i.setChildren(map.getOrDefault(i.getId(), new ArrayList<>())));
|
|
|
|
|
+ sysDeptList = map.get(sysDept.getParentId());
|
|
|
|
|
+ }
|
|
|
|
|
+ return sysDeptList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private List<SysDept> recursion(List<SysDept> sysDeptList, Map<String, List<SysDept>> conditionMap) {
|
|
|
|
|
+ List<SysDept> result = new ArrayList<>();
|
|
|
|
|
+ sysDeptList.forEach(i ->
|
|
|
|
|
+ conditionMap.forEach((key,value) -> {
|
|
|
|
|
+ if (i.getId().equals(key)) {
|
|
|
|
|
+ if(i.getChildren() == null){
|
|
|
|
|
+ i.setChildren(new ArrayList<>());
|
|
|
|
|
+ }
|
|
|
|
|
+ i.getChildren().addAll(value);
|
|
|
|
|
+ result.add(i);
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ );
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<SysDept> getUserList(String deptId) {
|
|
public List<SysDept> getUserList(String deptId) {
|
|
@@ -121,10 +162,11 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
|
|
|
@Override
|
|
@Override
|
|
|
public PageResult<SysDept> findSubDepts(PageRequest pageRequest) {
|
|
public PageResult<SysDept> findSubDepts(PageRequest pageRequest) {
|
|
|
String id = pageRequest.getColumnFilterValue(pageRequest, "id");
|
|
String id = pageRequest.getColumnFilterValue(pageRequest, "id");
|
|
|
-
|
|
|
|
|
|
|
+ String managementSource = pageRequest.getColumnFilterValue(pageRequest, "managementSource");
|
|
|
Page<SysDept> p = PageRequest.buildPageRequest(pageRequest);
|
|
Page<SysDept> p = PageRequest.buildPageRequest(pageRequest);
|
|
|
LambdaQueryWrapper<SysDept> lqw = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<SysDept> lqw = new LambdaQueryWrapper<>();
|
|
|
lqw.eq(StringUtils.isNotEmpty(id), SysDept::getParentId, id);
|
|
lqw.eq(StringUtils.isNotEmpty(id), SysDept::getParentId, id);
|
|
|
|
|
+ lqw.eq(StringUtils.isNotEmpty(managementSource), SysDept::getManagementSource, managementSource);
|
|
|
IPage<SysDept> pResult = page(p, lqw);
|
|
IPage<SysDept> pResult = page(p, lqw);
|
|
|
//传入查询条件
|
|
//传入查询条件
|
|
|
return PageResult.buildPageResult(pResult);
|
|
return PageResult.buildPageResult(pResult);
|