From e90998053faecd0346591c2bba2ce58e198776b4 Mon Sep 17 00:00:00 2001
From: “mitao” <“2763622819@qq.com”>
Date: 星期三, 04 三月 2026 19:47:13 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/service/impl/XpPricingServiceImpl.java    |   22 +++++++----
 xp-robotaxi-itinerary-boot/src/main/resources/i18n/messages.properties                                    |    5 ++
 xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/utils/map/GDMapGeocodingUtil.java         |   56 ++++++++++++++++++++++++++++
 xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/XpElectronicFenceServiceImpl.java |   18 ++++++--
 xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/constant/I18nKeyConstant.java             |    6 +++
 xp-robotaxi-itinerary-boot/src/main/resources/i18n/messages_zh_CN.properties                              |    5 ++
 xp-robotaxi-itinerary-boot/src/main/resources/i18n/messages_en_US.properties                              |    5 ++
 7 files changed, 101 insertions(+), 16 deletions(-)

diff --git a/xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/constant/I18nKeyConstant.java b/xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/constant/I18nKeyConstant.java
index 2a2d861..3ba76f6 100644
--- a/xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/constant/I18nKeyConstant.java
+++ b/xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/constant/I18nKeyConstant.java
@@ -53,4 +53,10 @@
 
     // 路径不存在
     String PATH_NOT_FOUND = "path.not.found";
+
+    //未找到步行路线
+    String WALKING_ROUTE_NOT_FOUND = "walking.route.not.found";
+
+    //城市不存在
+    String CITY_NOT_FOUND = "city.not.found";
 }
diff --git a/xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/service/impl/XpPricingServiceImpl.java b/xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/service/impl/XpPricingServiceImpl.java
index 9f15812..1af5616 100644
--- a/xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/service/impl/XpPricingServiceImpl.java
+++ b/xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/service/impl/XpPricingServiceImpl.java
@@ -37,6 +37,7 @@
 import com.xiaopeng.itinerary.utils.XpPricingUtil;
 import com.xiaopeng.itinerary.utils.holiday.HolidayUtil;
 import com.xiaopeng.itinerary.utils.map.FastDistanceCalculator;
+import com.xiaopeng.itinerary.utils.map.GDMapGeocodingUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.geo.GeoJsonPoint;
@@ -116,6 +117,9 @@
     @Resource
     private XpPushMessageClient xpPushMessageClient;
 
+    @Resource
+    private GDMapGeocodingUtil gdMapGeocodingUtil;
+
 
     // 自定义线程池用于并行执行任务
     private final ExecutorService executorService;
@@ -174,8 +178,6 @@
 
     @Override
     public RouteAndFareVo getRouteAndFare(RouteAndFareDto routeAndFareDto, String userId) {
-
-
         // 判断是否5分钟内进行了查询 相同站点的起始点  并且是同时段
         String key = "xp-map-query-" + routeAndFareDto.getOpenCityId()
                 + "-" + routeAndFareDto.getOrigin().getLongitude() + "-" + routeAndFareDto.getOrigin().getLatitude()
@@ -188,12 +190,16 @@
         }
 
         // 1. 基础数据查询
