| | |
| | | package com.xiaopeng.map.service.serviceimpl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.api.model.map.XpGeoFencingPolygon; |
| | | import com.xiaopeng.api.model.operation.*; |
| | | import com.xiaopeng.api.query.operation.PointListQuery; |
| | | import com.xiaopeng.api.query.operation.PointPageListListQuery; |
| | | import com.xiaopeng.api.query.operation.XpStationQuery; |
| | | import com.xiaopeng.api.vo.account.LoginUser; |
| | |
| | | @Resource |
| | | private BootCommonService bootCommonService; |
| | | |
| | | @Override |
| | | public List<XpStation> findListByElectronicId(Long electronicId) { |
| | | |
| | | LambdaQueryWrapper<XpStation> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(XpStation::getElectronicId, electronicId); |
| | | queryWrapper.eq(XpStation::getOperationType, 2); |
| | | queryWrapper.eq(XpStation::getDeleted, 0); |
| | | return super.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<XpStation> findList(XpStationQuery query) { |
| | |
| | | if(dto.getXpPointList().isEmpty()){ |
| | | throw new ServiceException("场站点位不能为空"); |
| | | } |
| | | //场站名字唯一 |
| | | // 场站名字唯一校验:新增时直接判断,编辑时需排除当前ID |
| | | LambdaQueryWrapper<XpStation> nameQueryWrapper = new LambdaQueryWrapper<>(); |
| | | nameQueryWrapper.eq(XpStation::getStationName, dto.getStationName()); |
| | | // 如果是编辑操作,需要排除当前记录 |
| | | if (dto.getId() != null) { |
| | | nameQueryWrapper.ne(XpStation::getId, dto.getId()); |
| | | } |
| | | long count = this.count(nameQueryWrapper); |
| | | if (count > 0) { |
| | | throw new ServiceException("场站名称已存在"); |
| | | } |
| | | |
| | | for (XpPoint xpPoint : dto.getXpPointList()) { |
| | | if(xpPoint.getId() == null ){ |
| | | throw new ServiceException("点位id不能为空"); |
| | |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if(dto.getEffectivePeriod() == null){ |
| | | dto.setEffectivePeriod(1); |
| | | } |
| | | //场站的自定义时间必须在 围栏运营时间内 |
| | | if(dto.getOperationType() == 2){ |
| | | // ["06:00-12:00", "13:00-21:00"] |
| | | if(StrUtil.isBlank(dto.getEffectiveTimePeriod())){ |
| | | throw new ServiceException("自定义时间段不能为空"); |
| | | } |
| | | boolean stationTimeFenceOperationStrategy = bootCommonService.getStationTime_fenceOperationStrategy(dto.getEffectivePeriod(), dto.getEffectiveTimePeriod(), electronicFence.getOperationStrategy()); |
| | | if(!stationTimeFenceOperationStrategy){ |
| | | throw new ServiceException("自定义时间必须在围栏运营时间内"); |
| | | } |
| | | } |
| | | |
| | |
| | | if(dto.getStatus() == 2){//场站状态 0=草稿 1=待启用 2=启用中 3=已停用 4=失效 |
| | | //运营状态 1=待启用 2=启用中 3=已停用 4=已失效 |
| | | xpPoint.setOperationStatus(2); |
| | | xpPoint.setVerificationStatus(5); |
| | | }else if(dto.getStatus() == 3){ |
| | | xpPoint.setOperationStatus(3); |
| | | } |