| | |
| | | if (list.isEmpty()) { |
| | | return new PageInfo<>(); |
| | | } |
| | | // List<Long> electronicIds = list.stream().map(XpElectronicFence::getId).collect(Collectors.toList()); |
| | | // Map<Long, List<XpElectronicFenceArea>> electronicFenceAreaMap = xpElectronicFenceAreaMapper.selectList(new LambdaQueryWrapper<XpElectronicFenceArea>() |
| | | // .in(XpElectronicFenceArea::getElectronicId, electronicIds)).stream() |
| | | // .collect(Collectors.groupingBy(XpElectronicFenceArea::getElectronicId)); |
| | | for (XpStation bean : list) { |
| | | |
| | | if(bean.getFencePoints() !=null){ |
| | | bean.setPointCount(bean.getFencePoints().split(",").length); //点位总数 |
| | | } |
| | | bean.setOperatingPointCount(0);//运营中点位数 |
| | | |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | |
| | | if (dto.getElectronicAreaId() == null) { |
| | | throw new ServiceException("运营区域ID不能为空"); |
| | | } |
| | | if (dto.getElectronicId() == null) { |
| | | throw new ServiceException("围栏ID不能为空"); |
| | | } |
| | | // if(dto.getXpPointList().isEmpty()){ |
| | | // throw new ServiceException("场站点位不能为空"); |
| | | // if (dto.getElectronicId() == null) { |
| | | // throw new ServiceException("围栏ID不能为空"); |
| | | // } |
| | | |
| | | if(dto.getXpPointList().isEmpty()){ |
| | | throw new ServiceException("场站点位不能为空"); |
| | | } |
| | | for (XpPoint xpPoint : dto.getXpPointList()) { |
| | | if(StrUtil.isBlank(xpPoint.getPointName()) ){ |
| | | throw new ServiceException("点位名称不能为空"); |
| | | if(xpPoint.getId() == null ){ |
| | | throw new ServiceException("点位id不能为空"); |
| | | } |
| | | if(StrUtil.isBlank(xpPoint.getPointPoi()) ){ |
| | | throw new ServiceException("点位poi不能为空"); |
| | | XpPoint point = xpPointService.getById(xpPoint.getId()); |
| | | if(point == null){ |
| | | throw new ServiceException(xpPoint.getId()+"点位不存在"); |
| | | } |
| | | if(StrUtil.isBlank(xpPoint.getPointAddress())){ |
| | | throw new ServiceException("点位地址不能为空"); |
| | | } |
| | | if(xpPoint.getPointLon() == null || xpPoint.getPointLat() == null){ |
| | | throw new ServiceException("点位经纬度不能为空"); |
| | | } |
| | | xpPoint.setPointLon(point.getPointLon()); |
| | | xpPoint.setPointLat(point.getPointLat()); |
| | | } |
| | | |
| | | if (dto.getEffectTime().isBefore(LocalDateTime.now())) { |
| | | throw new ServiceException("计划生效时间不能小于当前时间"); |
| | | } |
| | | XpElectronicFence electronicFence = xpElectronicFenceService.getById(dto.getElectronicId()); |
| | | if(electronicFence == null){ |
| | | throw new ServiceException("场站id错误"); |
| | | } |
| | | // if (dto.getEffectTime().isBefore(LocalDateTime.now())) { |
| | | // throw new ServiceException("计划生效时间不能小于当前时间"); |
| | | // } |
| | | XpElectronicFenceArea electronicFenceArea = xpElectronicFenceAreaService.getById(dto.getElectronicAreaId()); |
| | | if(electronicFenceArea == null){ |
| | | throw new ServiceException("所属运营区id错误"); |
| | | } |
| | | |
| | | dto.setElectronicId(electronicFenceArea.getElectronicId()); |
| | | XpElectronicFence electronicFence = xpElectronicFenceService.getById(electronicFenceArea.getElectronicId()); |
| | | dto.setCityCode(electronicFence.getCityCode()); |
| | | |
| | | double[] centerPoints = calculateCenterPoint(dto.getFencePoints());//场站中心点位 |
| | | dto.setCenterLon(centerPoints[0]); |
| | | dto.setCenterLat(centerPoints[1]); |
| | | //判断场站是否在 围栏里 |
| | | boolean polygonInPolygon = isPolygonInPolygon(electronicFenceArea.getFencePoints(), dto.getFencePoints()); |
| | | boolean polygonInPolygon = isPolygonInPolygon( dto.getFencePoints(),electronicFenceArea.getFencePoints()); |
| | | if(!polygonInPolygon){ |
| | | throw new ServiceException("场站不在 "+electronicFence.getElectronicName()+"围栏内"); |
| | | throw new ServiceException("场站不在"+electronicFence.getElectronicName()+"围栏内"); |
| | | |
| | | } |
| | | //判断点位是否在 场站里 |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | //获取现有的场站区域 |
| | | List<XpStation> listAll = findList(); |
| | | // 检查新区域与现有运营区域是否有重叠 |
| | | for (XpStation existingArea : listAll) { |
| | | if (polygonOverlapService.checkPolygonOverlap(dto.getFencePoints(),existingArea.getFencePoints())) { |
| | | throw new ServiceException("场站区域{}与现有场站区域{}发生重叠",I18nKeyConstant.EDIT_ELECTRONIC_ERROR, |
| | | new Object[]{dto.getStationName(), existingArea.getStationName()} |
| | | ); |
| | | if(dto.getId() != null){ |
| | | if(!dto.getId().equals(existingArea.getId())){ |
| | | if (polygonOverlapService.checkPolygonOverlap(dto.getFencePoints(),existingArea.getFencePoints())) { |
| | | throw new ServiceException("场站区域{}与现有场站区域{}发生重叠",I18nKeyConstant.EDIT_STATION_ERROR, |
| | | new Object[]{dto.getStationName(), existingArea.getStationName()} |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | String name = xpRegion.getName(); |
| | | dto.setCityName(name); |
| | | |
| | | dto.setStatus(0); //status = 场站状态 0=草稿 1=待测试 2=测试中 3=测试不通过 4=可运营 5=待生效 6=启用中 7=已停用 8=失效 |
| | | this.save(dto); |
| | | |
| | | //场站编号唯一 规则:城市首字母-HUB-4位流水号 |
| | |
| | | for (XpPoint xpPoint : dto.getXpPointList()) { |
| | | xpPoint.setStationSortNo(stationSortNo++); |
| | | xpPoint.setStationId(dto.getId()); |
| | | if(dto.getStatus() == 2){//场站状态 0=草稿 1=待启用 2=启用中 3=已停用 4=失效 |
| | | //运营状态 1=待启用 2=启用中 3=已停用 4=已失效 |
| | | xpPoint.setOperationStatus(2); |
| | | } |
| | | |
| | | if(xpPoint.getId() == null){ |
| | | xpPointService.getPointNumber(dto.getElectronicAreaId()); |
| | | xpPoint.setFpElectronicAreaId(dto.getElectronicAreaId()); |