| | |
| | | |
| | | // 第一次上线 或则设备之前是离线状态--进行通道同步和设备信息查询 |
| | | if (device.getCreateTime() == null) { |
| | | device.setOnline(true); |
| | | device.setOnLine(true); |
| | | device.setCreateTime(now); |
| | | logger.info("[设备上线,首次注册]: {},查询设备信息以及通道信息", device.getDeviceId()); |
| | | deviceMapper.add(device); |
| | |
| | | } |
| | | sync(device); |
| | | }else { |
| | | if(!device.isOnline()){ |
| | | device.setOnline(true); |
| | | if(!device.isOnLine()){ |
| | | device.setOnLine(true); |
| | | device.setCreateTime(now); |
| | | deviceMapper.update(device); |
| | | redisCatchStorage.updateDevice(device); |
| | |
| | | } |
| | | String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + deviceId; |
| | | dynamicTask.stop(registerExpireTaskKey); |
| | | device.setOnline(false); |
| | | device.setOnLine(false); |
| | | redisCatchStorage.updateDevice(device); |
| | | deviceMapper.update(device); |
| | | //进行通道离线 |
| | |
| | | } |
| | | logger.info("[移除目录订阅]: {}", device.getDeviceId()); |
| | | String taskKey = device.getDeviceId() + "catalog"; |
| | | if (device.isOnline()) { |
| | | if (device.isOnLine()) { |
| | | Runnable runnable = dynamicTask.get(taskKey); |
| | | if (runnable instanceof ISubscribeTask) { |
| | | ISubscribeTask subscribeTask = (ISubscribeTask) runnable; |
| | |
| | | } |
| | | logger.info("[移除移动位置订阅]: {}", device.getDeviceId()); |
| | | String taskKey = device.getDeviceId() + "mobile_position"; |
| | | if (device.isOnline()) { |
| | | if (device.isOnLine()) { |
| | | Runnable runnable = dynamicTask.get(taskKey); |
| | | if (runnable instanceof ISubscribeTask) { |
| | | ISubscribeTask subscribeTask = (ISubscribeTask) runnable; |
| | |
| | | |
| | | @Override |
| | | public void checkDeviceStatus(Device device) { |
| | | if (device == null || !device.isOnline()) { |
| | | if (device == null || !device.isOnLine()) { |
| | | return; |
| | | } |
| | | try { |
| | |
| | | |
| | | @Override |
| | | public void addDevice(Device device) { |
| | | device.setOnline(false); |
| | | device.setOnLine(false); |
| | | device.setCreateTime(DateUtil.getNow()); |
| | | device.setUpdateTime(DateUtil.getNow()); |
| | | deviceMapper.addCustomDevice(device); |