puzhibing
2026-03-01 11f229dd82d7a7ba2d9f36147677347a3b9eef99
xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/controller/PushOrderRouteController.java
@@ -1,5 +1,6 @@
package com.xiaopeng.pushMessage.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.xiaopeng.api.dto.operation.LonLatDto;
import com.xiaopeng.api.dto.pushMessage.PushOrderRouteDTO;
@@ -14,6 +15,7 @@
import com.xiaopeng.common.redis.service.RedisService;
import com.xiaopeng.pushMessage.utils.MapMatchingUtil;
import io.swagger.annotations.Api;
import org.powermock.core.ListMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
@@ -22,6 +24,7 @@
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import java.util.concurrent.TimeUnit;
@Api(tags = "订单推送轨迹接口")
@RestController
@@ -51,7 +54,15 @@
            routeType = xpOrder.getStatus() == 3 ? 1 : 2;
        }
        // 获取路线规划
        RouteVo routeVo = redisService.getCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +routeType);
        String key = "";
        //接驾情况,获取车辆位置到起点的导航
        if(1 == routeType){
            key = "ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId();
        }else{
            key = "ORDER_NAVIGATION_END_DATA:" + xpOrder.getAppUserId();
        }
        Object cacheObject = redisService.getCacheObject(key);
        RouteVo routeVo = JSON.parseObject(cacheObject.toString(), RouteVo.class);
        if(Objects.nonNull(routeVo)){
@@ -63,13 +74,17 @@
            routeVo.setPolyline(lonLatDtos);
            // 存储最新路线偏离缓存,后续进行轨迹截取
            redisService.setCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +routeType, routeVo);
//            redisService.setCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +routeType, routeVo);
            redisService.setCacheObject(key, JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS);
            // 封装轨迹点位集合
            Map<String, Object> polyline = new HashMap<>();
            List<Map<String, Object>> polyline = new ArrayList<>();
            for (LonLatDto lonLatDto : lonLatDtos) {
                polyline.put("longitude",lonLatDto.getLongitude());
                polyline.put("latitude",lonLatDto.getLatitude());
                Map<String, Object> polylineMap = new HashMap<>();
                polylineMap.put("longitude",lonLatDto.getLongitude());
                polylineMap.put("latitude",lonLatDto.getLatitude());
                polyline.add(polylineMap);
            }
            // 封装路由详情
            Map<String, Object> route = new HashMap<>();
@@ -78,8 +93,9 @@
            route.put("polyline",JSONObject.toJSONString(polyline));
            Map<String, Object> content = new HashMap<>();
            content.put("orderId",dto.getOrderId());
            content.put("orderId",dto.getOrderId().toString());
            content.put("routeType",routeType);
            content.put("direction",dto.getDirection());
            content.put("route",JSONObject.toJSONString(route));
            // 封装轨迹信息