package com.gyee.wisdom.alarm.sharding.schedule;

import com.gyee.wisdom.alarm.sharding.service.FaultStatisticWindturbineService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @auther: Wanghs
 * @date: 2022-03-31
 */

@Component
@Slf4j
@EnableScheduling
public class FaultStatScheduled {


    @Value("${count.fault}")
    public boolean fault;

    @Autowired
    private FaultStatisticWindturbineService faultStatisticWindturbineService;

    @Scheduled(cron = "0 20 0 ? * *")
    public String doTask() throws Exception {
        if (!fault) {
            return null;
        }
        String s = faultStatisticWindturbineService.queryCount();
        return s;
    }

}
