package com.iformall.schedule;


import com.iformall.mapper.KwBoxMapper;
import com.iformall.mapper.KwMeterMapper;
import com.iformall.mapper.WxDeviceMapper;



import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;


@Component
public class DeviceHbCheckSchedule {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    private final int TIME_OUT_VALUE = 15 * 60 * 1000; //15分钟


    @Autowired
    WxDeviceMapper wxDeviceMapper;

    @Autowired
    KwBoxMapper kwBoxMapper;

    @Autowired
    KwMeterMapper kwMeterMapper;

    @Scheduled(cron = "0 */5 * * * *?") // 每5分钟检查一次
    //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次
    public void offlineCheckSchedule() {
        Date expiredTime = new Date((new Date().getTime() - TIME_OUT_VALUE));
        wxDeviceMapper.offlineScan(expiredTime);
        kwBoxMapper.offlineScan(expiredTime);
        kwMeterMapper.offlineScan(expiredTime);
    }

}