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 ''),