package com.bcrjl.miwifi.job;

import com.bcrjl.miwifi.service.DeviceDayTrafficService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 设备任务
 *
 * @author yanqs
 */
@Slf4j
@Component
public class DeviceJob {
    @Resource
    private DeviceDayTrafficService deviceDayTrafficService;

    @Scheduled(cron = "0 0 0 * * ?")
    public void writeEverydayDeviceTraffic() {
        log.info("每日凌晨执行写入设备流量开始");
        try {
            deviceDayTrafficService.writeEverydayDeviceTraffic();
        } catch (Exception e) {
            log.error("每日写入数据异常", e);
        }
        log.info("每日凌晨执行写入设备流量结束");
    }
}
