|
@@ -1636,6 +1636,95 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg listAllMembNew(HttpServletRequest request, String keyword, String cursor) throws Exception {
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("TOKEN")).getCompanyId();
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ List<HashMap> userMapList = new ArrayList<>();
|
|
|
+ //通讯录查询人员
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
|
|
|
+ if (StringUtils.isNotBlank(keyword) && wxCorpInfo!=null && wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ HashMap<String, List> result = wxCorpInfoService.getOpenId(wxCorpInfo.getCorpid(), keyword, cursor,0,20);
|
|
|
+ List users = result.get("user");
|
|
|
+ List depts = result.get("dept");
|
|
|
+ if (users.size()!=0){
|
|
|
+ List<User> realUser = userMapper.selectList(new QueryWrapper<User>().in("corpwx_userid", users));
|
|
|
+ if (realUser.size()!=0){
|
|
|
+ List<DepartmentVO> listById = new ArrayList<>();
|
|
|
+ for (User item : realUser) {
|
|
|
+ HttpRespMsg departmentListById = getDepartmentListById(item);
|
|
|
+ listById = (List<DepartmentVO>) departmentListById.data;
|
|
|
+ if (listById.size()==0){
|
|
|
+ //加上未分配的部门
|
|
|
+ DepartmentVO unAssignedDeptById = new DepartmentVO();
|
|
|
+ unAssignedDeptById.setId(0);
|
|
|
+ //unAssignedDept.setLabel("未分配");
|
|
|
+ unAssignedDeptById.setLabel(MessageUtils.message("department.noDistribution"));
|
|
|
+ listById.add(unAssignedDeptById);
|
|
|
+ }
|
|
|
+ //封装员工信息
|
|
|
+ HashMap<String, Object> user = new HashMap<String, Object>();
|
|
|
+ user.put("id", item.getId());
|
|
|
+ user.put("name", item.getName());
|
|
|
+ user.put("departmentId", item.getDepartmentId());
|
|
|
+ userMapList.add(user);
|
|
|
+ fillDeptUser(listById, userMapList);
|
|
|
+ }
|
|
|
+// HashMap<String, Object> data = new HashMap<>();
|
|
|
+// data.put("data",listById);
|
|
|
+// data.put("nextCursor","");
|
|
|
+ msg.data = listById;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (depts.size()!=0){
|
|
|
+ List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().in("corpwx_deptid", depts).eq("company_id",companyId));
|
|
|
+ List<Department> allDepartmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",companyId));
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).eq("is_active",1));
|
|
|
+ List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("company_id", companyId));
|
|
|
+ //结果列表
|
|
|
+ List<DepartmentVO> list = new ArrayList<>();
|
|
|
+ List<Department> rootDepartments = departmentList.stream().filter(dept -> dept.getSuperiorId() == null).collect(Collectors.toList());
|
|
|
+ rootDepartments.forEach(root->{
|
|
|
+ DepartmentVO rootDeptVO = formatDepartmentToVO(root, departmentOtherManagerList);
|
|
|
+ list.add(rootDeptVO);
|
|
|
+ fillSubDepartmentList(allDepartmentList, rootDeptVO, departmentOtherManagerList);
|
|
|
+ });
|
|
|
+ //处理部门下人员列表
|
|
|
+ List<DepartmentVO> userListWithDept = getUserListWithDept(userList, list);
|
|
|
+// HashMap<String, Object> data = new HashMap<>();
|
|
|
+// data.put("data",userListWithDept);
|
|
|
+// data.put("nextCursor","");
|
|
|
+ msg.data = userListWithDept;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ ArrayList<Object> emptyList = new ArrayList<>();
|
|
|
+ msg.data = emptyList;
|
|
|
+ return msg;
|
|
|
+ }else {
|
|
|
+ HttpRespMsg departmentList = departmentService.getDepartmentList(request);
|
|
|
+ List<DepartmentVO> list = (List<DepartmentVO>) departmentList.data;
|
|
|
+ //加上未分配的部门
|
|
|
+ DepartmentVO unAssignedDept = new DepartmentVO();
|
|
|
+ unAssignedDept.setId(0);
|
|
|
+ //unAssignedDept.setLabel("未分配");
|
|
|
+ unAssignedDept.setLabel(MessageUtils.message("department.noDistribution"));
|
|
|
+ list.add(unAssignedDept);
|
|
|
+ //获取公司全部人员
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).eq("is_active", 1));
|
|
|
+ for (User u : userList) {
|
|
|
+ HashMap<String, Object> user = new HashMap<String, Object>();
|
|
|
+ user.put("id", u.getId());
|
|
|
+ user.put("name", u.getName());
|
|
|
+ user.put("departmentId", u.getDepartmentId());
|
|
|
+ userMapList.add(user);
|
|
|
+ }
|
|
|
+ fillDeptUser(list, userMapList);
|
|
|
+ msg.data = list;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 递归对返回的部门数据进行排序
|
|
|
* @param list
|