-- 阜宁运维定时任务：由 system_timer 微服务通过 quartz_job 调度
-- 前置：先执行 quartz_job.module.column.sql（若尚无 module 列）
-- bean_name 固定为 visitServiceJob（VisitServiceJobBiz），module 为 VisitServiceFegin 方法名
-- state：1=运行 2=暂停；新增后请在「作业调度」中恢复任务或重启 system_timer 以加载 Cron

INSERT INTO `quartz_job` (`bean_name`, `params`, `module`, `cron_expres`, `state`, `remark`, `create_time`)
SELECT 'visitServiceJob', '', 'getElectricalStatus', '0 */5 * * * ?', 1, '智能电表-采集器在线状态', CURRENT_TIMESTAMP
WHERE NOT EXISTS (
    SELECT 1 FROM `quartz_job` WHERE `module` = 'getElectricalStatus' AND `bean_name` = 'visitServiceJob'
);

INSERT INTO `quartz_job` (`bean_name`, `params`, `module`, `cron_expres`, `state`, `remark`, `create_time`)
SELECT 'visitServiceJob', '', 'syncElectricalMeterData', '30 0 * * * ?', 1, '智能电表-每小时批量抄表', CURRENT_TIMESTAMP
WHERE NOT EXISTS (
    SELECT 1 FROM `quartz_job` WHERE `module` = 'syncElectricalMeterData' AND `bean_name` = 'visitServiceJob'
);

INSERT INTO `quartz_job` (`bean_name`, `params`, `module`, `cron_expres`, `state`, `remark`, `create_time`)
SELECT 'visitServiceJob', '', 'cleanElectricalLog', '0 30 2 * * ?', 1, '智能电表-清理三个月前接口日志', CURRENT_TIMESTAMP
WHERE NOT EXISTS (
    SELECT 1 FROM `quartz_job` WHERE `module` = 'cleanElectricalLog' AND `bean_name` = 'visitServiceJob'
);

INSERT INTO `quartz_job` (`bean_name`, `params`, `module`, `cron_expres`, `state`, `remark`, `create_time`)
SELECT 'visitServiceJob', '', 'syncConditionerGatewayStatus', '0 */5 * * * ?', 1, '空调多联机-网关在线状态同步', CURRENT_TIMESTAMP
WHERE NOT EXISTS (
    SELECT 1 FROM `quartz_job` WHERE `module` = 'syncConditionerGatewayStatus' AND `bean_name` = 'visitServiceJob'
);

INSERT INTO `quartz_job` (`bean_name`, `params`, `module`, `cron_expres`, `state`, `remark`, `create_time`)
SELECT 'visitServiceJob', '', 'syncConditionerIndoorUnits', '0 */10 * * * ?', 1, '空调多联机-内机运行态同步', CURRENT_TIMESTAMP
WHERE NOT EXISTS (
    SELECT 1 FROM `quartz_job` WHERE `module` = 'syncConditionerIndoorUnits' AND `bean_name` = 'visitServiceJob'
);

INSERT INTO `quartz_job` (`bean_name`, `params`, `module`, `cron_expres`, `state`, `remark`, `create_time`)
SELECT 'visitServiceJob', '', 'syncConditionerUsagePreviousDay', '0 1 0 * * ?', 1, '空调多联机-同步前一日用量报表', CURRENT_TIMESTAMP
WHERE NOT EXISTS (
    SELECT 1 FROM `quartz_job` WHERE `module` = 'syncConditionerUsagePreviousDay' AND `bean_name` = 'visitServiceJob'
);
