| | |
| | | import com.ard.sample.manage.service.IDeviceService; |
| | | 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; |
| | |
| | | |
| | | 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.setWithExpire(RedisConst.OSD_STATUS_PREFIX + device.getDeviceSn(), code, RedisConst.DEVICE_ALIVE_SECOND); |
| | | } |
| | | } |
| | | } |
| | | dockOsd=mapper.writeValueAsString(jsonNode); |
| | | |
| | | Map<String, Object> receiverData = (Map<String, Object>) receiver.getData(); |
| | | data.setPayloads(payloadsList.stream() |
| | | .map(payload -> mapper.convertValue( |