This commit is contained in:
Marsway 2026-03-25 10:46:52 +08:00
parent ea2362a5f2
commit 64a9f582cc
1 changed files with 2 additions and 20 deletions

View File

@ -610,6 +610,7 @@ class SyncEhrToOaFormJob(BaseJob):
failed_count = 0 failed_count = 0
failed_data: dict[str, str] = {} failed_data: dict[str, str] = {}
do_trigger_bool = _to_bool_or_none(do_trigger) do_trigger_bool = _to_bool_or_none(do_trigger)
unique_filed_payload: list[str] | None = None
def _call_batch_update(*, form_code: str, chunk_rows: list[dict[str, Any]]) -> tuple[dict[str, Any], dict[str, Any], dict[str, Any]]: def _call_batch_update(*, form_code: str, chunk_rows: list[dict[str, Any]]) -> tuple[dict[str, Any], dict[str, Any], dict[str, Any]]:
resp_local = seeyon.batch_update_cap4_form_soap( resp_local = seeyon.batch_update_cap4_form_soap(
@ -617,7 +618,7 @@ class SyncEhrToOaFormJob(BaseJob):
loginName=oa_login_name, loginName=oa_login_name,
rightId=oa_right_id, rightId=oa_right_id,
dataList=chunk_rows, dataList=chunk_rows,
uniqueFiled=[job_field_code], uniqueFiled=unique_filed_payload,
doTrigger=do_trigger_bool, doTrigger=do_trigger_bool,
) )
rj_local = resp_local.json() if resp_local.content else {} rj_local = resp_local.json() if resp_local.content else {}
@ -651,25 +652,6 @@ class SyncEhrToOaFormJob(BaseJob):
chunk_success = int(data.get("successCount", 0) or 0) chunk_success = int(data.get("successCount", 0) or 0)
chunk_failed = int(data.get("failedCount", 0) or 0) chunk_failed = int(data.get("failedCount", 0) or 0)
all_no_master = (
chunk_success == 0
and chunk_failed == len(chunk)
and len(fd) > 0
and all("没有主表记录错误" in str(v or "") for v in fd.values())
)
# 兜底:若 formCode 选错,改用主表名重试一次。
if all_no_master and used_form_code != oa_master_table_name:
logger.warning(
"OA batch-update 全量无主表记录,使用主表名 formCode 重试一次origin_formCode=%s retry_formCode=%s chunk=%s",
used_form_code,
oa_master_table_name,
i // batch_size + 1,
)
used_form_code = oa_master_table_name
rj, data, fd = _call_batch_update(form_code=used_form_code, chunk_rows=chunk)
message = str(rj.get("message") or "")
chunk_success = int(data.get("successCount", 0) or 0)
chunk_failed = int(data.get("failedCount", 0) or 0)
success_count += chunk_success success_count += chunk_success
failed_count += chunk_failed failed_count += chunk_failed