From c880977abc130e6820212f66af41033b67b65b14 Mon Sep 17 00:00:00 2001
From: “mitao” <“2763622819@qq.com”>
Date: 星期六, 14 三月 2026 18:01:25 +0800
Subject: [PATCH] bugfix
---
xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/controller/XpElectronicFenceManagementController.java | 75 +++++++++++++++++++++++++++++++++++++
1 files changed, 74 insertions(+), 1 deletions(-)
diff --git a/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/controller/XpElectronicFenceManagementController.java b/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/controller/XpElectronicFenceManagementController.java
index 208c58c..5a9fa6d 100644
--- a/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/controller/XpElectronicFenceManagementController.java
+++ b/xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/controller/XpElectronicFenceManagementController.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xiaopeng.api.dto.operation.ElectronicFenceAddDto;
import com.xiaopeng.api.dto.operation.ElectronicFenceAreaUpdateStatusDto;
+import com.xiaopeng.api.dto.operation.ElectronicFenceOperationStrategyValidateDto;
import com.xiaopeng.api.dto.operation.ElectronicFenceUpdateDto;
import com.xiaopeng.api.feignClient.operation.XpElectronicClient;
import com.xiaopeng.api.model.operation.XpElectronicFence;
@@ -21,7 +22,9 @@
import com.xiaopeng.map.constant.I18nKeyConstant;
import com.xiaopeng.map.service.XpElectronicFenceAreaService;
import com.xiaopeng.map.service.XpElectronicFenceService;
+import com.xiaopeng.map.service.XpPointService;
import com.xiaopeng.map.service.XpRegionService;
+import com.xiaopeng.map.utils.OperationStrategyIndex;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@@ -34,10 +37,12 @@
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
+import javax.validation.Valid;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
import static com.xiaopeng.map.service.serviceimpl.XpElectronicFenceServiceImpl.getPinyinInitials;
@@ -66,6 +71,9 @@
private XpRegionService regionService;
@Autowired
private XpRegionService xpRegionService;
+
+ @Autowired
+ private XpPointService xpPointService;
/**
* 查询省市管理
*/
@@ -146,11 +154,76 @@
*/
@PostMapping("/edit")
@ApiOperation(value = "编辑电子围栏")
+ @Transactional
+ @ShardingSphereTransactionType(TransactionType.BASE)
public R edit(@Validated @RequestBody ElectronicFenceUpdateDto dto) {
return xpElectronicFenceService.editElectronic(dto);
}
/**
+ * 校验编辑围栏时运营时间段缩短影响的点位数量
+ * <p>
+ * 统计:围栏下 operation_type=2(自定义运营时间段) 的点位中,
+ * 当围栏运营时间范围发生缩短时,不在新运营时间范围(Union)内的点位数量(需要停用)。
+ * </p>
+ */
+ @PostMapping("/validateOperationStrategyShorten")
+ @ApiOperation(value = "校验围栏运营时间段缩短影响点位数量")
+ public R<Integer> validateOperationStrategyShorten(@Valid @RequestBody ElectronicFenceOperationStrategyValidateDto dto) {
+ XpElectronicFence fence = xpElectronicFenceService.getById(dto.getId());
+ if (fence == null) {
+ throw new ServiceException("围栏不存在", I18nKeyConstant.FENCE_NOT_EXIST);
+ }
+
+ OperationStrategyIndex oldIndex = OperationStrategyIndex.parse(fence.getOperationStrategy());
+ OperationStrategyIndex newIndex = OperationStrategyIndex.parse(dto.getOperationStrategy());
+ if (oldIndex.equalsNormalized(newIndex)) {
+ return R.ok(0);
+ }
+ if (!oldIndex.hasAnyShrinkComparedTo(newIndex)) {
+ return R.ok(0);
+ }
+
+ List<Long> fenceAreaIds = xpElectronicFenceAreaService.lambdaQuery()
+ .eq(XpElectronicFenceArea::getElectronicId, dto.getId())
+ .list()
+ .stream()
+ .map(XpElectronicFenceArea::getId)
+ .filter(Objects::nonNull)
+ .distinct()
+ .collect(Collectors.toList());
+ if (CollUtil.isEmpty(fenceAreaIds)) {
+ return R.ok(0);
+ }
+
+ List<XpPoint> customPoints = xpPointService.lambdaQuery()
+ .in(XpPoint::getElectronicAreaId, fenceAreaIds)
+ .eq(XpPoint::getPointType, 1)
+ .eq(XpPoint::getOperationType, 2)
+ .list();
+ if (CollUtil.isEmpty(customPoints)) {
+ return R.ok(0);
+ }
+
+ int disableCount = 0;
+ for (XpPoint point : customPoints) {
+ if (point == null || point.getEffectiveTimePeriod() == null || point.getEffectiveTimePeriod().isEmpty()) {
+ continue;
+ }
+ List<OperationStrategyIndex.TimeInterval> pointIntervals = OperationStrategyIndex.parsePointEffectiveTimePeriod(point.getEffectiveTimePeriod());
+ if (pointIntervals.isEmpty()) {
+ continue;
+ }
+
+ boolean shouldDisable = !newIndex.isPointScheduleWithin(pointIntervals);
+ if (shouldDisable) {
+ disableCount++;
+ }
+ }
+ return R.ok(disableCount);
+ }
+
+ /**
* 复制电子围栏
*/
@PostMapping("/copy")
--
Gitblit v1.7.1