package com.cpp.web.job;

import com.cpp.web.service.accuracy.CalcAccuracy;
import com.cpp.web.service.alarm.AlarmLog;
import com.cpp.web.service.datafactory.SftpFileParsing;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时任务管理类
 */
@RequiredArgsConstructor
@Component
public class ScheduledJob implements ApplicationRunner {
    private final SftpFileParsing sftpFileParsing;

    private final CalcAccuracy calcAccuracy;

    /**
     * 解析文件定时任务
     */
//    @Scheduled(fixedRate = 60000L)
    public void parsingFile() {
        sftpFileParsing.parsingFile();
    }


    /**
     * 计算准确率定时任务
     */
//    @Scheduled(cron = "0 17 9 * * *")
    public void calculate() {
        calcAccuracy.calculate();
    }

    /**
     * 告警消纳定时任务
     */
//    @Scheduled(fixedRate = 60000L)
    public void e() {
        AlarmLog.getInstance().eliminate();
    }


    @Override
    public void run(ApplicationArguments args) throws Exception {
        AlarmLog.getInstance().initMap();
    }
}
