feat(rpa): 实现库存源路由与 RPA Driver 方案

- 添加库存源解析逻辑,根据发货通知目的地解析 RPA 源
- 实现 DSV 360 和 Crane FootPrint 的库存源配置
- 增加自动登录功能,优化浏览器操作
- 更新本地启动脚本,支持跳过 Worker 启动
- 添加后端测试,验证库存源解析与任务取消逻辑
- 编写文档,描述库存源路由与 RPA Driver 方案
This commit is contained in:
hugo committed 2026-06-29 20:34:49 +08:00
commit 1921959fc1
61 files changed
+2347 -473

No files matched your search

+29
View File
@@ -36,6 +36,35 @@ def _worker_id() -> str:
return f"{host}:{id(db.session)}"
def _find_shipping_notice_job_id(task_no: str) -> int | None:
"""
按 task_no 查找发货任务对应的 KbJob。
Args:
task_no: 发货任务号;由 AI 或业务代码传入时可大小写混用。
Returns:
匹配到的最新 KbJob 主键;未找到返回 None。
"""
from app import db
from app.models import KbJob
normalized_task_no = str(task_no or '').strip().upper()
candidates = (
db.session.query(KbJob)
.filter(
KbJob.job_type == JobType.SHIPPING_NOTICE_RUN.value,
KbJob.status.in_(('queued', 'running', 'success', 'failed')),
)
.order_by(KbJob.id.desc())
.limit(50)
.all()
)
for job in candidates:
payload_json = job.payload_json or {}
if str(payload_json.get('task_no') or '').strip().upper() == normalized_task_no:
return job.id
return None
def enqueue(
job_type: JobType | str,
payload: dict[str, Any],