baseline: 批次A-D 成果 + membership 半成品(测试红)

This commit is contained in:
agent
2026-09-11 23:11:35 +08:00
commit b3f3095d53
311 changed files with 40540 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
"""预警调度任务 actors(Dramatiq)。"""
import dramatiq
from apps.core.models import Tenant
from . import services as notify_services
@dramatiq.actor(max_retries=3, time_limit=300_000)
def run_alert_checks_for_tenant(tenant_id: int):
"""单租户业务预警扫描(库存低限 + 应收逾期)。"""
tenant = Tenant.objects.get(pk=tenant_id, is_active=True)
result = notify_services.run_all_alert_checks(tenant)
return result
@dramatiq.actor(max_retries=3, time_limit=600_000)
def run_all_alert_checks_for_all_tenants():
"""遍历全部活跃租户执行业务预警扫描(由 crontab 每日 08:00 触发)。"""
summary = []
for tenant in Tenant.objects.filter(is_active=True):
result = notify_services.run_all_alert_checks(tenant)
summary.append({"tenant": tenant.code, **result})
return summary