feat(shipping-notice): 新增库存确认来源接口及相关逻辑

This commit is contained in:
hugo committed 2026-07-13 21:53:45 +08:00
1 parent a31735b689
commit 0a9bd6415d
69 files changed
+8442 -775

No files matched your search

@@ -19,6 +19,7 @@ from app.jobs.queue import process_next_job
from app.jobs.types import JobType
from app.services.shipping_notice import batch_orchestrator, dify_executor, dify_inputs, tools as shipping_tools
from app.services.shipping_notice.progress_workflow import auto_progress
from tests.conftest import seed_task_inventory_source
def _tool_headers(app):
@@ -655,6 +656,7 @@ def test_auto_progress_inventory_trigger_failure_marks_step3(app, tmp_path):
}
},
)
seed_task_inventory_source(task, source_code="DSV360_AWSDU")
db.session.add(task)
db.session.commit()
@@ -740,6 +742,7 @@ def test_auto_progress_resolves_dub_inventory_source_into_rpa_trigger(app, tmp_p
app.config["SHIPPING_NOTICE_AUTO_RPA_INVENTORY_ENABLED"] = True
app.config["FREIGHT_INVENTORY_DROP_DIR"] = str(tmp_path / "empty_inventory_drop")
app.config["FREIGHT_RPA_INVENTORY_TRIGGER_DIR"] = str(tmp_path / "inventory_triggers")
app.config["SHIPPING_NOTICE_INVENTORY_RPA_BATCH_ENABLED"] = False
with app.app_context():
user = User(username="shipping_inventory_source_user", email="shipping_inventory_source_user@example.com")
db.session.add(user)
@@ -792,8 +795,7 @@ def test_inventory_source_rules_cover_dsv360_programs(app):
resolution = resolve_inventory_source(task)
assert resolution.status == "resolved"
assert resolution.source is not None
assert resolution.source["source_code"] == expected_code
assert resolution.source_code == expected_code
def test_auto_progress_unknown_destination_requires_inventory_source_review(app):
@@ -822,7 +824,7 @@ def test_auto_progress_unknown_destination_requires_inventory_source_review(app)
db.session.refresh(task)
assert result["status"] == "needs_human"
assert result["checkpoint"] == "inventory_source_review"
assert task.process_status == "waiting_inventory"
assert task.process_status == "pending_review"
assert task.pending_human_reason == "inventory_source_unresolved"
assert task.step_payload_json["inventory_source_resolution"]["status"] == "unresolved"
assert len(result["data"]["inventory_source_candidates"]) >= 4
@@ -1447,6 +1449,7 @@ def test_run_shipping_parse_via_dify_passes_task_context_without_persisting_chat
agent = Agent(
name="货代发货通知 Agent",
agent_code="shipping_notice",
dify_api_key="test-dify-key",
is_active=True,
)