| | |
| | | import com.ard.sample.manage.model.receiver.OsdPayloadReceiver; |
| | | import com.ard.sample.manage.model.receiver.OsdSubDeviceReceiver; |
| | | import com.ard.sample.manage.service.IDeviceService; |
| | | import com.ard.sample.manage.service.IWaylineTrajectoryService; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.JsonNode; |
| | | import com.fasterxml.jackson.databind.node.ObjectNode; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | |
| | | |
| | | @Autowired |
| | | private IDeviceService _deviceService; |
| | | |
| | | @Autowired |
| | | private IWaylineTrajectoryService _waylineTrajectoryService; |
| | | |
| | | @Autowired |
| | | private DockWebSocketHandler _dockWebSocketHandler; |
| | |
| | | |
| | | OsdSubDeviceReceiver data = mapper.convertValue(receiver.getData(), OsdSubDeviceReceiver.class); |
| | | List<DevicePayloadDTO> payloadsList = device.getPayloadsList(); |
| | | //data.setChildDeviceSn(device.getDeviceSn()); |
| | | String dockOsd = ""; |
| | | receiver.setType(MessageType.STATUS.getType()+"-aircraft"); |
| | | // receiver.setData(data); |
| | | try { |
| | | dockOsd=mapper.writeValueAsString(receiver); |
| | | JsonNode jsonNode = mapper.readTree(dockOsd); |
| | | if(jsonNode.has("data") && jsonNode.get("data").has("mode_code")) { |
| | | Long code = jsonNode.get("data").get("mode_code").asLong(); |
| | | if("0,1,2,3,4,5,8,9,10,11,13,14".contains(code.toString())){ |
| | | _deviceService.updateWorkType(device.getDeviceSn(),code); |
| | | RedisOpsUtils.setWithExpire(RedisConst.OSD_STATUS_PREFIX + device.getDeviceSn(), code, RedisConst.DEVICE_ALIVE_SECOND); |
| | | //在JSON的data下插入childDeviceSn,飞行器的sn |
| | | if(jsonNode.get("data") instanceof ObjectNode){ |
| | | ObjectNode objectNode = (ObjectNode) jsonNode.get("data"); |
| | | objectNode.put("childDeviceSn", device.getDeviceSn()); |
| | | } |
| | | if(jsonNode.has("data")){ |
| | | |
| | | if(jsonNode.get("data").has("mode_code")) { |
| | | Long code = jsonNode.get("data").get("mode_code").asLong(); |
| | | if ("0,1,2,3,4,5,8,9,10,11,13,14".contains(code.toString())) { |
| | | _deviceService.updateWorkType(device.getDeviceSn(), code); |
| | | RedisOpsUtils.set(RedisConst.OSD_STATUS_PREFIX + device.getDeviceSn(), code); |
| | | } |
| | | } |
| | | } |
| | | dockOsd=mapper.writeValueAsString(jsonNode); |
| | | |
| | | Map<String, Object> receiverData = (Map<String, Object>) receiver.getData(); |
| | | data.setPayloads(payloadsList.stream() |
| | | .map(payload -> mapper.convertValue( |
| | |
| | | wsMessage.getData().setHost(data); |
| | | |
| | | // 发送给websocket客户端 |
| | | _dockWebSocketHandler.sendMessageToSubscribers(device.getDeviceSn(), MessageType.STATUS.getType(), dockOsd); |
| | | _dockWebSocketHandler.sendMessageToSubscribers(device.getDeviceSn(), MessageType.STATUS.getType(), dockOsd, ""); |
| | | |
| | | // 将飞行器的OSD数据dockOsd入库;device.getDeviceSn()为飞行器sn,这里要机场的sn,试试receiver.getGateway(); |
| | | _waylineTrajectoryService.setList(receiver.getGateway(),"0", dockOsd); |
| | | |
| | | sendMessageService.sendBatch(webSessions, wsMessage); |
| | | this.pushTelemetryData(data, device.getDeviceSn()); |