puzhibing
2026-02-28 e8cd57fc46fa84b0c095f7e93cb348c014d06eb4
xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/controller/PushOrderRouteController.java
@@ -1,6 +1,5 @@
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;
@@ -15,7 +14,6 @@
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;
@@ -24,7 +22,6 @@
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import java.util.concurrent.TimeUnit;
@Api(tags = "订单推送轨迹接口")
@RestController
@@ -54,15 +51,7 @@
            routeType = xpOrder.getStatus() == 3 ? 1 : 2;
        }
        // 获取路线规划
        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);
        RouteVo routeVo = redisService.getCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +routeType);
        if(Objects.nonNull(routeVo)){
@@ -74,17 +63,13 @@
            routeVo.setPolyline(lonLatDtos);
            // 存储最新路线偏离缓存,后续进行轨迹截取
//            redisService.setCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +routeType, routeVo);
            redisService.setCacheObject(key, JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS);
            redisService.setCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +routeType, routeVo);
            // 封装轨迹点位集合
            List<Map<String, Object>> polyline = new ArrayList<>();
            Map<String, Object> polyline = new HashMap<>();
            for (LonLatDto lonLatDto : lonLatDtos) {
                Map<String, Object> polylineMap = new HashMap<>();
                polylineMap.put("longitude",lonLatDto.getLongitude());
                polylineMap.put("latitude",lonLatDto.getLatitude());
                polyline.add(polylineMap);
                polyline.put("longitude",lonLatDto.getLongitude());
                polyline.put("latitude",lonLatDto.getLatitude());
            }
            // 封装路由详情
            Map<String, Object> route = new HashMap<>();
@@ -93,9 +78,8 @@
            route.put("polyline",JSONObject.toJSONString(polyline));
            Map<String, Object> content = new HashMap<>();
            content.put("orderId",dto.getOrderId().toString());
            content.put("orderId",dto.getOrderId());
            content.put("routeType",routeType);
            content.put("direction",dto.getDirection());
            content.put("route",JSONObject.toJSONString(route));
            // 封装轨迹信息