fix(automation): 修复账号供给补货队列饥饿

- 拆分订单补货和通用供给水位,供给保留独立 pending 配额
- 每批固定供给槽位,避免订单补货占满队列
- 只补覆盖/可兑换缺口,可分配缺口不再无效入队
- 重登工作超过 24h 自动转人工,清理待处理积压
- 补货阻塞告警和队列诊断信息
- 增加供给公平调度/过期清理回归测试
This commit is contained in:
yml
2026-11-24 13:38:19 +08:00
parent 5b6d146f93
commit eda6115ca3
10 changed files with 462 additions and 42 deletions
@@ -17,6 +17,7 @@ from ..models import (
AccountSyncRun,
AccountSyncState,
AccountWorkItem,
AutomationJob,
LoginAttempt,
)
from .account_capability_service import AVAILABILITY_AVAILABLE, AVAILABILITY_LIMITED
@@ -322,6 +323,30 @@ def _supply_snapshot(
"message": "尚未配置启用的账号供给目标",
}
)
refreshable = any(
item.covered_shortage or item.available_shortage
for item in inventories
)
supply_job = (
db.query(AutomationJob)
.filter(AutomationJob.key == "account_supply_replenishment")
.first()
)
if (
refreshable
and supply_job is not None
and "供给补货被订单队列阻塞" in str(supply_job.last_message or "")
):
alerts.append(
{
"code": "supply_replenishment_blocked",
"severity": "warning",
"message": (
"供给补货被同步队列占满,缺口未下降:"
f"{str(supply_job.last_message or '')[:240]}"
),
}
)
return supply_targets, alerts