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

@@ -0,0 +1,71 @@
"""
tests/test_shipping_uploaded_gate_closure.py
用途:锁定「已上传任务确认后,Execution 全部门禁必须收口」与「阶段投影不得被陈旧 Execution Gate 回退」的一致性。
背景:
- 订单生命周期工作台按 has_verified_upload_success / Notice 阶段裁决 → 展示「通知完成」;
- 批次中心 / 对话卡按 OT work-item 的 Execution.current_gate_code 覆盖 stage
(shipping_processing_projection),若该 Gate 仍是前置履约 Gate,会把 stage 回退成「通知准备」。
- sync_fulfillment_gates_from_task 的 STEP 1A 只在 _derived_fulfillment_status==uploaded 时收口全部前置 Gate;
因而 upload_status 未落到 uploaded(预约单未全量/迟回调覆盖)时,前置 Gate 保留,阶段投影即回退。
"""
from __future__ import annotations
from app import db
from app.models import ShippingNotice, ShippingProcessExecution, ShippingProcessGate
from app.services.shipping_notice.process_gate_bridge import sync_fulfillment_gates_from_task
from app.services.shipping_notice.process_gate_service import ensure_execution_for_workflow_version
def _mk_execution(task: ShippingNotice) -> ShippingProcessExecution:
"""建正式 20-Gate Execution,并把 inventory_sufficiency 置为人工阻断,让任务停留在「通知准备」。"""
execution = ensure_execution_for_workflow_version(task_id=int(task.id))
task.active_process_execution_id = int(execution.id)
suff = ShippingProcessGate.query.filter_by(
execution_id=execution.id, gate_code='inventory_sufficiency',
).one()
suff.status = 'blocked_manual'
suff.blocking_reason_code = 'inventory_shortage_review_required'
execution.status = 'blocked'
execution.current_gate_code = 'inventory_sufficiency'
db.session.commit()
return execution
def test_step1a_closes_all_gates_when_uploaded(app):
"""upload_status=uploaded → STEP 1A 收口全部前置 Gate,Execution 落到 completed。"""
task = ShippingNotice(task_no='SN-UPLOADED-GATE', upload_status='uploaded', match_status='fulfillable')
db.session.add(task)
db.session.flush()
execution = _mk_execution(task)
sync_fulfillment_gates_from_task(execution=execution, actor_type='user', actor_id=1)
db.session.commit()
db.session.refresh(execution)
open_cnt = ShippingProcessGate.query.filter(
ShippingProcessGate.execution_id == int(execution.id),
ShippingProcessGate.status.notin_(('passed', 'skipped')),
).count()
assert open_cnt == 0, f'已上传任务仍有 {open_cnt} 个 Gate 未收口'
assert execution.current_gate_code is None
assert execution.status == 'completed'
def test_missing_upload_status_keeps_gate_stuck(app):
"""upload_status != uploaded → STEP 1A 不触发,前置 Gate 保留(阶段投影可被回退)。"""
task = ShippingNotice(task_no='SN-UPLOAD-NOT-SET', upload_status='partial', match_status='fulfillable')
db.session.add(task)
db.session.flush()
execution = _mk_execution(task)
sync_fulfillment_gates_from_task(execution=execution, actor_type='user', actor_id=1)
db.session.commit()
db.session.refresh(execution)
suff = ShippingProcessGate.query.filter_by(
execution_id=execution.id, gate_code='inventory_sufficiency',
).one()
# 关键断言:非 uploaded 时前置 Gate 不能被收口 —— 这正是批次中心回退「通知准备」的根因。
assert suff.status != 'passed'