feat(contract-payment): 采购合同付款预警
This commit is contained in:
1 parent
5aa431cc8e
commit
03e5e88e27
113 files changed
+11381
-2991
No files matched your search
@@ -56,7 +56,7 @@ def _normalize_kb_job(job: KbJob) -> dict[str, Any]:
|
||||
def claim_next(*, queues: list[str] | None = None) -> dict[str, Any] | None:
|
||||
"""
|
||||
认领下一条待执行 Job(SELECT FOR UPDATE SKIP LOCKED,委托各域 queue_service)。
|
||||
核心逻辑:按 queues 顺序依次尝试 kb / shipping 队列;先 recover 卡死 running 任务。
|
||||
核心逻辑:按 queues 顺序依次尝试 kb / shipping / contract 队列;先 recover 卡死 running 任务。
|
||||
Args:
|
||||
queues: worker 消费的队列名,如 ['kb'] 或 ['kb', 'shipping']。
|
||||
Returns:
|
||||
@@ -90,6 +90,25 @@ def claim_next(*, queues: list[str] | None = None) -> dict[str, Any] | None:
|
||||
job_type=JobType.PROCUREMENT_CONTRACT_REVIEW,
|
||||
on_recovered=sync_review_after_job_recovery,
|
||||
)
|
||||
contract_payment_types = (
|
||||
JobType.CONTRACT_PAYMENT_SYNC,
|
||||
JobType.CONTRACT_PAYMENT_ALERT,
|
||||
JobType.CONTRACT_PAYMENT_ALERT_WEEKLY,
|
||||
)
|
||||
if {item.value for item in contract_payment_types} & allowed_types:
|
||||
from app.jobs.queue import recover_stale_jobs
|
||||
from flask import current_app
|
||||
|
||||
# [STEP 1] 合同付款与合同审核共用 procurement_contract 域,必须按 Job 类型
|
||||
# 分别回收,不能错误使用不存在的 contract_payment 域或套用审核的较短超时。
|
||||
for job_type in contract_payment_types:
|
||||
if job_type.value not in allowed_types:
|
||||
continue
|
||||
recover_stale_jobs(
|
||||
domain="procurement_contract",
|
||||
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:
|
||||
@@ -110,7 +129,12 @@ def claim_next(*, queues: list[str] | None = None) -> dict[str, Any] | None:
|
||||
|
||||
job = claim_next_job(
|
||||
domain="procurement_contract",
|
||||
job_types=[JobType.PROCUREMENT_CONTRACT_REVIEW],
|
||||
job_types=[
|
||||
JobType.PROCUREMENT_CONTRACT_REVIEW,
|
||||
JobType.CONTRACT_PAYMENT_SYNC,
|
||||
JobType.CONTRACT_PAYMENT_ALERT,
|
||||
JobType.CONTRACT_PAYMENT_ALERT_WEEKLY,
|
||||
],
|
||||
)
|
||||
if job:
|
||||
return _normalize_generic_job(job)
|
||||
|
||||
Reference in new issue
Block a user