update
This commit is contained in:
parent
bc83d4ccfc
commit
042dc392fe
|
|
@ -15,6 +15,7 @@
|
|||
- 默认写入后立即回读校验;如果 LDAP 返回成功但字段未落地,Job 会报失败并记录未生效字段。
|
||||
- EHR 目标值为空时不会清空 AD 字段。
|
||||
- 如果配置了 `target_sam_accounts`,只对列表中的 AD 账号执行同步。
|
||||
- 不同步 AD `title` 字段,不再往 AD 写入职务。
|
||||
- `displayName` 取 `employeeInfo.customProperties.extDDNIC_606508_303466862`。
|
||||
- `department` 写入“EHR 部门编码 + EHR 部门名称”,例如 `V000076 IT`。
|
||||
- `streetAddress` 默认取 `translateProperties.extgzddxx1_606508_892394263Text`。
|
||||
|
|
|
|||
|
|
@ -427,14 +427,6 @@ def _is_current_employee(item: dict[str, Any], current_status_values: set[str])
|
|||
return True
|
||||
|
||||
|
||||
def _job_post_name(job_post: dict[str, Any]) -> str:
|
||||
for key in ("name", "Name", "jobPostName", "JobPostName"):
|
||||
s = str(job_post.get(key) or "").strip()
|
||||
if s:
|
||||
return s
|
||||
return ""
|
||||
|
||||
|
||||
def _parse_target_sam_accounts(params: dict[str, Any]) -> set[str]:
|
||||
raw = params.get("target_sam_accounts")
|
||||
if raw is None:
|
||||
|
|
@ -538,16 +530,9 @@ class SyncEhrToAdUserJob(BaseJob):
|
|||
with_disabled=False,
|
||||
is_with_deleted=False,
|
||||
)
|
||||
job_post_res = ehr.get_all_job_posts_by_time_window(
|
||||
stop_time=stop_time,
|
||||
capacity=capacity,
|
||||
with_disabled=False,
|
||||
is_with_deleted=False,
|
||||
)
|
||||
emp_rows = emp_res.get("data") or []
|
||||
org_rows = org_res.get("data") or []
|
||||
job_post_rows = job_post_res.get("data") or []
|
||||
if not isinstance(emp_rows, list) or not isinstance(org_rows, list) or not isinstance(job_post_rows, list):
|
||||
if not isinstance(emp_rows, list) or not isinstance(org_rows, list):
|
||||
raise RuntimeError("EHR result invalid: data is not list")
|
||||
|
||||
org_by_oid: dict[str, dict[str, Any]] = {}
|
||||
|
|
@ -558,14 +543,6 @@ class SyncEhrToAdUserJob(BaseJob):
|
|||
if oid:
|
||||
org_by_oid[oid] = org
|
||||
|
||||
job_post_by_oid: dict[str, dict[str, Any]] = {}
|
||||
for job_post in job_post_rows:
|
||||
if not isinstance(job_post, dict):
|
||||
continue
|
||||
oid = str(job_post.get("oId") or job_post.get("oid") or job_post.get("id") or "").strip()
|
||||
if oid:
|
||||
job_post_by_oid[oid] = job_post
|
||||
|
||||
users_by_sam: dict[str, dict[str, Any]] = {}
|
||||
user_id_to_sam: dict[int, str] = {}
|
||||
for item in emp_rows:
|
||||
|
|
@ -586,11 +563,10 @@ class SyncEhrToAdUserJob(BaseJob):
|
|||
break
|
||||
|
||||
logger.info(
|
||||
"EHR 当前用户准备完成:employee_rows=%s current_with_ad_account=%s org_rows=%s job_post_rows=%s target_sam_accounts=%s",
|
||||
"EHR 当前用户准备完成:employee_rows=%s current_with_ad_account=%s org_rows=%s target_sam_accounts=%s",
|
||||
len(emp_rows),
|
||||
len(users_by_sam),
|
||||
len(org_rows),
|
||||
len(job_post_rows),
|
||||
len(target_sam_accounts),
|
||||
)
|
||||
|
||||
|
|
@ -605,7 +581,6 @@ class SyncEhrToAdUserJob(BaseJob):
|
|||
"sAMAccountName",
|
||||
"givenName",
|
||||
"sn",
|
||||
"title",
|
||||
"department",
|
||||
"manager",
|
||||
"proxyAddresses",
|
||||
|
|
@ -650,13 +625,10 @@ class SyncEhrToAdUserJob(BaseJob):
|
|||
|
||||
org_oid = str(rec.get("oIdDepartment") or rec.get("OIdDepartment") or "").strip()
|
||||
org = org_by_oid.get(org_oid, {})
|
||||
job_post_oid = str(rec.get("oIdJobPost") or rec.get("OIdJobPost") or "").strip()
|
||||
job_post = job_post_by_oid.get(job_post_oid, {})
|
||||
|
||||
given_name = _field_value(item, "PhoneticOfMing")
|
||||
surname = _field_value(item, "PhoneticOfXing")
|
||||
name = str(emp.get("name") or emp.get("Name") or "").strip()
|
||||
title = _field_translate_or_value(item, "OIdJobPost") or _job_post_name(job_post)
|
||||
department_code = _org_code(org)
|
||||
department_name = _field_translate_or_value(item, "OIdDepartment") or _org_name(org)
|
||||
department = _department_value(department_code, department_name)
|
||||
|
|
@ -716,7 +688,6 @@ class SyncEhrToAdUserJob(BaseJob):
|
|||
"sAMAccountName": sam,
|
||||
"givenName": given_name,
|
||||
"sn": surname,
|
||||
"title": title,
|
||||
"department": department,
|
||||
"manager": manager_dn,
|
||||
"proxyAddresses": _proxy_addresses(email, sam, proxy_alias_domain),
|
||||
|
|
|
|||
Loading…
Reference in New Issue