-- 待办任务过期与历史归档定时任务
-- 默认每天 02:30 执行；归档保留天数通过 todo.retention-days 配置，最少保留 180 天。

INSERT INTO sys_job (
  job_name, job_group, invoke_target, cron_expression,
  misfire_policy, concurrent, status, create_by, create_time, remark
)
SELECT
  '待办过期与历史归档', 'SYSTEM', 'todoTaskMaintenanceTask.maintain()', '0 30 2 * * ?',
  '3', '1', '0', 'system', sysdate(), '过期待处理任务并逻辑归档至少180天前的终态任务'
FROM DUAL
WHERE NOT EXISTS (
  SELECT 1 FROM sys_job
  WHERE invoke_target = 'todoTaskMaintenanceTask.maintain()'
);

SELECT job_id, job_name, invoke_target, cron_expression, status
FROM sys_job
WHERE invoke_target = 'todoTaskMaintenanceTask.maintain()';
