|
@@ -11,10 +11,7 @@ import com.management.platform.constant.Constant;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.vo.UserVO;
|
|
import com.management.platform.entity.vo.UserVO;
|
|
import com.management.platform.mapper.*;
|
|
import com.management.platform.mapper.*;
|
|
-import com.management.platform.service.DepartmentOtherManagerService;
|
|
|
|
-import com.management.platform.service.FeishuInfoService;
|
|
|
|
-import com.management.platform.service.SysRoleService;
|
|
|
|
-import com.management.platform.service.UserService;
|
|
|
|
|
|
+import com.management.platform.service.*;
|
|
import com.management.platform.service.impl.FeishuInfoServiceImpl;
|
|
import com.management.platform.service.impl.FeishuInfoServiceImpl;
|
|
import com.management.platform.util.*;
|
|
import com.management.platform.util.*;
|
|
import com.taobao.api.ApiException;
|
|
import com.taobao.api.ApiException;
|
|
@@ -68,8 +65,12 @@ public class FeishuInfoController {
|
|
@Resource
|
|
@Resource
|
|
private DepartmentFeishuMapper departmentFeishuMapper;
|
|
private DepartmentFeishuMapper departmentFeishuMapper;
|
|
@Resource
|
|
@Resource
|
|
|
|
+ private DepartmentFeishuService departmentFeishuService;
|
|
|
|
+ @Resource
|
|
private DepartmentMapper departmentMapper;
|
|
private DepartmentMapper departmentMapper;
|
|
@Resource
|
|
@Resource
|
|
|
|
+ private DepartmentService departmentService;
|
|
|
|
+ @Resource
|
|
private SysRoleMapper sysRoleMapper;
|
|
private SysRoleMapper sysRoleMapper;
|
|
@Resource
|
|
@Resource
|
|
private UserService userService;
|
|
private UserService userService;
|
|
@@ -645,6 +646,7 @@ public class FeishuInfoController {
|
|
if(feishuInfoList.size()>0){
|
|
if(feishuInfoList.size()>0){
|
|
FeishuInfo feishuInfo = feishuInfoList.get(0);
|
|
FeishuInfo feishuInfo = feishuInfoList.get(0);
|
|
List<User> allUserList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", feishuInfo.getCompanyId()));
|
|
List<User> allUserList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", feishuInfo.getCompanyId()));
|
|
|
|
+ List<Department> allDepartmentList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().eq(Department::getCompanyId, feishuInfo.getCompanyId()));
|
|
SysRole role = sysRoleMapper.selectOne(new QueryWrapper<SysRole>().eq("company_id",feishuInfo.getCompanyId()).eq("rolename","普通员工"));
|
|
SysRole role = sysRoleMapper.selectOne(new QueryWrapper<SysRole>().eq("company_id",feishuInfo.getCompanyId()).eq("rolename","普通员工"));
|
|
//通讯录权限范围变更
|
|
//通讯录权限范围变更
|
|
//todo:新增的
|
|
//todo:新增的
|
|
@@ -673,8 +675,7 @@ public class FeishuInfoController {
|
|
String openDepartmentId = String.valueOf(ob.getString("open_department_id"));
|
|
String openDepartmentId = String.valueOf(ob.getString("open_department_id"));
|
|
String departmentParentId =String.valueOf(ob.getString("parent_department_id"));
|
|
String departmentParentId =String.valueOf(ob.getString("parent_department_id"));
|
|
JSONArray leaders = ob.getJSONArray("leaders");
|
|
JSONArray leaders = ob.getJSONArray("leaders");
|
|
- Integer cut = departmentFeishuMapper.selectCount(new QueryWrapper<DepartmentFeishu>().eq("corpid",feishuInfo.getCorpid()).eq("feishu_deptid",departmentId));
|
|
|
|
- if(cut==0&&!departmentId.equals("0")){
|
|
|
|
|
|
+ if(!departmentId.equals("0")){
|
|
System.out.println("join===========");
|
|
System.out.println("join===========");
|
|
DepartmentFeishu departmentFeishu=new DepartmentFeishu();
|
|
DepartmentFeishu departmentFeishu=new DepartmentFeishu();
|
|
departmentFeishu.setCorpid(feishuInfo.getCorpid())
|
|
departmentFeishu.setCorpid(feishuInfo.getCorpid())
|
|
@@ -686,7 +687,11 @@ public class FeishuInfoController {
|
|
department.setCompanyId(feishuInfo.getCompanyId());
|
|
department.setCompanyId(feishuInfo.getCompanyId());
|
|
department.setDepartmentName(departmentName);
|
|
department.setDepartmentName(departmentName);
|
|
department.setFeishuDeptid(openDepartmentId);
|
|
department.setFeishuDeptid(openDepartmentId);
|
|
- departmentMapper.insert(department);
|
|
|
|
|
|
+ Optional<Department> optional = allDepartmentList.stream().filter(a -> a.getFeishuDeptid().equals(openDepartmentId)).findFirst();
|
|
|
|
+ if(optional.isPresent()){
|
|
|
|
+ department.setDepartmentId(optional.get().getDepartmentId());
|
|
|
|
+ }
|
|
|
|
+ departmentService.saveOrUpdate(department);
|
|
List<DepartmentOtherManager> odList=new ArrayList<>();
|
|
List<DepartmentOtherManager> odList=new ArrayList<>();
|
|
if(leaders!=null&&leaders.size()>0){
|
|
if(leaders!=null&&leaders.size()>0){
|
|
//todo:处理主要负责人
|
|
//todo:处理主要负责人
|
|
@@ -744,65 +749,70 @@ public class FeishuInfoController {
|
|
JSONObject userJson = userInfoWithDepartment.getJSONObject(m);
|
|
JSONObject userJson = userInfoWithDepartment.getJSONObject(m);
|
|
String curUserid = userJson.getString("user_id");
|
|
String curUserid = userJson.getString("user_id");
|
|
String openUserid = userJson.getString("open_id");
|
|
String openUserid = userJson.getString("open_id");
|
|
- if(!userJson.getJSONObject("status").getBoolean("is_activated")){
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
List<String> departments = (List<String>) userJson.get("department_ids");
|
|
List<String> departments = (List<String>) userJson.get("department_ids");
|
|
System.out.println("user info======:"+userJson.toString());
|
|
System.out.println("user info======:"+userJson.toString());
|
|
- boolean b = allUserList.stream().anyMatch(al -> al.getFeishuUserid() != null && al.getFeishuUserid().equals(userJson.getString("open_id")));
|
|
|
|
- if(!b){
|
|
|
|
- //不存在的人员, 进行插入
|
|
|
|
- User user = new User();
|
|
|
|
- //在当前部门下的员工
|
|
|
|
- user.setId(SnowFlake.nextId()+"")
|
|
|
|
- .setRoleId(role.getId())//默认普通员工
|
|
|
|
- .setRoleName(role.getRolename())
|
|
|
|
- .setCompanyId(feishuInfo.getCompanyId())
|
|
|
|
- .setName(userJson.getString("name"))
|
|
|
|
- .setFeishuUserid(openUserid)
|
|
|
|
- .setColor(ColorUtil.randomColor())
|
|
|
|
- .setJobNumber(curUserid)
|
|
|
|
- .setPassword(MD5Util.getPassword("000000"))
|
|
|
|
- .setFeishuDeptid(departmentFeishu.getFeishuDeptid());
|
|
|
|
- String max = departments.get(0);
|
|
|
|
- Optional<DepartmentFeishu> dpFs = departmentFeishuList.stream().filter(dl -> dl.getFeishuOpenDeptid().equals(max)).findFirst();
|
|
|
|
- if(dpFs.isPresent()){
|
|
|
|
- Optional<Department> dp = departmentList.stream().filter(dl -> dl.getDepartmentId().equals(dpFs.get().getSysDeptid())).findFirst();
|
|
|
|
- if(dp.isPresent()){
|
|
|
|
- user.setDepartmentName(dp.get().getDepartmentName());
|
|
|
|
- user.setDepartmentId(dp.get().getDepartmentId());
|
|
|
|
- user.setDepartmentCascade(convertDepartmentIdToCascade(dp.get().getDepartmentId(),departmentList));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- boolean c = newUserList.stream().anyMatch(ul ->ul.getFeishuUserid()!=null&&ul.getFeishuUserid().equals(user.getFeishuUserid()));
|
|
|
|
- if(!c){
|
|
|
|
- newUserList.add(user);
|
|
|
|
|
|
+ Optional<User> optional = allUserList.stream().filter(al -> al.getFeishuUserid() != null && al.getFeishuUserid().equals(userJson.getString("open_id"))).findFirst();
|
|
|
|
+ //不存在的人员, 进行插入
|
|
|
|
+ User user = new User();
|
|
|
|
+ //在当前部门下的员工
|
|
|
|
+ if(optional.isPresent()){
|
|
|
|
+ user.setId(optional.get().getId());
|
|
|
|
+ }else {
|
|
|
|
+ user.setId(SnowFlake.nextId()+"");
|
|
|
|
+ }
|
|
|
|
+ user.setRoleId(role.getId())//默认普通员工
|
|
|
|
+ .setRoleName(role.getRolename())
|
|
|
|
+ .setCompanyId(feishuInfo.getCompanyId())
|
|
|
|
+ .setName(userJson.getString("name"))
|
|
|
|
+ .setFeishuUserid(openUserid)
|
|
|
|
+ .setColor(ColorUtil.randomColor())
|
|
|
|
+ .setJobNumber(curUserid)
|
|
|
|
+ .setPassword(MD5Util.getPassword("000000"))
|
|
|
|
+ .setFeishuDeptid(departmentFeishu.getFeishuDeptid())
|
|
|
|
+ .setIsActive(userJson.getJSONObject("status").getBoolean("is_activated")?1:0);
|
|
|
|
+ String max = departments.get(0);
|
|
|
|
+ Optional<DepartmentFeishu> dpFs = departmentFeishuList.stream().filter(dl -> dl.getFeishuOpenDeptid().equals(max)).findFirst();
|
|
|
|
+ if(dpFs.isPresent()){
|
|
|
|
+ Optional<Department> dp = departmentList.stream().filter(dl -> dl.getDepartmentId().equals(dpFs.get().getSysDeptid())).findFirst();
|
|
|
|
+ if(dp.isPresent()){
|
|
|
|
+ user.setDepartmentName(dp.get().getDepartmentName());
|
|
|
|
+ user.setDepartmentId(dp.get().getDepartmentId());
|
|
|
|
+ user.setDepartmentCascade(convertDepartmentIdToCascade(dp.get().getDepartmentId(),departmentList));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ boolean c = newUserList.stream().anyMatch(ul ->ul.getFeishuUserid()!=null&&ul.getFeishuUserid().equals(user.getFeishuUserid()));
|
|
|
|
+ if(!c){
|
|
|
|
+ newUserList.add(user);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//todo:处理人员
|
|
//todo:处理人员
|
|
JSONArray userArrays = addedOb.getJSONArray("users");
|
|
JSONArray userArrays = addedOb.getJSONArray("users");
|
|
if(userArrays!=null&&userArrays.size()>0){
|
|
if(userArrays!=null&&userArrays.size()>0){
|
|
for (int i = 0; i < userArrays.size(); i++) {
|
|
for (int i = 0; i < userArrays.size(); i++) {
|
|
- JSONObject userOb = userArrays.getJSONObject(i);
|
|
|
|
- boolean b = allUserList.stream().anyMatch(al -> al.getFeishuUserid() != null && al.getFeishuUserid().equals(userOb.getString("open_id")));
|
|
|
|
- if(!b){
|
|
|
|
- //不存在的人员, 进行插入
|
|
|
|
- User user = new User();
|
|
|
|
- user.setId(SnowFlake.nextId()+"")
|
|
|
|
- .setRoleId(role.getId())//默认普通员工
|
|
|
|
- .setRoleName(role.getRolename())
|
|
|
|
- .setCompanyId(feishuInfo.getCompanyId())
|
|
|
|
- .setName(userOb.getString("name"))
|
|
|
|
- .setFeishuUserid(userOb.getString("open_id"))
|
|
|
|
- .setColor(ColorUtil.randomColor())
|
|
|
|
- .setJobNumber(userOb.getString("user_id"))
|
|
|
|
- .setPassword(MD5Util.getPassword("000000"));
|
|
|
|
- boolean c = newUserList.stream().anyMatch(ul ->ul.getFeishuUserid()!=null&&ul.getFeishuUserid().equals(user.getFeishuUserid()));
|
|
|
|
- if(!c){
|
|
|
|
- newUserList.add(user);
|
|
|
|
- }
|
|
|
|
|
|
+ String uid = userArrays.getString(i);
|
|
|
|
+ Optional<User> optional = allUserList.stream().filter(al -> al.getFeishuUserid() != null && al.getFeishuUserid().equals(uid)).findFirst();
|
|
|
|
+ //不存在的人员, 进行插入
|
|
|
|
+ User user = new User();
|
|
|
|
+ //在当前部门下的员工
|
|
|
|
+ if(optional.isPresent()){
|
|
|
|
+ user.setId(optional.get().getId());
|
|
|
|
+ }else {
|
|
|
|
+ user.setId(SnowFlake.nextId()+"");
|
|
|
|
+ }
|
|
|
|
+ JSONObject userOb = feishuInfoService.getUserInfo(feishuInfo, uid);
|
|
|
|
+ user.setRoleId(role.getId())
|
|
|
|
+ .setRoleId(role.getId())//默认普通员工
|
|
|
|
+ .setRoleName(role.getRolename())
|
|
|
|
+ .setCompanyId(feishuInfo.getCompanyId())
|
|
|
|
+ .setName(userOb.getString("name"))
|
|
|
|
+ .setFeishuUserid(userOb.getString("open_id"))
|
|
|
|
+ .setColor(ColorUtil.randomColor())
|
|
|
|
+ .setJobNumber(userOb.getString("user_id"))
|
|
|
|
+ .setPassword(MD5Util.getPassword("000000"));
|
|
|
|
+ boolean c = newUserList.stream().anyMatch(ul ->ul.getFeishuUserid()!=null&&ul.getFeishuUserid().equals(user.getFeishuUserid()));
|
|
|
|
+ if(!c){
|
|
|
|
+ newUserList.add(user);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -823,6 +833,7 @@ public class FeishuInfoController {
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
FeishuInfo feishuInfo = feishuInfoMapper.selectOne(new LambdaQueryWrapper<FeishuInfo>().eq(FeishuInfo::getCompanyId, companyId));
|
|
FeishuInfo feishuInfo = feishuInfoMapper.selectOne(new LambdaQueryWrapper<FeishuInfo>().eq(FeishuInfo::getCompanyId, companyId));
|
|
|
|
+ List<Department> allDepartmentList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().eq(Department::getCompanyId, companyId));
|
|
List<User> allUserList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, companyId));
|
|
List<User> allUserList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, companyId));
|
|
String corpId = feishuInfo.getCorpid();
|
|
String corpId = feishuInfo.getCorpid();
|
|
if(feishuInfo==null){
|
|
if(feishuInfo==null){
|
|
@@ -869,8 +880,7 @@ public class FeishuInfoController {
|
|
String openDepartmentId = String.valueOf(ob.getString("open_department_id"));
|
|
String openDepartmentId = String.valueOf(ob.getString("open_department_id"));
|
|
String departmentParentId =String.valueOf(ob.getString("parent_department_id"));
|
|
String departmentParentId =String.valueOf(ob.getString("parent_department_id"));
|
|
JSONArray leaders = ob.getJSONArray("leaders");
|
|
JSONArray leaders = ob.getJSONArray("leaders");
|
|
- Integer cut = departmentFeishuMapper.selectCount(new QueryWrapper<DepartmentFeishu>().eq("corpid",feishuInfo.getCorpid()).eq("feishu_deptid",departmentId));
|
|
|
|
- if(cut==0&&!departmentId.equals("0")){
|
|
|
|
|
|
+ if(!departmentId.equals("0")){
|
|
System.out.println("join===========");
|
|
System.out.println("join===========");
|
|
DepartmentFeishu departmentFeishu=new DepartmentFeishu();
|
|
DepartmentFeishu departmentFeishu=new DepartmentFeishu();
|
|
departmentFeishu.setCorpid(feishuInfo.getCorpid())
|
|
departmentFeishu.setCorpid(feishuInfo.getCorpid())
|
|
@@ -882,7 +892,11 @@ public class FeishuInfoController {
|
|
department.setCompanyId(feishuInfo.getCompanyId());
|
|
department.setCompanyId(feishuInfo.getCompanyId());
|
|
department.setDepartmentName(departmentName);
|
|
department.setDepartmentName(departmentName);
|
|
department.setFeishuDeptid(openDepartmentId);
|
|
department.setFeishuDeptid(openDepartmentId);
|
|
- departmentMapper.insert(department);
|
|
|
|
|
|
+ Optional<Department> optional = allDepartmentList.stream().filter(a -> a.getFeishuDeptid().equals(openDepartmentId)).findFirst();
|
|
|
|
+ if(optional.isPresent()){
|
|
|
|
+ department.setDepartmentId(optional.get().getDepartmentId());
|
|
|
|
+ }
|
|
|
|
+ departmentService.saveOrUpdate(department);
|
|
List<DepartmentOtherManager> odList=new ArrayList<>();
|
|
List<DepartmentOtherManager> odList=new ArrayList<>();
|
|
if(leaders!=null&&leaders.size()>0){
|
|
if(leaders!=null&&leaders.size()>0){
|
|
//todo:处理主要负责人
|
|
//todo:处理主要负责人
|
|
@@ -915,12 +929,17 @@ public class FeishuInfoController {
|
|
departmentMapper.updateById(department);
|
|
departmentMapper.updateById(department);
|
|
departmentList.add(department);
|
|
departmentList.add(department);
|
|
departmentFeishu.setSysDeptid(department.getDepartmentId());
|
|
departmentFeishu.setSysDeptid(department.getDepartmentId());
|
|
- departmentFeishuMapper.insert(departmentFeishu);
|
|
|
|
|
|
+ DepartmentFeishu feishu = departmentFeishuMapper.selectOne(new LambdaQueryWrapper<DepartmentFeishu>().eq(DepartmentFeishu::getFeishuOpenDeptid, departmentFeishu.getFeishuOpenDeptid()));
|
|
|
|
+ if(feishu!=null){
|
|
|
|
+ departmentFeishu.setId(feishu.getId());
|
|
|
|
+ }
|
|
|
|
+ departmentFeishuService.saveOrUpdate(departmentFeishu);
|
|
departmentFeishuList.add(departmentFeishu);
|
|
departmentFeishuList.add(departmentFeishu);
|
|
departmentOtherManagerService.saveBatch(odList);
|
|
departmentOtherManagerService.saveBatch(odList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
List<User> newUserList=new ArrayList<>();
|
|
List<User> newUserList=new ArrayList<>();
|
|
|
|
+ System.out.println("departmentFeishuList========"+departmentFeishuList.toString());
|
|
for (DepartmentFeishu departmentFeishu : departmentFeishuList) {
|
|
for (DepartmentFeishu departmentFeishu : departmentFeishuList) {
|
|
Optional<Department> first = departmentList.stream().filter(dl -> dl.getDepartmentId().equals(departmentFeishu.getSysDeptid())).findFirst();
|
|
Optional<Department> first = departmentList.stream().filter(dl -> dl.getDepartmentId().equals(departmentFeishu.getSysDeptid())).findFirst();
|
|
//获取到当前部门的上级部门
|
|
//获取到当前部门的上级部门
|
|
@@ -936,45 +955,48 @@ public class FeishuInfoController {
|
|
}
|
|
}
|
|
//处理部门下的人员
|
|
//处理部门下的人员
|
|
JSONArray userInfoWithDepartment=feishuInfoService.getUserInfoWithDepartment(feishuInfo,departmentFeishu.getFeishuOpenDeptid(),null);
|
|
JSONArray userInfoWithDepartment=feishuInfoService.getUserInfoWithDepartment(feishuInfo,departmentFeishu.getFeishuOpenDeptid(),null);
|
|
|
|
+ System.out.println("userInfoWithDepartment=========="+userInfoWithDepartment.toJSONString());
|
|
for (int m=0;m<userInfoWithDepartment.size(); m++) {
|
|
for (int m=0;m<userInfoWithDepartment.size(); m++) {
|
|
JSONObject userJson = userInfoWithDepartment.getJSONObject(m);
|
|
JSONObject userJson = userInfoWithDepartment.getJSONObject(m);
|
|
String curUserid = userJson.getString("user_id");
|
|
String curUserid = userJson.getString("user_id");
|
|
String openUserid = userJson.getString("open_id");
|
|
String openUserid = userJson.getString("open_id");
|
|
- if(!userJson.getJSONObject("status").getBoolean("is_activated")){
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
List<String> departments = (List<String>) userJson.get("department_ids");
|
|
List<String> departments = (List<String>) userJson.get("department_ids");
|
|
System.out.println("user info======:"+userJson.toString());
|
|
System.out.println("user info======:"+userJson.toString());
|
|
- boolean b = allUserList.stream().anyMatch(al -> al.getFeishuUserid() != null && al.getFeishuUserid().equals(userJson.getString("open_id")));
|
|
|
|
- if(!b){
|
|
|
|
- //不存在的人员, 进行插入
|
|
|
|
- User user = new User();
|
|
|
|
- //在当前部门下的员工
|
|
|
|
- user.setId(SnowFlake.nextId()+"")
|
|
|
|
- .setRoleId(role.getId())//默认普通员工
|
|
|
|
- .setRoleName(role.getRolename())
|
|
|
|
- .setCompanyId(feishuInfo.getCompanyId())
|
|
|
|
- .setName(userJson.getString("name"))
|
|
|
|
- .setFeishuUserid(openUserid)
|
|
|
|
- .setColor(ColorUtil.randomColor())
|
|
|
|
- .setJobNumber(curUserid)
|
|
|
|
- .setPassword(MD5Util.getPassword("000000"))
|
|
|
|
- .setFeishuDeptid(departmentFeishu.getFeishuDeptid());
|
|
|
|
- String max = departments.get(0);
|
|
|
|
- Optional<DepartmentFeishu> dpFs = departmentFeishuList.stream().filter(dl -> dl.getFeishuOpenDeptid().equals(max)).findFirst();
|
|
|
|
- if(dpFs.isPresent()){
|
|
|
|
- Optional<Department> dp = departmentList.stream().filter(dl -> dl.getDepartmentId().equals(dpFs.get().getSysDeptid())).findFirst();
|
|
|
|
- if(dp.isPresent()){
|
|
|
|
- user.setDepartmentName(dp.get().getDepartmentName());
|
|
|
|
- user.setDepartmentId(dp.get().getDepartmentId());
|
|
|
|
- user.setDepartmentCascade(convertDepartmentIdToCascade(dp.get().getDepartmentId(),departmentList));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- boolean c = newUserList.stream().anyMatch(ul ->ul.getFeishuUserid()!=null&&ul.getFeishuUserid().equals(user.getFeishuUserid()));
|
|
|
|
- if(!c){
|
|
|
|
- newUserList.add(user);
|
|
|
|
|
|
+ Optional<User> optional = allUserList.stream().filter(al -> al.getFeishuUserid() != null && al.getFeishuUserid().equals(userJson.getString("open_id"))).findFirst();
|
|
|
|
+ //不存在的人员, 进行插入
|
|
|
|
+ User user = new User();
|
|
|
|
+ //在当前部门下的员工
|
|
|
|
+ if(optional.isPresent()){
|
|
|
|
+ user.setId(optional.get().getId());
|
|
|
|
+ }else {
|
|
|
|
+ user.setId(SnowFlake.nextId()+"");
|
|
|
|
+ }
|
|
|
|
+ user.setRoleId(role.getId())//默认普通员工
|
|
|
|
+ .setRoleName(role.getRolename())
|
|
|
|
+ .setCompanyId(feishuInfo.getCompanyId())
|
|
|
|
+ .setName(userJson.getString("name"))
|
|
|
|
+ .setFeishuUserid(openUserid)
|
|
|
|
+ .setColor(ColorUtil.randomColor())
|
|
|
|
+ .setJobNumber(curUserid)
|
|
|
|
+ .setPassword(MD5Util.getPassword("000000"))
|
|
|
|
+ .setFeishuDeptid(departmentFeishu.getFeishuDeptid())
|
|
|
|
+ .setIsActive(userJson.getJSONObject("status").getBoolean("is_activated")?1:0);
|
|
|
|
+ String max = departments.get(0);
|
|
|
|
+ System.out.println("maxDept====="+max);
|
|
|
|
+ Optional<DepartmentFeishu> dpFs = departmentFeishuList.stream().filter(dl -> dl.getFeishuOpenDeptid().equals(max)).findFirst();
|
|
|
|
+ if(dpFs.isPresent()){
|
|
|
|
+ Optional<Department> dp = departmentList.stream().filter(dl -> dl.getDepartmentId().equals(dpFs.get().getSysDeptid())).findFirst();
|
|
|
|
+ if(dp.isPresent()){
|
|
|
|
+ System.out.println("Set Dept");
|
|
|
|
+ user.setDepartmentName(dp.get().getDepartmentName());
|
|
|
|
+ user.setDepartmentId(dp.get().getDepartmentId());
|
|
|
|
+ user.setDepartmentCascade(convertDepartmentIdToCascade(dp.get().getDepartmentId(),departmentList));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ boolean c = newUserList.stream().anyMatch(ul ->ul.getFeishuUserid()!=null&&ul.getFeishuUserid().equals(user.getFeishuUserid()));
|
|
|
|
+ if(!c){
|
|
|
|
+ newUserList.add(user);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//todo:处理人员
|
|
//todo:处理人员
|
|
@@ -984,29 +1006,33 @@ public class FeishuInfoController {
|
|
if(userArrays!=null&&userArrays.size()>0){
|
|
if(userArrays!=null&&userArrays.size()>0){
|
|
for (int i = 0; i < userArrays.size(); i++) {
|
|
for (int i = 0; i < userArrays.size(); i++) {
|
|
String uid = userArrays.getString(i);
|
|
String uid = userArrays.getString(i);
|
|
- boolean b = allUserList.stream().anyMatch(al -> al.getFeishuUserid() != null && al.getFeishuUserid().equals(uid));
|
|
|
|
- if(!b){
|
|
|
|
- //不存在的人员, 进行插入
|
|
|
|
- User user = new User();
|
|
|
|
- JSONObject userOb = feishuInfoService.getUserInfo(feishuInfo, uid);
|
|
|
|
- user.setId(SnowFlake.nextId()+"")
|
|
|
|
- .setRoleId(role.getId())//默认普通员工
|
|
|
|
- .setRoleName(role.getRolename())
|
|
|
|
- .setCompanyId(feishuInfo.getCompanyId())
|
|
|
|
- .setName(userOb.getString("name"))
|
|
|
|
- .setFeishuUserid(userOb.getString("open_id"))
|
|
|
|
- .setColor(ColorUtil.randomColor())
|
|
|
|
- .setJobNumber(userOb.getString("user_id"))
|
|
|
|
- .setPassword(MD5Util.getPassword("000000"));
|
|
|
|
- boolean c = newUserList.stream().anyMatch(ul ->ul.getFeishuUserid()!=null&&ul.getFeishuUserid().equals(user.getFeishuUserid()));
|
|
|
|
- if(!c){
|
|
|
|
- newUserList.add(user);
|
|
|
|
- }
|
|
|
|
|
|
+ Optional<User> optional = allUserList.stream().filter(al -> al.getFeishuUserid() != null && al.getFeishuUserid().equals(uid)).findFirst();
|
|
|
|
+ //不存在的人员, 进行插入
|
|
|
|
+ User user = new User();
|
|
|
|
+ //在当前部门下的员工
|
|
|
|
+ if(optional.isPresent()){
|
|
|
|
+ user.setId(optional.get().getId());
|
|
|
|
+ }else {
|
|
|
|
+ user.setId(SnowFlake.nextId()+"");
|
|
|
|
+ }
|
|
|
|
+ JSONObject userOb = feishuInfoService.getUserInfo(feishuInfo, uid);
|
|
|
|
+ user.setRoleId(role.getId())
|
|
|
|
+ .setRoleId(role.getId())//默认普通员工
|
|
|
|
+ .setRoleName(role.getRolename())
|
|
|
|
+ .setCompanyId(feishuInfo.getCompanyId())
|
|
|
|
+ .setName(userOb.getString("name"))
|
|
|
|
+ .setFeishuUserid(userOb.getString("open_id"))
|
|
|
|
+ .setColor(ColorUtil.randomColor())
|
|
|
|
+ .setJobNumber(userOb.getString("user_id"))
|
|
|
|
+ .setPassword(MD5Util.getPassword("000000"));
|
|
|
|
+ boolean c = newUserList.stream().anyMatch(ul ->ul.getFeishuUserid()!=null&&ul.getFeishuUserid().equals(user.getFeishuUserid()));
|
|
|
|
+ if(!c){
|
|
|
|
+ newUserList.add(user);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(newUserList.size()>0){
|
|
if(newUserList.size()>0){
|
|
- userService.saveBatch(newUserList);
|
|
|
|
|
|
+ userService.saveOrUpdateBatch(newUserList);
|
|
}
|
|
}
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|