| | |
| | | private final VinSaltProperties vinSaltProperties; |
| | | |
| | | @Override |
| | | public String uploadOddLayerFile(List<AreaInput> areas, String vin) { |
| | | public String uploadOddLayerFile(List<AreaInput> areas, String vin, long version) { |
| | | log.info("[ADC-OSS] uploadOddLayerFile 开始, vin={}, version={}, areasCount={}", vin, version, areas == null ? 0 : areas.size()); |
| | | if (areas != null) { |
| | | for (int i = 0; i < areas.size(); i++) { |
| | | AreaInput a = areas.get(i); |
| | | log.info("[ADC-OSS] area[{}]: areaId={}, isBlacklist={}, pointsCount={}", |
| | | i, a.getAreaId(), a.isBlacklist(), a.getPoints() == null ? 0 : a.getPoints().size()); |
| | | } |
| | | } |
| | | validateParams(areas, vin); |
| | | |
| | | String vehicleUuid = VehicleCodec.vinToUUID(vin, vinSaltProperties.getSalt1(), vinSaltProperties.getSalt2()); |
| | | log.info("[ADC-OSS] VIN={} -> UUID={}", vin, vehicleUuid); |
| | | |
| | | byte[] fbsBytes = XngpAreaRTreeFbsUtil.buildRTreeBytesFromMultiAreas(areas); |
| | | if (fbsBytes == null || fbsBytes.length == 0) { |
| | | log.info("[ADC-OSS] buildRTreeBytesFromMultiAreas 返回空, vin={}", vin); |
| | | throw new IllegalStateException("Failed to build RTree fbs from areas"); |
| | | } |
| | | log.info("[ADC-OSS] FBS构建成功, vin={}, fbsSize={}bytes", vin, fbsBytes.length); |
| | | |
| | | int version = (int) (System.currentTimeMillis() / 1000); |
| | | String binFileName = version + "_xngp_area_data.bin"; |
| | | |
| | | String objectKey = robotaxiOssService.uploadOddLayerFile(fbsBytes, binFileName, vehicleUuid); |
| | | log.info("[ADC-OSS] bin文件上传成功, vin={}, objectKey={}", vin, objectKey); |
| | | |
| | | byte[] pbBytes = MapAreaVersionProtoWriter.toByteArray(version, fbsBytes.length); |
| | | byte[] pbBytes = MapAreaVersionProtoWriter.toByteArray((int) version, fbsBytes.length); |
| | | robotaxiOssService.uploadOddLayerFile(pbBytes, "xngp_area_version.pb", vehicleUuid); |
| | | log.info("[ADC-OSS] pb版本文件上传成功, vin={}, version={}", vin, version); |
| | | |
| | | log.debug("AdcOssHandle uploaded ODD layer file, areasCount={}, objectKey={}", areas.size(), objectKey); |
| | | return objectKey; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> deleteOddLayerFiles(String vin) { |
| | | public String uploadEmptyFence(String vin, long version) { |
| | | log.info("[ADC-OSS] uploadEmptyFence 开始, vin={}, version={}", vin, version); |
| | | if (!StringUtils.hasText(vin)) { |
| | | throw new IllegalArgumentException("vin cannot be empty"); |
| | | } |
| | | |
| | | String vehicleUuid = VehicleCodec.vinToUUID(vin, vinSaltProperties.getSalt1(), vinSaltProperties.getSalt2()); |
| | | List<String> deleted = robotaxiOssService.deleteOddLayerFilesByPrefix(vehicleUuid); |
| | | log.debug("AdcOssHandle deleted ODD layer files, vin={}, count={}", vin, deleted.size()); |
| | | return deleted; |
| | | log.info("[ADC-OSS] VIN={} -> UUID={}", vin, vehicleUuid); |
| | | |
| | | byte[] fbsBytes = XngpAreaRTreeFbsUtil.buildEmptyRTreeBytes(); |
| | | if (fbsBytes == null || fbsBytes.length == 0) { |
| | | log.info("[ADC-OSS] buildEmptyRTreeBytes 返回空, vin={}", vin); |
| | | throw new IllegalStateException("Failed to build empty RTree fbs"); |
| | | } |
| | | log.info("[ADC-OSS] 空FBS构建成功, vin={}, fbsSize={}bytes", vin, fbsBytes.length); |
| | | |
| | | String binFileName = version + "_xngp_area_data.bin"; |
| | | String objectKey = robotaxiOssService.uploadOddLayerFile(fbsBytes, binFileName, vehicleUuid); |
| | | log.info("[ADC-OSS] 空FBS bin文件上传成功, vin={}, objectKey={}", vin, objectKey); |
| | | |
| | | byte[] pbBytes = MapAreaVersionProtoWriter.toByteArray((int) version, fbsBytes.length); |
| | | robotaxiOssService.uploadOddLayerFile(pbBytes, "xngp_area_version.pb", vehicleUuid); |
| | | log.info("[ADC-OSS] 空FBS pb版本文件上传成功, vin={}, version={}", vin, version); |
| | | |
| | | return objectKey; |
| | | } |
| | | |
| | | private void validateParams(List<AreaInput> areas, String vin) { |
| | | if (CollectionUtils.isEmpty(areas)) { |
| | | log.info("[ADC-OSS] validateParams失败: areas为空, vin={}", vin); |
| | | throw new IllegalArgumentException("areas cannot be empty"); |
| | | } |
| | | for (AreaInput area : areas) { |
| | | for (int i = 0; i < areas.size(); i++) { |
| | | AreaInput area = areas.get(i); |
| | | if (CollectionUtils.isEmpty(area.getPoints())) { |
| | | throw new IllegalArgumentException("each area must have non-empty points"); |
| | | log.info("[ADC-OSS] validateParams失败: area[{}] areaId={} points为空, vin={}", i, area.getAreaId(), vin); |
| | | throw new IllegalArgumentException("each area must have non-empty points, areaId=" + area.getAreaId()); |
| | | } |
| | | } |
| | | if (!StringUtils.hasText(vin)) { |
| | | log.info("[ADC-OSS] validateParams失败: vin为空"); |
| | | throw new IllegalArgumentException("vin cannot be empty"); |
| | | } |
| | | } |