From ba78f764042ca15bf3f3be62e7a3fc699df56d67 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期六, 07 三月 2026 20:59:53 +0800
Subject: [PATCH] 提交管理后台新接口,修改XPU报文相关功能,增加测试小程序状态流转接口
---
xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/service/KafkaConsumerService.java | 304 +++++++++++++++++++++++++++++---------------------
1 files changed, 177 insertions(+), 127 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 06fda15..47fea4d 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
@@ -4,7 +4,10 @@
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
+import com.google.protobuf.InvalidProtocolBufferException;
+import com.google.protobuf.util.JsonFormat;
import com.xiaopeng.api.dto.map.OrderRouteAndFareDto;
+import com.xiaopeng.api.dto.operation.CruisePointDto;
import com.xiaopeng.api.dto.operation.LonLatDto;
import com.xiaopeng.api.dto.operation.ReassignOrderDTO;
import com.xiaopeng.api.dto.order.PopOrderDto;
@@ -12,6 +15,7 @@
import com.xiaopeng.api.dto.pushMessage.SendMessageDTO;
import com.xiaopeng.api.feignClient.map.XpMapClient;
import com.xiaopeng.api.feignClient.operation.ReassignOrderClient;
+import com.xiaopeng.api.feignClient.operation.XpCruisePlanClient;
import com.xiaopeng.api.feignClient.order.XpCruiseOrderClient;
import com.xiaopeng.api.feignClient.order.XpOrderClient;
import com.xiaopeng.api.feignClient.pushMessage.XpPushMessageClient;
@@ -23,25 +27,7 @@
import com.xiaopeng.api.vo.OrderType;
import com.xiaopeng.api.vo.SystemEventType;
import com.xiaopeng.api.vo.automaticPilot.VehiclePosition;
-import com.xiaopeng.api.vo.automaticPilot.proto.down.GeoPoint;
-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.cloudCreateOrder.RTTask;
-import com.xiaopeng.api.vo.automaticPilot.proto.down.cloudCreateOrder.TaskStatus;
-import com.xiaopeng.api.vo.automaticPilot.proto.down.cloudCreateOrder.TaskType;
-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;
-import com.xiaopeng.api.vo.automaticPilot.proto.up.RtMsgHeader;
-import com.xiaopeng.api.vo.automaticPilot.proto.up.navigationDeviationEvent.NavigationDeviationEvent;
-import com.xiaopeng.api.vo.automaticPilot.proto.up.navigationDeviationEvent.NavigationDeviationMessage;
-import com.xiaopeng.api.vo.automaticPilot.proto.up.navigationDeviationEvent.RtEventType;
-import com.xiaopeng.api.vo.automaticPilot.proto.up.orderStateUpdateEvent.OrderStatusInfoEvent;
-import com.xiaopeng.api.vo.automaticPilot.proto.up.systemStatusXpu.*;
-import com.xiaopeng.api.vo.automaticPilot.proto.up.xpuNavigationRequest.NavigationRequest;
-import com.xiaopeng.api.vo.automaticPilot.proto.up.xpuNavigationRequest.OrderPhase;
+import com.xiaopeng.api.vo.automaticPilot.protobuf.*;
import com.xiaopeng.api.vo.operation.RouteVo;
import com.xiaopeng.api.vo.vehicleConvoy.CancelTaxiPassengerVo;
import com.xiaopeng.automaticPilot.util.XPUUtil;
@@ -54,7 +40,6 @@
import com.xiaopeng.common.core.utils.uuid.UUID;
import com.xiaopeng.common.redis.service.RedisService;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.geo.GeoJsonPoint;
import org.springframework.data.mongodb.core.query.Criteria;
@@ -65,6 +50,8 @@
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.TimeUnit;
+
+;
/**
* Kafka 消费者服务
@@ -105,8 +92,13 @@
@Resource
private Snowflake snowflake;
- @Autowired
+
+ @Resource
private RedisService redisService;
+
+ @Resource
+ private XpCruisePlanClient xpCruisePlanClient;
+
/**
@@ -114,16 +106,33 @@
*
*/
public void topicProdRobotaxiXpuHigh(String message) {
- MsgContent msgContent = JSON.parseObject(message, MsgContent.class);
- handleXPUMessage(msgContent, message);
+ MsgContent msgContent = parseMsgContent(message);
+ if (msgContent != null) {
+ handleXPUMessage(msgContent, message);
+ }
+
}
/**
* 消费消息 - XPU上报Robotaxi云端的消息topic(低优先级)
*/
public void topicProdRobotaxiXpuNormal(String message) {
- MsgContent msgContent = JSON.parseObject(message, MsgContent.class);
- handleXPUMessage(msgContent, message);
+ MsgContent msgContent = parseMsgContent(message);
+ if (msgContent != null) {
+ handleXPUMessage(msgContent, message);
+ }
+
+ }
+
+ private MsgContent parseMsgContent(String message) {
+ try {
+ MsgContent.Builder builder = MsgContent.newBuilder();
+ JsonFormat.parser().ignoringUnknownFields().merge(message, builder);
+ return builder.build();
+ } catch (InvalidProtocolBufferException e) {
+ log.error("Failed to parse message: {}", message, e);
+ return null;
+ }
}
@@ -133,12 +142,17 @@
* @param message
*/
public void handleXPUMessage(MsgContent msgContent, String message){
- RtMsgHeader header = msgContent.getHeader();
+ MsgHeader header = msgContent.getHeader();
MessageType type = header.getType();
//处理请求消息
if (MessageType.MESSAGE_TYPE_REQUEST == type) {
//区分业务类型
- RTCmdType cmd = header.getCmd();
+ int cmdValue = header.getCmd();
+ RTCmdType cmd = RTCmdType.getByValue(cmdValue);
+ if (cmd == null) {
+ log.warn("Unknown cmd value: {}", cmdValue);
+ return;
+ }
switch (cmd) {
case SYSTEM_STATUS_XPU:
log.info("XPU发布系统运行状态 (XPU→云端):{}", message);
@@ -203,10 +217,10 @@
//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);
- com.xiaopeng.api.vo.automaticPilot.proto.up.StatusCode code = resposne.getCode();
- Long requestSeq = resposne.getRequest_seq();
- if(code == com.xiaopeng.api.vo.automaticPilot.proto.up.StatusCode.OK){
+ ResponseMessage response = msgContent.getResponse();
+ StatusCode code = response.getCode();
+ long requestSeq = response.getRequestSeq();
+ if(code == StatusCode.OK){
Object sequence = redisTemplate.opsForValue().get(requestSeq);
if(sequence!=null){
JSONObject jsonObject = JSON.parseObject(sequence.toString());
@@ -238,21 +252,21 @@
*/
public void systemStatusXpu(MsgContent msgContent) {
//开始处理消息对应的业务逻辑
- SystemRuntimeStatus systemRuntimeStatus = msgContent.getContent_detail().getObject("systemRuntimeStatus", SystemRuntimeStatus.class);
+ SystemRuntimeStatus systemRuntimeStatus = msgContent.getSystemRuntimeStatus();
//获取实时位置
RealtimePose pose = systemRuntimeStatus.getPose();
- Wgs naviPose = pose.getNavi_pose();
- Double latitude = naviPose.getLatitude();
- Double longitude = naviPose.getLongitude();
+ Wgs naviPose = pose.getNaviPose();
+ double latitude = naviPose.getLatitude();
+ double longitude = naviPose.getLongitude();
Double course = naviPose.getCourse();
Float alt = naviPose.getAlt();
//获取车辆静态信息
- VehicleStaticInfo staticInfo = systemRuntimeStatus.getVehicle_status().getStatic_info();
- String xpuId = staticInfo.getXpu_id();
+ VehicleStaticInfo staticInfo = systemRuntimeStatus.getVehicleStatus().getStaticInfo();
+ String xpuId = staticInfo.getXpuId();
XpVehicle xpVehicle = xpVehicleClient.findByVehicleXpuId(xpuId).getData();
String vin = xpVehicle.getVehicleVin();
//先响应消息
- Long sequence = msgContent.getHeader().getSequence();
+ long sequence = msgContent.getHeader().getSequence();
responseMessage(sequence, vin);
//保存车辆实时位置到redis
redisTemplate.opsForGeo().add("vehiclePosition:" + vin, new GeoJsonPoint(longitude, latitude), vin);
@@ -266,16 +280,16 @@
vehiclePosition.setPoint(new GeoJsonPoint(longitude, latitude));
vehiclePosition.setCourse(course);
vehiclePosition.setAlt(alt);
- VehicleStatus vehicleStatus = systemRuntimeStatus.getVehicle_status();
+ VehicleStatus vehicleStatus = systemRuntimeStatus.getVehicleStatus();
//车辆动态信息
- VehicleDynamicStatus dynamicStatus = vehicleStatus.getDynamic_status();
- dynamicStatus.setSpeed(dynamicStatus.getSpeed());
- vehiclePosition.setCurrentElectricity(dynamicStatus.getBms_soc_disp());
- vehiclePosition.setMileageRange(dynamicStatus.getDst_bat_disp());
+ VehicleDynamicStatus dynamicStatus = vehicleStatus.getDynamicStatus();
+ vehiclePosition.setSpeed(dynamicStatus.getSpeed());
+ vehiclePosition.setCurrentElectricity(dynamicStatus.getBmsSocDisp());
+ vehiclePosition.setMileageRange(dynamicStatus.getDstBatDisp());
//订单信息
- OrderStatusInfo runningOrderStatusInfo = systemRuntimeStatus.getRunning_order_status_info();
+ OrderStatusInfo runningOrderStatusInfo = systemRuntimeStatus.getRunningOrderStatusInfo();
Long orderId = null;
- String order_id = runningOrderStatusInfo.getOrder_id();
+ String order_id = runningOrderStatusInfo.getOrderId();
vehiclePosition.setHasOrder(0);
if (StringUtils.isNotEmpty(order_id)) {
if (order_id.contains("XU")) {
@@ -289,14 +303,15 @@
mongoTemplate.save(vehiclePosition);
//调用推送服务接口
if (null != orderId) {
- RtTripInfo rtTripInfo = systemRuntimeStatus.getRt_trip_info();
+ RtTripInfo rtTripInfo = systemRuntimeStatus.getRtTripInfo();
PushOrderRouteDTO dto = new PushOrderRouteDTO();
dto.setOrderId(orderId);
dto.setRouteType(order_id.contains("XU") ? 2 : 1);
dto.setLongitude(longitude);
dto.setLatitude(latitude);
- dto.setDuration(rtTripInfo.getRemaining_time());
- dto.setDistance(rtTripInfo.getRemaining_distance().intValue());
+ //TODO 这两个字段现在拿不到
+// dto.setDuration(rtTripInfo.getRemaining_time());
+// dto.setDistance(rtTripInfo.getRemaining_distance().intValue());
xpPushMessageClient.pushOrderRoute(dto);
}
}
@@ -309,20 +324,19 @@
*/
public void systemStatusXpuAndReassign(MsgContent msgContent) {
//开始处理消息对应的业务逻辑
- SystemRuntimeStatus systemRuntimeStatus = msgContent.getContent_detail().getObject("systemRuntimeStatus", SystemRuntimeStatus.class);
- AbnormalReason abnormalReason = systemRuntimeStatus.getSystem_status().getAbnormal_reason();
+ SystemRuntimeStatus systemRuntimeStatus = msgContent.getSystemRuntimeStatus();
+ AbnormalReason abnormalReason = systemRuntimeStatus.getSystemStatus().getAbnormalReason();
// 存储车辆挡位
- GearLevel gearLevel = systemRuntimeStatus.getVehicle_status().getDynamic_status().getGear_level();
- int value = gearLevel.getValue();
- redisTemplate.opsForValue().set(CacheConstants.GEAR_LEVEL + systemRuntimeStatus.getVehicle_status().getStatic_info().getVin(), value);
-
+ GearLevel gearLevel = systemRuntimeStatus.getVehicleStatus().getDynamicStatus().getGearLevel();
+ int value = gearLevel.getNumber();
+ redisTemplate.opsForValue().set(CacheConstants.GEAR_LEVEL + systemRuntimeStatus.getVehicleStatus().getStaticInfo().getXpuId(), value);
// 判断是否为故障状态
if (abnormalReason == AbnormalReason.FAULT) {
log.info("车辆故障,开始处理故障");
// TODO 添加异常任务
// 解绑用户与车辆关系
CancelTaxiPassengerVo cancelTaxiPassengerVo = new CancelTaxiPassengerVo();
- String orderId = systemRuntimeStatus.getRunning_order_status_info().getOrder_id();
+ String orderId = systemRuntimeStatus.getRunningOrderStatusInfo().getOrderId();
XpOrder xpOrder = xpOrderClient.queryOrderById(Long.parseLong(orderId)).getData();
XpVehicle vehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData();
if (vehicle != null) {
@@ -346,21 +360,12 @@
reassignOrderDTO.setOrderNo(xpOrder.getOrderNumber());
reassignOrderDTO.setCount(10);
RealtimePose pose = systemRuntimeStatus.getPose();
- Wgs naviPose = pose.getNavi_pose();
+ Wgs naviPose = pose.getNaviPose();
Double latitude = naviPose.getLatitude();
Double longitude = naviPose.getLongitude();
reassignOrderDTO.setLongitude(longitude);
reassignOrderDTO.setLatitude(latitude);
reassignOrderClient.reassignOrder(reassignOrderDTO);
-
-
-
-
-
-
-
-
-
// }
}
}
@@ -372,11 +377,11 @@
*/
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();
+ NavigationRequest naviRequest = msgContent.getNavigationRequset();
+ String requestId = naviRequest.getRequestId();
+ String orderId = naviRequest.getOrderId();
+ String taskId = naviRequest.getTaskId();
+ OrderPhase orderPhase = naviRequest.getOrderPhase();
log.info("订单ID:{}", orderId);
log.info("任务ID:{}", taskId);
switch (orderPhase) {
@@ -406,27 +411,30 @@
*/
public void navigationDeviationEvent(MsgContent msgContent) {
//先响应消息
- Long sequence = msgContent.getHeader().getSequence();
+ long sequence = msgContent.getHeader().getSequence();
//开始处理消息对应的业务逻辑
- NavigationDeviationEvent deviationEvent = msgContent.getContent_detail().getObject("deviationEvent", NavigationDeviationEvent.class);
- String requestId = deviationEvent.getRequest_id();
+ NavigationDeviationEvent deviationEvent = msgContent.getNaviDeviationEvent();
+ // todo 请求id确认是否有这个参数
+// String requestId = deviationEvent.getRequestId();
+ String requestId = "";
//导航id
String routeID = "";
Long vehicleId = null;
String orderType = "";
//偏航事件类型 1:请求导航,2:取消导航
- if (deviationEvent.getEvent_type().equals(RtEventType.RT_EVENT_TYPE_REQUEST)) {
- NavigationDeviationMessage navigationDeviationMessage = deviationEvent.getNavigation_deviation_message();
- String orderId = navigationDeviationMessage.getOrder_id();
- String taskId = navigationDeviationMessage.getTask_id();
- Double longitude = navigationDeviationMessage.getLongitude();
- Double latitude = navigationDeviationMessage.getLatitude();
+// if (deviationEvent.getEvent_type().equals(RtEventType.RT_EVENT_TYPE_REQUEST)) {
+ NavigationDeviationMessage navigationDeviationMessage = deviationEvent.getNavigationDeviationMessage();
+ String orderId = navigationDeviationMessage.getOrderId();
+ String taskId = navigationDeviationMessage.getTaskId();
+ Wgs wgs = navigationDeviationMessage.getPoint();
+ Double longitude = wgs.getLongitude();
+ Double latitude = wgs.getLatitude();
//订单类型 1:乘客订单,2=巡游订单
LonLatDto destination = new LonLatDto();
LonLatDto origin = new LonLatDto();
+
if (orderId.contains("XU")) {
orderType = OrderType.CRUISE_ORDER;
-
R<XpCruiseOrder> cruiseOrder = xpCruiseOrderClient.getCruiseOrder(orderId);
XpCruiseOrder xpCruiseOrder = cruiseOrder.getData();
@@ -512,10 +520,11 @@
if (200 != stringR.getCode()) {
throw new RuntimeException("根据导航ID获取车端需要的导航数据失败");
}
+ //TODO 这里的逻辑不太对,收到导航偏航事件之后
//构建导航下发请求对象
cloudPushNavigationInfo(requestId, routeID, stringR.getData(), orderType, orderId, xpVehicle.getVehicleVin(), xpVehicle.getXpuId());
}
- }
+// }
}
@@ -650,44 +659,46 @@
*/
public void cloudOrderOperation(Integer orderType, String orderId, String taskId, RouteVo routeVo, String vin) {
//构建消息体
- OrderOperation orderOperation = new OrderOperation();
- orderOperation.setOrder_id(orderId);
- orderOperation.setTask_id(taskId);
- orderOperation.setOperation_type(OrderOperationType.CLOUD_UPDATE_WAYPOINTS);
+ OrderOperation.Builder orderOperationBuilder = OrderOperation.newBuilder();
+ orderOperationBuilder.setOrderId(orderId);
+ orderOperationBuilder.setTaskId(taskId);
+ orderOperationBuilder.setOperationType(OrderOperationType.CLOUD_UPDATE_WAYPOINTS);
+
//构建航点
List<Waypoint> waypoints = new ArrayList<>();
List<LonLatDto> polyline = routeVo.getPolyline();
for (int i = 0; i < polyline.size(); i++) {
LonLatDto lonLatDto = polyline.get(i);
- Waypoint waypoint = new Waypoint();
- waypoint.setWaypoint_id(UUID.randomUUID().toString());
+ Waypoint.Builder waypointBuilder = Waypoint.newBuilder();
+ waypointBuilder.setWaypointId(UUID.randomUUID().toString());
if (0 == i) {
- waypoint.setPoint_type(PointType.START_POINT);
+ waypointBuilder.setPointType(PointType.START_POINT);
//订单类型不同,点位的动作类型不同
- waypoint.setAction_type(1 == orderType ? ActionType.PICK_UP : ActionType.ACTION_UNSPECIFIED);
+ waypointBuilder.setActionType(1 == orderType ? ActionType.PICK_UP : ActionType.ACTION_UNSPECIFIED);
} else if (polyline.size() - 1 == i) {
- waypoint.setPoint_type(PointType.END_POINT);
- waypoint.setAction_type(1 == orderType ? ActionType.DROP_OFF : ActionType.ACTION_UNSPECIFIED);
+ waypointBuilder.setPointType(PointType.END_POINT);
+ waypointBuilder.setActionType(1 == orderType ? ActionType.DROP_OFF : ActionType.ACTION_UNSPECIFIED);
} else {
- waypoint.setPoint_type(PointType.WAY_POINT);
+ waypointBuilder.setPointType(PointType.WAY_POINT);
//订单类型不同,点位的动作类型不同
- waypoint.setAction_type(ActionType.ACTION_UNSPECIFIED);
+ waypointBuilder.setActionType(ActionType.ACTION_UNSPECIFIED);
}
//构建经纬度
- GeoPoint geoPoint = new GeoPoint();
- geoPoint.setLongitude(lonLatDto.getLongitude());
- geoPoint.setLatitude(lonLatDto.getLatitude());
- waypoint.setPoint(geoPoint);
- waypoint.setSequence(i + 1);
- waypoints.add(waypoint);
+ GeoPoint.Builder geoPointBuilder = GeoPoint.newBuilder();
+ geoPointBuilder.setLongitude(lonLatDto.getLongitude());
+ geoPointBuilder.setLatitude(lonLatDto.getLatitude());
+ waypointBuilder.setPoint(geoPointBuilder.build());
+ waypointBuilder.setSequence(i + 1);
+ waypoints.add(waypointBuilder.build());
+
}
- orderOperation.setWaypoints(waypoints);
+ orderOperationBuilder.addAllWaypoints(waypoints);
long sequence = snowflake.nextId();
// 处理数据
redisTemplate.opsForValue().set(sequence,"pushOrder_"+orderId+"_"+vin,30, TimeUnit.MINUTES);
//开发发送请求到XPU
- xpuUtil.cloudOrderOperation(orderOperation, vin,sequence);
+ xpuUtil.cloudOrderOperation(orderOperationBuilder.build(), vin,sequence);
}
@@ -695,11 +706,12 @@
* 构建响应消息
*/
public void responseMessage(Long request_seq, String vin) {
- ResponseMessage responseMessage = new ResponseMessage();
- responseMessage.setRequest_seq(request_seq);
- responseMessage.setCode(StatusCode.OK);
- responseMessage.setTimestamp(System.currentTimeMillis());
- xpuUtil.responseMessage(responseMessage, vin);
+ ResponseMessage.Builder responseMessageBuilder = ResponseMessage.newBuilder();
+ responseMessageBuilder.setRequestSeq(request_seq);
+ responseMessageBuilder.setCode(StatusCode.OK);
+ responseMessageBuilder.setTimestamp(System.currentTimeMillis());
+ xpuUtil.responseMessage(responseMessageBuilder.build(), vin);
+
}
@@ -709,15 +721,15 @@
*/
public void orderStateUpdateEvent(MsgContent msgContent) {
//先响应消息
- Long sequence = msgContent.getHeader().getSequence();
+ long sequence = msgContent.getHeader().getSequence();
//开始处理消息对应的业务逻辑
- OrderStatusInfoEvent orderStatusInfoEvent = msgContent.getContent_detail().getObject("orderStatusInfoEvent", OrderStatusInfoEvent.class);
+ OrderStatusInfoEvent orderStatusInfoEvent = msgContent.getOrderStatusInfoEvent();
//只处理请求消息
- if (orderStatusInfoEvent.getEvent_type().equals(RtEventType.RT_EVENT_TYPE_REQUEST)) {
- com.xiaopeng.api.vo.automaticPilot.proto.up.orderStateUpdateEvent.OrderStatusInfo orderStatusInfo = orderStatusInfoEvent.getOrder_status_info();
- String orderId = orderStatusInfo.getOrder_id();
+ if (orderStatusInfoEvent.getEventType().equals(RtEventType.kEventOrderStateUpdate)) {
+ OrderStatusInfo orderStatusInfo = orderStatusInfoEvent.getOrderStatusInfo();
+ String orderId = orderStatusInfo.getOrderId();
//普通单
- com.xiaopeng.api.vo.automaticPilot.proto.up.orderStateUpdateEvent.OrderStatus status = orderStatusInfo.getStatus();
+ OrderStatus status = orderStatusInfo.getStatus();
switch (status) {
case ORDER_STATUS_UNSPECIFIED:
//订单状态未知
@@ -834,24 +846,62 @@
lastXpCruiseOrder.setStatus(1);
xpCruiseOrderClient.addCruiseOrder(lastXpCruiseOrder);
+ com.xiaopeng.api.vo.automaticPilot.protobuf.RtTask.Builder taskBuilder = com.xiaopeng.api.vo.automaticPilot.protobuf.RtTask.newBuilder();
+ taskBuilder.setOrderId(lastXpCruiseOrder.getId());
+ taskBuilder.setTaskId("MISSION_"+ IdUtil.fastUUID());
+ taskBuilder.setTaskType(com.xiaopeng.api.vo.automaticPilot.protobuf.OrderType.ORDER_TYPE_CRUISE);
- RTTask task = new RTTask();
- task.setOrder_id(lastXpCruiseOrder.getId());
- task.setTask_id("MISSION_"+ IdUtil.fastUUID());
- task.setTask_type(TaskType.CRUISE);
- task.setStatus(TaskStatus.PENDING);
+ com.xiaopeng.api.vo.automaticPilot.protobuf.RtTask task = taskBuilder.build();
+ com.xiaopeng.api.vo.automaticPilot.protobuf.RtTaskList taskList = com.xiaopeng.api.vo.automaticPilot.protobuf.RtTaskList.newBuilder().addTasks(task).build();
+
+
SnowFlake snowFlake = new SnowFlake(0, 0);
snowFlake.withStartTimestamp(1420041600000L);
long sequence1 = snowFlake.nextId();
- xpuUtil.cloudCreateOrder(task, xpVehicle.getVehicleVin(),sequence1);
+ xpuUtil.cloudCreateOrder(taskList, xpVehicle.getVehicleVin(),sequence1);
}else if(xpCruiseOrder.getOrderType()==1){
- // 正常巡游 找到下一个点位 若到达最后点位 则反向找点位 TODO v
+ // 正常巡游 找到下一个点位 若到达最后点位 则反向找点位
+ // 起点
+ Double endLon = xpCruiseOrder.getEndLon();
+ Double endLat = xpCruiseOrder.getEndLat();
+ XpCruiseOrder newXpCruiseOrder = new XpCruiseOrder();
+ newXpCruiseOrder.setId("XU"+ IdUtil.fastUUID());
+ newXpCruiseOrder.setVehicleId(xpCruiseOrder.getVehicleId());
+ newXpCruiseOrder.setVehicleVin(xpCruiseOrder.getVehicleVin());
+ newXpCruiseOrder.setFleetId(xpCruiseOrder.getFleetId());
+ newXpCruiseOrder.setOrderType(1);
+ newXpCruiseOrder.setStartLat(endLat);
+ newXpCruiseOrder.setStartLon(endLon);
+ newXpCruiseOrder.setStartPointId(xpCruiseOrder.getEndPointId());
+ newXpCruiseOrder.setStartPointName(xpCruiseOrder.getEndPointName());
+ newXpCruiseOrder.setStatus(1);
+ newXpCruiseOrder.setLastOrderId(xpCruiseOrder.getId());
+ // 通过车找终点id
+ CruisePointDto cruisePointDto = new CruisePointDto();
+ cruisePointDto.setNewXpCruiseOrder(newXpCruiseOrder);
+ cruisePointDto.setVehicleId(xpCruiseOrder.getVehicleId());
+ cruisePointDto.setPointId(newXpCruiseOrder.getStartPointId());
+ cruisePointDto.setOrderReverse(xpCruiseOrder.getOrderReverse());
+ R<XpCruiseOrder> cruisePoint = xpCruisePlanClient.getCruisePoint(cruisePointDto);
+ if(cruisePoint!=null){
+ xpCruiseOrderClient.addCruiseOrder(cruisePoint.getData());
+ RtTask.Builder taskBuilder = RtTask.newBuilder();
+ //TODO 设置目标地点信息
+ taskBuilder.setOrderId(newXpCruiseOrder.getId());
+ taskBuilder.setTaskId("MISSION_"+ IdUtil.fastUUID());
+ taskBuilder.setTaskType(com.xiaopeng.api.vo.automaticPilot.protobuf.OrderType.ORDER_TYPE_CRUISE);
+ RtTaskList.Builder taskListBuilder = RtTaskList.newBuilder();
+ taskListBuilder.addTasks(taskBuilder.build());
+
+ SnowFlake snowFlake = new SnowFlake(0, 0);
+ snowFlake.withStartTimestamp(1420041600000L);
+ long sequence1 = snowFlake.nextId();
+ xpuUtil.cloudCreateOrder(taskListBuilder.build(), xpVehicle.getVehicleVin(),sequence1);
+ }
}
-
}
-
}
}
}else{
@@ -893,11 +943,11 @@
*/
public void cloudPushNavigationInfo(String requestId, String routeId, String routeDataContent, String orderType, String orderId, String vin, String xpuId) {
//组装报文,将routeDateContent信息推送到XPU
- RestoreNavigationData navigationData = new RestoreNavigationData();
- navigationData.setRoute_id(routeId);
- navigationData.setRequest_id(requestId);
- navigationData.setContent(routeDataContent);
- navigationData.setTimestamp(System.currentTimeMillis());
+ RestoreNavigationData.Builder navigationDataBuilder = RestoreNavigationData.newBuilder();
+ navigationDataBuilder.setRouteId(routeId);
+ navigationDataBuilder.setRequestId(requestId);
+ navigationDataBuilder.setContent(routeDataContent);
+ navigationDataBuilder.setTimestamp(System.currentTimeMillis());
long sequence = snowflake.nextId();
// 处理数据
JSONObject jsonObject = new JSONObject();
@@ -906,7 +956,7 @@
jsonObject.put("orderId", orderId);
jsonObject.put("vin", vin);
redisTemplate.opsForValue().set(sequence, jsonObject.toJSONString(),30, TimeUnit.MINUTES);
- xpuUtil.cloudPushNavigation(navigationData, xpuId, sequence);
+ xpuUtil.cloudPushNavigation(navigationDataBuilder.build(), xpuId, sequence);
}
}
--
Gitblit v1.7.1