From 4edaaf570a2cd8af8a9c35694a46289cdf9278b3 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期五, 17 四月 2026 11:58:16 +0800
Subject: [PATCH] Merge branch '1.0' of http://120.76.84.145:10101/gitblit/r/java/Robotaxi into 1.0

---
 xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/controller/XpMapController.java |   49 ++++++++++++++++++++++++++++++++-----------------
 1 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/controller/XpMapController.java b/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/controller/XpMapController.java
index c08b40a..23e0be2 100644
--- a/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/controller/XpMapController.java
+++ b/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/controller/XpMapController.java
@@ -1,12 +1,11 @@
 package com.xiaopeng.map.controller;
 
 
-import com.fasterxml.jackson.databind.ObjectMapper;
+import com.xiaopeng.api.dto.WeatherDTO;
 import com.xiaopeng.api.dto.map.HistoryPointDto;
 import com.xiaopeng.api.dto.map.OrderRouteAndFareDto;
 import com.xiaopeng.api.dto.map.RouteAndFareDto;
 import com.xiaopeng.api.feignClient.order.XpOrderClient;
-import com.xiaopeng.api.dto.WeatherDTO;
 import com.xiaopeng.api.vo.map.PointByIpVo;
 import com.xiaopeng.api.vo.operation.RouteVo;
 import com.xiaopeng.common.core.domain.R;
@@ -37,6 +36,9 @@
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
+import com.fasterxml.jackson.databind.ObjectMapper;
 
 @Slf4j
 @RestController
@@ -70,7 +72,7 @@
         List<Document> pointsInFence = xpGeoFencingPolygonService.findPointsByParentId(fenceId, "fenceId", "prohibited_area");
 
         // 避让区域
-        ArrayList<String> pointStrParam = new ArrayList<>();
+        ArrayList<JSONObject> pointStrParam = new ArrayList<>();
         try {
             for (Document document : pointsInFence) {
                 // 获取points字段(它是GeoJSON对象)
@@ -83,25 +85,31 @@
                     if (coordinates != null && !coordinates.isEmpty()) {
                         // 获取第一个多边形环(通常只有一个)
                         List<List<Double>> polygonPoints = coordinates.get(0);
-
+                        List<String> coordinatesList = new ArrayList<>();
                         // 转换为经纬度字符串
                         for (List<Double> point : polygonPoints) {
                             if (point.size() >= 2) {
-                                pointStrParam.add(point.get(0) + "," + point.get(1));
+                                coordinatesList.add(point.get(0) + "," + point.get(1));
                             }
                         }
+                        JSONObject jsonObject = new JSONObject();
+                        jsonObject.put("coordinates", coordinatesList);
+                        pointStrParam.add(jsonObject);
                     }
                 }
             }
 
             List<HistoryPointDto> history = new ArrayList<>();
             if(null != dto.getVehicleId()){
-                history = redisService.getCacheList("VEHICLE_HISTORY_POINT_LIST:" + dto.getVehicleId());
+//                history = redisService.getCacheList("VEHICLE_HISTORY_POINT_LIST:" + dto.getVehicleId());
+//                if(history.size() > 10){
+//                    history = history.subList(history.size() - 10, history.size());
+//                }
+//                history.forEach(s->{
+//                    s.setDirection(new BigDecimal(s.getDirection()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
+//                });
+//                redisService.setCacheList("VEHICLE_HISTORY_POINT_LIST:" + dto.getVehicleId(), history);
             }
-            if(history.size() > 10){
-                history = history.subList(history.size() - 10, history.size());
-            }
-            redisService.setCacheList("VEHICLE_HISTORY_POINT_LIST:" + dto.getVehicleId(), history);
             RouteVo routeVo = gdMapGeocodingUtil.getDistanceAndTime(dto.getOrigin(), dto.getDestination(), pointStrParam, fenceId,dto.getRoutePlanRule(), history);
             if(routeVo==null){
                 return R.fail("没有找到路线");
@@ -128,27 +136,34 @@
         GeoPoint startPoint = new GeoPoint(dto.getOrigin().getLongitude(),dto.getOrigin().getLatitude());
         List<String> operatingArea = xpGeoFencingPolygonService.findFencesContainingPoint(startPoint, "operating_area", "points");
         // 避让区域
-        ArrayList<String> pointStrParam = new ArrayList<>();
+        ArrayList<JSONObject> pointStrParam = new ArrayList<>();
         String fenceId = null;
         if(!operatingArea.isEmpty()){
             fenceId = operatingArea.get(0);
             List<Document> pointsInFence = xpGeoFencingPolygonService.findPointsByParentId(fenceId, "parentId", "prohibited_area");
             for (Document document : pointsInFence) {
                 List<GeoPoint> points = document.getList("points", GeoPoint.class);
+                List<String> coordinatesList = new ArrayList<>();
                 // 一个区域的点位
                 for (GeoPoint point : points) {
-                    pointStrParam.add(point.getLongitude()+","+point.getLatitude());
+                    coordinatesList.add(point.getLongitude()+","+point.getLatitude());
                 }
+                JSONObject jsonObject = new JSONObject();
+                jsonObject.put("coordinates", coordinatesList);
+                pointStrParam.add(jsonObject);
             }
         }
         List<HistoryPointDto> history = new ArrayList<>();
         if(null != dto.getVehicleId()){
-            history = redisService.getCacheList("VEHICLE_HISTORY_POINT_LIST:" + dto.getVehicleId());
+//            history = redisService.getCacheList("VEHICLE_HISTORY_POINT_LIST:" + dto.getVehicleId());
+//            if(history.size() > 10){
+//                history = history.subList(history.size() - 10, history.size());
+//            }
+//            history.forEach(s->{
+//                s.setDirection(new BigDecimal(s.getDirection()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
+//            });
+//            redisService.setCacheList("VEHICLE_HISTORY_POINT_LIST:" + dto.getVehicleId(), history);
         }
-        if(history.size() > 10){
-            history = history.subList(history.size() - 10, history.size());
-        }
-        redisService.setCacheList("VEHICLE_HISTORY_POINT_LIST:" + dto.getVehicleId(), history);
         RouteVo routeVo = gdMapGeocodingUtil.getDistanceAndTime(dto.getOrigin(), dto.getDestination(), pointStrParam, fenceId,dto.getRoutePlanRule(), history);
         if(routeVo==null){
             return R.fail("没有找到路线");

--
Gitblit v1.7.1