| | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.google.protobuf.InvalidProtocolBufferException; |
| | | import com.google.protobuf.util.JsonFormat; |
| | | import com.xiaopeng.api.dto.automaticPilot.MqttPublishDto; |
| | | import com.xiaopeng.api.dto.map.OrderRouteAndFareDto; |
| | | import com.xiaopeng.api.dto.operation.CruisePointDto; |
| | | import com.xiaopeng.api.dto.operation.LonLatDto; |
| | |
| | | log.warn("Unknown cmd value: {}", cmdValue); |
| | | return; |
| | | } |
| | | //云端下发订单的响应报文 |
| | | if (cmd == RTCmdType.CLOUD_SEND_RT_TASK) { |
| | | RtTaskListResponse response = msgContent.getRtTaskListResponse(); |
| | | try { |
| | | log.info("云端下发订单操作的响应消息 (XPU→云端):{}", jsonPrinter.print(response)); |
| | | Object sequence = redisTemplate.opsForValue().get("CREATE_ORDER:" + response.getResults().getOrderId()); |
| | | if(sequence!=null){ |
| | | JSONObject jsonObject = JSON.parseObject(sequence.toString()); |
| | | String orderId = jsonObject.getString("orderId"); |
| | | String vin = jsonObject.getString("vin"); |
| | | String orderType = jsonObject.getString("orderType"); |
| | | PopOrderDto dto = new PopOrderDto(); |
| | | dto.setOrderId(Long.valueOf(orderId)); |
| | | dto.setXpVehicleVin(vin); |
| | | dto.setOrderType(orderType); |
| | | xpOrderClient.popOrder(dto); |
| | | log.info("订单状态更新:{}", response.getResults().getOrderId()); |
| | | } |
| | | } catch (InvalidProtocolBufferException e) { |
| | | log.error("Failed to print RtTaskListResponse: {}", response, e); |
| | | } |
| | | } else { |
| | | log.info("响应消息不在处理范围内,忽略:{}", message); |
| | | } |
| | | // ResponseMessage response = msgContent.getResponse(); |
| | | // StatusCode code = response.getCode(); |
| | | // long requestSeq = response.getRequestSeq(); |
| | | // if(code == StatusCode.OK){ |
| | | // log.info("收到XPU消息的响应,code: {}, message: {}", code.getNumber(), message); |
| | | // Object sequence = redisTemplate.opsForValue().get(requestSeq); |
| | | // if(sequence!=null){ |
| | | // log.info("收到XPU消息的响应,sequence: {}", sequence); |
| | | // JSONObject jsonObject = JSON.parseObject(sequence.toString()); |
| | | // String event = jsonObject.getString("event"); |
| | | // //推送导航的响应消息 |
| | | // if(SystemEventType.PUSH_NAVIGATION.equals(event)){ |
| | | // log.info("推送导航的响应消息,{}", jsonObject.toJSONString()); |
| | | // String orderId = jsonObject.getString("orderId"); |
| | | // String vin = jsonObject.getString("vin"); |
| | | // String orderType = jsonObject.getString("orderType"); |
| | | // PopOrderDto dto = new PopOrderDto(); |
| | | // dto.setOrderId(Long.valueOf(orderId)); |
| | | // dto.setXpVehicleVin(vin); |
| | | // dto.setOrderType(orderType); |
| | | // xpOrderClient.popOrder(dto); |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | } |
| | | |
| | |
| | | vehicleId = xpOrder.getVehicleId(); |
| | | } |
| | | |
| | | if(StringUtils.isNotEmpty(routeID)){ |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(vehicleId).getData(); |
| | | R<String> stringR = xpMapClient.queryRouted(routeID); |
| | | if (200 != stringR.getCode()) { |
| | | throw new RuntimeException("根据导航ID获取车端需要的导航数据失败"); |
| | | } |
| | | //TODO 这里的逻辑不太对,收到导航偏航事件之后 |
| | | //构建导航下发请求对象 |
| | | cloudPushNavigationInfo(requestId, routeID, stringR.getData(), orderType, orderId, xpVehicle.getVehicleVin(), xpVehicle.getXpuId()); |
| | | } |
| | | // TODO 在请求导航哪里返回导航数据 |
| | | // if(StringUtils.isNotEmpty(routeID)){ |
| | | // XpVehicle xpVehicle = xpVehicleClient.queryById(vehicleId).getData(); |
| | | // R<String> stringR = xpMapClient.queryRouted(routeID); |
| | | // if (200 != stringR.getCode()) { |
| | | // throw new RuntimeException("根据导航ID获取车端需要的导航数据失败"); |
| | | // } |
| | | // //TODO 这里的逻辑不太对,收到导航偏航事件之后 |
| | | // //构建响应导航数据给车端 |
| | | // cloudPushNavigationInfo(requestId, routeID, stringR.getData(), orderType, orderId, xpVehicle.getVehicleVin(), xpVehicle.getXpuId()); |
| | | // } |
| | | // } |
| | | } |
| | | |
| | |
| | | Long vehicleId = null; |
| | | String orderType = ""; |
| | | if (orderId.contains("XU")) { |
| | | |
| | | orderType = OrderType.CRUISE_ORDER; |
| | | //巡游单 |
| | | if (orderPhase.equals(OrderPhase.ROUTE_TO_CRUISE)) { |
| | | //先响应消息 |
| | | responseMessage(sequence, ""); |
| | | /* 构建导航数据给到车端 */ |
| | | R<XpCruiseOrder> cruiseOrder = xpCruiseOrderClient.getCruiseOrder(orderId); |
| | | XpCruiseOrder xpCruiseOrder = cruiseOrder.getData(); |
| | |
| | | } |
| | | XpOrder xpOrder = xpOrderR.getData(); |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); |
| | | //先响应消息 |
| | | responseMessage(sequence, xpVehicle.getVehicleVin()); |
| | | //驶往上车点的行程 |
| | | if (orderPhase.equals(OrderPhase.ROUTE_TO_PICKUP)) { |
| | | //查询车辆位置 |
| | |
| | | jsonObject.put("orderId", orderId); |
| | | jsonObject.put("vin", vin); |
| | | redisTemplate.opsForValue().set(sequence, jsonObject.toJSONString(),30, TimeUnit.MINUTES); |
| | | xpuUtil.cloudPushNavigation(navigationDataBuilder.build(), xpuId, sequence); |
| | | MqttPublishDto mqttPublishDto = xpuUtil.cloudPushNavigation(navigationDataBuilder.build(), xpuId, sequence); |
| | | log.info("推送导航的响应消息,{}", JSON.toJSONString(mqttPublishDto)); |
| | | } |
| | | |
| | | } |