fix(shipping-process-gates): 收口技术重试并补齐运维 UI
跨 Job 累计技术失败次数,耗尽后将 Attempt/Gate 置为 failed_terminal; 收缩旧 action_buttons;healthcheck 增加 Worker 领取探针;恢复卡展示责任方与审计,Admin 诊断改主从布局。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
323928626b
commit
cef3d5b26a
15 files changed
+489
-150
No files matched your search
@@ -6,7 +6,8 @@ services/shipping_notice/process_gate_job_service.py
|
||||
process_gate_service、fulfillment_audit。
|
||||
逻辑:由 recovery_service 对异步动作调用 enqueue;Worker Handler 调用
|
||||
claim_and_run_gate_attempt;重试/轮询使用 force_new 避免复用 running Job;
|
||||
waiting_external 超时转入 blocked_manual;心跳 commit 后对其他 Worker 可见。
|
||||
waiting_external 超时转入 blocked_manual;心跳 commit 后对其他 Worker 可见;
|
||||
enqueue_process_gate_healthcheck_probe 供部署脚本验证 Worker 真实领取。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -54,6 +55,31 @@ def _heartbeat_seconds() -> int:
|
||||
return max(int(current_app.config.get('SHIPPING_PROCESS_GATE_HEARTBEAT_SECONDS', 15) or 15), 5)
|
||||
|
||||
|
||||
def enqueue_process_gate_healthcheck_probe(*, created_by_id: int | None = None) -> int:
|
||||
"""
|
||||
入队门禁健康检查探针 Job,供 deploy healthcheck 验证 Worker 真实领取。
|
||||
|
||||
核心逻辑:payload.healthcheck_probe=True,handler 领取后直接 finish,不依赖 Attempt。
|
||||
|
||||
Returns:
|
||||
Job 主键。
|
||||
"""
|
||||
business_ref = f'healthcheck:process-gate:{_utc_now().strftime("%Y%m%d%H%M%S")}:{uuid.uuid4().hex[:8]}'
|
||||
return int(
|
||||
enqueue(
|
||||
JobType.SHIPPING_PROCESS_GATE,
|
||||
{'healthcheck_probe': True},
|
||||
domain=SHIPPING_PROCESS_GATE_JOB_DOMAIN,
|
||||
business_ref=business_ref,
|
||||
created_by_id=created_by_id,
|
||||
message='Process Gate healthcheck probe',
|
||||
max_attempts=1,
|
||||
dedupe_active=False,
|
||||
commit=True,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def enqueue_gate_attempt_job(
|
||||
*,
|
||||
attempt_id: int,
|
||||
|
||||
@@ -6,8 +6,8 @@ services/shipping_notice/ui_state.py
|
||||
process_gate_projection(统一 Gate 用户摘要)。
|
||||
逻辑:从 ShippingTask DB 字段经状态机解析 checkpoint/checkpoint_kind/action_buttons,
|
||||
再补充七步流程与可解释 summary(当前待办、暂停原因、下一自动步骤、操作入口、stp_facts);
|
||||
若存在 ProcessExecution 且当前有 blocking Gate,则清空 action_buttons,
|
||||
恢复动作仅由 process_gate 驱动(Gate 为唯一业务真相);
|
||||
若存在 ProcessExecution:阻断时清空 action_buttons;非阻断时仅保留
|
||||
download_excel / mark_manual_uploaded / refresh(恢复动作仅由 process_gate 驱动);
|
||||
批次 UI 仅作会话上传集合摘要,不作为履约写操作面。
|
||||
"""
|
||||
|
||||
@@ -555,9 +555,17 @@ def build_task_ui_state(task: ShippingTask) -> dict[str, Any]:
|
||||
ui = resolve_task_ui_state(task)
|
||||
action_buttons = _action_buttons_for_task(task)
|
||||
process_gate = _process_gate_user_summary_for_task(task)
|
||||
# [STEP] Gate 阻断时旧 action_buttons 不再作为业务恢复真相,避免双卡片/双动作。
|
||||
if isinstance(process_gate, dict) and process_gate.get('current_blocking_gate'):
|
||||
action_buttons = []
|
||||
# [STEP] 存在 ProcessExecution 时恢复动作仅由 process_gate 驱动;
|
||||
# 仅保留非恢复类 STP 动作(下载 Excel / 人工上传凭据 / 刷新)。
|
||||
_non_recovery_action_ids = frozenset({'download_excel', 'mark_manual_uploaded', 'refresh'})
|
||||
if isinstance(process_gate, dict):
|
||||
if process_gate.get('current_blocking_gate'):
|
||||
action_buttons = []
|
||||
else:
|
||||
action_buttons = [
|
||||
button for button in action_buttons
|
||||
if str((button or {}).get('id') or '') in _non_recovery_action_ids
|
||||
]
|
||||
steps = build_shipping_workflow_steps(task, ui.checkpoint)
|
||||
current_index = _derive_current_step_index(task)
|
||||
current_step = steps[current_index] if 0 <= current_index < len(steps) else None
|
||||
|
||||
Reference in new issue
Block a user