|
|
@@ -1,5 +1,6 @@
|
|
|
package com.ydtech.modules.admin.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
@@ -16,6 +17,7 @@ import com.ydtech.exception.SystemException;
|
|
|
import com.ydtech.modules.admin.constants.QuMarks;
|
|
|
import com.ydtech.modules.admin.constants.RoleConstants;
|
|
|
import com.ydtech.modules.admin.constants.UserWorkStatus;
|
|
|
+import com.ydtech.modules.admin.dao.SysDeptMapper;
|
|
|
import com.ydtech.modules.admin.dao.SysUserLinkAreaMapper;
|
|
|
import com.ydtech.modules.admin.dao.SysUserMapper;
|
|
|
import com.ydtech.modules.admin.model.*;
|
|
|
@@ -90,6 +92,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
|
|
|
@Autowired
|
|
|
private SysUserLinkAreaMapper sysUserLinkAreaMapper;
|
|
|
+ @Autowired
|
|
|
+ private SysDeptMapper sysDeptMapper;
|
|
|
|
|
|
@Override
|
|
|
public IPage<SysUserBaseVO> findUserList(PageDto<SysUserDto> pageDto) {
|
|
|
@@ -1731,4 +1735,36 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
public List<String> getGroupByUserId(String userId) {
|
|
|
return sysUserMapper.getGroupByUserId(userId);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<SysDeptTreeVo> getTreeDeptUser() {
|
|
|
+ List<SysUser> hxUserList = sysUserMapper.findHxUserListNew();
|
|
|
+ Map<String, List<SysUser>> groupedByDeptId = hxUserList.stream()
|
|
|
+ .collect(Collectors.groupingBy(SysUser::getDeptId, Collectors.toList()));
|
|
|
+
|
|
|
+
|
|
|
+ SysDept sysDept = this.sysDeptService.getById("9");
|
|
|
+ LambdaQueryWrapper<SysDept> lqw = new LambdaQueryWrapper<>();
|
|
|
+ lqw.eq(SysDept::getDelFlag, 0);
|
|
|
+// lqw.isNull(SysDept::getComlevel);
|
|
|
+ lqw.likeRight(SysDept::getId, "9");
|
|
|
+ lqw.orderByAsc(SysDept::getOrderNum);
|
|
|
+ List<SysDept> sysDeptList = sysDeptMapper.selectList(lqw);
|
|
|
+ List<SysDeptTreeVo> sysDeptTreeVos = BeanUtil.copyToList(sysDeptList, SysDeptTreeVo.class);
|
|
|
+ Map<String, List<SysDeptTreeVo>> map = sysDeptTreeVos.stream().sorted(Comparator.comparing(SysDeptTreeVo::getId)).collect(Collectors.groupingBy(SysDeptTreeVo::getParentId));
|
|
|
+ sysDeptTreeVos.forEach(i -> {
|
|
|
+ if(map.get(i.getId()) ==null ){
|
|
|
+ List<SysUser> orDefault = groupedByDeptId.getOrDefault(i.getId(), new ArrayList<>());
|
|
|
+ List<SysDeptTreeVo> sysDeptTreeVos1 = BeanUtil.copyToList(orDefault, SysDeptTreeVo.class);
|
|
|
+ i.setChildren(sysDeptTreeVos1);
|
|
|
+ }else {
|
|
|
+ i.setChildren(map.getOrDefault(i.getId(), new ArrayList<>()));
|
|
|
+ i.setDeptCount(i.getChildren().size());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ sysDeptTreeVos = map.get(sysDept.getParentId());
|
|
|
+
|
|
|
+ return sysDeptTreeVos;
|
|
|
+ }
|
|
|
}
|