puzhibing
2026-03-27 8d2cd1ee705d9dcec4115531aafcfa34a2c904cb
修改bug
7个文件已修改
291 ■■■■■ 已修改文件
xp-robotaxi-api/src/main/java/com/xiaopeng/api/factory/operation/XpTestPlanClientFallbackFactory.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-api/src/main/java/com/xiaopeng/api/feignClient/operation/XpTestPlanClient.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-api/src/main/java/com/xiaopeng/api/vo/operation/RouteVo.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/controller/XpTestPlanController.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpTestOrderServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/controller/PushOrderRouteController.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/utils/MapMatchingUtil.java 245 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-api/src/main/java/com/xiaopeng/api/factory/operation/XpTestPlanClientFallbackFactory.java
@@ -32,11 +32,7 @@
                return R.fail("获取测试计划点失败");
            }
            @Override
            public R<XpTestPoint> getXpTestPointById(Long id) {
                log.error("获取测试计划点位失败:{}", cause.getMessage());
                return R.fail("获取测试计划点位失败");
            }
            @Override
            public R<List<XpTestPlanVehicle>> getXpTestPlanVehicleByTestPlanId(Long testPlanId) {
xp-robotaxi-api/src/main/java/com/xiaopeng/api/feignClient/operation/XpTestPlanClient.java
@@ -36,13 +36,7 @@
    R<XpTestPlanPoint> getXpTestPlanPointById(@RequestParam Long id);
    /**
     * 根据id获取测试计划点位
     * @param id
     * @return
     */
    @PostMapping("/inner/v1/xp-test-plan/getXpTestPointById")
    R<XpTestPoint> getXpTestPointById(@RequestParam Long id);
xp-robotaxi-api/src/main/java/com/xiaopeng/api/vo/operation/RouteVo.java
@@ -21,4 +21,7 @@
    private Double direction;
    private List<LonLatDto> polyline;
    @ApiModelProperty("被截取的点位,用于前端使用")
    private List<LonLatDto> served;
}
xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/controller/XpTestPlanController.java
@@ -107,17 +107,6 @@
    /**
     * 根据id获取测试计划点位
     * @param id
     * @return
     */
    @PostMapping("/inner/v1/xp-test-plan/getXpTestPointById")
    public R<XpTestPoint> getXpTestPointById(@RequestParam Long id){
        XpTestPoint xpTestPoint = xpTestPointService.queryById(id).getData();
        return R.ok(xpTestPoint);
    }
    /**
     * 根据测试计划获取车辆信息
xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpTestOrderServiceImpl.java
@@ -142,6 +142,7 @@
    private final MongoTemplate mongoTemplate;
    private final XpElectronicFenceClient xpElectronicFenceClient;
    private final XpElectronicClient xpElectronicClient;
    private final XpTestPointClient testPointClient;
@@ -156,8 +157,8 @@
    public void addTestOrder(AddTestOrderVo query) {
        Long startTestPointId = query.getStartTestPointId();
        Long endTestPointId = query.getEndTestPointId();
        XpTestPoint xpPoint = xpTestPlanClient.getXpTestPointById(startTestPointId).getData();
        XpTestPoint endXpPoint = xpTestPlanClient.getXpTestPointById(endTestPointId).getData();
        XpTestPoint xpPoint = testPointClient.queryById(startTestPointId).getData();
        XpTestPoint endXpPoint = testPointClient.queryById(endTestPointId).getData();
        if(xpPoint ==null || xpPoint.getOperationStatus()!=2){
            throw new ServiceException("起站点已停止运营", 200,I18nKeyConstant.NO_CURRENT_POINT);
        }
xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/controller/PushOrderRouteController.java
@@ -71,7 +71,7 @@
                Integer distance = dto.getDistance();
                Integer duration = dto.getDuration();
                // 计算实时点位到线段的最优截取
                List<LonLatDto> lonLatDtos = MapMatchingUtil.getRemainingNavigation(routeVo.getPolyline(), dto.getLongitude(), dto.getLatitude());
                Map<String, List<LonLatDto>> remainingNavigation = MapMatchingUtil.getRemainingNavigation(routeVo.getPolyline(), dto.getLongitude(), dto.getLatitude());
                //当订单状态为5的时候(乘客已上车)需要推送导航的距离和剩余时间
                //因为这个状态,车端推的依然是接驾的剩余里程和时间,就会导致数据和小程序的页面跳转匹配不上
                //小程序是只要乘客上车后就跳转到行程开始页面
@@ -82,7 +82,10 @@
                    distance = routeVo.getDistance();
                    duration = routeVo.getDuration();
                }
                List<LonLatDto> lonLatDtos = remainingNavigation.get("unserved");
                List<LonLatDto> lonLatDtos1 = remainingNavigation.get("served");
                routeVo.setPolyline(lonLatDtos);
                routeVo.setServed(lonLatDtos1);
                // 存储最新路线偏离缓存,后续进行轨迹截取
                redisService.setCacheObject(key, JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS);
@@ -95,11 +98,19 @@
                    polylineMap.put("latitude",lonLatDto.getLatitude());
                    polyline.add(polylineMap);
                }
                List<Map<String, Object>> served = new ArrayList<>();
                for (LonLatDto lonLatDto : lonLatDtos1) {
                    Map<String, Object> polylineMap = new HashMap<>();
                    polylineMap.put("longitude",lonLatDto.getLongitude());
                    polylineMap.put("latitude",lonLatDto.getLatitude());
                    served.add(polylineMap);
                }
                // 封装路由详情
                Map<String, Object> route = new HashMap<>();
                route.put("distance",distance);
                route.put("duration",duration);
                route.put("polyline",JSONObject.toJSONString(polyline));
                route.put("served",JSONObject.toJSONString(served));
                Map<String, Object> content = new HashMap<>();
                content.put("orderId",dto.getOrderId().toString());
xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/utils/MapMatchingUtil.java
@@ -10,9 +10,7 @@
import org.gavaghan.geodesy.GeodeticCurve;
import org.gavaghan.geodesy.GlobalCoordinates;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.*;
import java.util.concurrent.*;
@@ -29,8 +27,9 @@
     * @param latitude
     * @return
     */
    public static List<LonLatDto> getRemainingNavigation(List<LonLatDto> polyline, Double longitude, Double latitude){
    public static Map<String, List<LonLatDto>> getRemainingNavigation(List<LonLatDto> polyline, Double longitude, Double latitude){
        //导航数据只有一个点的情况
        Map<String, List<LonLatDto>> map = new HashMap<>();
        if(polyline.size() == 1){
            LonLatDto lonLatDto = polyline.get(0);
            GlobalCoordinates source1 = new GlobalCoordinates(lonLatDto.getLatitude(), lonLatDto.getLongitude());
@@ -39,12 +38,16 @@
            double distance =geoCurve1.getEllipsoidalDistance();
            //判断距离小于5米,则可以返回空数据
            if(5 >= distance){
                return Collections.emptyList();
                map.put("unserved", Collections.emptyList());
                map.put("served", Collections.emptyList());
                return map;
            }
            //大于5米的情况,将车子当前位置添加进结果中
            lonLatDto = new LonLatDto(longitude, latitude);
            polyline.add(0, lonLatDto);
            return polyline;
            map.put("unserved", polyline);
            map.put("served", Collections.emptyList());
            return map;
        }
        //多个点位的情况,需要找出当前点位处于那两个点位之间,然后截取掉超出的部分轨迹
        return getRecentlyPoint(polyline, longitude, latitude);
@@ -59,7 +62,8 @@
     * @param latitude
     * @return
     */
    public static List<LonLatDto> getRecentlyPoint(List<LonLatDto> polyline, Double longitude, Double latitude){
    public static Map<String, List<LonLatDto>> getRecentlyPoint(List<LonLatDto> polyline, Double longitude, Double latitude){
        Map<String, List<LonLatDto>> map = new HashMap<>();
        for (int i = 0; i < polyline.size(); i++) {
            LonLatDto lonLatDto1 = polyline.get(i);
@@ -82,124 +86,131 @@
            //判断当前位置是否处于两个点位之间
            if((distance1 + distance2) == distance3 || (distance1 + distance2) <= distance3 + 5){
                //剩余未服务的点位
                List<LonLatDto> lonLatDtos = polyline.subList(i + 1, polyline.size());
                lonLatDtos.add(0, new LonLatDto(longitude, latitude));
                return lonLatDtos;
                //已经服务的点位,给到前端处理
                List<LonLatDto> lonLatDtos1 = polyline.subList(0, i + 1);
                map.put("unserved", lonLatDtos);
                map.put("served", lonLatDtos1);
                return map;
            }
        }
        polyline.add(0, new LonLatDto(longitude, latitude));
        return polyline;
        map.put("unserved", polyline);
        map.put("served", Collections.emptyList());
        return map;
    }
    public static void main(String[] args) {
        JSONArray objects = JSON.parseArray("[{\n" +
                "\t\t\"latitude\": 30.58549,\n" +
                "\t\t\"longitude\": 104.054501\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.585938,\n" +
                "\t\t\"longitude\": 104.054501\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.586522,\n" +
                "\t\t\"longitude\": 104.054501\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.587026,\n" +
                "\t\t\"longitude\": 104.054507\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.587922,\n" +
                "\t\t\"longitude\": 104.054518\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.588062,\n" +
                "\t\t\"longitude\": 104.054518\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.588292,\n" +
                "\t\t\"longitude\": 104.054528\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.588292,\n" +
                "\t\t\"longitude\": 104.0544\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.588292,\n" +
                "\t\t\"longitude\": 104.0544\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.587949,\n" +
                "\t\t\"longitude\": 104.054384\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.587311,\n" +
                "\t\t\"longitude\": 104.054389\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.587118,\n" +
                "\t\t\"longitude\": 104.054394\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.586704,\n" +
                "\t\t\"longitude\": 104.054394\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.586125,\n" +
                "\t\t\"longitude\": 104.0544\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.585938,\n" +
                "\t\t\"longitude\": 104.054405\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.585476,\n" +
                "\t\t\"longitude\": 104.054405\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.584693,\n" +
                "\t\t\"longitude\": 104.054405\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.584403,\n" +
                "\t\t\"longitude\": 104.054416\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.584312,\n" +
                "\t\t\"longitude\": 104.054416\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.583593,\n" +
                "\t\t\"longitude\": 104.054416\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.583486,\n" +
                "\t\t\"longitude\": 104.054416\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.583116,\n" +
                "\t\t\"longitude\": 104.054421\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.582391,\n" +
                "\t\t\"longitude\": 104.054426\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.582397,\n" +
                "\t\t\"longitude\": 104.054577\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.582397,\n" +
                "\t\t\"longitude\": 104.054577\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.582815,\n" +
                "\t\t\"longitude\": 104.054561\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.58311,\n" +
                "\t\t\"longitude\": 104.05455\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.58311,\n" +
                "\t\t\"longitude\": 104.05455\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.58311,\n" +
                "\t\t\"longitude\": 104.054899\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.583143,\n" +
                "\t\t\"longitude\": 104.054931\n" +
                "\t}, {\n" +
                "\t\t\"latitude\": 30.583148,\n" +
                "\t\t\"longitude\": 104.054973\n" +
                "\t}]");
        List<LonLatDto> lonLatDtoList = new ArrayList<>();
        for (int i = 0; i < objects.size(); i++) {
            JSONObject object = objects.getJSONObject(i);
            LonLatDto lonLatDto = new LonLatDto(object.getDouble("longitude"), object.getDouble("latitude"));
            lonLatDtoList.add(lonLatDto);
        }
        for (int i = 0; i < 20; i++) {
            List<LonLatDto> remainingNavigation = getRemainingNavigation(lonLatDtoList, 104.054503, 30.58549);
            lonLatDtoList = remainingNavigation;
        }
    }
//    public static void main(String[] args) {
//        JSONArray objects = JSON.parseArray("[{\n" +
//                "\t\t\"latitude\": 30.58549,\n" +
//                "\t\t\"longitude\": 104.054501\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.585938,\n" +
//                "\t\t\"longitude\": 104.054501\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.586522,\n" +
//                "\t\t\"longitude\": 104.054501\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.587026,\n" +
//                "\t\t\"longitude\": 104.054507\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.587922,\n" +
//                "\t\t\"longitude\": 104.054518\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.588062,\n" +
//                "\t\t\"longitude\": 104.054518\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.588292,\n" +
//                "\t\t\"longitude\": 104.054528\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.588292,\n" +
//                "\t\t\"longitude\": 104.0544\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.588292,\n" +
//                "\t\t\"longitude\": 104.0544\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.587949,\n" +
//                "\t\t\"longitude\": 104.054384\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.587311,\n" +
//                "\t\t\"longitude\": 104.054389\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.587118,\n" +
//                "\t\t\"longitude\": 104.054394\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.586704,\n" +
//                "\t\t\"longitude\": 104.054394\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.586125,\n" +
//                "\t\t\"longitude\": 104.0544\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.585938,\n" +
//                "\t\t\"longitude\": 104.054405\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.585476,\n" +
//                "\t\t\"longitude\": 104.054405\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.584693,\n" +
//                "\t\t\"longitude\": 104.054405\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.584403,\n" +
//                "\t\t\"longitude\": 104.054416\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.584312,\n" +
//                "\t\t\"longitude\": 104.054416\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.583593,\n" +
//                "\t\t\"longitude\": 104.054416\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.583486,\n" +
//                "\t\t\"longitude\": 104.054416\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.583116,\n" +
//                "\t\t\"longitude\": 104.054421\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.582391,\n" +
//                "\t\t\"longitude\": 104.054426\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.582397,\n" +
//                "\t\t\"longitude\": 104.054577\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.582397,\n" +
//                "\t\t\"longitude\": 104.054577\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.582815,\n" +
//                "\t\t\"longitude\": 104.054561\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.58311,\n" +
//                "\t\t\"longitude\": 104.05455\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.58311,\n" +
//                "\t\t\"longitude\": 104.05455\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.58311,\n" +
//                "\t\t\"longitude\": 104.054899\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.583143,\n" +
//                "\t\t\"longitude\": 104.054931\n" +
//                "\t}, {\n" +
//                "\t\t\"latitude\": 30.583148,\n" +
//                "\t\t\"longitude\": 104.054973\n" +
//                "\t}]");
//        List<LonLatDto> lonLatDtoList = new ArrayList<>();
//        for (int i = 0; i < objects.size(); i++) {
//            JSONObject object = objects.getJSONObject(i);
//            LonLatDto lonLatDto = new LonLatDto(object.getDouble("longitude"), object.getDouble("latitude"));
//            lonLatDtoList.add(lonLatDto);
//        }
//        for (int i = 0; i < 20; i++) {
//            List<LonLatDto> remainingNavigation = getRemainingNavigation(lonLatDtoList, 104.054503, 30.58549);
//            lonLatDtoList = remainingNavigation;
//        }
//
//
//    }
    /**