Forráskód Böngészése

增加用户树包含离职接口

chenjun 1 éve
szülő
commit
0baac69b6c

+ 5 - 0
zjugis-business/src/main/java/com/zjugis/business/controller/CommonController.java

@@ -48,6 +48,11 @@ public class CommonController {
         return commonService.getUserTree();
     }
 
+    @GetMapping("/user-tree-all")
+    public String userTreeAll() {
+        return commonService.getUserTreeAll();
+    }
+
     @GetMapping("/project-type-tree")
     public CommonResult<List<zTree>> projectTypeTree() {
         return CommonResult.success(commonService.getProjectTypeZTree());

+ 2 - 0
zjugis-business/src/main/java/com/zjugis/business/service/CommonService.java

@@ -41,4 +41,6 @@ public interface CommonService {
      * @return 部门编号集合
      */
     Set<String> getDeptCondition(String deptId);
+
+    String getUserTreeAll();
 }

+ 5 - 0
zjugis-business/src/main/java/com/zjugis/business/service/impl/CommonServiceImpl.java

@@ -164,6 +164,11 @@ public class CommonServiceImpl implements CommonService {
         return deptIds;
     }
 
+    @Override
+    public String getUserTreeAll() {
+        return workflowClient.getUserTreeAll();
+    }
+
     private void convertProjectType2Ztree(List<ProjectTypeNode> tree, String pid,List<zTree>  zTrees){
         for (ProjectTypeNode projectTypeNode : tree) {
             zTree node = new zTree();

+ 2 - 0
zjugis-framework/zjugis-spring-boot-starter-workflow/src/main/java/com/zjugis/framework/workflow/rpc/remote/WorkflowClient.java

@@ -54,4 +54,6 @@ public interface WorkflowClient {
     @PostMapping("/FlowInstanceApi/getFlowUrl")
     CommonResult<String> getFlowUrl(@Valid @RequestBody IFlowInstanceReq iFlowInstanceReq);
 
+    @PostMapping("/Common/getUserTreeAll")
+    String getUserTreeAll();
 }

+ 5 - 0
zjugis-module-system/zjugis-module-system-api/src/main/java/com/zjugis/module/system/api/user/AdminUserApi.java

@@ -78,6 +78,11 @@ public interface AdminUserApi {
     @Parameter(name = "deptIds", description = "部门编号数组", example = "1,2", required = true)
     CommonResult<List<AdminUserRespDTO>> getUserListByDeptIds(@RequestParam("deptIds") Collection<String> deptIds);
 
+    @GetMapping(PREFIX + "/list-all-by-dept-id")
+    @Operation(summary = "获得指定部门的用户数组(包含未开启)")
+    @Parameter(name = "deptIds", description = "部门编号数组", example = "1,2", required = true)
+    CommonResult<List<AdminUserRespDTO>> getUserListAllByDeptIds(@RequestParam("deptIds") Collection<String> deptIds);
+
     @GetMapping(PREFIX + "/list-by-post-id")
     @Operation(summary = "获得指定岗位的用户数组")
     @Parameter(name = "postIds", description = "岗位编号数组", example = "2,3", required = true)

+ 6 - 0
zjugis-module-system/zjugis-module-system-biz/src/main/java/com/zjugis/module/system/api/user/AdminUserApiImpl.java

@@ -116,6 +116,12 @@ public class AdminUserApiImpl implements AdminUserApi {
         return success(UserConvert.INSTANCE.convertList4(users));
     }
 
+    @Override
+    public CommonResult<List<AdminUserRespDTO>> getUserListAllByDeptIds(Collection<String> deptIds) {
+        List<AdminUserDO> users = userService.getUserListAllByDeptIds(deptIds);
+        return success(UserConvert.INSTANCE.convertList4(users));
+    }
+
     @Override
     public CommonResult<List<AdminUserRespDTO>> getUserListByPostIds(Collection<Long> postIds) {
         List<AdminUserDO> users = userService.getUserListByPostIds(postIds);

+ 5 - 0
zjugis-module-system/zjugis-module-system-biz/src/main/java/com/zjugis/module/system/dal/mysql/user/AdminUserMapper.java

@@ -80,4 +80,9 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
     }
 
     void insertUser(AdminUserDO user);
+
+    default List<AdminUserDO>  selectListAllByDeptIds(Collection<String> deptIds) {
+        return selectList(new LambdaQueryWrapperX<AdminUserDO>()
+                .inIfPresent(AdminUserDO::getDeptId, deptIds));
+    }
 }

+ 7 - 0
zjugis-module-system/zjugis-module-system-biz/src/main/java/com/zjugis/module/system/service/user/AdminUserService.java

@@ -274,4 +274,11 @@ public interface AdminUserService {
      * 关闭用户账号
      */
     void closeUser(String userId);
+
+    /**
+     * 获得指定部门的用户数组(包含未开启)
+     * @param deptIds
+     * @return
+     */
+    List<AdminUserDO> getUserListAllByDeptIds(Collection<String> deptIds);
 }

+ 12 - 0
zjugis-module-system/zjugis-module-system-biz/src/main/java/com/zjugis/module/system/service/user/AdminUserServiceImpl.java

@@ -613,6 +613,18 @@ public class AdminUserServiceImpl implements AdminUserService {
         userMapper.updateById(user);
     }
 
+    @Override
+    public List<AdminUserDO> getUserListAllByDeptIds(Collection<String> deptIds) {
+        if (CollUtil.isEmpty(deptIds)) {
+            return Collections.emptyList();
+        }
+        Set<String> userIds = convertSet(userMapper.selectListAllByDeptIds(deptIds), AdminUserDO::getId);
+        if (CollUtil.isEmpty(userIds)) {
+            return Collections.emptyList();
+        }
+        return userMapper.selectBatchIds(userIds);
+    }
+
     /**
      * 对密码进行加密
      *

+ 18 - 0
zjugis-workflow/src/main/java/com/zjugis/z_workflow/controller/CommonController.java

@@ -225,6 +225,24 @@ public class CommonController extends BaseController {
         }
     }
 
+
+    /**
+     * 获取部门树列表,包含用户(未开启)
+     * @Date 2020/4/16 10:43
+     * @Param []
+     * @Return java.lang.String
+     **/
+    @ResponseBody
+    @RequestMapping(method = RequestMethod.POST)
+    public String getUserTreeAll(Boolean iOpen) {
+        try {
+            return ok(callInterfaceService.getOrgTreeAll(iOpen,""));
+        } catch (Exception ex) {
+            log.error(ex.getMessage(),ex);
+            return error(ex.getMessage(), ErrorCode.DEFAULT);
+        }
+    }
+
     /**
      * 下载数据包
      * @param fileName

+ 36 - 0
zjugis-workflow/src/main/java/com/zjugis/z_workflow/service/CallInterfaceService.java

@@ -827,4 +827,40 @@ public class CallInterfaceService {
 			throw ex;
 		}
 	}
+
+	public Object getOrgTreeAll(Boolean iOpen, String deptId) {
+		List<zTree> treeList = new ArrayList();
+		CommonResult<List<DeptRespDTO>> result = StringUtils.isNotBlank(deptId) ? deptApi.getDeptWithChildList(deptId):deptApi.getDeptList();
+		if (result.getCode() != 0) {
+			throw new RuntimeException(result.getMsg());
+		}
+		List<DeptRespDTO> list = result.getData();
+		List<String> deptIds = list.stream().map(DeptRespDTO::getId).collect(Collectors.toList());
+		CommonResult<List<AdminUserRespDTO>> userResult = adminUserApi.getUserListByDeptIds(deptIds);
+		if (userResult.getCode() != 0) {
+			throw new RuntimeException(result.getMsg());
+		}
+		List<AdminUserRespDTO> users = userResult.getData();
+		//遍历数据,转换为需要的格式
+		zTree ztree;
+		for (DeptRespDTO dept : list) {
+			ztree = new zTree();
+			ztree.setId(String.valueOf(dept.getId()));
+			ztree.setName(dept.getName());
+			ztree.setPid((dept.getParentId() == null || "0".equals(dept.getParentId())) ? "" : dept.getParentId());
+			ztree.setType(1);
+			ztree.setOpen(Objects.isNull(iOpen) ? true : iOpen);
+			treeList.add(ztree);
+		}
+		for (AdminUserRespDTO user : users) {
+			ztree = new zTree();
+			ztree.setId(user.getId());
+			ztree.setName(user.getNickname());
+			ztree.setPid(user.getDeptId());
+			ztree.setType(3);
+			ztree.setOpen(Objects.isNull(iOpen) ? true : iOpen);
+			treeList.add(ztree);
+		}
+		return treeList;
+	}
 }