Commit 3ccacd2f authored by 吴泽佳's avatar 吴泽佳

修改 用户ID 生成规则

parent 7c5236a6
...@@ -179,6 +179,8 @@ public class UserInfo implements Serializable { ...@@ -179,6 +179,8 @@ public class UserInfo implements Serializable {
private String ifaNo; private String ifaNo;
/** 真实姓名,禁用于运营维护 */ /** 真实姓名,禁用于运营维护 */
private String realname; private String realname;
/** 企业微信uid */
private String wxcpUid;
/** id 构造器*/ /** id 构造器*/
public UserInfo(String id) { public UserInfo(String id) {
this.setId(id); this.setId(id);
......
...@@ -35,7 +35,7 @@ import java.util.*; ...@@ -35,7 +35,7 @@ import java.util.*;
@Slf4j @Slf4j
public class OrgSyncByWxcpJob { public class OrgSyncByWxcpJob {
final static String keyStr = "{\"corpId\":\"ww08675a3a48c9e8a2\",\"agentId\":\"1000006\",\"corpSecret\":\"VNh2sdxSOPJ0wcHVoWWUrcCjXFXPsxOs12KkAogyCQI\",\"token\":\"jyzyceshi888\",\"aesKey\":\"wHkEDvDLOM8xqiuGn0VCeN9rtJWgeaQ12cxKpcmWsSS\"}"; final static String keyStr = "{\"corpId\":\"ww08675a3a48c9e8a2\",\"agentId\":\"1000006\",\"corpSecret\":\"VNh2sdxSOPJ0wcHVoWWUrcCjXFXPsxOs12KkAogyCQI\",\"token\":\"jyzyceshi888\",\"aesKey\":\"wHkEDvDLOM8xqiuGn0VCeN9rtJWgeaQ12cxKpcmWsSS\",\"sendMessageAppId\":\"wxe177c62fa1e1c602\"}\n";
@Resource @Resource
private OrgExtService orgExtService; private OrgExtService orgExtService;
...@@ -104,11 +104,12 @@ public class OrgSyncByWxcpJob { ...@@ -104,11 +104,12 @@ public class OrgSyncByWxcpJob {
} }
//5 开始比对 5张表 数据 user_info employee department department_employee employee_role //5 开始比对 5张表 数据 user_info employee department department_employee employee_role
WorkDataDto<UserInfo> workUserInfo = userInfoWork(org.getId(), wxCpDepartDtoList); String corpId = wxCpDefaultConfig.getCorpId();
WorkDataDto<Employee> workEmployee = employeeWork(org.getId(), wxCpDepartDtoList); WorkDataDto<UserInfo> workUserInfo = userInfoWork(org.getId(), wxCpDepartDtoList, corpId);
WorkDataDto<Employee> workEmployee = employeeWork(org.getId(), wxCpDepartDtoList, corpId);
WorkDataDto<Department> workDepartment = departmentWork(org.getId(), wxCpDepartDtoList); WorkDataDto<Department> workDepartment = departmentWork(org.getId(), wxCpDepartDtoList);
WorkDataDto<DepartmentEmployee> workDepartmentEmployee = departmentEmployeeWork(org.getId(), wxCpDepartDtoList); WorkDataDto<DepartmentEmployee> workDepartmentEmployee = departmentEmployeeWork(org.getId(), wxCpDepartDtoList, corpId);
WorkDataDto<EmployeeRole> workEmployeeRole = employeeRoleWork(org.getId(), wxCpDepartDtoList); WorkDataDto<EmployeeRole> workEmployeeRole = employeeRoleWork(org.getId(), wxCpDepartDtoList, corpId);
//6 删除列表中 管理员 用户信息 //6 删除列表中 管理员 用户信息
deleteAdmin(orgId, workUserInfo, workEmployee, workEmployeeRole); deleteAdmin(orgId, workUserInfo, workEmployee, workEmployeeRole);
...@@ -183,7 +184,7 @@ public class OrgSyncByWxcpJob { ...@@ -183,7 +184,7 @@ public class OrgSyncByWxcpJob {
} }
private WorkDataDto<EmployeeRole> employeeRoleWork(String orgId, List<WxCpDepartDto> wxCpDepartDtoList) { private WorkDataDto<EmployeeRole> employeeRoleWork(String orgId, List<WxCpDepartDto> wxCpDepartDtoList, String corpId) {
WorkDataDto<EmployeeRole> workDataDto = new WorkDataDto<>(); WorkDataDto<EmployeeRole> workDataDto = new WorkDataDto<>();
List<EmployeeRole> insertList = new ArrayList<>(); List<EmployeeRole> insertList = new ArrayList<>();
List<EmployeeRole> deleteList = new ArrayList<>(); List<EmployeeRole> deleteList = new ArrayList<>();
...@@ -199,7 +200,7 @@ public class OrgSyncByWxcpJob { ...@@ -199,7 +200,7 @@ public class OrgSyncByWxcpJob {
for (WxCpUser wxCpUser : wxCpUserList) { for (WxCpUser wxCpUser : wxCpUserList) {
// key employee_id + '&' + role_id // key employee_id + '&' + role_id
String type = wxCpUser.getIsLeader() == 1 ? "t" : "i"; String type = wxCpUser.getIsLeader() == 1 ? "t" : "i";
hashMap.put(orgId + "_" + wxCpUser.getUserId() + "&" + roleMap.get(type), wxCpUser); hashMap.put(corpId + "_" + wxCpUser.getUserId() + "&" + roleMap.get(type), wxCpUser);
} }
} }
for (EmployeeRole employeeRole : employeeRoleList) { for (EmployeeRole employeeRole : employeeRoleList) {
...@@ -233,7 +234,7 @@ public class OrgSyncByWxcpJob { ...@@ -233,7 +234,7 @@ public class OrgSyncByWxcpJob {
} }
private WorkDataDto<DepartmentEmployee> departmentEmployeeWork(String orgId, List<WxCpDepartDto> wxCpDepartDtoList) { private WorkDataDto<DepartmentEmployee> departmentEmployeeWork(String orgId, List<WxCpDepartDto> wxCpDepartDtoList, String corpId) {
WorkDataDto<DepartmentEmployee> workDataDto = new WorkDataDto<>(); WorkDataDto<DepartmentEmployee> workDataDto = new WorkDataDto<>();
List<DepartmentEmployee> insertList = new ArrayList<>(); List<DepartmentEmployee> insertList = new ArrayList<>();
List<DepartmentEmployee> deleteList = new ArrayList<>(); List<DepartmentEmployee> deleteList = new ArrayList<>();
...@@ -246,7 +247,7 @@ public class OrgSyncByWxcpJob { ...@@ -246,7 +247,7 @@ public class OrgSyncByWxcpJob {
List<WxCpUser> wxCpUserList = wxCpDepartDto.getWxCpUserList(); List<WxCpUser> wxCpUserList = wxCpDepartDto.getWxCpUserList();
for (WxCpUser wxCpUser : wxCpUserList) { for (WxCpUser wxCpUser : wxCpUserList) {
// key department_id + '&' + employee_id // key department_id + '&' + employee_id
hashMap.put(orgId + "_" + wxCpDepartDto.getId()+ "&" + orgId + "_" + wxCpUser.getUserId(), wxCpUser); hashMap.put(orgId + "_" + wxCpDepartDto.getId()+ "&" + corpId + "_" + wxCpUser.getUserId(), wxCpUser);
} }
} }
...@@ -348,7 +349,7 @@ public class OrgSyncByWxcpJob { ...@@ -348,7 +349,7 @@ public class OrgSyncByWxcpJob {
return 1 + getLevel(hashMap2, hashMap2.get(id).getParentId()); return 1 + getLevel(hashMap2, hashMap2.get(id).getParentId());
} }
private WorkDataDto<Employee> employeeWork(String orgId, List<WxCpDepartDto> wxCpDepartDtoList) { private WorkDataDto<Employee> employeeWork(String orgId, List<WxCpDepartDto> wxCpDepartDtoList, String corpId) {
WorkDataDto<Employee> workDataDto = new WorkDataDto<>(); WorkDataDto<Employee> workDataDto = new WorkDataDto<>();
List<Employee> insertList = new ArrayList<>(); List<Employee> insertList = new ArrayList<>();
List<Employee> deleteList = new ArrayList<>(); List<Employee> deleteList = new ArrayList<>();
...@@ -361,7 +362,7 @@ public class OrgSyncByWxcpJob { ...@@ -361,7 +362,7 @@ public class OrgSyncByWxcpJob {
for (WxCpDepartDto wxCpDepartDto : wxCpDepartDtoList) { for (WxCpDepartDto wxCpDepartDto : wxCpDepartDtoList) {
List<WxCpUser> wxCpUserList = wxCpDepartDto.getWxCpUserList(); List<WxCpUser> wxCpUserList = wxCpDepartDto.getWxCpUserList();
for (WxCpUser wxCpUser : wxCpUserList) { for (WxCpUser wxCpUser : wxCpUserList) {
hashMap.put(orgId + "_" + wxCpUser.getUserId(), wxCpUser); hashMap.put(corpId + "_" + wxCpUser.getUserId(), wxCpUser);
} }
} }
...@@ -392,7 +393,7 @@ public class OrgSyncByWxcpJob { ...@@ -392,7 +393,7 @@ public class OrgSyncByWxcpJob {
for (String key : hashMap.keySet()) { for (String key : hashMap.keySet()) {
WxCpUser wxCpUser = hashMap.get(key); WxCpUser wxCpUser = hashMap.get(key);
Employee employee = new Employee(); Employee employee = new Employee();
employee.setEmployeeId(orgId + "_" + wxCpUser.getUserId()); employee.setEmployeeId(corpId + "_" + wxCpUser.getUserId());
employee.setName(wxCpUser.getName()); employee.setName(wxCpUser.getName());
employee.setPhone(wxCpUser.getMobile()); employee.setPhone(wxCpUser.getMobile());
employee.setMail(wxCpUser.getEmail()); employee.setMail(wxCpUser.getEmail());
...@@ -408,7 +409,7 @@ public class OrgSyncByWxcpJob { ...@@ -408,7 +409,7 @@ public class OrgSyncByWxcpJob {
return workDataDto; return workDataDto;
} }
private WorkDataDto<UserInfo> userInfoWork(String orgId, List<WxCpDepartDto> wxCpDepartDtoList) { private WorkDataDto<UserInfo> userInfoWork(String orgId, List<WxCpDepartDto> wxCpDepartDtoList, String corpId) {
WorkDataDto<UserInfo> workDataDto = new WorkDataDto<>(); WorkDataDto<UserInfo> workDataDto = new WorkDataDto<>();
List<UserInfo> insertList = new ArrayList<>(); List<UserInfo> insertList = new ArrayList<>();
List<UserInfo> deleteList = new ArrayList<>(); List<UserInfo> deleteList = new ArrayList<>();
...@@ -421,7 +422,7 @@ public class OrgSyncByWxcpJob { ...@@ -421,7 +422,7 @@ public class OrgSyncByWxcpJob {
for (WxCpDepartDto wxCpDepartDto : wxCpDepartDtoList) { for (WxCpDepartDto wxCpDepartDto : wxCpDepartDtoList) {
List<WxCpUser> wxCpUserList = wxCpDepartDto.getWxCpUserList(); List<WxCpUser> wxCpUserList = wxCpDepartDto.getWxCpUserList();
for (WxCpUser wxCpUser : wxCpUserList) { for (WxCpUser wxCpUser : wxCpUserList) {
hashMap.put(orgId + "_" + wxCpUser.getUserId(), wxCpUser); hashMap.put(corpId + "_" + wxCpUser.getUserId(), wxCpUser);
} }
} }
...@@ -436,9 +437,10 @@ public class OrgSyncByWxcpJob { ...@@ -436,9 +437,10 @@ public class OrgSyncByWxcpJob {
continue; continue;
} }
// 更新 // 更新
if (!userInfo.getUiUsername().equals(wxCpUser.getName()) || StrUtil.isBlankIfStr(userInfo.getUiHeadimgMp())) { if (!userInfo.getUiUsername().equals(wxCpUser.getName()) || StrUtil.isBlankIfStr(userInfo.getUiHeadimgMp()) || !wxCpUser.getUserId().equals(userInfo.getWxcpUid())) {
userInfo.setUiUsername(wxCpUser.getName()); userInfo.setUiUsername(wxCpUser.getName());
userInfo.setUiHeadimgMp(wxCpUser.getThumbAvatar()); userInfo.setUiHeadimgMp(wxCpUser.getThumbAvatar());
userInfo.setWxcpUid(wxCpUser.getUserId());
updateList.add(userInfo); updateList.add(userInfo);
} }
hashMap.remove(id); hashMap.remove(id);
...@@ -458,7 +460,7 @@ public class OrgSyncByWxcpJob { ...@@ -458,7 +460,7 @@ public class OrgSyncByWxcpJob {
userInfo.setCreatetime((new Date())); userInfo.setCreatetime((new Date()));
userInfo.setOrgId(orgId); userInfo.setOrgId(orgId);
// userInfo.setId(employeeId); // userInfo.setId(employeeId);
userInfo.setId(orgId + "_" + wxCpUser.getUserId()); userInfo.setId(corpId + "_" + wxCpUser.getUserId());
userInfo.setUiMobilephoneMp(wxCpUser.getMobile()); userInfo.setUiMobilephoneMp(wxCpUser.getMobile());
userInfo.setDeletetag("0"); userInfo.setDeletetag("0");
userInfo.setUiShenfen("0"); userInfo.setUiShenfen("0");
...@@ -475,6 +477,7 @@ public class OrgSyncByWxcpJob { ...@@ -475,6 +477,7 @@ public class OrgSyncByWxcpJob {
userInfo.setUiSource("pc"); userInfo.setUiSource("pc");
userInfo.setUiRegisterTime(userInfo.getCreatetime()); userInfo.setUiRegisterTime(userInfo.getCreatetime());
userInfo.setUiChannel(null); userInfo.setUiChannel(null);
userInfo.setWxcpUid(wxCpUser.getUserId());
insertList.add(userInfo); insertList.add(userInfo);
} }
workDataDto.setDeleteList(deleteList); workDataDto.setDeleteList(deleteList);
...@@ -528,18 +531,16 @@ public class OrgSyncByWxcpJob { ...@@ -528,18 +531,16 @@ public class OrgSyncByWxcpJob {
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String a = "MALE".equals("MALE") ? "0" : "1"; OrgSyncByWxcpJob orgSyncByWxcpJob = new OrgSyncByWxcpJob();
System.out.println(a); WxCpDefaultConfigImpl wxCpDefaultConfig = JSONUtil.toBean(keyStr, WxCpDefaultConfigImpl.class);
// OrgSyncByWxcpJob orgSyncByWxcpJob = new OrgSyncByWxcpJob();
// WxCpDefaultConfigImpl wxCpDefaultConfig = JSONUtil.toBean(keyStr, WxCpDefaultConfigImpl.class); List<WxCpDepart> wxCpDepartList = orgSyncByWxcpJob.getWxCpDepartList(wxCpDefaultConfig); // 机构信息
// List<WxCpDepartDto> wxCpDepartDtoList = orgSyncByWxcpJob.getWxCpUserList(wxCpDepartList,wxCpDefaultConfig);
// List<WxCpDepart> wxCpDepartList = orgSyncByWxcpJob.getWxCpDepartList(wxCpDefaultConfig); // 机构信息 log.info("=========================");
// List<WxCpDepartDto> wxCpDepartDtoList = orgSyncByWxcpJob.getWxCpUserList(wxCpDepartList,wxCpDefaultConfig); // log.info(JSONUtil.toJsonStr(wxCpDepartDtoList));
// log.info("=========================");
//// log.info(JSONUtil.toJsonStr(wxCpDepartDtoList)); String digestHex = MD5.create().digestHex(JSONUtil.toJsonStr(wxCpDepartDtoList));
// log.info(digestHex);
// String digestHex = MD5.create().digestHex(JSONUtil.toJsonStr(wxCpDepartDtoList));
// log.info(digestHex);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment