提交
This commit is contained in:
1 parent
725774ef0c
commit
c3be9d1dce
176 files changed
+41925
-6342
No files matched your search
@@ -20,6 +20,7 @@ def init_scheduled_tasks(get_db_session):
|
||||
remind_customer_recycle,
|
||||
warn_customer_recycle,
|
||||
)
|
||||
from app.tasks.db_auto_plan import auto_generate_monthly_plans_job
|
||||
|
||||
scheduler.add_job(
|
||||
check_customer_protect_time,
|
||||
@@ -27,6 +28,12 @@ def init_scheduled_tasks(get_db_session):
|
||||
id="check_customer_protect_time",
|
||||
replace_existing=True,
|
||||
)
|
||||
scheduler.add_job(
|
||||
auto_generate_monthly_plans_job,
|
||||
"cron", day=1, hour=1, minute=30,
|
||||
id="db_auto_generate_monthly_plans",
|
||||
replace_existing=True,
|
||||
)
|
||||
scheduler.add_job(
|
||||
remind_customer_recycle,
|
||||
"cron", hour=9, minute=0,
|
||||
@@ -47,6 +54,7 @@ def init_scheduled_tasks(get_db_session):
|
||||
)
|
||||
logger.info(
|
||||
"已注册定时任务: check_customer_protect_time(01:00), "
|
||||
"db_auto_generate_monthly_plans(每月1日01:30), "
|
||||
"pool_recovery_job(02:00), remind_customer_recycle(09:00), "
|
||||
"warn_customer_recycle(10:00)"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
"""地磅计划按月自动生成定时任务"""
|
||||
import logging
|
||||
|
||||
from app.core.database import SessionLocal
|
||||
from app.services.db.auto_generate_plans import run_auto_generate_monthly_plans
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def auto_generate_monthly_plans_job():
|
||||
"""每月 1 日凌晨执行:按上月计划模板生成本月计划。"""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
logger.info("======== 开始执行地磅计划按月自动生成任务 ========")
|
||||
result = run_auto_generate_monthly_plans(db, force=False)
|
||||
logger.info(
|
||||
"======== 地磅计划按月自动生成任务完成:created=%s, month=%s, skipped=%s ========",
|
||||
result.get("created_count"),
|
||||
result.get("current_month"),
|
||||
result.get("skipped_reason"),
|
||||
)
|
||||
except Exception:
|
||||
db.rollback()
|
||||
logger.exception("地磅计划按月自动生成任务异常")
|
||||
finally:
|
||||
db.close()
|
||||
Reference in new issue
Block a user