zhaowenyu
2025-10-31 153091d6b8962fddcf9af750164c81c8aab80be2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.ard.sample.manage.service.impl;
 
import com.ard.sample.manage.model.dto.DeviceDTO;
import com.ard.sample.manage.service.IDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import java.util.List;
 
@Component
public class DockOnlineServiceImpl {
 
    @Autowired
    private IDeviceService _deviceService;
 
    /**
     * 定时任务,每5秒取一次机场设备的在线状态,如已离线更新状态
     * */
    @Scheduled(cron = "0/5 * * * * ?")
    public void cronOnlineTask() {
        List<DeviceDTO> devicesList = _deviceService.getDevicesTopoForWeb();
        for (DeviceDTO device : devicesList) {
            //String key = "online:" + device.getDeviceSn();
            //System.out.println("在线状态:"+RedisOpsUtils.checkExist(key));
            // 更新机场设备状态:"3"-"设备已离线",
            if(!_deviceService.checkDeviceOnline(device.getDeviceSn())){
                _deviceService.updateWorkType(device.getDeviceSn(), 3L);
            }
        }
    }
}