refactor(shipping-notice): 统一料号字段,移除过时的 SKU 相关字段,更新相关逻辑以支持新字段命名
This commit is contained in:
1 parent
dde25344ca
commit
46eb63f5bb
111 files changed
+3116
-1250
No files matched your search
@@ -11,11 +11,11 @@ from __future__ import annotations
|
||||
from typing import Any
|
||||
|
||||
from app.core.errors import ValidationError
|
||||
from app.services.shipping_notice.notice_lines import normalize_notice_line
|
||||
from app.services.shipping_notice.notice_lines import non_atomic_part_number_field, normalize_notice_line
|
||||
from app.services.shipping_notice.po_number import normalize_po_number
|
||||
from app.services.shipping_notice.reservation_id import validated_reservation_id
|
||||
|
||||
BUILD_REQUIRED_FIELDS = ('sku', 'qty')
|
||||
BUILD_REQUIRED_FIELDS = ('part_number', 'qty')
|
||||
PROCESS_FIELDS = ('reservation_id',)
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ def assess_candidate_business_summary(summary: dict[str, Any] | None) -> dict[st
|
||||
"""
|
||||
评估规则/LLM订单结果是否达到自动建单最低条件,同时保留不完整内容供自然对话修订。
|
||||
|
||||
核心逻辑:SKU + 正数 Qty 是建单硬条件;Reservation ID 是唯一流程门禁字段。
|
||||
行级 source_type 仅保留为可选库存源路由线索,缺失时不阻断建单或后续流程。
|
||||
核心逻辑:原子 part_number + 正数 Qty 是建单硬条件;Reservation ID 是唯一流程门禁字段。
|
||||
inventory_source_hint 仅保留为可选库存源路由线索,缺失时不阻断建单或后续流程。
|
||||
|
||||
Args:
|
||||
summary: 单个订单的业务摘要。
|
||||
@@ -38,9 +38,18 @@ def assess_candidate_business_summary(summary: dict[str, Any] | None) -> dict[st
|
||||
normalized_lines: list[dict[str, Any]] = []
|
||||
invalid_lines: list[dict[str, Any]] = []
|
||||
for index, item in enumerate(raw_lines):
|
||||
normalized = normalize_notice_line(item if isinstance(item, dict) else None)
|
||||
raw_line = item if isinstance(item, dict) else None
|
||||
non_atomic_field = non_atomic_part_number_field(raw_line)
|
||||
if non_atomic_field:
|
||||
invalid_lines.append({
|
||||
'line_index': index,
|
||||
'reason': 'non_atomic_part_number',
|
||||
'field': non_atomic_field,
|
||||
})
|
||||
continue
|
||||
normalized = normalize_notice_line(raw_line)
|
||||
if normalized is None:
|
||||
invalid_lines.append({'line_index': index, 'reason': 'missing_sku_or_positive_qty'})
|
||||
invalid_lines.append({'line_index': index, 'reason': 'missing_part_number_or_positive_qty'})
|
||||
continue
|
||||
raw_reservation = str(normalized.get('reservation_id') or '').strip()
|
||||
if raw_reservation and not validated_reservation_id(raw_reservation):
|
||||
@@ -114,11 +123,13 @@ def normalize_candidate_business_summary(summary: dict[str, Any] | None) -> dict
|
||||
if assessment['invalid_lines']:
|
||||
first = assessment['invalid_lines'][0]
|
||||
reason = str(first.get('reason') or '')
|
||||
message = (
|
||||
f"第 {int(first.get('line_index') or 0) + 1} 条订单行 Reservation ID 不满足业务格式契约"
|
||||
if reason == 'invalid_reservation_id'
|
||||
else f"第 {int(first.get('line_index') or 0) + 1} 条订单行缺少有效 SKU 或数量"
|
||||
)
|
||||
line_number = int(first.get('line_index') or 0) + 1
|
||||
if reason == 'invalid_reservation_id':
|
||||
message = f"第 {line_number} 条订单行 Reservation ID 不满足业务格式契约"
|
||||
elif reason == 'non_atomic_part_number':
|
||||
message = f"第 {line_number} 条订单行 {first.get('field')} 必须是不可包含 / 的原子料号"
|
||||
else:
|
||||
message = f"第 {line_number} 条订单行缺少有效内部料号或数量"
|
||||
raise ValidationError(
|
||||
code='SHIPPING_NOTICE.CANDIDATE_REVIEW_REQUIRED',
|
||||
message=message,
|
||||
|
||||
Reference in new issue
Block a user