| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- # -*- coding: utf-8 -*-
- """Generate fs_qw_task_sys_job_seed.sql from original fs-qw-task @Scheduled config."""
- from pathlib import Path
- # (job_name, invoke_target, cron_expression, remark)
- # cron from git HEAD fs-qw-task before migration to fs-task
- QW_JOBS = [
- ("企微-SOP规则检查", "qwTask.qwCheckSopRuleTime()", "0 10 1 * * ?", "原 qwTask @Scheduled 0 10 1 * * ?"),
- ("企微-客户打标签", "qwTask.addTag()", "0 0/20 * * * ?", "原 qwTask @Scheduled 0 0/20 * * * ?"),
- ("企微-营期生成SOP日志", "qwTask.selectSopUserLogsListByTime()", "0 5 * * * ?", "原 qwTask @Scheduled 0 5 * * * ?"),
- ("企微-微信SOP处理", "qwTask.wxSop()", "0 5 * * * ?", "原 qwTask @Scheduled 0 5 * * * ?"),
- ("企微-官方接口群发(单链)", "qwTask.SendQwApiSopLogTimer()", "0 20 1 * * ?", "原 qwTask @Scheduled 0 20 1 * * ?"),
- ("企微-官方接口群发(新版)", "qwTask.SendQwApiSopLogTimerNew()", "0 10 0,1 * * ?", "原 qwTask @Scheduled 0 10 0,1 * * ?"),
- ("企微-获取群发结果", "qwTask.GetQwApiSopLogResultTimerNew()", "0 0 8 * * ?", "原 qwTask @Scheduled 0 0 8 * * ?"),
- ("企微-客户群发处理", "qwTask.sendQwGroupMsgTask()", "0 0/10 * * * ?", "原 qwTask @Scheduled 0 0/10 * * * ?"),
- ("企微-发送转换消息", "qwTask.sendQwBySop()", "0 0 8 * * ?", "原 qwTask @Scheduled 0 0 8 * * ?"),
- ("企微-标签备注补偿", "qwTask.qwExternalErrRetryTimer()", "0 0/3 * * * ?", "原 qwTask @Scheduled 0 0/3 * * * ?"),
- ("企微-补发过期完课消息", "qwTask.updateQwSopLogsByCancel()", "0 0 * * * ?", "原 qwTask @Scheduled 0 0 * * * ?"),
- ("企微-批量处理过期消息", "qwTask.batchProcessingExpiredMessages()", "0 0/8 * * * ?", "原 qwTask @Scheduled 0 0/8 * * * ?"),
- ("企微-清理历史SOP日志", "qwTask.deleteQwSopLogsByDate()", "0 10 0 * * ?", "原 qwTask @Scheduled 0 10 0 * * ?"),
- ("企微-修复营期异常数据", "qwTask.processRepairQwSopLogsTimer()", "0 30 0/3 * * ?", "原 qwTask @Scheduled 0 30 0/3 * * ?"),
- ("企微-E级未看课恢复", "qwTask.processSopUserLogsInfoByIsDaysNotStudy()", "0 35 2 * * ?", "原 qwTask @Scheduled 0 35 2 * * ?"),
- ("企微-客户分级评级", "qwTask.processQwSopExternalContactRatingTimer()", "0 45 3 * * ?", "原 qwTask @Scheduled 0 45 3 * * ?"),
- ("企微-超7天未看课标E级", "qwTask.processQwSopExternalContactRatingMoreSevenDaysTimer()", "0 30 3 * * ?", "原 qwTask @Scheduled 0 30 3 * * ?"),
- ("企微-更新前一天待发送", "qwTask.updateQwSopLogsDayBefore()", "0 3 0 * * ?", "原 qwTask @Scheduled 0 3 0 * * ?"),
- ("企微-同步外部联系人UnionId", "qwTask.updateQwExternalContactUnionid()", "0 1 0 */2 * ?", "原 qwTask @Scheduled 0 1 0 */2 * ?"),
- ("企微-自动拉人进群", "qwTask.autoPullGroup()", "0 0 16 * * ?", "原 qwTask @Scheduled 0 0 16 * * ?"),
- ("看课-检查看课状态", "courseWatchLogScheduler.checkWatchStatus()", "0 0/1 * * * ?", "原 fixedRate 60000,用 cron 近似每分钟"),
- ("看课-创建完课消息", "courseWatchLogScheduler.createCourseFinishMsg()", "0 0/5 * * * ?", "原 fixedRate 300000,用 cron 近似每5分钟"),
- ("看课-删除过期短链", "courseWatchLogScheduler.delCourseExpireLink()", "0 0 0 * * ?", "原 CourseWatchLogScheduler @Scheduled 0 0 0 * * ?"),
- ("企微-同步企微员工", "qwUserAsyncTask.syncQwUserAsync()", "0 0 0/3 * * ?", "原 QwUserAsyncTask @Scheduled 0 0 0/3 * * ?"),
- ("看课-会员看课统计", "userCourseWatchCountTask.userCourseCountTask()", "0 */20 * * * ?", "原 UserCourseWatchCountTask @Scheduled 0 */20 * * * ?"),
- ("看课-刷新课程配置缓存", "sopLogsTaskServiceImpl.refreshCourseConfig()", "0 0/1 * * * ?", "原 SopLogsTaskServiceImpl fixedDelay 60000"),
- ("企微-刷新评级配置", "qwExternalContactRatingServiceImpl.refreshRatingConfig()", "0 50 0/6 * * ?", "原 QwExternalContactRatingServiceImpl @Scheduled"),
- ("企微-刷新超7天评级配置", "qwExternalContactRatingMoreSevenDaysServiceImpl.refreshRatingConfig()", "0 50 0/6 * * ?", "原 QwExternalContactRatingMoreSevenDaysServiceImpl @Scheduled"),
- ]
- HEADER = (
- "-- fs-qw-task 迁移至 fs-task 后的 sys_job 种子数据\n"
- "-- job_group=QW_TASK;status=0 启用,status=1 暂停(默认暂停)\n"
- "-- invoke_target 须与 fs-task 模块 Spring Bean 方法一致\n\n"
- )
- def render_job(job_name, invoke_target, cron, remark):
- return (
- "INSERT INTO sys_job (job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark)\n"
- f"SELECT '{job_name}', 'QW_TASK', '{invoke_target}', '{cron}', '3', '1', '1', 'admin', NOW(), '{remark}'\n"
- f"WHERE NOT EXISTS (SELECT 1 FROM sys_job WHERE invoke_target = '{invoke_target}');\n"
- )
- def main():
- lines = [HEADER]
- for job in QW_JOBS:
- lines.append(render_job(*job))
- lines.append("\n")
- lines.append(
- "-- 备注:selectChatSopUserLogsListByTime 原 @Scheduled 已注释,未写入\n"
- "-- 备注:checkFsUserWatchStatus(fixedRate 30s) 未迁移至 fs-task,未写入\n"
- )
- out = Path(__file__).resolve().parent / "fs_qw_task_sys_job_seed.sql"
- out.write_text("".join(lines), encoding="utf-8")
- print("OK", out, "jobs=", len(QW_JOBS))
- if __name__ == "__main__":
- main()
|