From 1efb165fd58239cf4be1abb3678e0254385907c0 Mon Sep 17 00:00:00 2001 From: caohuipeng Date: Thu, 15 Oct 2026 00:26:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(shipping-notice):=20=E8=B0=83=E6=95=B4XFA?= =?UTF-8?q?=20=E8=BA=AB=E4=BB=BD=E6=8C=87=E7=BA=B9=E6=BC=82=E7=A7=BB?= =?UTF-8?q?=E9=99=8D=E7=BA=A7=E8=BD=AF=E9=97=A8=E7=A6=81=E5=B9=B6=E6=94=BE?= =?UTF-8?q?=E8=A1=8C=20datasets=20=E5=8F=96=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 供应商换代重导 XFA 表单必变 template 包指纹,原硬拦截使视觉已唯一 命中的单据永远停在无数据人工复核。 - 身份校验改为状态判定写入 decision.xfa_identity_state (matched/incomplete/mismatch),漂移仅记 fallback 码不拦截; - 放行后按模板既有 bindings 对新包 datasets 取值,仍强制 validate_xfa_extraction 业务交叉校验兜底; - 取值/业务校验失败时身份码前置转 Review,复核者可见漂移根因。 --- .../xfa_dataset.py | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/backend/app/services/shipping_notice/order_profile_value_adapters/xfa_dataset.py b/backend/app/services/shipping_notice/order_profile_value_adapters/xfa_dataset.py index 7f97af58..56e4a84e 100644 --- a/backend/app/services/shipping_notice/order_profile_value_adapters/xfa_dataset.py +++ b/backend/app/services/shipping_notice/order_profile_value_adapters/xfa_dataset.py @@ -1901,10 +1901,24 @@ def extract( live_fingerprint = live_fingerprint or signature.get('dataset_structure_fingerprint') source = selected.get('definition', {}).get('source_contract') if isinstance(selected.get('definition'), dict) else {} source = source if isinstance(source, dict) else {} + identity_state = 'matched' if not source.get('template_packet_checksum') or not source.get('dataset_structure_fingerprint'): - return review('xfa_profile_identity_incomplete') - if source.get('template_packet_checksum') != live_template or source.get('dataset_structure_fingerprint') != live_fingerprint: - return review('xfa_profile_identity_mismatch') + identity_state = 'incomplete' + elif ( + source.get('template_packet_checksum') != live_template + or source.get('dataset_structure_fingerprint') != live_fingerprint + ): + identity_state = 'mismatch' + # [SOFT GATE] XFA 身份指纹漂移不再硬拦截(回归 SNER-20261014-35E35017:供应商 + # 换代必变指纹,硬拦截使 XFA 单据永远空转人工)。视觉 Route 已唯一命中,datasets + # 取值后仍有 validate_xfa_extraction 业务交叉校验兜底;漂移降级为决策留痕 + # (xfa_identity_state)+ fallback 码,仅当取值/校验失败时与业务原因码一起转 Review。 + decision['xfa_identity_state'] = identity_state + if identity_state != 'matched': + decision['fallback_reason_codes'] = [ + *(decision.get('fallback_reason_codes') or []), + f'xfa_profile_identity_{identity_state}', + ] table_id = workflow._profile_visual_main_table_id(selected, document.get('layout_snapshot') or {}) if not table_id: return review('xfa_visual_main_table_missing') @@ -1947,7 +1961,11 @@ def extract( # 审计故障不能篡改已冻结的取值/Review 裁决。 pass if extraction.status != 'parsed' or extraction.reason_codes: - return review(*(list(extraction.reason_codes or []) or ['xfa_required_field_missing'])) + codes = list(extraction.reason_codes or []) or ['xfa_required_field_missing'] + if identity_state != 'matched': + # 漂移被软门禁放行后取值仍失败:身份码前置,让复核者看到根因。 + codes = [f'xfa_profile_identity_{identity_state}', *codes] + return review(*codes) validation = validate_xfa_extraction( raw_profile=selected, dataset_analysis=outcome.dataset_analysis, extraction=extraction, pdf_bytes=pdf_bytes, ) @@ -1960,7 +1978,10 @@ def extract( 'profile_checksum': str(selected.get('checksum') or ''), } if not validation.passed: - return review(*(list(validation.reason_codes or []) or ['xfa_business_validation_failed'])) + validation_codes = list(validation.reason_codes or []) or ['xfa_business_validation_failed'] + if identity_state != 'matched': + validation_codes = [f'xfa_profile_identity_{identity_state}', *validation_codes] + return review(*validation_codes) table = { 'profile_id': selected.get('profile_id') or selected.get('id'), 'profile_code': str(selected.get('profile_code') or ''), 'profile_version': int(selected.get('version') or 0), 'profile_checksum': str(selected.get('checksum') or ''),