-- fs-qw-task 迁移至 fs-task 后的 sys_job_template 种子数据
-- scope=TENANT（租户级任务）；module_tag=QW_TASK（对应原 job_group）
-- default_status=1 表示新租户默认暂停，需总后台手动开启后同步；status=0 表示模板启用
-- invoke_target 须与 fs-task 模块 Spring Bean 方法一致

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.checkSopRuleTime',          '企微-SOP规则检查',              'QW_TASK', 'qwTask.qwCheckSopRuleTime()',                                                 '0 10 1 * * ?',    '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 10 1 * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.checkSopRuleTime');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.addTag',                    '企微-客户打标签',                'QW_TASK', 'qwTask.addTag()',                                                              '0 0/20 * * * ?',  '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 0/20 * * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.addTag');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.selectSopUserLogs',         '企微-营期生成SOP日志',            'QW_TASK', 'qwTask.selectSopUserLogsListByTime()',                                         '0 5 * * * ?',     '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 5 * * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.selectSopUserLogs');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.wxSop',                     '企微-微信SOP处理',               'QW_TASK', 'qwTask.wxSop()',                                                              '0 5 * * * ?',     '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 5 * * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.wxSop');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.sendQwApiSopLog',           '企微-官方接口群发(单链)',          'QW_TASK', 'qwTask.SendQwApiSopLogTimer()',                                                '0 20 1 * * ?',    '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 20 1 * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.sendQwApiSopLog');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.sendQwApiSopLogNew',        '企微-官方接口群发(新版)',          'QW_TASK', 'qwTask.SendQwApiSopLogTimerNew()',                                             '0 10 0,1 * * ?',  '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 10 0,1 * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.sendQwApiSopLogNew');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.getQwApiSopLogResult',      '企微-获取群发结果',               'QW_TASK', 'qwTask.GetQwApiSopLogResultTimerNew()',                                          '0 0 8 * * ?',     '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 0 8 * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.getQwApiSopLogResult');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.sendQwGroupMsg',            '企微-客户群发处理',               'QW_TASK', 'qwTask.sendQwGroupMsgTask()',                                                   '0 0/10 * * * ?',  '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 0/10 * * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.sendQwGroupMsg');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.sendQwBySop',               '企微-发送转换消息',               'QW_TASK', 'qwTask.sendQwBySop()',                                                          '0 0 8 * * ?',     '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 0 8 * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.sendQwBySop');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.externalErrRetry',          '企微-标签备注补偿',               'QW_TASK', 'qwTask.qwExternalErrRetryTimer()',                                              '0 0/3 * * * ?',   '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 0/3 * * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.externalErrRetry');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.updateSopLogsByCancel',     '企微-补发过期完课消息',            'QW_TASK', 'qwTask.updateQwSopLogsByCancel()',                                              '0 0 * * * ?',     '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 0 * * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.updateSopLogsByCancel');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.batchProcessingExpired',    '企微-批量处理过期消息',            'QW_TASK', 'qwTask.batchProcessingExpiredMessages()',                                       '0 0/8 * * * ?',   '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 0/8 * * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.batchProcessingExpired');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.deleteSopLogsByDate',       '企微-清理历史SOP日志',            'QW_TASK', 'qwTask.deleteQwSopLogsByDate()',                                                '0 10 0 * * ?',    '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 10 0 * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.deleteSopLogsByDate');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.processRepairSopLogs',      '企微-修复营期异常数据',            'QW_TASK', 'qwTask.processRepairQwSopLogsTimer()',                                          '0 30 0/3 * * ?',  '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 30 0/3 * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.processRepairSopLogs');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.processIsDaysNotStudy',     '企微-E级未看课恢复',              'QW_TASK', 'qwTask.processSopUserLogsInfoByIsDaysNotStudy()',                                '0 35 2 * * ?',    '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 35 2 * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.processIsDaysNotStudy');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.externalContactRating',     '企微-客户分级评级',               'QW_TASK', 'qwTask.processQwSopExternalContactRatingTimer()',                                '0 45 3 * * ?',    '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 45 3 * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.externalContactRating');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.ratingMoreSevenDays',       '企微-超7天未看课标E级',           'QW_TASK', 'qwTask.processQwSopExternalContactRatingMoreSevenDaysTimer()',                   '0 30 3 * * ?',    '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 30 3 * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.ratingMoreSevenDays');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.updateSopLogsDayBefore',    '企微-更新前一天待发送',            'QW_TASK', 'qwTask.updateQwSopLogsDayBefore()',                                             '0 3 0 * * ?',     '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 3 0 * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.updateSopLogsDayBefore');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.updateExternalUnionid',     '企微-同步外部联系人UnionId',       'QW_TASK', 'qwTask.updateQwExternalContactUnionid()',                                        '0 1 0 */2 * ?',   '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 1 0 */2 * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.updateExternalUnionid');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.autoPullGroup',             '企微-自动拉人进群',               'QW_TASK', 'qwTask.autoPullGroup()',                                                        '0 0 16 * * ?',    '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 qwTask @Scheduled 0 0 16 * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.autoPullGroup');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'course.checkWatchStatus',      '看课-检查看课状态',               'QW_TASK', 'courseWatchLogScheduler.checkWatchStatus()',                                    '0 0/1 * * * ?',   '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 fixedRate 60000，用 cron 近似每分钟'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'course.checkWatchStatus');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'course.createCourseFinishMsg', '看课-创建完课消息',               'QW_TASK', 'courseWatchLogScheduler.createCourseFinishMsg()',                               '0 0/5 * * * ?',   '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 fixedRate 300000，用 cron 近似每5分钟'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'course.createCourseFinishMsg');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'course.delCourseExpireLink',   '看课-删除过期短链',               'QW_TASK', 'courseWatchLogScheduler.delCourseExpireLink()',                                 '0 0 0 * * ?',     '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 CourseWatchLogScheduler @Scheduled 0 0 0 * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'course.delCourseExpireLink');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.syncQwUser',                '企微-同步企微员工',               'QW_TASK', 'qwUserAsyncTask.syncQwUserAsync()',                                              '0 0 0/3 * * ?',   '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 QwUserAsyncTask @Scheduled 0 0 0/3 * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.syncQwUser');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'course.userCourseCount',       '看课-会员看课统计',               'QW_TASK', 'userCourseWatchCountTask.userCourseCountTask()',                                '0 */20 * * * ?',  '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 UserCourseWatchCountTask @Scheduled 0 */20 * * * ?'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'course.userCourseCount');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'sop.refreshCourseConfig',      '看课-刷新课程配置缓存',            'QW_TASK', 'sopLogsTaskServiceImpl.refreshCourseConfig()',                                  '0 0/1 * * * ?',   '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 SopLogsTaskServiceImpl fixedDelay 60000'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'sop.refreshCourseConfig');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.refreshRatingConfig',       '企微-刷新评级配置',               'QW_TASK', 'qwExternalContactRatingServiceImpl.refreshRatingConfig()',                      '0 50 0/6 * * ?',  '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 QwExternalContactRatingServiceImpl @Scheduled'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.refreshRatingConfig');

INSERT INTO sys_job_template (template_code, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, scope, module_tag, default_status, status, create_by, create_time, remark)
SELECT 'qw.refreshRatingMoreSeven',    '企微-刷新超7天评级配置',           'QW_TASK', 'qwExternalContactRatingMoreSevenDaysServiceImpl.refreshRatingConfig()',          '0 50 0/6 * * ?',  '3', '1', 'TENANT', 'QW_TASK', '1', '0', 'admin', NOW(), '原 QwExternalContactRatingMoreSevenDaysServiceImpl @Scheduled'
WHERE NOT EXISTS (SELECT 1 FROM sys_job_template WHERE template_code = 'qw.refreshRatingMoreSeven');

-- 备注：selectChatSopUserLogsListByTime 原 @Scheduled 已注释，未写入
-- 备注：checkFsUserWatchStatus(fixedRate 30s) 未迁移至 fs-task，未写入