-        XpOpenCity xpOpenCity = xpOpenCityMapper.selectById(routeAndFareDto.getOpenCityId());
-        if (xpOpenCity == null) {
-            throw new ServiceException("未找到步行路线", I18nKeyConstant.CITY_INFORMATION_DOES_NOT_EXIST);
+        Map<String, String> geocode = gdMapGeocodingUtil.geocode(routeAndFareDto.getOrigin().getLongitude().toString(), routeAndFareDto.getOrigin().getLatitude().toString());
+        if(null == geocode){
+            throw new ServiceException("获取城市信息失败", I18nKeyConstant.CITY_NOT_FOUND);
         }
-        String cityCode = xpOpenCity.getCityCode();
-
+        String cityCode = geocode.get("cityCode");
+        XpOpenCity xpOpenCity = xpOpenCityMapper.selectOne(new LambdaQueryWrapper<XpOpenCity>().eq(XpOpenCity::getCityCode, cityCode));
+        if (xpOpenCity == null) {
+            throw new ServiceException("获取城市信息失败", I18nKeyConstant.CITY_NOT_FOUND);
+        }
+        routeAndFareDto.setOpenCityId(xpOpenCity.getId());
         XpRoutePlan xpRoutePlan = xpRoutePlanMapper.selectOne(new LambdaQueryWrapper<XpRoutePlan>().eq(XpRoutePlan::getAuditStatus, 2).eq(XpRoutePlan::getCityCode, cityCode));
         if (xpRoutePlan != null) {
             routeAndFareDto.setRoutePlanRule(xpRoutePlan.getRoutePlanRule());
@@ -208,7 +214,7 @@
 //        // 算距离
         R<RouteVo> distanceAndDuration = xpMapClient.getDistanceAndDuration(routeAndFareDto);
         if (distanceAndDuration.getCode() != 200) {
-            throw new ServiceException("未找到路径", I18nKeyConstant.PATH_NOT_FOUND);
+            throw new ServiceException("获取导肮信息失败", I18nKeyConstant.PATH_NOT_FOUND);
         }
 
 
diff --git a/xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/utils/map/GDMapGeocodingUtil.java b/xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/utils/map/GDMapGeocodingUtil.java
new file mode 100644
index 0000000..d982fe6
--- /dev/null
+++ b/xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/utils/map/GDMapGeocodingUtil.java
@@ -0,0 +1,56 @@
+package com.xiaopeng.itinerary.utils.map;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.xiaopeng.common.core.utils.HttpUtils;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 高德地图的地理编码工具类
+ */
+@Component
+@Lazy
+public class GDMapGeocodingUtil {
+
+    private String key = "66ae577f63898dae3016d599fda57221";
+
+
+
+
+
+    /**
+     * 根据经纬度获取行政区域信息
+     * @param lon
+     * @param lan
+     * @return
+     * @throws Exception
+     */
+    public Map<String, String> geocode(String lon, String lan) {
+        String url = "https://restapi.amap.com/v3/geocode/regeo?key=" + key + "&location=" + lon + "," + lan;
+        String forObject = HttpUtils.sendGet(url);
+        JSONObject jsonObject = JSON.parseObject(forObject);
+        Map<String, String> map = new HashMap<>();
+        if(jsonObject.getString("status").equals("1")){
+            JSONObject regeocode = jsonObject.getJSONObject("regeocode");
+            JSONObject addressComponent = regeocode.getJSONObject("addressComponent");
+            String address = regeocode.getString("formatted_address");
+            map.put("address", address);
+            String code = addressComponent.getString("adcode");
+            String province = addressComponent.getString("province");
+            String city = addressComponent.getString("city");
+            String district = addressComponent.getString("district");
+            map.put("province", province);
+            map.put("provinceCode", code.substring(0, 2) + "0000");
+            map.put("city", city);
+            map.put("cityCode", code.substring(0, 4) + "00");
+            map.put("district", district);
+            map.put("districtCode", code);
+        }
+        return map;
+    }
+
+}
diff --git a/xp-robotaxi-itinerary-boot/src/main/resources/i18n/messages.properties b/xp-robotaxi-itinerary-boot/src/main/resources/i18n/messages.properties
index 4f9dca3..eada312 100644
--- a/xp-robotaxi-itinerary-boot/src/main/resources/i18n/messages.properties
+++ b/xp-robotaxi-itinerary-boot/src/main/resources/i18n/messages.properties
@@ -1,4 +1,7 @@
 # 中文
-path.not.found=路径不存在
+city.not.found=获取城市信息失败
+no.current.region=当前区域未开通服务
+path.not.found=获取导航信息失败
 to.work=当前的接送点距离过近。建议步行前往
+walking.route.not.found=未找到步行路线
 welcome.message=欢迎来到我们的应用程序!
\ No newline at end of file
diff --git a/xp-robotaxi-itinerary-boot/src/main/resources/i18n/messages_en_US.properties b/xp-robotaxi-itinerary-boot/src/main/resources/i18n/messages_en_US.properties
index beb79cd..c47fa83 100644
--- a/xp-robotaxi-itinerary-boot/src/main/resources/i18n/messages_en_US.properties
+++ b/xp-robotaxi-itinerary-boot/src/main/resources/i18n/messages_en_US.properties
@@ -1,4 +1,7 @@
 # English (US)
-path.not.found=Path does not exist
+city.not.found=city.not.found
+no.current.region=no.current.region
+path.not.found=Failed to obtain navigation information
 to.work=\ The current pick-up and drop-off points are too close to each other. It is recommended to walk there
+walking.route.not.found=walking.route.not.found
 welcome.message=Welcome to our application!
\ No newline at end of file
diff --git a/xp-robotaxi-itinerary-boot/src/main/resources/i18n/messages_zh_CN.properties b/xp-robotaxi-itinerary-boot/src/main/resources/i18n/messages_zh_CN.properties
index 4f9dca3..eada312 100644
--- a/xp-robotaxi-itinerary-boot/src/main/resources/i18n/messages_zh_CN.properties
+++ b/xp-robotaxi-itinerary-boot/src/main/resources/i18n/messages_zh_CN.properties
@@ -1,4 +1,7 @@
 # 中文
-path.not.found=路径不存在
+city.not.found=获取城市信息失败
+no.current.region=当前区域未开通服务
+path.not.found=获取导航信息失败
 to.work=当前的接送点距离过近。建议步行前往
+walking.route.not.found=未找到步行路线
 welcome.message=欢迎来到我们的应用程序!
\ No newline at end of file
diff --git a/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/XpElectronicFenceServiceImpl.java b/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/XpElectronicFenceServiceImpl.java
index 0bcd642..e2b402c 100644
--- a/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/XpElectronicFenceServiceImpl.java
+++ b/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/XpElectronicFenceServiceImpl.java
@@ -25,6 +25,7 @@
 import com.xiaopeng.map.mapper.XpElectronicFenceMapper;
 import com.xiaopeng.map.mapper.XpPointMapper;
 import com.xiaopeng.map.mapper.XpRegionMapper;
+import com.xiaopeng.map.service.XpElectronicFenceAreaService;
 import com.xiaopeng.map.service.XpElectronicFenceService;
 import com.xiaopeng.map.utils.GDMapGeocodingUtil;
 import com.xiaopeng.map.utils.PolygonOverlapService;
@@ -69,6 +70,8 @@
     private XpRegionMapper xpRegionMapper;
     @Autowired
     private GDMapGeocodingUtil gdMapGeocodingUtil;
+    @Resource
+    private XpElectronicFenceAreaService xpElectronicFenceAreaService;
 
     @Override
     public PageInfo<XpElectronicFence> pageList(ElectronicPageListQuery query) {
@@ -389,10 +392,7 @@
 
             this.updateById(xpElectronicFence);
             // 删除旧的区域数据,然后保存新的区域数据
-            xpElectronicFenceAreaMapper.delete(new LambdaQueryWrapper<XpElectronicFenceArea>()
-                    .eq(XpElectronicFenceArea::getElectronicId, dto.getId()));
             mongoTemplate.remove(new Query(Criteria.where("fenceId").is(String.valueOf(dto.getId()))), XpGeoFencingPolygon.class);
-
             if (xpElectronicFence.getStatus() == 2) {
                 // 设置电子围栏ID并保存区域数据
                 for (XpElectronicFenceArea area : updatedElectronicFenceAreas) {
@@ -400,7 +400,11 @@
                     area.setAreaStatus(1);
                     area.setArea(area.getArea());
                     area.setCityCode(dto.getCityCode());
-                    xpElectronicFenceAreaMapper.insert(area);
+                    if(null != area.getId()){
+                        xpElectronicFenceAreaService.updateById(area);
+                    }else{
+                        xpElectronicFenceAreaService.save(area);
+                    }
                 }
             }else{
                 // 设置电子围栏ID并保存区域数据
@@ -409,7 +413,11 @@
                     area.setAreaStatus(2);
                     area.setArea(area.getArea());
                     area.setCityCode(dto.getCityCode());
-                    xpElectronicFenceAreaMapper.insert(area);
+                    if(null != area.getId()){
+                        xpElectronicFenceAreaService.updateById(area);
+                    }else{
+                        xpElectronicFenceAreaService.save(area);
+                    }
                 }
             }
             if (dto.getStatus() == 1 || dto.getStatus() == 2) {

--
Gitblit v1.7.1