From b8d0dc0a294ba8e07e861b3b78e953d7d5ba480c Mon Sep 17 00:00:00 2001
From: zhouhn <zhouhn@xiaopeng.com>
Date: 星期六, 07 三月 2026 20:58:06 +0800
Subject: [PATCH] 完善云端导航信息下发的逻辑
---
xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/service/KafkaConsumerService.java | 34 ++++++++++++++++++++++++++--------
1 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/service/KafkaConsumerService.java b/xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/service/KafkaConsumerService.java
index fe309c5..2641a3d 100644
--- a/xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/service/KafkaConsumerService.java
+++ b/xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/service/KafkaConsumerService.java
@@ -22,6 +22,7 @@
import com.xiaopeng.api.vo.automaticPilot.proto.down.ResponseMessage;
import com.xiaopeng.api.vo.automaticPilot.proto.down.StatusCode;
import com.xiaopeng.api.vo.automaticPilot.proto.down.cloudOrderOperation.*;
+import com.xiaopeng.api.vo.automaticPilot.proto.down.cloudPushNavigation.RestoreNavigationData;
import com.xiaopeng.api.vo.automaticPilot.proto.up.MessageType;
import com.xiaopeng.api.vo.automaticPilot.proto.up.MsgContent;
import com.xiaopeng.api.vo.automaticPilot.proto.up.RTCmdType;
@@ -182,7 +183,7 @@
log.info("消息不在处理范围内,忽略:{}", message);
}
}
- //TODO 有点看不懂
+ //TODO 这里的逻辑要再确认下
//消息应答
if(MessageType.MESSAGE_TYPE_RESPONSE == type){
com.xiaopeng.api.vo.automaticPilot.proto.up.ResponseMessage resposne = msgContent.getContent_detail().getObject("resposne", com.xiaopeng.api.vo.automaticPilot.proto.up.ResponseMessage.class);
@@ -331,7 +332,6 @@
}
}
-
/**
* XPU向云端请求导航
*
@@ -340,6 +340,7 @@
public void xpuNavigationRequest(MsgContent msgContent) {
//开始处理消息对应的业务逻辑
NavigationRequest naviRequest = msgContent.getContent_detail().getObject("naviRequest", NavigationRequest.class);
+ String requestId = naviRequest.getRequest_id();
String orderId = naviRequest.getOrder_id();
String taskId = naviRequest.getTask_id();
OrderPhase orderPhase = naviRequest.getOrder_phase();
@@ -351,15 +352,15 @@
break;
case ROUTE_TO_PICKUP:
log.info("驶往上车点的行程");
- buildNaviRequest(orderId, taskId, orderPhase, msgContent.getHeader().getSequence());
+ buildNaviRequest(requestId, orderId, taskId, orderPhase, msgContent.getHeader().getSequence());
break;
case ROUTE_TO_DESTINATION:
log.info("驶往下车点的行程");
- buildNaviRequest(orderId, taskId, orderPhase, msgContent.getHeader().getSequence());
+ buildNaviRequest(requestId, orderId, taskId, orderPhase, msgContent.getHeader().getSequence());
break;
case ROUTE_TO_CRUISE:
log.info("巡游阶段路线");
- buildNaviRequest(orderId, taskId, orderPhase, msgContent.getHeader().getSequence());
+ buildNaviRequest(requestId, orderId, taskId, orderPhase, msgContent.getHeader().getSequence());
break;
}
}
@@ -445,7 +446,7 @@
* @param taskId
* @param orderPhase
*/
- public void buildNaviRequest(String orderId, String taskId, OrderPhase orderPhase, Long sequence) {
+ public void buildNaviRequest(String requestId, String orderId, String taskId, OrderPhase orderPhase, Long sequence) {
//订单类型 1:乘客订单,2=巡游订单
Integer orderType = 1;
LonLatDto destination = new LonLatDto();
@@ -506,7 +507,8 @@
RouteVo routeVo = routeVoR.getData();
//TODO 这里有问题,应该是下发导航信息,不是下发订单信息
//构建导航下发请求对象
- cloudOrderOperation(orderType, orderId, taskId, routeVo, xpVehicle.getVehicleVin());
+// cloudOrderOperation(orderType, orderId, taskId, routeVo, xpVehicle.getVehicleVin());
+ cloudPushNavigationInfo(requestId, orderId, taskId, xpVehicle.getVehicleVin(), xpVehicle.getXpuId());
}
}
@@ -555,7 +557,7 @@
// 处理数据
redisTemplate.opsForValue().set(sequence,"pushOrder_"+orderId+"_"+vin,30, TimeUnit.MINUTES);
//开发发送请求到XPU
- xpuUtil.cloudOrderOperation(orderOperation, vin,sequence);
+ xpuUtil.cloudOrderOperation(orderOperation, vin, sequence);
}
@@ -692,4 +694,20 @@
}
}
+ //TODO 完善逻辑
+ public void cloudPushNavigationInfo(String requestId, String orderId, String taskId, String vin, String xpuId) {
+ //根据orderId查询派单时查询到的Route信息,获取其中的routeId信息,应该在小程序端下单的时候进行了缓存
+ String routeId = "";
+ //根据routeId,调用高德的https://tsapi.amap.com/v1/route/query/routeid?key=#接口,还原路线信息,提取其中的data字段信息
+ String routeDataContent = "";
+ //组装报文,将routeDateContent信息推送到XPU
+ RestoreNavigationData navigationData = new RestoreNavigationData();
+ navigationData.setRoute_id(routeId);
+ navigationData.setRequest_id(requestId);
+ navigationData.setContent(routeDataContent);
+ navigationData.setTimestamp(System.currentTimeMillis());
+
+ xpuUtil.cloudPushNavigation(navigationData, xpuId, snowflake.nextId());
+ }
+
}
--
Gitblit v1.7.1