feat(shipping-notice): 新增临时库存管理功能,支持创建会话、获取分析结果及字段映射建议

This commit is contained in:
hugo committed 2026-07-18 11:41:02 +08:00
1 parent 46eb63f5bb
commit e9bdd81f1a
320 files changed
+28361 -10487

No files matched your search

@@ -3,7 +3,7 @@ backend/tests/test_shipping_customer_identity_gate.py
用途:验证客户人工确认与库存/RPA/匹配/Excel/上传统一 Gate。
依赖:内存数据库、customer_identity_gate、各货代公共 workflow 入口。
逻辑:构造 pending 任务逐入口断言无副作用;确认后验证业务单/修订同步和历史兼容。
逻辑:构造 pending 或缺失业务单的任务逐入口断言无副作用;确认后验证业务单/修订同步。
"""
from __future__ import annotations
@@ -26,7 +26,7 @@ from app.services.shipping_notice.inventory_rpa_workflow import (
_validate_rpa_callback_gate,
ensure_inventory_via_rpa,
)
from app.services.shipping_notice.inventory_workflow import ensure_inventory, parse_inventory, upload_inventory_file
from app.services.shipping_notice.inventory_workflow import ensure_inventory, upload_inventory_file
from app.services.shipping_notice.progress_workflow import auto_progress
from app.services.shipping_notice.task_workflow import retry_task
@@ -71,7 +71,6 @@ def test_pending_customer_blocks_every_downstream_entry(app):
results = [
auto_progress({'task_id': task.task_no}),
parse_inventory({'task_id': task.task_no, 'inventory_lines': [{'sku': 'A001', 'available_qty': 10}]}),
ensure_inventory({'task_id': task.task_no, 'inventory_lines': [{'sku': 'A001', 'available_qty': 10}]}),
upload_inventory_file(
task.task_no,
@@ -140,8 +139,8 @@ def test_confirm_customer_syncs_revision_chain_and_assigns_number(app):
assert db.session.query(ShippingTaskEvent).filter_by(event_type='business_number_assigned').count() == 2
def test_inactive_customer_reblocks_and_legacy_task_is_compatible(app):
"""已确认客户停用后重新阻断;历史无业务单任务继续兼容。"""
def test_inactive_customer_reblocks_and_missing_case_is_blocked(app):
"""已确认客户停用后重新阻断;缺少业务单的任务也必须阻断。"""
with app.app_context():
task, customer, user = _seed_task()
confirm_task_customer(task, customer_id=customer.id, actor_id=user.id)
@@ -151,9 +150,11 @@ def test_inactive_customer_reblocks_and_legacy_task_is_compatible(app):
assert_customer_identity_gate(task, operation='match_inventory')
assert exc_info.value.code == 'SHIPPING.CUSTOMER_CONFIRMATION_REQUIRED'
legacy, _other_customer, _other_user = _seed_task(with_case=False)
assert_customer_identity_gate(legacy, operation='match_inventory')
assert customer_identity_is_confirmed(legacy) is True
missing_case, _other_customer, _other_user = _seed_task(with_case=False)
with pytest.raises(AppError) as missing_case_error:
assert_customer_identity_gate(missing_case, operation='match_inventory')
assert missing_case_error.value.code == 'SHIPPING.CUSTOMER_CONFIRMATION_REQUIRED'
assert customer_identity_is_confirmed(missing_case) is False
def test_workspace_customer_search_and_confirmation_api(app, client):