| | |
| | | package com.ard.sample.manage.service.impl; |
| | | |
| | | import com.ard.common.core.redis.RedisConst; |
| | | import com.ard.common.core.redis.RedisOpsUtils; |
| | | import com.ard.sample.component.mqtt.model.CommonTopicReceiver; |
| | | import com.ard.sample.component.websocket.config.ConcurrentWebSocketSession; |
| | | import com.ard.sample.component.websocket.enums.MessageType; |
| | |
| | | if (DeviceDomainEnum.DOCK.getVal() == device.getDomain()) { |
| | | wsMessage.setBizCode(BizCodeEnum.DOCK_OSD.getCode()); |
| | | OsdDockReceiver data = mapper.convertValue(receiver.getData(), OsdDockReceiver.class); |
| | | receiver.setType(MessageType.STATUS.getType()); |
| | | // receiver.setType(MessageType.STATUS.getType()); |
| | | String dockOsd=""; |
| | | String dockOsdData=""; |
| | | try{ |
| | | dockOsd=mapper.writeValueAsString(receiver); |
| | | dockOsdData=mapper.writeValueAsString(receiver.getData()); |
| | | if (dockOsdData.contains("flighttask_step_code")) { |
| | | JsonNode jsonNode = mapper.readTree(dockOsdData); |
| | |
| | | //只要状态 "0":"作业准备中","1":"飞行作业中","5":"任务空闲" |
| | | if(code == 0 || code == 1 || code == 5) { |
| | | _deviceService.updateWorkType(deviceSn,code); |
| | | RedisOpsUtils.setWithExpire(RedisConst.OSD_STATUS_PREFIX + deviceSn, code, RedisConst.DEVICE_ALIVE_SECOND); |
| | | } |
| | | } |
| | | } |
| | | |
| | | receiver.setType(MessageType.STATUS.getType()+"-flighttask"); |
| | | } else if (dockOsdData.contains("network_state")) { |
| | | JsonNode jsonNode = mapper.readTree(dockOsdData); |
| | | if (jsonNode.has("drone_in_dock") && jsonNode.get("sub_device").has("device_online_status")) { |
| | | String childDeviceSn=jsonNode.get("sub_device").get("device_sn").asText(); |
| | | Long inDock=jsonNode.get("drone_in_dock").asLong(); |
| | | Long deviceOnlineStatus=jsonNode.get("sub_device").get("device_online_status").asLong(); |
| | | if(inDock.equals(1L) && deviceOnlineStatus.equals(0L)) |
| | | {// 飞行器在舱内且关机状态为6 |
| | | _deviceService.updateWorkType(childDeviceSn,6L); |
| | | if(jsonNode.get("sub_device").has("device_sn")) { |
| | | String childDeviceSn = jsonNode.get("sub_device").get("device_sn").asText(); |
| | | Long inDock = jsonNode.get("drone_in_dock").asLong(); |
| | | Long deviceOnlineStatus = jsonNode.get("sub_device").get("device_online_status").asLong(); |
| | | if (inDock.equals(1L) && deviceOnlineStatus.equals(0L)) {// 飞行器在舱内且关机状态为6 |
| | | _deviceService.updateWorkType(childDeviceSn, 6L); |
| | | RedisOpsUtils.setWithExpire(RedisConst.OSD_STATUS_PREFIX + device.getChildDeviceSn(), 6, RedisConst.DEVICE_ALIVE_SECOND); |
| | | } |
| | | } |
| | | } |
| | | receiver.setType(MessageType.STATUS.getType()+"-network"); |
| | | } else if (dockOsdData.contains("job_number")) { |
| | | receiver.setType(MessageType.STATUS.getType()+"-job"); |
| | | } |
| | | dockOsd=mapper.writeValueAsString(receiver); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |