update
This commit is contained in:
parent
b502b11bba
commit
63c1f1ad29
|
|
@ -315,6 +315,9 @@ class SyncEhrToOaFormJob(BaseJob):
|
|||
preview_limit = int(params.get("preview_limit") or 20)
|
||||
if preview_limit <= 0:
|
||||
preview_limit = 20
|
||||
debug_only = _to_bool_or_none(params.get("debug_only"))
|
||||
if debug_only is None:
|
||||
debug_only = False
|
||||
|
||||
seeyon = SeeyonClient(base_url=oa_base_url, rest_user=rest_user, rest_password=rest_password, loginName=login_name)
|
||||
ehr = SyncEhrToOaApi(
|
||||
|
|
@ -417,6 +420,15 @@ class SyncEhrToOaFormJob(BaseJob):
|
|||
rid = _extract_reporting_user_id(p)
|
||||
if rid > 0:
|
||||
reporting_user_ids.append(rid)
|
||||
# 3.2.1) 从任职记录直接收集汇报人 userId,避免只靠 Reportings 漏掉数据
|
||||
manager_user_ids: list[int] = []
|
||||
for item in ehr_by_job_no.values():
|
||||
rec2 = item.get("recordInfo") or {}
|
||||
if not isinstance(rec2, dict):
|
||||
continue
|
||||
mid = _to_int_safe(rec2.get("pOIdEmpAdmin"))
|
||||
if mid > 0:
|
||||
manager_user_ids.append(mid)
|
||||
# 3.3) 收集 HRBP userId(来自 recordInfo 自定义字段),并统一反查工号
|
||||
hrbp_user_ids: list[int] = []
|
||||
for item in ehr_by_job_no.values():
|
||||
|
|
@ -426,7 +438,7 @@ class SyncEhrToOaFormJob(BaseJob):
|
|||
hrbp_uid = _to_int_safe(rec.get(_EHR_HRBP_ID_KEY) or _custom_prop_value(rec.get("customProperties"), _EHR_HRBP_ID_KEY))
|
||||
if hrbp_uid > 0:
|
||||
hrbp_user_ids.append(hrbp_uid)
|
||||
resolve_user_ids = list({*reporting_user_ids, *hrbp_user_ids})
|
||||
resolve_user_ids = list({*reporting_user_ids, *manager_user_ids, *hrbp_user_ids})
|
||||
resolve_profile_by_user_id = ehr.get_staff_profiles_by_user_ids(user_ids=resolve_user_ids)
|
||||
user_id_to_staff_code: dict[int, str] = {}
|
||||
for uid, profile in resolve_profile_by_user_id.items():
|
||||
|
|
@ -454,9 +466,10 @@ class SyncEhrToOaFormJob(BaseJob):
|
|||
except Exception as e: # noqa: BLE001
|
||||
logger.warning("OA 人员查询失败:code=%s err=%r", code, e)
|
||||
logger.info(
|
||||
"人员工号反查完成:staff_profiles=%s reportings=%s hrbp_ids=%s resolved_staff_codes=%s resolved_member_ids=%s",
|
||||
"人员工号反查完成:staff_profiles=%s reportings=%s manager_ids=%s hrbp_ids=%s resolved_staff_codes=%s resolved_member_ids=%s",
|
||||
len(staff_profile_by_user_id),
|
||||
len(reporting_user_ids),
|
||||
len(manager_user_ids),
|
||||
len(hrbp_user_ids),
|
||||
len(user_id_to_staff_code),
|
||||
len(code_to_member),
|
||||
|
|
@ -831,17 +844,18 @@ class SyncEhrToOaFormJob(BaseJob):
|
|||
len(data_list),
|
||||
not_found_in_oa,
|
||||
)
|
||||
logger.warning("DEBUG模式:已停止 batch-update,仅输出映射日志,debug_rows=%s", debug_rows)
|
||||
return {
|
||||
"debug_only": True,
|
||||
"ehr_total_rows": len(emp_rows),
|
||||
"ehr_distinct_job_numbers": len(ehr_by_job_no),
|
||||
"oa_existing_job_numbers": len(oa_id_by_job_no),
|
||||
"prepared_updates": len(data_list),
|
||||
"not_found_in_oa": not_found_in_oa,
|
||||
"unmatched_sample": unmatched_samples[:50],
|
||||
"debug_rows": debug_rows,
|
||||
}
|
||||
if debug_only:
|
||||
logger.warning("DEBUG模式:已停止 batch-update,仅输出映射日志,debug_rows=%s", debug_rows)
|
||||
return {
|
||||
"debug_only": True,
|
||||
"ehr_total_rows": len(emp_rows),
|
||||
"ehr_distinct_job_numbers": len(ehr_by_job_no),
|
||||
"oa_existing_job_numbers": len(oa_id_by_job_no),
|
||||
"prepared_updates": len(data_list),
|
||||
"not_found_in_oa": not_found_in_oa,
|
||||
"unmatched_sample": unmatched_samples[:50],
|
||||
"debug_rows": debug_rows,
|
||||
}
|
||||
|
||||
# 6) 分批执行 batch-update
|
||||
success_count = 0
|
||||
|
|
|
|||
Loading…
Reference in New Issue