Compare commits
No commits in common. "dev_v1" and "master" have entirely different histories.
|
|
@ -30,11 +30,11 @@ public class HumanUserAddExe {
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void execute(UserAddCmd cmd) {
|
public void execute(UserAddCmd cmd) {
|
||||||
log.info("开始新增人员信息,用户名:{}", cmd.getName());
|
log.info("开始新增人员信息,用户名:{}", cmd.getName());
|
||||||
// SingleResponse<Long> response = userFacade.add(cmd);
|
SingleResponse<Long> response = userFacade.add(cmd);
|
||||||
// if (response == null || !response.isSuccess()) {
|
if (response == null || !response.isSuccess()) {
|
||||||
// throw new BizException("新增人员信息失败");
|
throw new BizException("新增人员信息失败");
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// log.info("新增人员信息成功,用户ID:{},用户名:{}", response.getData(), cmd.getName());
|
log.info("新增人员信息成功,用户ID:{},用户名:{}", response.getData(), cmd.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ public class HumanUserRemoveExe {
|
||||||
log.info("开始删除人员信息,ID:{}", id);
|
log.info("开始删除人员信息,ID:{}", id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// userFacade.delete(id);
|
userFacade.delete(id);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new BizException("删除人员信息失败:" + e.getMessage());
|
throw new BizException("删除人员信息失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@ import com.zcloud.gbscommon.zcloudcorp.response.ZcloudCorpInfoCO;
|
||||||
import com.zcloud.gbscommon.zclouddepartment.face.ZcloudDepartmentFacade;
|
import com.zcloud.gbscommon.zclouddepartment.face.ZcloudDepartmentFacade;
|
||||||
import com.zcloud.gbscommon.zclouddepartment.request.ZcloudDepartmentPageQry;
|
import com.zcloud.gbscommon.zclouddepartment.request.ZcloudDepartmentPageQry;
|
||||||
import com.zcloud.gbscommon.zclouddepartment.response.ZcloudDepartmentInfoCo;
|
import com.zcloud.gbscommon.zclouddepartment.response.ZcloudDepartmentInfoCo;
|
||||||
|
import com.zcloud.gbscommon.zcloudpost.facade.ZcloudPostFacade;
|
||||||
|
import com.zcloud.gbscommon.zcloudpost.request.ZcloudPostQry;
|
||||||
|
import com.zcloud.gbscommon.zcloudpost.response.ZcloudPostCO;
|
||||||
import com.zcloud.gbscommon.zclouduser.facade.ZcloudUserFacade;
|
import com.zcloud.gbscommon.zclouduser.facade.ZcloudUserFacade;
|
||||||
import com.zcloud.gbscommon.zclouduser.request.ZcloudUserAddCmd;
|
import com.zcloud.gbscommon.zclouduser.request.ZcloudUserAddCmd;
|
||||||
import com.zcloud.gbscommon.zclouduser.request.ZcloudUserInfoQry;
|
import com.zcloud.gbscommon.zclouduser.request.ZcloudUserInfoQry;
|
||||||
|
|
@ -133,6 +136,9 @@ public class HumanUserSyncExe {
|
||||||
private ZcloudCorpFacade zcloudCorpFacade;
|
private ZcloudCorpFacade zcloudCorpFacade;
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private ZcloudDepartmentFacade zcloudDepartmentFacade;
|
private ZcloudDepartmentFacade zcloudDepartmentFacade;
|
||||||
|
@DubboReference
|
||||||
|
private ZcloudPostFacade zcloudPostFacade;
|
||||||
|
|
||||||
private final HumanUserGateway humanUserGateway;
|
private final HumanUserGateway humanUserGateway;
|
||||||
private final HumanUserRepository humanUserRepository;
|
private final HumanUserRepository humanUserRepository;
|
||||||
|
|
||||||
|
|
@ -435,6 +441,51 @@ public class HumanUserSyncExe {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, Long> getDeptPostNameIdMap(Long corpId, Long deptId) {
|
||||||
|
if (corpId == null || deptId == null) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
ZcloudPostQry qry = new ZcloudPostQry();
|
||||||
|
qry.setCorpinfoId(corpId);
|
||||||
|
qry.setDepartmentId(deptId);
|
||||||
|
MultiResponse<ZcloudPostCO> response = zcloudPostFacade.listByPostIds(qry);
|
||||||
|
if (response == null || !response.isSuccess() || response.getData() == null) {
|
||||||
|
log.warn("获取岗位列表失败,corpId={},deptId={}", corpId, deptId);
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Long> result = new HashMap<>();
|
||||||
|
for (ZcloudPostCO post : response.getData()) {
|
||||||
|
if (post == null || !corpId.equals(post.getCorpinfoId())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!isPostBelongsToDept(post, deptId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String postName = normalizeLookupName(post.getPostName());
|
||||||
|
if (StringUtils.isEmpty(postName) || post.getId() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
result.put(postName, post.getId());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPostBelongsToDept(ZcloudPostCO post, Long deptId) {
|
||||||
|
if (post == null || deptId == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (deptId.equals(post.getDepartmentId())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (post.getDepartmentList() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return post.getDepartmentList().stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.anyMatch(item -> deptId.equals(item.getDepartmentId()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据部门ID和人员姓名判断人员是否已经存在,并返回人员ID。
|
* 根据部门ID和人员姓名判断人员是否已经存在,并返回人员ID。
|
||||||
*
|
*
|
||||||
|
|
@ -1051,7 +1102,7 @@ public class HumanUserSyncExe {
|
||||||
skipCount++;
|
skipCount++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(employeeName) || StringUtils.isEmpty(idCardNumber) || StringUtils.isEmpty(phoneNumber)) {
|
if (StringUtils.isEmpty(employeeName) || StringUtils.isEmpty(idCardNumber)|| StringUtils.isEmpty(phoneNumber)) {
|
||||||
log.info("跳过无效人员变更数据:姓名或身份证号或手机号为空,原始数据={}", jsonObject);
|
log.info("跳过无效人员变更数据:姓名或身份证号或手机号为空,原始数据={}", jsonObject);
|
||||||
skipCount++;
|
skipCount++;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -1074,25 +1125,61 @@ public class HumanUserSyncExe {
|
||||||
skipCount++;
|
skipCount++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Map<String, Long> deptNameIdMap = corpId == null ? Collections.emptyMap() : getTargetCorpDeptNameIdMap(corpId);
|
||||||
String syncDeptName = StringUtils.isNotEmpty(realDeptName) ? realDeptName : deptName;
|
Long deptId = StringUtils.isEmpty(realDeptName) || deptNameIdMap == null ? null : deptNameIdMap.get(realDeptName);
|
||||||
String syncPostName = StringUtils.isNotEmpty(realPostName) ? realPostName : postName;
|
if (deptId == null) {
|
||||||
|
log.info("未找到目标部门,跳过同步,三方企业名={},三方部门名={},映射部门名={},corpId={},原始数据={}",
|
||||||
|
corporationName, deptName, realDeptName, corpId, jsonObject);
|
||||||
|
skipCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Map<String, Long> postNameIdMap = getDeptPostNameIdMap(corpId, deptId);
|
||||||
|
Long postId = postNameIdMap.get(realPostName);
|
||||||
|
if (corpId == null || deptId == null || postId == null) {
|
||||||
|
log.info("跳过用户状态同步:企业、部门或岗位未匹配,身份证号={},三方企业名={},三方部门名={},三方岗位名={},映射企业名={},映射部门名={},映射岗位名={},corpId={},deptId={},postId={},原始数据={}",
|
||||||
|
idCardNumber, corporationName, deptName, postName, realCorpName, realDeptName, realPostName, corpId, deptId, postId, jsonObject);
|
||||||
|
skipCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
HumanUserE existingHumanUser = humanUserGateway.getByIdCardNumber(idCardNumber);
|
HumanUserE existingHumanUser = humanUserGateway.getByIdCardNumber(idCardNumber);
|
||||||
|
|
||||||
if (existingHumanUser == null) {
|
if (existingHumanUser == null) {
|
||||||
|
Long linkedUserId = resolveZcloudUserId(idCardNumber, phoneNumber);
|
||||||
|
if (linkedUserId == null && canCreateZcloudUser(corpId, deptId, postId)) {
|
||||||
|
linkedUserId = addThirdPartyUser(jsonObject, corpId, deptId, postId);
|
||||||
|
if (linkedUserId != null) {
|
||||||
|
userUpdateCount++;
|
||||||
|
log.info("用户状态同步新增统一用户成功,身份证号={},userId={}", idCardNumber, linkedUserId);
|
||||||
|
} else {
|
||||||
|
log.warn("用户状态同步新增统一用户失败,身份证号={},原始数据={}", idCardNumber, jsonObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
existingHumanUser = buildHumanUser(jsonObject);
|
existingHumanUser = buildHumanUser(jsonObject);
|
||||||
existingHumanUser.setUserId(null);
|
existingHumanUser.setUserId(linkedUserId);
|
||||||
humanUserGateway.add(existingHumanUser);
|
humanUserGateway.add(existingHumanUser);
|
||||||
localUpdateCount++;
|
localUpdateCount++;
|
||||||
log.info("用户状态同步新增本地human_user成功,身份证号={},corpId={},部门名={},岗位名={}",
|
log.info("用户状态同步新增本地human_user成功,身份证号={},userId={}", idCardNumber, linkedUserId);
|
||||||
idCardNumber, corpId, syncDeptName, syncPostName);
|
|
||||||
|
|
||||||
HumanUserRecordE record = buildHumanUserRecord(jsonObject, null);
|
if (linkedUserId != null) {
|
||||||
humanUserRecordGateway.add(record);
|
HumanUserRecordE record = buildHumanUserRecord(jsonObject, linkedUserId);
|
||||||
recordCount++;
|
humanUserRecordGateway.add(record);
|
||||||
|
recordCount++;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (existingHumanUser.getUserId() == null) {
|
||||||
|
Long linkedUserId = resolveZcloudUserId(idCardNumber, phoneNumber);
|
||||||
|
if (linkedUserId == null) {
|
||||||
|
linkedUserId = addThirdPartyUser(jsonObject, corpId, deptId, postId);
|
||||||
|
}
|
||||||
|
existingHumanUser.setUserId(linkedUserId);
|
||||||
|
if (linkedUserId != null) {
|
||||||
|
userUpdateCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HumanUserRecordE record = buildHumanUserRecord(jsonObject, existingHumanUser.getUserId());
|
HumanUserRecordE record = buildHumanUserRecord(jsonObject, existingHumanUser.getUserId());
|
||||||
humanUserRecordGateway.add(record);
|
humanUserRecordGateway.add(record);
|
||||||
recordCount++;
|
recordCount++;
|
||||||
|
|
@ -1101,21 +1188,13 @@ public class HumanUserSyncExe {
|
||||||
humanUserGateway.update(existingHumanUser);
|
humanUserGateway.update(existingHumanUser);
|
||||||
localUpdateCount++;
|
localUpdateCount++;
|
||||||
|
|
||||||
Long resolvedUserId = resolveZcloudUserId(idCardNumber, phoneNumber);
|
if (existingHumanUser.getUserId() != null) {
|
||||||
if (resolvedUserId != null) {
|
log.info("开始统一用户更新,userId={}", existingHumanUser.getUserId());
|
||||||
existingHumanUser.setUserId(resolvedUserId);
|
if (updateBasicInfodUser(existingHumanUser, deptId, corpId, postId, postName)) {
|
||||||
humanUserGateway.update(existingHumanUser);
|
|
||||||
log.info("开始统一用户更新,userId={},corpId={},部门名={},岗位名={}",
|
|
||||||
resolvedUserId, corpId, syncDeptName, syncPostName);
|
|
||||||
if (updateBasicInfodUser(existingHumanUser, corpId,syncDeptName, syncPostName)) {
|
|
||||||
userUpdateCount++;
|
userUpdateCount++;
|
||||||
} else {
|
} else {
|
||||||
log.warn("统一用户更新未成功,userId={},身份证号={},corpId={},部门名={},岗位名={}",
|
log.warn("统一用户更新未成功,userId={},身份证号={}", existingHumanUser.getUserId(), idCardNumber);
|
||||||
resolvedUserId, idCardNumber, corpId, syncDeptName, syncPostName);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
log.info("未反查到统一用户,跳过统一用户更新,身份证号={},手机号={},corpId={},部门名={},岗位名={}",
|
|
||||||
idCardNumber, phoneNumber, corpId, syncDeptName, syncPostName);
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("处理人员变更数据失败,原始数据={}", item, e);
|
log.error("处理人员变更数据失败,原始数据={}", item, e);
|
||||||
|
|
@ -1149,12 +1228,16 @@ public class HumanUserSyncExe {
|
||||||
return trimmedValue.matches("^\\d{17}[0-9Xx]$");
|
return trimmedValue.matches("^\\d{17}[0-9Xx]$");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean canCreateZcloudUser(Long corpId, Long deptId, Long postId) {
|
||||||
|
return corpId != null && deptId != null && postId != null;
|
||||||
|
}
|
||||||
|
|
||||||
private Long resolveZcloudUserId(String idCardNumber, String phoneNumber) {
|
private Long resolveZcloudUserId(String idCardNumber, String phoneNumber) {
|
||||||
String encodedIdCardNumber = StringUtils.isNotEmpty(idCardNumber) ? Base64.encodeToString(idCardNumber) : null;
|
String encodedIdCardNumber = StringUtils.isNotEmpty(idCardNumber) ? Base64.encodeToString(idCardNumber) : null;
|
||||||
return isUserExists(encodedIdCardNumber, phoneNumber);
|
return isUserExists(encodedIdCardNumber, phoneNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean updateBasicInfodUser(HumanUserE humanUser, Long corpId, String syncDeptName,String postName) {
|
private boolean updateBasicInfodUser(HumanUserE humanUser, Long deptId, Long corpId, Long postId, String postName) {
|
||||||
|
|
||||||
String phoneNumber = StringUtils.isNotEmpty(humanUser.getPhoneNumber()) ? humanUser.getPhoneNumber() : null;
|
String phoneNumber = StringUtils.isNotEmpty(humanUser.getPhoneNumber()) ? humanUser.getPhoneNumber() : null;
|
||||||
String idCardNumber = StringUtils.isNotEmpty(humanUser.getIdCardNumber()) ? Base64.encodeToString(humanUser.getIdCardNumber()) :null;
|
String idCardNumber = StringUtils.isNotEmpty(humanUser.getIdCardNumber()) ? Base64.encodeToString(humanUser.getIdCardNumber()) :null;
|
||||||
|
|
@ -1183,11 +1266,15 @@ public class HumanUserSyncExe {
|
||||||
if (corpId != null) {
|
if (corpId != null) {
|
||||||
cmd.setCorpinfoId(corpId);
|
cmd.setCorpinfoId(corpId);
|
||||||
}
|
}
|
||||||
|
if (deptId != null) {
|
||||||
|
cmd.setDepartmentId(deptId);
|
||||||
|
}
|
||||||
|
if (postId != null) {
|
||||||
|
cmd.setPostId(postId);
|
||||||
|
}
|
||||||
if (StringUtils.isNotEmpty(postName)) {
|
if (StringUtils.isNotEmpty(postName)) {
|
||||||
cmd.setPostName(postName);
|
cmd.setPostName(postName);
|
||||||
}
|
}
|
||||||
// cmd.setDepartmentId(humanUser.getde);
|
|
||||||
cmd.setDepartmentName(syncDeptName);
|
|
||||||
cmd.setRzFlag(1);
|
cmd.setRzFlag(1);
|
||||||
UserEmploymentFlagEnum byDesc = UserEmploymentFlagEnum.getByDesc(humanUser.getEmployeeStatus());
|
UserEmploymentFlagEnum byDesc = UserEmploymentFlagEnum.getByDesc(humanUser.getEmployeeStatus());
|
||||||
cmd.setEmploymentFlag(byDesc==null?null:byDesc.getCode());
|
cmd.setEmploymentFlag(byDesc==null?null:byDesc.getCode());
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,11 @@ public class HumanUserUpdateExe {
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void execute(UserUpdateCmd cmd) {
|
public void execute(UserUpdateCmd cmd) {
|
||||||
log.info("开始更新人员信息,ID:{}", cmd.getId());
|
log.info("开始更新人员信息,ID:{}", cmd.getId());
|
||||||
// Response response = userFacade.update(cmd);
|
Response response = userFacade.update(cmd);
|
||||||
// if (response == null || !response.isSuccess()) {
|
if (response == null || !response.isSuccess()) {
|
||||||
// throw new BizException("更新人员信息失败");
|
throw new BizException("更新人员信息失败");
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// log.info("更新人员信息成功,ID:{}", cmd.getId());
|
log.info("更新人员信息成功,ID:{}", cmd.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue