From ed838e62602c0a63a64ff4bd144a0d16cc9a7cf8 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 10 四月 2026 09:39:25 +0800
Subject: [PATCH] 和客户同步1.0版本
---
xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/util/XPUUtil.java | 50 +++++++++++++++++++++++++++++++++-----------------
1 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/util/XPUUtil.java b/xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/util/XPUUtil.java
index 2fdfcc3..f151abc 100644
--- a/xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/util/XPUUtil.java
+++ b/xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/util/XPUUtil.java
@@ -6,8 +6,11 @@
import com.xiaopeng.api.dto.automaticPilot.MqttPublishDto;
import com.xiaopeng.api.feignClient.automaticPilot.VmpOpenServiceClient;
import com.xiaopeng.api.feignClient.automaticPilot.XPUClient;
+import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient;
+import com.xiaopeng.api.model.vehicleConvoy.XpVehicle;
import com.xiaopeng.api.vo.automaticPilot.MqttPublishVo;
import com.xiaopeng.api.vo.automaticPilot.protobuf.*;
+import com.xiaopeng.common.core.domain.R;
import com.xiaopeng.common.core.utils.StringUtils;
import com.xiaopeng.common.core.utils.uuid.UUID;
import lombok.extern.slf4j.Slf4j;
@@ -34,6 +37,8 @@
@Resource
private VmpOpenServiceClient vmpOpenServiceClient;
+ @Resource
+ private XpVehicleClient xpVehicleClient;
// 查询车管绑定类型,1:XPUID,2:待扩展
public static final String XPU_ID_TYPE = "1";
@@ -75,11 +80,11 @@
try {
MqttPublishDto dto = xpuClient.publish(vo);
log.info("XPU返回:{}", JSON.toJSONString(dto));
- if(200 != dto.getCode()){
+ if (200 != dto.getCode()) {
dto = againPushMessage(vo);
}
return dto;
- }catch (Exception e){
+ } catch (Exception e) {
throw new RuntimeException("云端-->XPU 创建订单失败:", e);
}
}
@@ -87,6 +92,7 @@
/**
* 取消订单、修改途经点、终点
+ *
* @param operation
* @return
*/
@@ -115,16 +121,14 @@
try {
MqttPublishDto dto = xpuClient.publish(vo);
log.info("XPU返回:{}", JSON.toJSONString(dto));
- if(200 != dto.getCode()){
+ if (200 != dto.getCode()) {
dto = againPushMessage(vo);
}
return dto;
- }catch (Exception e){
+ } catch (Exception e) {
throw new RuntimeException("云端-->XPU 修改订单失败:", e);
}
}
-
-
/**
@@ -156,15 +160,14 @@
try {
MqttPublishDto dto = xpuClient.publish(vo);
log.info("XPU返回:{}", JSON.toJSONString(dto));
- if(200 != dto.getCode()){
+ if (200 != dto.getCode()) {
dto = againPushMessage(vo);
}
return dto;
- }catch (Exception e){
+ } catch (Exception e) {
throw new RuntimeException("云端-->XPU 下发导航信息失败:", e);
}
}
-
/**
@@ -173,12 +176,12 @@
* @param responseMessage
* @return
*/
- public MqttPublishDto responseMessage(ResponseMessage responseMessage, String vin) {
+ public MqttPublishDto responseMessage(RTCmdType cmd, ResponseMessage responseMessage, String vin) {
MsgContent.Builder msgContentBuilder = MsgContent.newBuilder();
MsgHeader.Builder headerBuilder = MsgHeader.newBuilder();
headerBuilder.setMsgId(UUID.randomUUID().toString());
headerBuilder.setTimestamp(System.currentTimeMillis());
- headerBuilder.setCmd(RTCmdType.CLOUD_TASK_CONTROL.getValue());
+ headerBuilder.setCmd(cmd.getValue());
Snowflake snowflake = IdUtil.getSnowflake(0, 0);
headerBuilder.setSequence(snowflake.nextId());
headerBuilder.setType(MessageType.MESSAGE_TYPE_RESPONSE);
@@ -198,17 +201,29 @@
}
-
+ /**
+ * @description: 根据vin查询xpuId
+ * @param: vin
+ * @return: xpuId
+ */
+ public String getXpuIdByVin(String vin) {
+ R<XpVehicle> xpVehicleR = xpVehicleClient.findByVehicleVin(vin);
+ if (xpVehicleR.getCode() != 200 || xpVehicleR.getData() == null) {
+ log.error("根据vin查询车辆信息失败,vin={},msg={}", vin, xpVehicleR.getMsg());
+ return "";
+ }
+ return xpVehicleR.getData().getXpuId();
+ }
/**
* @description: 根据vin查询xpuId
* @param: vin
* @return: xpuId
*/
- public String getXpuIdByVin(String vin) {
+ public String getXpuIdByVinForVehicleControl(String vin) {
Map<String, String> xpuIdMapping = vmpOpenServiceClient.getVehicleBindInfoByVin(vin, TYPE_LIST);
- log.info("getMqttPublishTopic vin,{},xpuIdMapping,{}", vin, JSON.toJSONString(xpuIdMapping));
- if (xpuIdMapping == null || StringUtils.isEmpty(xpuIdMapping.get(XPU_ID_TYPE)) ) {
+ log.info("getMqttPublishTopic vin,{},xpuIdMapping,{}", vin, JSON.toJSONString(xpuIdMapping));
+ if (xpuIdMapping == null || StringUtils.isEmpty(xpuIdMapping.get(XPU_ID_TYPE))) {
log.error("根据vin查询车辆xpuid信息为空,vin={}", vin);
throw new RuntimeException("根据vin查询车辆xpuid信息为空");
}
@@ -237,6 +252,7 @@
/**
* 消息下发XPU重试机制
+ *
* @param message
* @return
*/
@@ -246,11 +262,11 @@
for (int i = 0; i < 3; i++) {
try {
dto = xpuClient.publish(message);
- log.info("云端-->XPU 消息重试{}次:{}", (i+1), message);
+ log.info("云端-->XPU 消息重试{}次:{}", (i + 1), message);
if (dto.getCode() == 200) {
break;
}
- }catch (Exception e){
+ } catch (Exception e) {
log.error("云端-->XPU 推送失败:{}", message);
}
}
--
Gitblit v1.7.1