feat(equipment-acceptance): 预警扫描发送改异步并错开合同付款排程

手动扫描/发送入队由 schedule worker 执行,避免 Nginx 504;默认扫描 06:30、周五发送 18:30。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
sophieandCursor committed 2026-10-30 15:09:16 +08:00
1 parent 2e8405e2f0
commit 537e3e18f0
16 files changed
+334 -73

No files matched your search

+27 -1
View File
@@ -109,6 +109,23 @@ def claim_next(*, queues: list[str] | None = None) -> dict[str, Any] | None:
timeout_seconds=float(current_app.config.get("CONTRACT_PAYMENT_JOB_TIMEOUT_SECONDS", 1800)),
job_type=job_type,
)
equipment_acceptance_types = (
JobType.EQUIPMENT_ACCEPTANCE_ALERT_SCAN,
JobType.EQUIPMENT_ACCEPTANCE_ALERT_WEEKLY,
)
if {item.value for item in equipment_acceptance_types} & allowed_types:
from app.jobs.queue import recover_stale_jobs
from flask import current_app
# 设备验收发送可能要给很多收件人发企微,超时与合同付款周汇总同级。
for job_type in equipment_acceptance_types:
if job_type.value not in allowed_types:
continue
recover_stale_jobs(
domain="equipment_acceptance",
timeout_seconds=float(current_app.config.get("CONTRACT_PAYMENT_JOB_TIMEOUT_SECONDS", 1800)),
job_type=job_type,
)
# [STEP 2] 按队列优先级 claim
for name in queue_names:
@@ -149,13 +166,22 @@ def claim_next(*, queues: list[str] | None = None) -> dict[str, Any] | None:
)
if job:
return _normalize_generic_job(job)
# file-check / 企微通讯录同步与排程共用 schedule worker,但 domain 不同
# file-check / 企微通讯录同步 / 设备验收手动扫描发送与排程共用 schedule worker
job = claim_next_job(
domain=None,
job_types=[JobType.FILE_CHECK_RUN, JobType.WECOM_DIRECTORY_SYNC],
)
if job:
return _normalize_generic_job(job)
job = claim_next_job(
domain="equipment_acceptance",
job_types=[
JobType.EQUIPMENT_ACCEPTANCE_ALERT_SCAN,
JobType.EQUIPMENT_ACCEPTANCE_ALERT_WEEKLY,
],
)
if job:
return _normalize_generic_job(job)
elif name == 'transfer':
# 在途调拨域:预检/票级执行/行级任务共用 domain="in_transit_transfer"
# (与 execution_service 入队口径一致);缺此分支时 transfer worker