package com.gyee.runeconomy.task;

import com.gyee.runeconomy.service.EarlyWarning.EarlyWarningReliableService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@EnableAsync  // 启用异步方法执行
public class AnalysisTask {
    private static final Logger logger = LoggerFactory.getLogger(AnalysisTask.class);

    @Autowired
    private EarlyWarningReliableService earlyWarningReliableService;
    // 每日1点 - 日曲线偏差
    @Async
    @Scheduled(cron = "0 0 1 1/1 * ?")
    public void rqxpc() {
        try {
            logger.info("预警报告计算开始运行");
            earlyWarningReliableService.Electricity();
            logger.info("预警报告计算运行完成");
        } catch (Exception e) {
            logger.error("预警报告计算运行失败", e);
        }
    }

}
