feat(shipping-notice): 落地 XFA 拆分、版面签名、统一进度与处理域履约
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3a9fbac2fc
commit
d2b3d74def
571 files changed
+78064
-24681
No files matched your search
@@ -13,6 +13,7 @@ from typing import Any
|
||||
|
||||
from app.core.errors import ValidationError
|
||||
from app.services.shipping_notice.notice_lines import non_atomic_part_number_field, normalize_notice_line
|
||||
from app.services.shipping_notice.notice_line_values import parse_number
|
||||
from app.services.shipping_notice.order_schema.field_rules import compute_effective_reservation_id
|
||||
from app.services.shipping_notice.po_number import normalize_atomic_po_number
|
||||
from app.services.shipping_notice.reservation_id import validated_reservation_id
|
||||
@@ -40,6 +41,7 @@ def assess_candidate_business_summary(summary: dict[str, Any] | None) -> dict[st
|
||||
raw_lines = raw.get('lines') if isinstance(raw.get('lines'), list) else []
|
||||
normalized_lines: list[dict[str, Any]] = []
|
||||
invalid_lines: list[dict[str, Any]] = []
|
||||
missing_required: set[str] = set()
|
||||
for index, item in enumerate(raw_lines):
|
||||
raw_line = item if isinstance(item, dict) else None
|
||||
non_atomic_field = non_atomic_part_number_field(raw_line)
|
||||
@@ -52,7 +54,23 @@ def assess_candidate_business_summary(summary: dict[str, Any] | None) -> dict[st
|
||||
continue
|
||||
normalized = normalize_notice_line(raw_line)
|
||||
if normalized is None:
|
||||
invalid_lines.append({'line_index': index, 'reason': 'missing_part_number_or_positive_qty'})
|
||||
raw_part_number = str((raw_line or {}).get('part_number') or '').strip()
|
||||
raw_qty = parse_number(
|
||||
(raw_line or {}).get('qty')
|
||||
if (raw_line or {}).get('qty') is not None
|
||||
else (raw_line or {}).get('quantity')
|
||||
)
|
||||
line_missing = []
|
||||
if not raw_part_number:
|
||||
line_missing.append('part_number')
|
||||
if raw_qty is None or raw_qty <= 0:
|
||||
line_missing.append('qty')
|
||||
missing_required.update(line_missing)
|
||||
invalid_lines.append({
|
||||
'line_index': index,
|
||||
'reason': 'missing_part_number_or_positive_qty',
|
||||
'fields': line_missing,
|
||||
})
|
||||
continue
|
||||
raw_reservation = str(normalized.get('reservation_id') or '').strip()
|
||||
if raw_reservation and not validated_reservation_id(raw_reservation):
|
||||
@@ -81,9 +99,8 @@ def assess_candidate_business_summary(summary: dict[str, Any] | None) -> dict[st
|
||||
))
|
||||
})
|
||||
|
||||
missing_required: list[str] = []
|
||||
if not normalized_lines:
|
||||
missing_required.extend(BUILD_REQUIRED_FIELDS)
|
||||
if not normalized_lines and not invalid_lines:
|
||||
missing_required.update(BUILD_REQUIRED_FIELDS)
|
||||
# 有效 Reservation 是逐行匹配键;头级可回填行级缺失。
|
||||
missing_process = [
|
||||
field
|
||||
@@ -103,7 +120,7 @@ def assess_candidate_business_summary(summary: dict[str, Any] | None) -> dict[st
|
||||
'normalized_summary': normalized_summary,
|
||||
'can_create_task': bool(normalized_lines) and not invalid_lines,
|
||||
'can_auto_progress': bool(normalized_lines) and not invalid_lines and not missing_process,
|
||||
'missing_required_fields': sorted(set(missing_required)),
|
||||
'missing_required_fields': sorted(missing_required),
|
||||
'missing_process_fields': missing_process,
|
||||
'invalid_lines': invalid_lines,
|
||||
'process_issues': [],
|
||||
|
||||
Reference in new issue
Block a user