puzhibing
2026-04-21 67a1b3997ff33f286a2e91bce3f876c7a301b981
xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/XpPointServiceImpl.java
@@ -130,9 +130,19 @@
        }
        validatePointNameUnique(pointAddDto.getPointName(), null);
        String cityPrefix = buildCityPrefix(pointAddDto.getElectronicAreaId());
        String lockKey = buildPointNumberLockKey(cityPrefix, POINT_BIZ_TYPE);
        String pointNumber = getPointNumber(pointAddDto.getElectronicAreaId());
        XpPoint xpPoint = new XpPoint();
        BeanUtils.copyProperties(pointAddDto, xpPoint);
        xpPoint.setFpElectronicAreaId(pointAddDto.getElectronicAreaId());
        xpPoint.setPointNumber(pointNumber);
        this.save(xpPoint);
        return xpPoint;
    }
    @Override
    public String getPointNumber(Long electronicAreaId) {
        String cityPrefix = buildCityPrefix(electronicAreaId);
        String lockKey = buildPointNumberLockKey(cityPrefix, POINT_BIZ_TYPE);
        RLock lock = redissonClient.getLock(lockKey);
        boolean locked = false;
        String pointNumber;
@@ -159,13 +169,7 @@
                log.warn("释放点位编号生成锁失败 lockKey={}", lockKey, e);
            }
        }
        XpPoint xpPoint = new XpPoint();
        BeanUtils.copyProperties(pointAddDto, xpPoint);
        xpPoint.setFpElectronicAreaId(pointAddDto.getElectronicAreaId());
        xpPoint.setPointNumber(pointNumber);
        this.save(xpPoint);
        return xpPoint;
        return pointNumber;
    }
    @Override
@@ -674,6 +678,29 @@
            return Collections.emptySet();
        }
    }
    @Override
    public List<XpPoint> listByStationId(Long stationId) {
        if (stationId == null) {
            return Collections.emptyList();
        }
        return this.lambdaQuery()
                .eq(XpPoint::getStationId, stationId)
                .list();
    }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void clearStationInfoByStationId(Long stationId) {
        if (stationId == null) {
            return;
        }
        this.lambdaUpdate()
                .eq(XpPoint::getStationId, stationId)
                .set(XpPoint::getStationId, null)
                .set(XpPoint::getStationSortNo, null)
                .update();
    }
    /**
     * 查询用户收藏的点位ID。
@@ -695,4 +722,52 @@
        }
    }
    /**
     * 场站停用
     *     -  操作项展示为 [停用]。点击后弹出二次确认框,“当前场站包含12个点位,确认一起停用?
     *       - 是:确认后场站以及子点位状态流转至“已停用”。
     *       - 否:子点位维持当前状态,但自动退回为“独立点位”。
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void statusStopByStationId(Long stationId, Boolean pointStop) {
        if (stationId == null) {
            return;
        }
        if(pointStop){
            this.lambdaUpdate()
                    .eq(XpPoint::getStationId, stationId)
                    .set(XpPoint::getOperationStatus, 3)//运营状态 1=待启用 2=启用中 3=已停用 4=已失效
                    .update();
        }else{
            clearStationInfoByStationId(stationId);
        }
    }
    /**
     * 场站删除
     *       - 删除拦截逻辑:
     *         - 测试阶段(待测试、测试中等):点击直接删除。
     *         - 历史运营阶段(已停用、失效):点击弹出二次确认框“当前场站包含12个点位,确认一起删除?”
     *           - 是:点位统一一起删除
     *           - 否:不自动删除点位,点位自动退回为[待测试]的“独立点位”,并自动继承父级运营区的运营时段
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void pointDeleteByStationId(Long stationId, Boolean pointDelete) {
        if (stationId == null) {
            return;
        }
        if(pointDelete){
            this.lambdaUpdate()
                    .eq(XpPoint::getStationId, stationId)
                    .set(XpPoint::getDeleted, 1)
                    .update();
        }else{
            clearStationInfoByStationId(stationId);
        }
    }
}