From 560be817c1342d4da523760ba38433c4c0f52983 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期二, 12 五月 2026 10:56:09 +0800
Subject: [PATCH] Merge branch '1.1' of http://120.76.84.145:10101/gitblit/r/java/Robotaxi into 1.1

---
 xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/utils/GDMapGeocodingUtil.java |   78 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/utils/GDMapGeocodingUtil.java b/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/utils/GDMapGeocodingUtil.java
index a776845..89118b7 100644
--- a/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/utils/GDMapGeocodingUtil.java
+++ b/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/utils/GDMapGeocodingUtil.java
@@ -154,6 +154,84 @@
     }
 
 
+    /**
+     * 根据起始点获取驾车距离 和 时间  以及避让区域
+     *
+     * @param start         起点
+     * @param end           终点
+     * @param avoidRoads    避让点
+     * @param fenceId       mango id
+     * @param routePlanRule 线路规划规则
+     * @return
+     * @throws Exception
+     */
+    public List<RouteVo> getDistanceAndTimeList(LonLatDto start, LonLatDto end,ArrayList<JSONObject> avoidRoads,String fenceId,Integer routePlanRule, List<HistoryPointDto> history)  {
+        String url = "https://tsapi.amap.com/v1/route/price?key=" + key + "&extensions=all&start=" + start.getLongitude() + "," + start.getLatitude();
+        HashMap<String, Object> params = new HashMap<>();
+        params.put("extensions", "all");
+        params.put("start", start.getLongitude() + "," + start.getLatitude());
+        params.put("end", end.getLongitude() + "," + end.getLatitude());
+        params.put("routeUserType", 2);
+        if (avoidRoads != null && !avoidRoads.isEmpty()) {
+            params.put("avoidPolygons", avoidRoads);
+        }
+        if (routePlanRule != null) {
+            params.put("strategy", routePlanRule);
+        }
+        if(null != history && !history.isEmpty()){
+            params.put("history", history);
+        }
+        log.info("高德地图接口:{}", url);
+        log.info("高德地图参数:{}", JSON.toJSONString(params));
+        String post = HttpUtils.post(url, JSON.toJSONString(params));
+        log.info("高德地图返回结果:" + post);
+        JSONObject jsonObject = JSON.parseObject(post);
+        String data = jsonObject.getString("data");
+
+        JSONObject jsonObject1 = JSON.parseObject(data);
+        JSONArray path = jsonObject1.getJSONArray("paths");
+        log.info("开始判断导航路径是否在运营区域范围内 {}", fenceId);
+        List<RouteVo> list = new ArrayList<>();
+        for (Object o : path) {
+            RouteVo routeVo = new RouteVo();
+            JSONObject jsonObject2 = (JSONObject) o;
+            String routeID = jsonObject2.getString("routeID");
+            String points = jsonObject2.getString("points");
+            String[] split = points.split(";");
+            List<LonLatDto> pointsArray = new ArrayList<>();
+            for (int i = 0; i < split.length; i++) {
+                if((i % 2) == 0){
+                    String[] split1 = split[i].split(",");
+                    LonLatDto lonLatDto = new LonLatDto(Double.parseDouble(split1[0]), Double.parseDouble(split1[1]));
+                    pointsArray.add(lonLatDto);
+                }
+            }
+            ForkJoinPool pool = new ForkJoinPool(); // 创建ForkJoinPool对象(默认使用处理器的核心数作为线程池大小)
+            ArrayPointsTask arrayPointsTask = new ArrayPointsTask(pointsArray, fenceId); // 创建求和任务对象并传入数组作为参数(这里也可以传入数组的一部分作为参数来实现更细粒度的拆分)
+            Long temp = pool.invoke(arrayPointsTask); // 提交任务并等待处理完成(也可以使用submit方法提交任务并获取一个Future对象来异步获取结果)
+            pool.shutdown(); // 关闭ForkJoinPool(释放资源)
+            if (temp == 0) {
+                Integer costTime = jsonObject2.getInteger("costTime");
+                Integer distance = jsonObject2.getInteger("distance");
+                routeVo.setDistance(distance);
+                routeVo.setDuration(costTime);
+                ArrayList<LonLatDto> lonLatDtos = new ArrayList<>(split.length);
+                for (String s : split) {
+                    String[] split1 = s.split(",");
+                    LonLatDto lonLatDto = new LonLatDto(Double.parseDouble(split1[0]), Double.parseDouble(split1[1]));
+                    lonLatDtos.add(lonLatDto);
+                }
+                routeVo.setPolyline(lonLatDtos);
+                routeVo.setRouteID(routeID);
+                log.info("导航 {} 在 {} 运营区域内", routeVo.getRouteID(), fenceId);
+                list.add(routeVo);
+            }
+        }
+        return list;
+
+    }
+
+
     public static void main(String[] args) {
         String url = "https://tsapi.amap.com/v1/route/price?key=" + "66ae577f63898dae3016d599fda57221" + "&extensions=all&start=" + "113.384932" + "," + "23.155455";
         HashMap<String, Object> params = new HashMap<>();

--
Gitblit v1.7.1