| New file |
| | |
| | | package com.ard.sample.manage.service.impl; |
| | | |
| | | import com.ard.common.core.redis.RedisOpsUtils; |
| | | 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(!RedisOpsUtils.checkExist(key)){ |
| | | _deviceService.updateWorkType(device.getDeviceSn(), 3L); |
| | | } |
| | | } |
| | | } |
| | | } |