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

@@ -6,7 +6,10 @@ backend/tests/test_shipping_notice_business_case.py
逻辑:直接调用领域服务并断言业务单关系,不触发解析和库存副作用。
"""
import pytest
from app import db
from app.core.errors import ConflictError
from app.models import ShippingCase, ShippingTask
from app.services.shipping_notice.business_case_service import resolve_shipping_case_for_new_task
from app.services.shipping_notice.task_workflow import create_batch_tasks, create_task
@@ -52,20 +55,20 @@ def test_revision_inherits_existing_parent_case(app):
assert ShippingCase.query.count() == 1
def test_revision_backfills_case_for_legacy_parent(app):
"""历史父任务没有业务单时,首次修订应补建并复用同一业务单。"""
def test_revision_rejects_parent_without_business_case(app):
"""修订父任务缺少业务单时必须阻断,禁止隐式补建。"""
with app.app_context():
parent = _task('SN-CASE-LEGACY-1')
db.session.add(parent)
db.session.flush()
resolved = resolve_shipping_case_for_new_task(
supersedes_task_id=parent.id,
duplicate_resolution_type='revision',
)
db.session.flush()
assert parent.shipping_case_id == resolved.id
assert ShippingCase.query.count() == 1
with pytest.raises(ConflictError) as exc_info:
resolve_shipping_case_for_new_task(
supersedes_task_id=parent.id,
duplicate_resolution_type='revision',
)
assert exc_info.value.code == 'SHIPPING_NOTICE.REVISION_CASE_MISSING'
assert ShippingCase.query.count() == 0
def test_revision_chain_reuses_root_case(app):