From 1632956ff51882192bb01dbfc5a3761482ff4603 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 17 四月 2026 10:34:02 +0800
Subject: [PATCH] 合并线上代码
---
xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/controller/XpMapController.java | 76 ++++++++++++++++++++++++--------------
1 files changed, 48 insertions(+), 28 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 baa9153..26e5f69 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,6 +1,9 @@
package com.xiaopeng.map.controller;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
+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.dto.operation.LonLatDto;
@@ -17,6 +20,7 @@
import com.xiaopeng.map.utils.AmapWalkingRouteUtil;
import com.xiaopeng.map.utils.GDMapGeocodingUtil;
import com.xiaopeng.map.utils.mangoUtils.MongoGeoFenceUtil;
+import com.xiaopeng.unifiedverification.interceptor.XpClientCheck;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@@ -27,13 +31,14 @@
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@RestController
-@RequestMapping("/base/v1/mini-program")
+@RequestMapping("")
@Api(tags = "地图调用服务")
public class XpMapController {
@@ -53,7 +58,7 @@
}
- @PostMapping("/map/getDistanceAndDuration")
+ @PostMapping("/base/v1/map/getDistanceAndDuration")
public R<RouteVo> getDistanceAndDuration(@RequestBody RouteAndFareDto dto){
// 获取电子围栏的禁行区域点位
GeoPoint startPoint = new GeoPoint(dto.getOrigin().getLongitude(),dto.getOrigin().getLatitude());
@@ -63,7 +68,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对象)
@@ -76,22 +81,32 @@
if (coordinates != null && !coordinates.isEmpty()) {
// 获取第一个多边形环(通常只有一个)
List<List<Double>> polygonPoints = coordinates.get(0);
-
+ List<String> coordinatesList = new ArrayList<>();
// 转换为经纬度字符串
- ArrayList<String> pointStr = new ArrayList<>();
for (List<Double> point : polygonPoints) {
if (point.size() >= 2) {
- pointStr.add(point.get(0) + "," + point.get(1));
+ coordinatesList.add(point.get(0) + "," + point.get(1));
}
}
-
- if (!pointStr.isEmpty()) {
- pointStrParam.add(String.join(";", pointStr));
- }
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("coordinates", coordinatesList);
+ pointStrParam.add(jsonObject);
}
}
}
- RouteVo routeVo = gdMapGeocodingUtil.getDistanceAndTime(dto.getOrigin(), dto.getDestination(), String.join("|", pointStrParam), fenceId,dto.getRoutePlanRule());
+
+ List<HistoryPointDto> history = new ArrayList<>();
+ if(null != 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);
+ }
+ RouteVo routeVo = gdMapGeocodingUtil.getDistanceAndTime(dto.getOrigin(), dto.getDestination(), pointStrParam, fenceId,dto.getRoutePlanRule(), history);
if(routeVo==null){
return R.fail("没有找到路线");
}
@@ -111,40 +126,44 @@
* @param dto
* @return
*/
- @PostMapping("/map/getOrderDistanceAndDuration")
+ @PostMapping("/base/v1/map/getOrderDistanceAndDuration")
public R<RouteVo> getOrderDistanceAndDuration(@Validated @RequestBody OrderRouteAndFareDto dto){
// 获取电子围栏的禁行区域点位
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<>();
// 一个区域的点位
- ArrayList<String> pointStr = new ArrayList<>();
for (GeoPoint point : points) {
- pointStr.add( point.getLongitude()+","+point.getLatitude());
+ coordinatesList.add(point.getLongitude()+","+point.getLatitude());
}
- if(!pointStr.isEmpty()){
- pointStrParam.add(String.join(";", pointStr));
- }
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("coordinates", coordinatesList);
+ pointStrParam.add(jsonObject);
}
}
-
- RouteVo routeVo = gdMapGeocodingUtil.getDistanceAndTime(dto.getOrigin(), dto.getDestination(), String.join("|", pointStrParam), fenceId,dto.getRoutePlanRule());
+ List<HistoryPointDto> history = new ArrayList<>();
+ if(null != 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);
+ }
+ RouteVo routeVo = gdMapGeocodingUtil.getDistanceAndTime(dto.getOrigin(), dto.getDestination(), pointStrParam, fenceId,dto.getRoutePlanRule(), history);
if(routeVo==null){
return R.fail("没有找到路线");
}
-
- // 存储redis
- redisService.setCacheObject(CacheConstants.ORDER_ROUTE + "_" + dto.getOrderId() + "_" +dto.getRouteType(), routeVo);
- // 存储路线偏离缓存,后续进行轨迹截取
-// redisService.setCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +dto.getRouteType(), routeVo);
-
return R.ok(routeVo);
}
@@ -153,7 +172,7 @@
* @param routedID
* @return
*/
- @PostMapping("/map/queryRouted")
+ @PostMapping("/base/v1/map/queryRouted")
public R<String> getOrderDistanceAndDuration(@RequestParam("routedID") String routedID){
return R.ok(gdMapGeocodingUtil.routed(routedID));
}
@@ -163,7 +182,8 @@
* 根据ip获取点位
*/
@ApiOperation(value = "根据ip获取点位", tags = {"小程序-站点导航"})
- @GetMapping("/point/getPointByIp")
+ @GetMapping("/base/v1/mini-program/point/getPointByIp")
+ @XpClientCheck(checkToken = false, checkOtpToken = true)
public R<PointByIpVo> getPointByIp(HttpServletRequest request) throws IOException {
String ip = request.getRemoteAddr();
PointByIpVo pointByIpVo = AmapWalkingRouteUtil.ipLocation(ip);
--
Gitblit v1.7.1