package com.huimv.modular.timer.tasks;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Author Anchor
 * @Date 2021/8/14 17:46
 * @Version 1.0.1
 */

@Slf4j
@Component
public class CheckDeviceAble {

    //查找掉线的设备是否还掉线，让他上线
/*
    @Autowired
    private CollectorRegisterService collectorRegisterService;


    @Autowired
    private HeartBeatRecordDao heartBeatRecordDao ;


    @Autowired
    private CollectorRegisterDao collectorRegisterDao;*/

   // @Scheduled(cron = "0/5 * * * * ?")
    public void  checkDeviceAble() {
        System.out.println( "test");
       /* LambdaQueryWrapper<CollectorRegisterEntity> wrapper11 = new LambdaQueryWrapper();
        wrapper11.eq(CollectorRegisterEntity::getCanStatus, 0);
        List<CollectorRegisterEntity> collectorRegisterEntities = collectorRegisterDao.selectList(wrapper11);
        for (CollectorRegisterEntity collectorRegisterEntity : collectorRegisterEntities) {

            LambdaQueryWrapper<HeartBeatRecordEntity> wrapper = new LambdaQueryWrapper();
            wrapper.eq(HeartBeatRecordEntity::getDeviceCode,collectorRegisterEntity.getDeviceCode()).orderByDesc( HeartBeatRecordEntity::getId ).last( "limit 1");;
            HeartBeatRecordEntity heartBeatRecordEntity = heartBeatRecordDao.selectOne(wrapper);
            Date date = new Date();
            if ((date.getTime() -heartBeatRecordEntity.getCreateTime().getTime())< ImportanteConfig.CHECK_DEVICE_UNABLE_GAP_TIME){
                collectorRegisterEntity.setCanStatus(1);
                collectorRegisterService.updateById(collectorRegisterEntity );

            }

        }*/

    }



}
