refactor(shipping-notice): 统一料号字段,移除过时的 SKU 相关字段,更新相关逻辑以支持新字段命名

This commit is contained in:
hugo committed 2026-07-16 20:02:33 +08:00
1 parent dde25344ca
commit 46eb63f5bb
111 files changed
+3116 -1250

No files matched your search

@@ -4,7 +4,7 @@ backend/app/services/shipping_notice/business_fingerprint.py
用途:基于业务摘要生成稳定业务指纹与强度判定(货代域,不含文件哈希)。
依赖:po_number / reservation_id 标准化函数。
逻辑:intake_parse_workflow / Candidate 级 duplicate_detection / 建单门闩共用;
身份算法版本 shipping-v1,内容算法版本 shipping-content-v3。
身份算法版本 shipping-v1,内容算法版本 shipping-content-v4。
"""
from __future__ import annotations
@@ -18,7 +18,7 @@ from app.services.shipping_notice.po_number import normalize_po_number
from app.services.shipping_notice.reservation_id import validated_reservation_id
FINGERPRINT_VERSION = 'shipping-v1'
CONTENT_FINGERPRINT_VERSION = 'shipping-content-v3'
CONTENT_FINGERPRINT_VERSION = 'shipping-content-v4'
def _norm_text(value: Any) -> str:
@@ -39,12 +39,12 @@ def _line_digest(lines: list[dict[str, Any]]) -> str:
for line in lines:
if not isinstance(line, dict):
continue
sku = _norm_text(line.get('sku'))
part_number = _norm_text(line.get('part_number'))
rid = validated_reservation_id(str(line.get('reservation_id') or '')) or ''
qty = _norm_qty(line.get('qty'))
if not sku and not rid and not qty:
if not part_number and not rid and not qty:
continue
parts.append(f'{sku}|{rid}|{qty}')
parts.append(f'{part_number}|{rid}|{qty}')
parts.sort()
return '\n'.join(parts)
@@ -194,7 +194,7 @@ def build_content_fingerprint(business_summary: dict[str, Any] | None) -> dict[s
values = [
_norm_text(line.get('line_no')),
validated_reservation_id(line.get('reservation_id')) or '',
_norm_text(line.get('sku')),
_norm_text(line.get('part_number')),
_norm_qty(line.get('qty')),
_norm_text(line.get('uom')),
_norm_qty(line.get('unit_price')),
@@ -203,9 +203,9 @@ def build_content_fingerprint(business_summary: dict[str, Any] | None) -> dict[s
_norm_text(line.get('required_date')),
normalize_po_number(line.get('po_number')) or '',
_norm_text(line.get('allocation_id')),
_norm_text(line.get('source_type')),
_norm_text(line.get('customer_sku')),
_norm_text(line.get('vendor_part_number')),
_norm_text(line.get('inventory_source_hint')),
_norm_text(line.get('customer_part_number')),
_norm_text(line.get('aws_part_number')),
]
if any(values):
parts.append('|'.join(values))