|
@@ -1444,7 +1444,6 @@ public class WeiXinCorpController {
|
|
|
.setColor(ColorUtil.randomColor())
|
|
|
.setJobNumber(curUserid)
|
|
|
.setCorpwxDeptid(maxDeptId);
|
|
|
- System.out.println("姓名=="+user.getName());
|
|
|
allCorpWxUserList.add(user);
|
|
|
}
|
|
|
|
|
@@ -1474,7 +1473,6 @@ public class WeiXinCorpController {
|
|
|
//有父部门需要更新
|
|
|
curDept.setCorpwxDeptpid(parentId);
|
|
|
departmentMapper.updateById(curDept);
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1514,9 +1512,8 @@ public class WeiXinCorpController {
|
|
|
u.setDepartmentId(0);
|
|
|
u.setDepartmentCascade("0");
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
-
|
|
|
+ userService.updateBatchById(updateUserList);
|
|
|
return new HttpRespMsg();
|
|
|
}
|
|
|
|
|
@@ -1554,16 +1551,16 @@ public class WeiXinCorpController {
|
|
|
}
|
|
|
int companyId = company.getId();
|
|
|
//获取公司根部门人员,也就是没有分配部门的人员
|
|
|
- List<JSONObject> hasDirectLdMembs = new ArrayList<>();
|
|
|
+// List<JSONObject> hasDirectLdMembs = new ArrayList<>();
|
|
|
SysRole defaultRole = sysRoleMapper.selectOne(
|
|
|
new QueryWrapper<SysRole>().eq("company_id", companyId).eq("is_default", 1));
|
|
|
|
|
|
int companyRootDeptId = 1;
|
|
|
if (syncMembs == 1) {
|
|
|
- JSONArray unAssignedUserList = getDeptUserInfo(curCorpAccessToken, companyRootDeptId);
|
|
|
+ JSONArray allCorpWxUserJsonArray = getDeptUserInfo(curCorpAccessToken, companyRootDeptId);
|
|
|
//获取远程的带姓名的详情,通过企业通讯录的token获取
|
|
|
JSONArray remoteUnAUserList = null;
|
|
|
- if (unAssignedUserList.size() > 0) {
|
|
|
+ if (allCorpWxUserJsonArray.size() > 0) {
|
|
|
remoteUnAUserList = remoteGetDeptUserDetail(wxCorpInfo, corpContactAccessToken, companyRootDeptId);
|
|
|
//做id转化
|
|
|
List<String> corpUserIds = new ArrayList<>();
|
|
@@ -1594,15 +1591,16 @@ public class WeiXinCorpController {
|
|
|
}
|
|
|
|
|
|
List<User> updateUserList = new ArrayList<>();
|
|
|
- for (int m=0;m<unAssignedUserList.size(); m++) {
|
|
|
- JSONObject userJson = unAssignedUserList.getJSONObject(m);
|
|
|
+
|
|
|
+ for (int m=0;m<allCorpWxUserJsonArray.size(); m++) {
|
|
|
+ JSONObject userJson = allCorpWxUserJsonArray.getJSONObject(m);
|
|
|
String curUserid = userJson.getString("userid");
|
|
|
//跳过非激活状态的员工
|
|
|
if (userJson.getInteger("status") != 1) continue;
|
|
|
System.out.println("userid="+curUserid+", name=" + userJson.getString("name")+", department="+userJson.getJSONArray("department"));
|
|
|
- if (userJson.getJSONArray("direct_leader").size() > 0) {
|
|
|
- hasDirectLdMembs.add(userJson);
|
|
|
- }
|
|
|
+// if (userJson.getJSONArray("direct_leader").size() > 0) {
|
|
|
+// hasDirectLdMembs.add(userJson);
|
|
|
+// }
|
|
|
//不存在的人员, 进行插入
|
|
|
User user = new User();
|
|
|
|
|
@@ -1753,9 +1751,9 @@ public class WeiXinCorpController {
|
|
|
String curUserid = userJson.getString("userid");
|
|
|
if (userJson.getInteger("status") != 1) continue;
|
|
|
log.info("userid="+curUserid+", name=" + userJson.getString("name")+", mobile="+userJson.getString("mobile"));
|
|
|
- if (userJson.getJSONArray("direct_leader").size() > 0) {
|
|
|
- hasDirectLdMembs.add(userJson);
|
|
|
- }
|
|
|
+// if (userJson.getJSONArray("direct_leader").size() > 0) {
|
|
|
+// hasDirectLdMembs.add(userJson);
|
|
|
+// }
|
|
|
//不存在的人员, 进行插入
|
|
|
User user = new User();
|
|
|
|
|
@@ -1843,37 +1841,37 @@ public class WeiXinCorpController {
|
|
|
departmentService.updateBatchById(needUpdateDepts);
|
|
|
}
|
|
|
//更新人员的直属上级
|
|
|
- if (hasDirectLdMembs.size() > 0) {
|
|
|
- List<String> corpwxUids = new ArrayList<>();
|
|
|
- for (JSONObject userJson : hasDirectLdMembs) {
|
|
|
- String curUserid = userJson.getString("userid");
|
|
|
- //取第一个leaderId
|
|
|
- JSONArray directLeader = userJson.getJSONArray("direct_leader");
|
|
|
- String string = directLeader.getString(0);
|
|
|
- corpwxUids.add(curUserid);
|
|
|
- if (!corpwxUids.contains(string)) {
|
|
|
- corpwxUids.add(string);
|
|
|
- }
|
|
|
- }
|
|
|
- List<User> userList = userMapper.selectList(new QueryWrapper<User>().select("id, corpwx_userid, superior_id").in("corpwx_userid", corpwxUids));
|
|
|
- List<User> updateUserList = new ArrayList<>();
|
|
|
- for (JSONObject userJson : hasDirectLdMembs) {
|
|
|
- String curUserid = userJson.getString("userid");
|
|
|
- User user = userList.stream().filter(u -> u.getCorpwxUserid().equals(curUserid)).findFirst().get();
|
|
|
- JSONArray directLeader = userJson.getJSONArray("direct_leader");
|
|
|
- String leaderCorpWxuid = directLeader.getString(0);
|
|
|
- //查找leader
|
|
|
- User leader = userList.stream().filter(u -> u.getCorpwxUserid().equals(leaderCorpWxuid)).findFirst().get();
|
|
|
- if (!leader.getId().equals(user.getSuperiorId())) {
|
|
|
- user.setSuperiorId(leader.getId());
|
|
|
- updateUserList.add(user);
|
|
|
- }
|
|
|
- }
|
|
|
- if (updateUserList.size() > 0) {
|
|
|
- //批量更新上级领导
|
|
|
- userService.updateBatchById(updateUserList);
|
|
|
- }
|
|
|
- }
|
|
|
+// if (hasDirectLdMembs.size() > 0) {
|
|
|
+// List<String> corpwxUids = new ArrayList<>();
|
|
|
+// for (JSONObject userJson : hasDirectLdMembs) {
|
|
|
+// String curUserid = userJson.getString("userid");
|
|
|
+// //取第一个leaderId
|
|
|
+// JSONArray directLeader = userJson.getJSONArray("direct_leader");
|
|
|
+// String string = directLeader.getString(0);
|
|
|
+// corpwxUids.add(curUserid);
|
|
|
+// if (!corpwxUids.contains(string)) {
|
|
|
+// corpwxUids.add(string);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// List<User> userList = userMapper.selectList(new QueryWrapper<User>().select("id, corpwx_userid, superior_id").in("corpwx_userid", corpwxUids));
|
|
|
+// List<User> updateUserList = new ArrayList<>();
|
|
|
+// for (JSONObject userJson : hasDirectLdMembs) {
|
|
|
+// String curUserid = userJson.getString("userid");
|
|
|
+// User user = userList.stream().filter(u -> u.getCorpwxUserid().equals(curUserid)).findFirst().get();
|
|
|
+// JSONArray directLeader = userJson.getJSONArray("direct_leader");
|
|
|
+// String leaderCorpWxuid = directLeader.getString(0);
|
|
|
+// //查找leader
|
|
|
+// User leader = userList.stream().filter(u -> u.getCorpwxUserid().equals(leaderCorpWxuid)).findFirst().get();
|
|
|
+// if (!leader.getId().equals(user.getSuperiorId())) {
|
|
|
+// user.setSuperiorId(leader.getId());
|
|
|
+// updateUserList.add(user);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (updateUserList.size() > 0) {
|
|
|
+// //批量更新上级领导
|
|
|
+// userService.updateBatchById(updateUserList);
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
//更新人员的deptcascade
|
|
|
updateUserDeptCascade(companyId);
|