feat(shipping-notice): 完善订单模板解析与库存 RPA 调度流程

- 新增行字段补充合并与订单模板匹配能力
- 优化运行时解析策略、签名校验及资料验证
- 完善库存 RPA 归档、收尾与 Worker 启动流程
- 补充前后端测试、多语言文案及功能文档
This commit is contained in:
hugo committed 2026-09-09 14:32:43 +08:00
1 parent 8f2f568f92
commit dabf140e41
45 files changed
+2007 -151

No files matched your search

+51
View File
@@ -323,6 +323,57 @@ def test_batch_scheduled_trigger_skips_per_source_task_identity(monkeypatch, tmp
assert not (failed_dir / trigger_path.name).exists()
def test_batch_configuration_test_skips_per_source_task_identity(monkeypatch, tmp_path):
"""配置测试无订单 Attempt/Gate 身份:不得 trigger_identity_invalid,须回调专用 ready。"""
worker = _load_freight_rpa_worker()
trigger_dir = tmp_path / "triggers"
drop_dir = tmp_path / "drop"
processed_dir = trigger_dir / "processed"
failed_dir = trigger_dir / "failed"
trigger_dir.mkdir()
drop_dir.mkdir()
run_no = "CONFIG-DSV360_AWSBI_BYAWSPRD01-20260909020428918536"
trigger_path = trigger_dir / f"inventory_export_batch_{run_no}.json"
# 与 inventory_configuration_test.start_test_export 写入形状一致:
# trigger_type=configuration_test,无 task_no / gate_id / execution_id 等生产身份。
trigger_path.write_text(json.dumps({
"action": "inventory_export_batch",
"schema_version": "shipping_inventory_rpa.v2",
"callback_id": f"{run_no}:batch:C1",
"batch_run_no": run_no,
"run_no": run_no,
"trigger_type": "configuration_test",
"configuration_test_run_id": 42,
"requested_at": "2026-09-09T02:04:28.918536",
"inventory_sources": [{
"source_code": "DSV360_AWSBI_BYAWSPRD01",
"connector_type": "dbs",
"worker_connector_type": "dsv360",
"warehouse_id": "BYAWSPRD01",
"login_url": "https://s360.dbschenker.com/",
"entry_url": "https://s360.dbschenker.com/",
"navigation": {},
"parameters": [],
"query": {},
"credential_envelope": {},
}],
}), encoding="utf-8")
callbacks: list[tuple[str, dict]] = []
monkeypatch.setenv("SHIPPING_NOTICE_RPA_WORKER_MOCK", "true")
monkeypatch.setattr(worker, "_post_callback", lambda path, body: callbacks.append((path, body)))
worker._handle_inventory_batch_trigger(trigger_path, drop_dir, processed_dir)
assert not any(body.get("error_code") == "trigger_identity_invalid" for _, body in callbacks)
ready = next(body for path, body in callbacks if path.endswith("/inventory-configuration-test-ready"))
assert ready["run_no"] == run_no
assert ready["status"] == "success"
assert ready.get("file_path")
assert not any(path.endswith("/inventory-batch-ready") for path, _ in callbacks)
assert (processed_dir / trigger_path.name).is_file()
assert not (failed_dir / trigger_path.name).exists()
def test_batch_interrupt_keeps_trigger_and_completes_best_effort_browser_cleanup(monkeypatch, tmp_path):
"""Ctrl+C 中断导出时不回调或移动 trigger,且清理异常不能阻止停止 Playwright。"""
worker = _load_freight_rpa_worker()