Merge remote-tracking branch 'base-version/test' into dev

# Conflicts:
#	zt-module-databus/zt-module-databus-server-app/src/main/resources/application-dev.yml
This commit is contained in:
chenbowen
2026-01-15 22:43:56 +08:00
5 changed files with 67 additions and 26 deletions

View File

@@ -28,7 +28,10 @@ import com.zt.plat.module.system.util.sync.SyncVerifyUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@@ -39,6 +42,8 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
private static final String JOB_CODE_PREFIX = "IWORK_JOB_";
private static final int DEFAULT_SORT = 999;
/** 当上游密码缺失时,用空字符串的 MD5 作为占位,保证账号可创建 */
private static final String EMPTY_PASSWORD_PLACEHOLDER = DigestUtils.md5DigestAsHex("".getBytes(StandardCharsets.UTF_8)).toUpperCase(Locale.ROOT);
private final DeptService deptService;
private final PostService postService;
@@ -326,9 +331,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 {
@@ -350,9 +354,8 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
continue;
}
if (StrUtil.isBlank(externalPassword)) {
log.warn("[iWork] 人员缺少密码信息无法创建id={} username={}", user.getId(), username);
result.increaseFailed();
continue;
externalPassword = EMPTY_PASSWORD_PLACEHOLDER;
log.info("[iWork] 人员缺少密码信息使用空密码占位同步id={} username={}", user.getId(), username);
}
outcome = createUser(user, username, deptId, postId, status, externalPassword);
} else {
@@ -545,7 +548,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 +779,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();
}