package com.steerinfo.abnormalHandler.scheduler;

import com.steerinfo.abnormalHandler.service.StatusSyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 状态同步定时调度器
 * 每分钟执行一次，通过配置开关控制是否启用
 */
@Component
@Slf4j
@ConditionalOnProperty(name = "meter.sync.enabled", havingValue = "true", matchIfMissing = false)
public class StatusSyncScheduler {

    @Autowired
    private StatusSyncService statusSyncService;

    /**
     * 每分钟执行一次状态同步
     */
//    @Scheduled(cron = "0 */3 * * * ?")
    public void scheduledSync() {
        log.info("========== 开始执行状态同步定时任务 ==========");
        statusSyncService.doSync();
    }
}