From 736c4d730af55904edab3e194fcffd7134eb3f94 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期五, 24 四月 2026 20:21:07 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/Robotaxi

---
 xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/XpPointServiceImpl.java |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/XpPointServiceImpl.java b/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/XpPointServiceImpl.java
index e013adf..a5aa323 100644
--- a/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/XpPointServiceImpl.java
+++ b/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/XpPointServiceImpl.java
@@ -72,6 +72,7 @@
 public class XpPointServiceImpl extends ServiceImpl<XpPointMapper, XpPoint> implements XpPointService {
 
     private static final String POINT_BIZ_TYPE = "PUD";
+    private static final int MAX_POINTS_PER_FENCE = 15;
     private static final int SERIAL_WIDTH = 6;
     private static final int LOCK_WAIT_SECONDS = 5;
     private static final int LOCK_LEASE_SECONDS = 30;
@@ -120,6 +121,7 @@
             if (!locked) {
                 throw new ServiceException("点位编号生成繁忙,请稍后重试", I18nKeyConstant.POINT_NUMBER_LOCK_FAIL);
             }
+            validateFencePointCountLimit(pointAddDto.getElectronicAreaId());
             String maxPointNumber = this.baseMapper.selectMaxPointNumber(cityPrefix, POINT_BIZ_TYPE);
             int nextSerial = 1;
             if (StringUtils.hasText(maxPointNumber)) {
@@ -238,6 +240,36 @@
         return getPinyinInitials(prefix).toUpperCase();
     }
 
+    private void validateFencePointCountLimit(Long electronicAreaId) {
+        if (electronicAreaId == null || electronicAreaId == 0L) {
+            return;
+        }
+        XpElectronicFenceArea currentArea = xpElectronicFenceAreaService.getById(electronicAreaId);
+        if (currentArea == null) {
+            throw new ServiceException("运营区域不存在", I18nKeyConstant.POINT_ELECTRONIC_AREA_NOT_EXIST);
+        }
+        Long fenceId = currentArea.getElectronicId();
+        if (fenceId == null) {
+            throw new ServiceException("运营区域不存在", I18nKeyConstant.POINT_ELECTRONIC_AREA_NOT_EXIST);
+        }
+        List<Long> areaIds = xpElectronicFenceAreaService.lambdaQuery()
+                .eq(XpElectronicFenceArea::getElectronicId, fenceId)
+                .list()
+                .stream()
+                .map(XpElectronicFenceArea::getId)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toList());
+        if (areaIds.isEmpty()) {
+            return;
+        }
+        long pointCount = this.lambdaQuery()
+                .in(XpPoint::getElectronicAreaId, areaIds)
+                .count();
+        if (pointCount >= MAX_POINTS_PER_FENCE) {
+            throw new ServiceException("当前围栏最多只能添加15个点位", I18nKeyConstant.POINT_FENCE_POINT_LIMIT_EXCEEDED);
+        }
+    }
+
     private static String buildPointNumberLockKey(String cityPrefix, String bizType) {
         return "xp:point:number:" + cityPrefix + ":" + bizType;
     }

--
Gitblit v1.7.1