Merge branch 'dev' into test
This commit is contained in:
@@ -4,6 +4,7 @@ import com.fhs.core.trans.vo.VO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -20,6 +21,12 @@ public class AdminUserRespDTO implements VO {
|
||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小王")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "工号", example = "A00123")
|
||||
private String workcode;
|
||||
|
||||
@Schema(description = "备注", example = "我是一个用户")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "租户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long tenantId;
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user