From df851ece762f3e4b5867f2de83e655dfd5506e04 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期六, 14 二月 2026 16:10:42 +0800
Subject: [PATCH] 点位修改

---
 xp-robotaxi-operation-boot/src/main/resources/i18n/messages.properties                                 |    1 
 xp-robotaxi-api/src/main/java/com/xiaopeng/api/vo/order/XpPointsListVo.java                            |    9 ++++
 xp-robotaxi-operation-boot/src/main/resources/i18n/messages_zh_CN.properties                           |    1 
 xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/XpPointService.java            |    9 ++++
 xp-robotaxi-operation-boot/src/main/resources/mapper/operation/XpPointMapper.xml                       |    2 
 xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpPointServiceImpl.java   |   34 ++++++++++------
 xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpPricingServiceImpl.java |   26 ++++++++++--
 xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/constant/I18nKeyConstant.java          |    3 +
 xp-robotaxi-operation-boot/src/main/resources/i18n/messages_en_US.properties                           |    1 
 9 files changed, 67 insertions(+), 19 deletions(-)

diff --git a/xp-robotaxi-api/src/main/java/com/xiaopeng/api/vo/order/XpPointsListVo.java b/xp-robotaxi-api/src/main/java/com/xiaopeng/api/vo/order/XpPointsListVo.java
index ce5b6b3..dd3ed08 100644
--- a/xp-robotaxi-api/src/main/java/com/xiaopeng/api/vo/order/XpPointsListVo.java
+++ b/xp-robotaxi-api/src/main/java/com/xiaopeng/api/vo/order/XpPointsListVo.java
@@ -28,4 +28,13 @@
 
     @ApiModelProperty("电子围栏区域id")
     private Long electronicAreaId;
+
+    private Integer effectivePeriod;
+
+
+    private String effectiveTimePeriod;
+
+    private Integer state=1;
+
+
 }
diff --git a/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/constant/I18nKeyConstant.java b/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/constant/I18nKeyConstant.java
index d2825c6..682a429 100644
--- a/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/constant/I18nKeyConstant.java
+++ b/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/constant/I18nKeyConstant.java
@@ -11,6 +11,9 @@
 
     String NO_CURRENT_REGION = "no.current.region";
 
+
+    String NO_CURRENT_POINT = "no.current.point";
+
     String SYSTEM_EXCEPTION = "system.exception";
 
     String TO_WORK = "to.work";
diff --git a/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/XpPointService.java b/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/XpPointService.java
index 1a61de9..dc3f3df 100644
--- a/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/XpPointService.java
+++ b/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/XpPointService.java
@@ -18,6 +18,7 @@
 import com.xiaopeng.api.dto.operation.PointMapQuery;
 import com.xiaopeng.operation.vo.OrderDistanceVo;
 
+import java.time.LocalTime;
 import java.util.List;
 
 /**
@@ -35,6 +36,14 @@
      * 获取附近上车站点
      */
     NearestVo nearest(@Valid NearestDto dto);
+
+
+    /**
+     * 判断点位是否时间段内
+     * @param now
+     * @return
+     */
+    boolean getInTime(LocalTime now,  Integer effectivePeriod, String effectiveTimePeriod);
     List<XpPoint> pointMap(PointMapQuery query);
 
     List<XpPoint> listAll(PointPageListQuery query);
