feat(shipping-notice): 新增货代客户管理功能,支持客户导入、识别证据管理与客户确认
This commit is contained in:
1 parent
b595e157e9
commit
4fbaed2b4c
176 files changed
+14011
-994
No files matched your search
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
Freight RPA worker (PoC).
|
||||
|
||||
轮询 trigger JSON → 按 source_type 调用 DSV/Crane driver → 回调 hxops Tool API。
|
||||
轮询 trigger JSON → 按 connector_type 调用 DSV/Crane driver → 回调 hxops Tool API。
|
||||
DSV 逻辑见 dsv_driver / dsv_session / dsv_navigation / dsv_report_export;Crane 见 crane_*。
|
||||
|
||||
Usage:
|
||||
@@ -570,14 +570,16 @@ def _save_batch_download(download: Any, drop_dir: Path, run_no: str, source: dic
|
||||
def _validate_inventory_source_for_rpa(source: dict[str, Any]) -> None:
|
||||
"""
|
||||
校验单个库存 RPA source 的最小定位条件。
|
||||
核心逻辑:DSV 必须有 site_id;Crane 只需要 source_type 即可分发,warehouse id 由库存 Excel 结果决定。
|
||||
核心逻辑:DSV 必须有 site_id;Crane 只需要 connector_type 即可分发,warehouse id 由库存 Excel 结果决定。
|
||||
"""
|
||||
source_type = str(source.get("source_type") or "").strip()
|
||||
connector_type = str(source.get("connector_type") or "").strip()
|
||||
source_code = str(source.get("source_code") or "").strip() or "UNKNOWN"
|
||||
site_id = str(source.get("site_id") or "").strip()
|
||||
if source_type not in {"dsv360", "crane_footprint"}:
|
||||
raise RuntimeError(f"{source_code}: source_type must be dsv360 or crane_footprint")
|
||||
if source_type == "dsv360" and not site_id:
|
||||
if connector_type not in {"dsv360", "crane_footprint"}:
|
||||
raise RuntimeError(
|
||||
f"{source_code}: connector_type must be dsv360 or crane_footprint"
|
||||
)
|
||||
if connector_type == "dsv360" and not site_id:
|
||||
raise RuntimeError(f"{source_code}: site_id is required for dsv360")
|
||||
|
||||
|
||||
@@ -752,8 +754,8 @@ def _download_inventory_with_browser(trigger: dict[str, Any], drop_dir: Path) ->
|
||||
source = trigger.get("rpa_inventory_source")
|
||||
if not isinstance(source, dict):
|
||||
raise RuntimeError("inventory trigger missing rpa_inventory_source")
|
||||
source_type = str(source.get("source_type") or "").strip()
|
||||
source_code = str(source.get("source_code") or "").strip() or source_type or "UNKNOWN"
|
||||
connector_type = str(source.get("connector_type") or "").strip()
|
||||
source_code = str(source.get("source_code") or "").strip() or connector_type or "UNKNOWN"
|
||||
_validate_inventory_source_for_rpa(source)
|
||||
|
||||
playwright = context = runtime_profile_dir = None
|
||||
@@ -761,12 +763,12 @@ def _download_inventory_with_browser(trigger: dict[str, Any], drop_dir: Path) ->
|
||||
failed = False
|
||||
try:
|
||||
playwright, context, page, runtime_profile_dir = _open_browser(drop_dir)
|
||||
if source_type == "dsv360":
|
||||
if connector_type == "dsv360":
|
||||
download = _download_dsv360_inventory(page, trigger, source)
|
||||
elif source_type == "crane_footprint":
|
||||
elif connector_type == "crane_footprint":
|
||||
download = _download_crane_inventory(page, trigger, source)
|
||||
else:
|
||||
raise RuntimeError(f"unsupported inventory source_type: {source_type}")
|
||||
raise RuntimeError(f"unsupported inventory connector_type: {connector_type}")
|
||||
return _save_download(download, drop_dir, task_no, source_code)
|
||||
except Exception:
|
||||
failed = True
|
||||
@@ -879,7 +881,7 @@ def _handle_inventory_batch_trigger(trigger_path: Path, drop_dir: Path, processe
|
||||
for source in sources:
|
||||
if not isinstance(source, dict):
|
||||
continue
|
||||
site = str(source.get("source_type") or "").strip()
|
||||
site = str(source.get("connector_type") or "").strip()
|
||||
grouped.setdefault(site, []).append(source)
|
||||
|
||||
for site, site_sources in grouped.items():
|
||||
@@ -899,8 +901,8 @@ def _handle_inventory_batch_trigger(trigger_path: Path, drop_dir: Path, processe
|
||||
"warehouse_id": source.get("warehouse_id"),
|
||||
"status": "failed",
|
||||
"success": False,
|
||||
"error_code": "unsupported_source_type",
|
||||
"error_message": f"unsupported source_type: {site}",
|
||||
"error_code": "unsupported_connector_type",
|
||||
"error_message": f"unsupported connector_type: {site}",
|
||||
})
|
||||
continue
|
||||
|
||||
|
||||
Reference in new issue
Block a user