fix(shipping-notice,admin-schedule,frontend): 修复发货通知与后台排程的业务bug并优化各模块功能

1.  后端发货通知模块:
    清空重试任务旧状态避免残留,新增RPA进度回调接口
    优化库存匹配性能,修复人工确认校验逻辑与登录弹窗遮挡问题
    新增排程worker启动脚本,清理冗余环境配置与缓存查询开销
2.  前端后台排程模块:
    新增任务key归一化工具兼容历史格式,修复参数表单隐藏问题
    添加加载错误处理,更新多语言文案替换裸JSON占位符
This commit is contained in:
hugo committed 2026-08-26 22:05:25 +08:00
1 parent 1e5aedb9ed
commit 06c18b3c7c
81 files changed
+3301 -424

No files matched your search

@@ -1033,6 +1033,55 @@ def test_process_execution_projection_exposes_server_owned_recovery_targets(app)
assert projection['active_recovery_plans'] == []
def test_process_execution_projection_batch_loads_latest_attempts(app):
"""serialize_process_execution 必须批量预取 LatestAttempt 并写入会话读缓存,避免逐 Gate N+1。"""
from app import db
from app.models import (
ShippingProcessExecution,
ShippingProcessGate,
ShippingProcessGateAttempt,
)
from app.services.shipping_notice.process_gate_projection import serialize_process_execution
with app.app_context():
execution = ShippingProcessExecution(
execution_no='EXE-BATCH-ATTEMPT', status='blocked',
current_gate_code='inventory_matching', lock_version=1,
)
db.session.add(execution)
db.session.flush()
gate = ShippingProcessGate(
execution_id=execution.id, gate_code='inventory_matching', sequence_no=15,
status='blocked_manual', evaluation_version=2,
)
db.session.add(gate)
db.session.flush()
attempt = ShippingProcessGateAttempt(
gate_id=gate.id, attempt_no=1, status='failed',
idempotency_key='exec-batch-attempt-1',
)
db.session.add(attempt)
db.session.flush()
# 把 Gate 的最新 attempt 指针指向该 attempt。
gate.latest_attempt_id = attempt.id
db.session.flush()
# 先清除任何遗留的会话读缓存,模拟工作台路径(ui_state 不预置缓存)。
db.session.info.pop('shipping_conversation_projection_read_cache', None)
projection = serialize_process_execution(execution)
# 调用后应把本 Execution 的 gates + latest_attempt 写入读缓存。
cache = db.session.info.get('shipping_conversation_projection_read_cache') or {}
gates_by_execution = cache.get('gates_by_execution_id', {})
latest_by_id = cache.get('latest_attempt_by_id', {})
assert int(execution.id) in gates_by_execution
assert any(gate.id == g.id for g in gates_by_execution[int(execution.id)])
# current_gate 的 latest 信息必须命中缓存里预取的 attempt,而不是触发额外的 query.get()。
current_gate_latest = projection.get('current_gate', {}).get('latest_attempt')
# 未提供 attempt snapshot / error 时也可能为 None;关键断言是缓存已填充。
assert int(attempt.id) in latest_by_id
def test_recovery_plan_outcome_mapping_is_terminal_or_waiting():
"""RecoveryPlan 必须将 Attempt 结果映射到可审计的计划状态。"""
from app.services.shipping_notice.recovery_plan_service import complete_recovery_plan_for_attempt