diff --git a/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpPointServiceImpl.java b/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpPointServiceImpl.java
index dcb3feb..eb9d86d 100644
--- a/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpPointServiceImpl.java
+++ b/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpPointServiceImpl.java
@@ -76,7 +76,7 @@
 
         for (XpPoint xpPoint : list) {
             // 判断是否在时间段内
-            boolean intime = getInTime(now, xpPoint);
+            boolean intime = getInTime(now, xpPoint.getEffectivePeriod(), xpPoint.getEffectiveTimePeriod());
             if (!intime) {
                 continue;
             }
@@ -108,36 +108,35 @@
 
 
 
-    private boolean getInTime(LocalTime now,XpPoint xpPoint){
+    public boolean getInTime(LocalTime now,  Integer effectivePeriod, String effectiveTimePeriod){
         //  2非工作日  0工作日  1节假日 3调休日
         Integer holidayToday = holidayUtil.isHolidayToday();
-        Integer operationType = xpPoint.getEffectivePeriod();
-        if(operationType==1){
-            boolean inTime = TimeRangeChecker.isCurrentTimeInRanges(now, xpPoint.getEffectiveTimePeriod());
+        if(effectivePeriod==1){
+            boolean inTime = TimeRangeChecker.isCurrentTimeInRanges(now,effectiveTimePeriod);
             if (!inTime) {
                 return false;
             }
-        }else if(operationType==2){
+        }else if(effectivePeriod==2){
             if(holidayToday!=0){
                 return false;
             }
-            boolean inTime = TimeRangeChecker.isCurrentTimeInRanges(now, xpPoint.getEffectiveTimePeriod());
+            boolean inTime = TimeRangeChecker.isCurrentTimeInRanges(now,effectiveTimePeriod);
             if (!inTime) {
                 return false;
             }
-        }else if(operationType==3){
+        }else if(effectivePeriod==3){
             if(holidayToday!=2){
                 return false;
             }
-            boolean inTime = TimeRangeChecker.isCurrentTimeInRanges(now, xpPoint.getEffectiveTimePeriod());
+            boolean inTime = TimeRangeChecker.isCurrentTimeInRanges(now,effectiveTimePeriod);
             if (!inTime) {
                 return false;
             }
-        }else if(operationType==4){
+        }else if(effectivePeriod==4){
             if(holidayToday!=1){
                 return false;
             }
-            boolean inTime = TimeRangeChecker.isCurrentTimeInRanges(now, xpPoint.getEffectiveTimePeriod());
+            boolean inTime = TimeRangeChecker.isCurrentTimeInRanges(now,effectiveTimePeriod);
             if (!inTime) {
                 return false;
             }
@@ -204,9 +203,18 @@
             return searchVo;
         }
 
+        LocalTime now = LocalTime.now();
+        for (XpPointsListVo xpPointsListVo : list) {
+            boolean inTime = getInTime(now, xpPointsListVo.getEffectivePeriod(), xpPointsListVo.getEffectiveTimePeriod());
+            if (!inTime) {
+                // 不在运营段
+                xpPointsListVo.setState(0);
+            }
 
-        // 组装数据 并排序
-        List<XpPointsListVo> resultList = list.stream().peek(vo -> vo.setDistance(FastDistanceCalculator.distanceFast(query.getLat(), query.getLon(), vo.getLatitude(), vo.getLongitude()))).collect(Collectors.toList());
+        }
+
+        // 组装数据 并排序 剔除不在运营段的 数据
+        List<XpPointsListVo> resultList = list.stream().peek(vo -> vo.setDistance(FastDistanceCalculator.distanceFast(query.getLat(), query.getLon(), vo.getLatitude(), vo.getLongitude()))).filter(vo -> vo.getState() == 1).collect(Collectors.toList());
 
         // 可用点位
         List<XpPointsListVo> availablePoints = resultList.stream().filter(e -> query.getElectronicAreaId() != null && e.getElectronicAreaId().equals(query.getElectronicAreaId())).sorted(Comparator.comparing(XpPointsListVo::getDistance)).collect(Collectors.toList());//
diff --git a/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpPricingServiceImpl.java b/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpPricingServiceImpl.java
index f59e5db..062b9fd 100644
--- a/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpPricingServiceImpl.java
+++ b/xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpPricingServiceImpl.java
@@ -36,6 +36,7 @@
 import com.xiaopeng.operation.mapper.*;
 import com.xiaopeng.operation.query.PricingPageListQuery;
 import com.xiaopeng.operation.service.IXpGeoQueryEntityService;
+import com.xiaopeng.operation.service.XpPointService;
 import com.xiaopeng.operation.service.XpPricingService;
 import com.xiaopeng.operation.utils.XpPricingUtil;
 import com.xiaopeng.operation.utils.holiday.HolidayUtil;
@@ -48,6 +49,7 @@
 import javax.annotation.PreDestroy;
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
+import java.time.LocalTime;
 import java.util.*;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -97,9 +99,6 @@
 
 
     @Resource
-    private XpPointMapper xpPointMapper;
-
-    @Resource
     private XpWhitelistMapper xpWhitelistMapper;
 
     @Resource
@@ -113,6 +112,9 @@
 
     @Autowired
     private XpElectronicFenceMapper xpElectronicFenceMapper;
+
+    @Autowired
+    private XpPointService xpPointService;
 
 
     // 自定义线程池用于并行执行任务
@@ -396,6 +398,9 @@
 
     @Override
     public Long saveOrder(XpOrderDto dto, String uid) {
+
+
+
         // 是否在运营区域时间内
         XpElectronicFenceArea xpElectronicFenceArea = xpElectronicFenceAreaMapper.selectById(dto.getXpElectronicFenceAreaId());
         XpElectronicFence xpElectronicFence = xpElectronicFenceMapper.selectById(xpElectronicFenceArea.getElectronicId());
@@ -414,10 +419,21 @@
         }
 
         // 获取起点经纬度
-        XpPoint xpPoint = xpPointMapper.selectById(dto.getStartPointId());
+        XpPoint xpPoint = xpPointService.getById(dto.getStartPointId());
 
         // 终点
-        XpPoint endXpPoint = xpPointMapper.selectById(dto.getStartPointId());
+        XpPoint endXpPoint = xpPointService.getById(dto.getStartPointId());
+
+        // 判断点位是否在运营区域内
+        LocalTime now = LocalTime.now();
+        boolean inTime = xpPointService.getInTime(now, xpPoint.getEffectivePeriod(), xpPoint.getEffectiveTimePeriod());
+        if(!inTime){
+            throw new ServiceException("当前点位未开通服务", I18nKeyConstant.NO_CURRENT_REGION);
+        }
+        inTime = xpPointService.getInTime(now, endXpPoint.getEffectivePeriod(), endXpPoint.getEffectiveTimePeriod());
+        if(!inTime){
+            throw new ServiceException("当前点位未开通服务", I18nKeyConstant.NO_CURRENT_REGION);
+        }
 
         // 判断当天取消的次数 后台配置 redis 查询
         Object cancelOrder = redisService.getCacheObject("CANCEL_ORDER_" + uid);
diff --git a/xp-robotaxi-operation-boot/src/main/resources/i18n/messages.properties b/xp-robotaxi-operation-boot/src/main/resources/i18n/messages.properties
index a183f62..f090fa4 100644
--- a/xp-robotaxi-operation-boot/src/main/resources/i18n/messages.properties
+++ b/xp-robotaxi-operation-boot/src/main/resources/i18n/messages.properties
@@ -17,3 +17,4 @@
 pricing.not.exist=定价不存在
 pricing.json.invalid=价格配置JSON格式不正确
 pricing.rule.empty=价格规则不能为空
+no.current.point=?????????
diff --git a/xp-robotaxi-operation-boot/src/main/resources/i18n/messages_en_US.properties b/xp-robotaxi-operation-boot/src/main/resources/i18n/messages_en_US.properties
index b897962..0831451 100644
--- a/xp-robotaxi-operation-boot/src/main/resources/i18n/messages_en_US.properties
+++ b/xp-robotaxi-operation-boot/src/main/resources/i18n/messages_en_US.properties
@@ -17,3 +17,4 @@
 pricing.not.exist=Pricing does not exist
 pricing.json.invalid=Invalid JSON format for pricing configuration
 pricing.rule.empty=Price rule cannot be empty
+no.current.point=The current location is not open for service
diff --git a/xp-robotaxi-operation-boot/src/main/resources/i18n/messages_zh_CN.properties b/xp-robotaxi-operation-boot/src/main/resources/i18n/messages_zh_CN.properties
index 466b90b..2bf0dbd 100644
--- a/xp-robotaxi-operation-boot/src/main/resources/i18n/messages_zh_CN.properties
+++ b/xp-robotaxi-operation-boot/src/main/resources/i18n/messages_zh_CN.properties
@@ -17,3 +17,4 @@
 pricing.not.exist=定价不存在
 pricing.json.invalid=价格配置JSON格式不正确
 pricing.rule.empty=价格规则不能为空
+no.current.point=?????????
diff --git a/xp-robotaxi-operation-boot/src/main/resources/mapper/operation/XpPointMapper.xml b/xp-robotaxi-operation-boot/src/main/resources/mapper/operation/XpPointMapper.xml
index e890bf4..69f1117 100644
--- a/xp-robotaxi-operation-boot/src/main/resources/mapper/operation/XpPointMapper.xml
+++ b/xp-robotaxi-operation-boot/src/main/resources/mapper/operation/XpPointMapper.xml
@@ -91,7 +91,7 @@
 
 
     <select id="queryPointByName" resultType="com.xiaopeng.api.vo.order.XpPointsListVo">
-        select p.id,p.electronic_area_id as electronicAreaId,p.point_name as name,p.point_address as address,p.point_lon as longitude,p.point_lat as latitude
+        select p.id,p.electronic_area_id as electronicAreaId,p.point_name as name,p.point_address as address,p.point_lon as longitude,p.point_lat as latitude,p.effective_period,p.effective_time_period
         from xp_electronic_fence_area xefa
         left join xp_point p on p.electronic_area_id = xefa.id
         where p.is_deleted = 0 and p.operation_status =2 and xefa.is_deleted = 0

--
Gitblit v1.7.1