Merge remote-tracking branch 'base-version/main' into dev
This commit is contained in:
@@ -72,6 +72,7 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
|
||||
while (iterator.hasNext()) {
|
||||
IWorkHrSubcompanyPageRespVO.Subcompany sub = iterator.next();
|
||||
if (shouldSkipByCanceled(sub.getCanceled(), options)) {
|
||||
logSkip("分部", sub.getSubcompanyid1(), "iWork 标记为失效且当前不同步失效记录");
|
||||
result.increaseSkipped();
|
||||
iterator.remove();
|
||||
continue;
|
||||
@@ -131,6 +132,7 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
|
||||
while (iterator.hasNext()) {
|
||||
IWorkHrDepartmentPageRespVO.Department dept = iterator.next();
|
||||
if (shouldSkipByCanceled(dept.getCanceled(), options)) {
|
||||
logSkip("部门", dept.getId(), "iWork 标记为失效且当前不同步失效记录");
|
||||
result.increaseSkipped();
|
||||
iterator.remove();
|
||||
continue;
|
||||
@@ -186,6 +188,7 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
|
||||
continue;
|
||||
}
|
||||
if (shouldSkipByCanceled(job.getCanceled(), options)) {
|
||||
logSkip("岗位", job.getJobtitleid(), "iWork 标记为失效且当前不同步失效记录");
|
||||
result.increaseSkipped();
|
||||
continue;
|
||||
}
|
||||
@@ -224,6 +227,7 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
|
||||
}
|
||||
boolean inactive = isInactiveUser(user.getStatus());
|
||||
if (inactive && !options.isIncludeCanceled()) {
|
||||
logSkip("人员", user.getId(), "用户状态为离职且当前不同步离职记录");
|
||||
result.increaseSkipped();
|
||||
continue;
|
||||
}
|
||||
@@ -246,16 +250,19 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
|
||||
UserSyncOutcome outcome;
|
||||
if (existing == null) {
|
||||
if (!options.isCreateIfMissing()) {
|
||||
logSkip("人员", username, "系统未找到该账号且不同步缺失用户");
|
||||
result.increaseSkipped();
|
||||
continue;
|
||||
}
|
||||
outcome = createUser(user, username, deptId, postId, status);
|
||||
} else {
|
||||
if (!Objects.equals(existing.getUserSource(), UserSourceEnum.IWORK.getSource())) {
|
||||
logSkip("人员", existing.getId(), "非 iWork 来源用户,保持原状");
|
||||
result.increaseSkipped();
|
||||
continue;
|
||||
}
|
||||
if (!options.isAllowUpdate()) {
|
||||
logSkip("人员", existing.getId(), "当前策略禁止更新已存在用户");
|
||||
result.increaseSkipped();
|
||||
continue;
|
||||
}
|
||||
@@ -281,6 +288,7 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
|
||||
DeptDO existing = deptService.getDept(deptId);
|
||||
if (existing == null) {
|
||||
if (!options.isCreateIfMissing()) {
|
||||
logSkip("部门", deptId, "当前策略禁止创建缺失部门");
|
||||
return new DeptSyncOutcome(SyncAction.SKIPPED, false, null);
|
||||
}
|
||||
desired.setId(deptId);
|
||||
@@ -288,9 +296,11 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
|
||||
return new DeptSyncOutcome(SyncAction.CREATED, CommonStatusEnum.isDisable(desired.getStatus()), createdId);
|
||||
}
|
||||
if (!Objects.equals(existing.getDeptSource(), DeptSourceEnum.IWORK.getSource())) {
|
||||
logSkip("部门", existing.getId(), "来源非 iWork,保持原状");
|
||||
return new DeptSyncOutcome(SyncAction.SKIPPED, false, existing.getId());
|
||||
}
|
||||
if (!options.isAllowUpdate()) {
|
||||
logSkip("部门", existing.getId(), "当前策略禁止更新已存在部门");
|
||||
return new DeptSyncOutcome(SyncAction.SKIPPED, false, existing.getId());
|
||||
}
|
||||
desired.setId(existing.getId());
|
||||
@@ -309,6 +319,7 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
|
||||
boolean disabled = CommonStatusEnum.isDisable(status);
|
||||
if (existing == null) {
|
||||
if (!options.isCreateIfMissing()) {
|
||||
logSkip("岗位", job.getJobtitleid(), "当前策略禁止创建缺失岗位");
|
||||
return new JobSyncOutcome(SyncAction.SKIPPED, false, null);
|
||||
}
|
||||
PostSaveReqVO createReq = new PostSaveReqVO();
|
||||
@@ -334,6 +345,7 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
|
||||
return new JobSyncOutcome(SyncAction.CREATED, disabled, effectivePostId);
|
||||
}
|
||||
if (!options.isAllowUpdate()) {
|
||||
logSkip("岗位", existing.getId(), "当前策略禁止更新已存在岗位");
|
||||
return new JobSyncOutcome(SyncAction.SKIPPED, false, existing.getId());
|
||||
}
|
||||
PostSaveReqVO updateReq = new PostSaveReqVO();
|
||||
@@ -678,6 +690,12 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
|
||||
};
|
||||
}
|
||||
|
||||
private void logSkip(String entityLabel, Object identifier, String reason) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("[iWork] {}[id={}] 跳过:{}", entityLabel, identifier, reason);
|
||||
}
|
||||
}
|
||||
|
||||
private record ParentHolder(Long parentId) {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user