From 701c37e4268c075c8b083e173efb46a4db79ad1d Mon Sep 17 00:00:00 2001
From: “mitao” <“2763622819@qq.com”>
Date: 星期一, 16 三月 2026 00:49:01 +0800
Subject: [PATCH] bugfix

---
 xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/XpElectronicFenceServiceImpl.java |   31 ++++++++++++++++++++++++++-----
 1 files changed, 26 insertions(+), 5 deletions(-)

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 c3f4db4..4eb3197 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
@@ -234,7 +234,7 @@
                             existingArea.getFencePoints())) {
                         throw new ServiceException(
                                 "运营区域{}与现有运营区域{}发生重叠",
-                                I18nKeyConstant.EDIT_ELECTRONIC_ERROR,
+                                I18nKeyConstant.AREA_OVERLAP_ERROR,
                                 new Object[]{existingArea.getAreaName(), existingArea.getAreaName()}
                         );
                     }
@@ -732,11 +732,32 @@
             }
         }
 
+        // 围栏改为已停用(3)时:将围栏下启用中点位(operation_status=2)更新为已停用(operation_status=3)
+        if (newFenceStatus != null && newFenceStatus == 3) {
+            XpElectronicFenceArea operationAreaToDisable = xpElectronicFenceAreaService.lambdaQuery()
+                    .eq(XpElectronicFenceArea::getElectronicId, dto.getId())
+                    .eq(XpElectronicFenceArea::getAreaType, 1)
+                    .orderByDesc(XpElectronicFenceArea::getId)
+                    .last("limit 1")
+                    .one();
+            if (operationAreaToDisable == null || operationAreaToDisable.getId() == null) {
+                log.warn("围栏停用同步停用点位跳过:未查询到运营区 fenceId={}", dto.getId());
+            } else {
+                Long operationAreaIdToDisable = operationAreaToDisable.getId();
+                boolean updated = xpPointService.lambdaUpdate()
+                        .eq(XpPoint::getElectronicAreaId, operationAreaIdToDisable)
+                        .eq(XpPoint::getPointType, 1)
+                        .eq(XpPoint::getOperationStatus, 2)
+                        .set(XpPoint::getOperationStatus, 3)
+                        .update();
+                log.info("围栏停用同步停用点位完成 fenceId={}, operationAreaId={}, updated={}",
+                        dto.getId(), operationAreaIdToDisable, updated);
+            }
+        }
+
         OperationStrategyIndex oldIndex = OperationStrategyIndex.parse(oldOperationStrategy);
         OperationStrategyIndex newIndex = OperationStrategyIndex.parse(newOperationStrategy);
-        // boolean needAutoDisableByUnion = !oldIndex.equalsNormalized(newIndex) && oldIndex.hasAnyShrinkComparedTo(newIndex);
-        boolean needAutoDisableByUnion = true;
-
+        boolean needAutoDisableByUnion = !oldIndex.equalsNormalized(newIndex);
         List<Long> addPointIds = normalizePointIds(dto.getAddPointIdList());
         List<Long> delPointIds = normalizePointIds(dto.getDelPointIdList());
         List<Long> disablePointIds = normalizePointIds(dto.getDisablePointIdList());
@@ -787,7 +808,7 @@
         }
 
         // 围栏运营时间缩短校验:若缩短后点位时间段不在新范围内,则更新为已停用(operation_status=3)
-        if (operationAreaId != null) {
+        if (needAutoDisableByUnion && operationAreaId != null) {
             LambdaQueryWrapper<XpPoint> pointQuery = new LambdaQueryWrapper<>();
             pointQuery.eq(XpPoint::getElectronicAreaId, operationAreaId)
                     .eq(XpPoint::getPointType, 1)

--
Gitblit v1.7.1