feat(shipping-notice): 完善发货通知自动推进与多库存源复核闭环
This commit is contained in:
1 parent
cfa19a0b7b
commit
8e0bbf7a81
180 files changed
+31210
-1864
No files matched your search
@@ -396,6 +396,9 @@ def _build_stp_facts(task: ShippingNotice) -> dict[str, Any] | None:
|
||||
Returns:
|
||||
stp_facts 字典或 None。
|
||||
"""
|
||||
from app.services.shipping_notice.inventory_candidate_projection import (
|
||||
project_inventory_candidate_facts,
|
||||
)
|
||||
from app.services.shipping_notice.stp_inventory_freeze import task_frozen_inventory_source_codes
|
||||
from app.services.shipping_notice.stp_line_inventory_match import multi_source_recovery_source_codes
|
||||
from app.services.shipping_notice.stp_progress_contract import STP_FACTS_ALLOWED_KEYS
|
||||
@@ -403,25 +406,26 @@ def _build_stp_facts(task: ShippingNotice) -> dict[str, Any] | None:
|
||||
payload = task.step_payload_json if isinstance(task.step_payload_json, dict) else {}
|
||||
status = str(task.inventory_source_status or '').strip()
|
||||
method = str(task.inventory_source_method or '').strip()
|
||||
candidates = payload.get('line_inventory_candidates') if isinstance(payload.get('line_inventory_candidates'), dict) else {}
|
||||
resolutions_raw = payload.get('line_inventory_resolutions')
|
||||
resolutions = [item for item in resolutions_raw if isinstance(item, dict)] if isinstance(resolutions_raw, list) else []
|
||||
multi_block = bool(payload.get('multi_source_excel_block'))
|
||||
frozen_codes = list(candidates.get('source_codes') or []) or task_frozen_inventory_source_codes(task)
|
||||
candidate_projection = project_inventory_candidate_facts(task)
|
||||
frozen_codes = list(candidate_projection.get('candidate_source_codes') or []) or task_frozen_inventory_source_codes(task)
|
||||
has_stp = (
|
||||
status in {'candidates_frozen', 'resolved'}
|
||||
or method.startswith('stp')
|
||||
or bool(frozen_codes)
|
||||
or bool(resolutions)
|
||||
or multi_block
|
||||
or bool(payload.get('line_inventory_candidates'))
|
||||
or bool(candidate_projection.get('current_set'))
|
||||
)
|
||||
if not has_stp:
|
||||
return None
|
||||
|
||||
counts: dict[str, int] = {}
|
||||
compact_resolutions: list[dict[str, Any]] = []
|
||||
for item in resolutions:
|
||||
resolution_source = list(candidate_projection.get('line_resolutions') or []) or resolutions
|
||||
for item in resolution_source:
|
||||
disposition = str(item.get('disposition') or 'unknown')
|
||||
counts[disposition] = counts.get(disposition, 0) + 1
|
||||
compact_resolutions.append({
|
||||
@@ -441,6 +445,14 @@ def _build_stp_facts(task: ShippingNotice) -> dict[str, Any] | None:
|
||||
'inventory_source_code': str(task.inventory_source_code or '').strip().upper() or None,
|
||||
'inventory_source_method': method or None,
|
||||
'frozen_candidate_codes': [str(code).strip().upper() for code in frozen_codes if str(code or '').strip()],
|
||||
'candidate_set_id': candidate_projection.get('candidate_set_id'),
|
||||
'candidate_set_version': candidate_projection.get('candidate_set_version'),
|
||||
'candidate_set_status': candidate_projection.get('candidate_set_status'),
|
||||
'candidate_source_codes': list(candidate_projection.get('candidate_source_codes') or []),
|
||||
'prepared_source_codes': list(candidate_projection.get('prepared_source_codes') or []),
|
||||
'pending_source_codes': list(candidate_projection.get('pending_source_codes') or []),
|
||||
'failed_source_codes': list(candidate_projection.get('failed_source_codes') or []),
|
||||
'source_attempts': dict(candidate_projection.get('source_attempts') or {}),
|
||||
'resolution_counts': counts,
|
||||
'line_resolutions': compact_resolutions,
|
||||
'multi_source_excel_block': multi_block,
|
||||
|
||||
Reference in new issue
Block a user