|
@@ -0,0 +1,266 @@
|
|
|
+package com.idea.oa.searchuser;
|
|
|
+
|
|
|
+import com.rockstar.biz.model.BizMain;
|
|
|
+import com.rockstar.biz.model.BizUser;
|
|
|
+import com.rockstar.biz.service.BizMainService;
|
|
|
+import com.rockstar.biz.service.BizUserService;
|
|
|
+import com.rockstar.frame.model.FramePost;
|
|
|
+import com.rockstar.frame.model.FrameUser;
|
|
|
+import com.rockstar.frame.model.FrameUserExample;
|
|
|
+import com.rockstar.frame.service.FramePostService;
|
|
|
+import com.rockstar.frame.service.FrameUserService;
|
|
|
+import com.rockstar.shiro.util.ShiroUtils;
|
|
|
+import com.rockstar.system.model.SysDept;
|
|
|
+import com.rockstar.system.service.SysDeptService;
|
|
|
+import com.rockstar.util.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class FrameExclusiveUserService {
|
|
|
+
|
|
|
+ //文件mapper
|
|
|
+ @Autowired
|
|
|
+ private SysDeptService sysDeptService;
|
|
|
+ @Autowired
|
|
|
+ private FrameUserService frameUserService;
|
|
|
+ @Autowired
|
|
|
+ private FramePostService framePostService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BizMainService bizMainService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BizUserService bizUserService;
|
|
|
+
|
|
|
+ //按组织
|
|
|
+ public List<Map<String, Object>> deptRecursion(String parentid,String groupId){
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>();
|
|
|
+ SysDept reqData = new SysDept();
|
|
|
+ reqData.setGroupId(groupId);
|
|
|
+ reqData.setParentId(parentid);
|
|
|
+ List<SysDept> deptList = sysDeptService.listAll(reqData);
|
|
|
+ FrameUser fuser = null;
|
|
|
+ if(deptList.size() > 0){
|
|
|
+ for (SysDept sysDept : deptList) {
|
|
|
+ //部门
|
|
|
+ Map<String, Object> dept = new HashMap<>();
|
|
|
+ dept.put("id", sysDept.getId());
|
|
|
+ dept.put("label", sysDept.getDeptName());
|
|
|
+ dept.put("selectType", false);
|
|
|
+ dept.put("children", deptRecursion(sysDept.getId(),groupId));
|
|
|
+ result.add(dept);
|
|
|
+
|
|
|
+ }
|
|
|
+ //人员
|
|
|
+ fuser = new FrameUser();
|
|
|
+ fuser.setDelFlag("0");
|
|
|
+ fuser.setStatus("1");
|
|
|
+ fuser.setDepartment(parentid);
|
|
|
+ List<FrameUser> userList = frameUserService.listAll(fuser, null);
|
|
|
+ if (userList.size() > 0) {
|
|
|
+ for (FrameUser frameUser : userList) {
|
|
|
+ Map<String, Object> user = new HashMap<>();
|
|
|
+ user.put("id", frameUser.getId());
|
|
|
+ user.put("label", frameUser.getTruename());
|
|
|
+ user.put("selectType", true);
|
|
|
+ result.add(user);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //人员
|
|
|
+ fuser = new FrameUser();
|
|
|
+ fuser.setDelFlag("0");
|
|
|
+ fuser.setStatus("1");
|
|
|
+ fuser.setGroupId(groupId);
|
|
|
+ fuser.setDepartment(parentid);
|
|
|
+ List<FrameUser> userList = frameUserService.listAll(fuser, null);
|
|
|
+ if (userList.size() > 0) {
|
|
|
+ for (FrameUser frameUser : userList) {
|
|
|
+ Map<String, Object> user = new HashMap<>();
|
|
|
+ user.put("id", frameUser.getId());
|
|
|
+ user.put("label", frameUser.getTruename());
|
|
|
+ user.put("selectType", true);
|
|
|
+ result.add(user);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //按岗位
|
|
|
+ public List<Map<String, Object>> postRecursion(String groupId){
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>();
|
|
|
+ FramePost reqDate = new FramePost();
|
|
|
+ reqDate.setStatus("0");
|
|
|
+ reqDate.setGroupId(groupId);
|
|
|
+ List<FramePost> postList = framePostService.listAll(reqDate, null);
|
|
|
+ for (FramePost framePost : postList) {
|
|
|
+ Map<String, Object> post = new HashMap<>();
|
|
|
+ post.put("id", framePost.getId());
|
|
|
+ post.put("label", framePost.getPostName());
|
|
|
+ post.put("selectType", false);
|
|
|
+ //组织人员
|
|
|
+ FrameUser postFrameUser = new FrameUser();
|
|
|
+ postFrameUser.setDelFlag("0");
|
|
|
+ postFrameUser.setStatus("1");
|
|
|
+ postFrameUser.setGroupId(groupId);
|
|
|
+ postFrameUser.setPosts(framePost.getId());
|
|
|
+ List<FrameUser> userList = frameUserService.listAll(postFrameUser, framePost.getId());
|
|
|
+ if(userList.size()>0){
|
|
|
+ List<Map<String, Object>> children = new ArrayList<>();
|
|
|
+ for (FrameUser frameUser : userList) {
|
|
|
+ Map<String, Object> user = new HashMap<>();
|
|
|
+ user.put("id", frameUser.getId());
|
|
|
+ user.put("label", frameUser.getTruename());
|
|
|
+ user.put("selectType", true);
|
|
|
+ children.add(user);
|
|
|
+ }
|
|
|
+ post.put("children", children);
|
|
|
+ }
|
|
|
+ result.add(post);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ //我的下属
|
|
|
+ public List<Map<String, Object>> userRecursion(FrameUser user){
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>();
|
|
|
+ FrameUserExample reqDate = new FrameUserExample();
|
|
|
+ FrameUserExample.Criteria criteria = reqDate.createCriteria();
|
|
|
+ List<String> strings = frameUserService.genStaffUserIds(user.getId());
|
|
|
+ Iterator<String> iter = strings.iterator();
|
|
|
+ while (iter.hasNext()) {
|
|
|
+ String item = iter.next();
|
|
|
+ if (item.equals(user.getId())) {
|
|
|
+ iter.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ criteria.andStatusEqualTo("1");
|
|
|
+ criteria.andIdIn(strings);
|
|
|
+ List<FrameUser> userList = frameUserService.selectByExample(reqDate);
|
|
|
+ if(userList.size() > 0){
|
|
|
+ for (FrameUser frameUser : userList) {
|
|
|
+ Map<String, Object> userMap = new HashMap<>();
|
|
|
+ userMap.put("id", frameUser.getId());
|
|
|
+ userMap.put("label", frameUser.getTruename());
|
|
|
+ userMap.put("selectType", true);
|
|
|
+ result.add(userMap);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }else{
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<Map<String, Object>> getUserListGroupType(String groupType,String groupId) {
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> all = new ArrayList<>();
|
|
|
+ Map<String,Object> allMap = new HashMap<>();
|
|
|
+ allMap.put("id", "0");
|
|
|
+ allMap.put("label", "全部");
|
|
|
+ allMap.put("selectType", false);
|
|
|
+ if("1".equals(groupType)){ //按组织
|
|
|
+ all = deptRecursion("0",groupId);
|
|
|
+ allMap.put("children", all);
|
|
|
+ result.add(allMap);
|
|
|
+ }else if("2".equals(groupType)){
|
|
|
+ //按岗位
|
|
|
+ all = postRecursion(groupId);
|
|
|
+ allMap.put("children", all);
|
|
|
+ result.add(allMap);
|
|
|
+ }else if("3".equals(groupType)){
|
|
|
+ //我的下属
|
|
|
+ FrameUser nowUser = frameUserService.selectByPrimaryKey(ShiroUtils.getUserId());
|
|
|
+ if(null != nowUser){
|
|
|
+ all = userRecursion(nowUser);
|
|
|
+ allMap.put("children", all);
|
|
|
+ result.add(allMap);
|
|
|
+ }
|
|
|
+ }else if("4".equals(groupType)){
|
|
|
+ //我的部门
|
|
|
+ FrameUser nowUser = frameUserService.selectByPrimaryKey(ShiroUtils.getUserId());
|
|
|
+ if(null != nowUser){
|
|
|
+ if(StringUtils.isNotBlank(nowUser.getDepartment())){
|
|
|
+ all = deptRecursion(nowUser.getDepartment(),groupId);
|
|
|
+ allMap.put("children", all);
|
|
|
+ result.add(allMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<Map<String, Object>> getBizUserList(){
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>();
|
|
|
+ List<BizMain> bizMains = bizMainService.listAll(new BizMain());
|
|
|
+ List<BizUser> bizUsers = bizUserService.listAll(new BizUser());
|
|
|
+ List<Map<String, Object>> all = new ArrayList<>();
|
|
|
+ for(BizMain bizMain:bizMains){
|
|
|
+ Map<String, Object> userMap = new HashMap<>();
|
|
|
+ userMap.put("id", bizMain.getId());
|
|
|
+ userMap.put("label", bizMain.getBusinessName());
|
|
|
+ userMap.put("selectType", false);
|
|
|
+ userMap.put("children", bizUserList(bizUsers,bizMain.getId()));
|
|
|
+ all.add(userMap);
|
|
|
+ }
|
|
|
+ Map<String,Object> allMap = new HashMap<>();
|
|
|
+ allMap.put("id", "0");
|
|
|
+ allMap.put("label", "全部");
|
|
|
+ allMap.put("selectType", false);
|
|
|
+ allMap.put("children", all);
|
|
|
+ result.add(allMap);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<Map<String, Object>> bizUserList(List<BizUser> bizUsers,String bizMainId){
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>();
|
|
|
+ for(BizUser bizUser:bizUsers){
|
|
|
+ if(bizUser.getMainId().equals(bizMainId)){
|
|
|
+ Map<String,Object> user = new HashMap<>();
|
|
|
+ user.put("id", bizUser.getId());
|
|
|
+ user.put("label", bizUser.getDispName());
|
|
|
+ user.put("selectType", true);
|
|
|
+ result.add(user);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取我及我的下属id
|
|
|
+ public List<String> getMyBelow(List<String> users, String userId){
|
|
|
+ users.add(userId);
|
|
|
+ FrameUserExample example = new FrameUserExample();
|
|
|
+ example.createCriteria().andLeaderEqualTo(userId).andDelFlagEqualTo("0").andStatusEqualTo("1");
|
|
|
+ List<FrameUser> userList = frameUserService.selectByExample(example);
|
|
|
+ if(null == userList || null == userList)
|
|
|
+ return users;
|
|
|
+ for (FrameUser user : userList) {
|
|
|
+ getMyBelow(users, user.getId());
|
|
|
+ }
|
|
|
+ return users;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取我的直系下属
|
|
|
+ public List<FrameUser> getUserBranch(String userId){
|
|
|
+ FrameUserExample example = new FrameUserExample();
|
|
|
+ example.createCriteria().andLeaderEqualTo(userId).andStatusEqualTo("1");
|
|
|
+ List<FrameUser> userList = frameUserService.selectByExample(example);
|
|
|
+ return userList;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取我的所有下属
|
|
|
+ public void getUserBranchAll(String userId, List<String> userList){
|
|
|
+ FrameUserExample example = new FrameUserExample();
|
|
|
+ example.createCriteria().andLeaderEqualTo(userId).andStatusEqualTo("1");
|
|
|
+ List<FrameUser> users = frameUserService.selectByExample(example);
|
|
|
+ for (FrameUser user : users) {
|
|
|
+ userList.add(user.getId());
|
|
|
+ getUserBranchAll(user.getId(), userList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|