| | |
| | | import com.ard.common.core.redis.RedisOpsUtils; |
| | | import com.ard.sample.component.websocket.enums.MessageType; |
| | | import com.ard.sample.component.websocket.handler.DockWebSocketHandler; |
| | | import com.ard.sample.component.websocket.handler.LiveStreamHandler; |
| | | import com.ard.sample.component.websocket.service.ISendMessageService; |
| | | import com.ard.sample.manage.model.dto.BasicDeviceProperty; |
| | | import com.ard.sample.manage.model.dto.DeviceDTO; |
| | |
| | | |
| | | @Autowired |
| | | private IDeviceService _deviceService; |
| | | |
| | | @Autowired |
| | | private LiveStreamHandler _liveStreamHandler; |
| | | |
| | | // @Autowired |
| | | // private IWebSocketManageService webSocketManageService; |
| | |
| | | |
| | | boolean isExist = deviceService.checkDeviceOnline(sn); |
| | | if (!isExist) { |
| | | return ResponseResult.error(CommonErrorEnum.DEVICE_OFFLINE.getErrorMsg()); |
| | | return ResponseResult.error(CommonErrorEnum.DEVICE_OFFLINE.getErrorCode(), CommonErrorEnum.DEVICE_OFFLINE.getErrorMsg()); |
| | | } |
| | | DeviceDTO device = (DeviceDTO) RedisOpsUtils.get(RedisConst.DEVICE_ONLINE_PREFIX + sn); |
| | | // 重启机场时清redis视频直播地址,机场重启不掉线。但是流停了。 |
| | | if(RemoteControlMethodEnum.DEVICE_REBOOT == controlMethodEnum) { |
| | | // 重启机场时,读取舱盖状态,开舱盖不让重启,关舱盖重启 |
| | | Integer cover_state = (Integer)RedisOpsUtils.get(RedisConst.COVER_STATE_OSD_PREFIX + device.getDeviceSn()); |
| | | if(cover_state != null && cover_state != 0) { |
| | | return ResponseResult.error(111111,"请关闭舱盖再执行重启操作!"); |
| | | } |
| | | RedisOpsUtils.del(RedisConst.WEBSOCKET_VIDEO_ADDRESS_PREFIX + sn); |
| | | RedisOpsUtils.del(RedisConst.COVER_STATE_PREFIX + sn); |
| | | RedisOpsUtils.del(RedisConst.WEBSOCKET_VIDEO_ADDRESS_PREFIX + device.getChildDeviceSn()); |
| | | } |
| | | if(RemoteControlMethodEnum.DRONE_CLOSE == controlMethodEnum) { |
| | | // 飞行器关机时drone_close,关闭飞行器视频流 |
| | | _liveStreamHandler.StopLiveStreaming(device.getChildDeviceSn()); |
| | | RedisOpsUtils.del(RedisConst.WEBSOCKET_VIDEO_ADDRESS_PREFIX + device.getChildDeviceSn()); |
| | | } |
| | | String topic = TopicConst.THING_MODEL_PRE + TopicConst.PRODUCT + sn + TopicConst.SERVICES_SUF; |
| | | String bid = UUID.randomUUID().toString(); |
| | |
| | | //关闭,摄像头为舱外;将摄像头状态存到redis,格式为:CONVERSTATE:设备SN:1(舱外)或0(舱内) |
| | | _deviceService.setRedisCameraPosition(sn,1); |
| | | } |
| | | // 重启机场时清redis视频直播地址,机场重启不掉线。但是流停了。 |
| | | if(RemoteControlMethodEnum.DEVICE_REBOOT == controlMethodEnum) { |
| | | RedisOpsUtils.del(RedisConst.WEBSOCKET_VIDEO_ADDRESS_PREFIX + sn); |
| | | RedisOpsUtils.del(RedisConst.COVER_STATE_PREFIX + sn); |
| | | } |
| | | |
| | | return ResponseResult.success(); |
| | | } |
| | |
| | | String deviceSn = receiver.getGateway(); |
| | | if(method.equals("cover_close")){ |
| | | _deviceService.updateWorkType(deviceSn, 2L); |
| | | RedisOpsUtils.setWithExpire(RedisConst.OSD_STATUS_PREFIX + deviceSn, 2, RedisConst.DEVICE_ALIVE_SECOND); |
| | | RedisOpsUtils.set(RedisConst.OSD_STATUS_PREFIX + deviceSn, 2); |
| | | } |
| | | String sn = RedisOpsUtils.get(key).toString(); |
| | | receiver.setType(MessageType.PROGRESS.getType()); |
| | |
| | | // 更新设备列表状态--飞行器开机中... |
| | | if(method.equals("drone_open")){ |
| | | _deviceService.updateWorkType(device.getChildDeviceSn(), 7L); |
| | | RedisOpsUtils.setWithExpire(RedisConst.OSD_STATUS_PREFIX + device.getChildDeviceSn(), 7, RedisConst.DEVICE_ALIVE_SECOND); |
| | | RedisOpsUtils.set(RedisConst.OSD_STATUS_PREFIX + device.getChildDeviceSn(), 7); |
| | | } |
| | | // 机场重启状态--ok后删除redis状态 |
| | | if(method.equals("device_reboot")){ |
| | | if(eventsReceiver.getOutput().getProgress().getPercent() == 100){ |
| | | RedisOpsUtils.del(RedisConst.WEBSOCKET_VIDEO_ADDRESS_PREFIX + sn); |
| | | RedisOpsUtils.del(RedisConst.COVER_STATE_PREFIX + sn); |
| | | RedisOpsUtils.del(RedisConst.WEBSOCKET_VIDEO_ADDRESS_PREFIX + device.getChildDeviceSn()); |
| | | } |
| | | } |
| | | |
| | | |
| | | String dockProgress =""; |
| | | try { |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | // 设备控制进度消息websocket发给前端 |
| | | _dockWebSocketHandler.sendMessageToSubscribers(sn, MessageType.PROGRESS.getType(), dockProgress); |
| | | _dockWebSocketHandler.sendMessageToSubscribers(sn, MessageType.PROGRESS.getType(), dockProgress, ""); |
| | | |
| | | if (receiver.getNeedReply() != null && receiver.getNeedReply() == 1) { |
| | | String topic = headers.get(MqttHeaders.RECEIVED_TOPIC) + TopicConst._REPLY_SUF; |