iwork 同步用户的规则调整

This commit is contained in:
chenbowen
2026-01-15 17:50:21 +08:00
parent d1e2e25b96
commit a0ec76a8d8

View File

@@ -326,9 +326,8 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
boolean inactive = isInactiveUser(user.getStatus());
String username = resolveUsername(user);
if (StrUtil.isBlank(username)) {
log.warn("[iWork] 人员缺少可用账号(工号={}, 登录账号={})跳过id={} name={}",
user.getWorkcode(), user.getLoginid(), user.getId(), user.getLastname());
result.increaseFailed();
logSkip("人员", user.getId(), "缺少工号与登录账号,跳过同步");
result.increaseSkipped();
continue;
}
try {
@@ -545,7 +544,7 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
CommonStatusEnum status) {
UserSaveReqVO req = new UserSaveReqVO();
req.setUsername(username);
req.setWorkcode(trimToNull(source.getWorkcode()));
req.setWorkcode(resolveWorkcode(source));
req.setNickname(limitLength(StrUtil.blankToDefault(source.getLastname(), username), 30));
req.setRemark(buildUserRemark(source));
if (deptId != null) {
@@ -776,6 +775,26 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
* 工号优先、登录账号兜底,确保账号体系与 iWork 一致
*/
private String resolveUsername(IWorkHrUserPageRespVO.User user) {
if (user == null) {
return null;
}
String workcode = resolveWorkcode(user);
if (StrUtil.isNotBlank(workcode)) {
return workcode;
}
if (StrUtil.isNotBlank(user.getLoginid())) {
return user.getLoginid().trim();
}
return null;
}
/**
* 工号为空时自动使用登录账号作为工号兜底,避免因缺失工号而跳过同步。
*/
private String resolveWorkcode(IWorkHrUserPageRespVO.User user) {
if (user == null) {
return null;
}
if (StrUtil.isNotBlank(user.getWorkcode())) {
return user.getWorkcode().trim();
}