| | |
| | | import com.dji.sample.manage.service.IDeviceDictionaryService; |
| | | import com.dji.sample.media.dao.IFileMapper; |
| | | import com.dji.sample.media.dao.IMarkMapper; |
| | | import com.dji.sample.media.dao.INailMapper; |
| | | import com.dji.sample.media.model.*; |
| | | import com.dji.sample.media.service.IFileService; |
| | | import com.dji.sample.media.util.ImgUtil; |
| | |
| | | import com.dji.sample.patches.utils.TimerUtil; |
| | | import com.dji.sample.territory.pojo.TerritoryConfigPojo; |
| | | import com.dji.sample.territory.service.impl.TbFjServiceImpl; |
| | | import com.dji.sample.territory.utils.ImgZipUtil; |
| | | import com.dji.sample.territory.utils.WaterMarkUtil; |
| | | import com.dji.sample.wayline.service.IWaylineFileService; |
| | | import com.dji.sample.wayline.service.IWaylineJobService; |
| | |
| | | @Autowired |
| | | private IMarkMapper markMapper; |
| | | @Autowired |
| | | private INailMapper nailMapper; |
| | | @Autowired |
| | | private GetPatchesMapper patchesMapper; |
| | | @Autowired |
| | | private IDeviceDictionaryService deviceDictionaryService; |
| | |
| | | private IWaylineJobService waylineJobService; |
| | | @Autowired |
| | | private IWaylineFileService waylineFileService; |
| | | @Autowired |
| | | private MinioPojo pojo; |
| | | |
| | | private ObjectMapper objectMapper = new ObjectMapper(); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer saveFile(String workspaceId, FileUploadDTO file) { |
| | | public Integer saveFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException { |
| | | MediaFileEntity fileEntity = this.fileUploadConvertToEntity(file); |
| | | fileEntity.setWorkspaceId(workspaceId); |
| | | fileEntity.setFileId(UUID.randomUUID().toString()); |
| | | String url = pojo.getEndpoint() + "/" + pojo.getBucket() + file.getObjectKey(); |
| | | File file1 = TbFjServiceImpl.downloadFile(url); |
| | | Object data = ImgUtil.getInfo(file1); |
| | | fileEntity.setDroneData(data); |
| | | return mapper.insert(fileEntity); |
| | | } |
| | | |
| | | public void saveMarkFile(String workspaceId, FileUploadDTO file) throws IOException, FontFormatException, ImageProcessingException { |
| | | public void saveMarkFile(String workspaceId, FileUploadDTO file) throws IOException { |
| | | boolean endsWith = file.getObjectKey().endsWith(".mp4"); |
| | | if (endsWith) { |
| | | MediaFileMarkEntity mediaFileMarkEntity = this.fileUploadConvertToMarkEntity(file); |
| | | mediaFileMarkEntity.setWorkspaceId(workspaceId); |
| | | mediaFileMarkEntity.setFileId(UUID.randomUUID().toString()); |
| | | markMapper.insert(mediaFileMarkEntity); |
| | | MediaFileNailEntity nailEntity = this.fileUploadConvertToNailEntity((file)); |
| | | nailEntity.setWorkspaceId(workspaceId); |
| | | nailEntity.setFileId(UUID.randomUUID().toString()); |
| | | nailMapper.insert(nailEntity); |
| | | } else { |
| | | boolean contains = file.getName().contains("~"); |
| | | if (contains) { |
| | | String name = TimerUtil.getDkbh(file.getName()); |
| | | List<LotInfo> lotInfos = patchesMapper.selectList(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, name)); |
| | | if (!lotInfos.isEmpty()) { |
| | | LambdaUpdateWrapper<LotInfo> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(LotInfo::getDkbh, name) |
| | | .eq(LotInfo::getInvestigate, 0) |
| | | .set(LotInfo::getInvestigate, 1); |
| | | patchesMapper.update(null, updateWrapper); |
| | | } |
| | | } |
| | | MediaFileMarkEntity mediaFileMarkEntity = this.fileUploadConvertToMarkEntity(file); |
| | | String url = "http://dev.jxpskj.com:9000/cloud-bucket" + file.getObjectKey(); |
| | | String endpoint = pojo.getEndpoint(); |
| | | String accessKey = pojo.getAccessKey(); |
| | | String secretKey = pojo.getSecretKey(); |
| | | String bucketName = pojo.getBucket(); |
| | | String url = pojo.getEndpoint() + "/" + pojo.getBucket() + file.getObjectKey(); |
| | | File file1 = TbFjServiceImpl.downloadFile(url); |
| | | long timestamp = convertToTimestamp(file.getMetadata().getCreatedTime()); |
| | | File file2 = new File(WaterMarkUtil.addWatermark(file1, timestamp, file.getMetadata().getShootPosition().getLat(), |
| | | file.getMetadata().getShootPosition().getLng(), file.getMetadata().getGimbalYawDegree()).toURI()); |
| | | Object data = ImgUtil.getInfo(file1); |
| | | mediaFileMarkEntity.setDronedata(data); |
| | | mediaFileMarkEntity.setWorkspaceId(workspaceId); |
| | | mediaFileMarkEntity.setIsadd(0); |
| | | mediaFileMarkEntity.setFileId(UUID.randomUUID().toString()); |
| | | mediaFileMarkEntity.setObjectKey("/mark" + file.getPath() + "/" + file.getName()); |
| | | mediaFileMarkEntity.setFileName("mark" + file.getName()); |
| | | mediaFileMarkEntity.setFilePath("mark" + file.getPath()); |
| | | String endpoint = "http://dev.jxpskj.com:9000"; |
| | | String accessKey = "pskj"; |
| | | String secretKey = "pskj@2021"; |
| | | String bucketName = "cloud-bucket"; |
| | | String objectName = mediaFileMarkEntity.getObjectKey(); // 例如 "folder/file.txt" |
| | | uploadFile(endpoint, accessKey, secretKey, bucketName, objectName, file2); |
| | | markMapper.insert(mediaFileMarkEntity); |
| | | File nailFile = new File(ImgZipUtil.compressImage(file1, 50).toURI()); |
| | | MediaFileNailEntity nailEntity = this.fileUploadConvertToNailEntity(file); |
| | | nailEntity.setIsOriginal(false); |
| | | nailEntity.setWorkspaceId(workspaceId); |
| | | nailEntity.setFileName("nail" + file.getName()); |
| | | nailEntity.setObjectKey("/nail" + file.getPath() + "/" + file.getName()); |
| | | nailEntity.setFilePath("nail" + file.getPath()); |
| | | String nailName = nailEntity.getObjectKey(); |
| | | nailEntity.setFileId(UUID.randomUUID().toString()); |
| | | uploadFile(endpoint, accessKey, secretKey, bucketName, nailName, nailFile, "image/jpeg"); |
| | | nailMapper.insert(nailEntity); |
| | | try { |
| | | if (file.getName().contains("~")) { |
| | | String name = TimerUtil.getDkbh(file.getName()); |
| | | List<LotInfo> lotInfos = patchesMapper.selectList(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, name)); |
| | | if (!lotInfos.isEmpty()) { |
| | | LambdaUpdateWrapper<LotInfo> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(LotInfo::getDkbh, name) |
| | | .eq(LotInfo::getInvestigate, 0) |
| | | .set(LotInfo::getInvestigate, 1); |
| | | patchesMapper.update(null, updateWrapper); |
| | | } |
| | | } |
| | | MediaFileMarkEntity mediaFileMarkEntity = this.fileUploadConvertToMarkEntity(file); |
| | | long timestamp = convertToTimestamp(file.getMetadata().getCreatedTime()); |
| | | File markFile = new File(WaterMarkUtil.addWatermark(file1, timestamp, file.getMetadata().getShootPosition().getLat(), |
| | | file.getMetadata().getShootPosition().getLng(), file.getMetadata().getGimbalYawDegree()).toURI()); |
| | | Object data = ImgUtil.getInfo(file1); |
| | | mediaFileMarkEntity.setDronedata(data); |
| | | mediaFileMarkEntity.setWorkspaceId(workspaceId); |
| | | mediaFileMarkEntity.setIsadd(0); |
| | | mediaFileMarkEntity.setIsOriginal(false); |
| | | mediaFileMarkEntity.setFileId(UUID.randomUUID().toString()); |
| | | mediaFileMarkEntity.setObjectKey("/mark" + file.getPath() + "/" + file.getName()); |
| | | mediaFileMarkEntity.setFileName("mark" + file.getName()); |
| | | mediaFileMarkEntity.setFilePath("mark" + file.getPath()); |
| | | String objectName = mediaFileMarkEntity.getObjectKey(); // 例如 "folder/file.txt" |
| | | uploadFile(endpoint, accessKey, secretKey, bucketName, objectName, markFile, "image/jpeg"); |
| | | markMapper.insert(mediaFileMarkEntity); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Object mediaInfo(String filename) { |
| | | String name = "mark" + filename; |
| | | MediaFileMarkEntity entity = markMapper.selectOne(new LambdaQueryWrapper<MediaFileMarkEntity>() |
| | | String name = filename; |
| | | if (!filename.contains("mark")) { |
| | | name = "mark" + filename; |
| | | } |
| | | List<MediaFileMarkEntity> entity = markMapper.selectList(new LambdaQueryWrapper<MediaFileMarkEntity>() |
| | | .eq(MediaFileMarkEntity::getFileName, name)); |
| | | return entity.getDronedata(); |
| | | if (entity != null) { |
| | | return entity.get(0).getDronedata(); |
| | | } else { |
| | | List<MediaFileEntity> entitys = mapper.selectList(new LambdaQueryWrapper<MediaFileEntity>() |
| | | .eq(MediaFileEntity::getFileName, name)); |
| | | return entitys.get(0).getDroneData(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public PaginationData<MediaFileEntity> MediaQuery(Integer page, Integer pageSize, Long updateStart, Long updateEnd, Long photoStart, Long photoEnd, String jobName, String workspaceId, String type) { |
| | | // 创建分页对象 |
| | | Page<MediaFileEntity> pageObj = new Page<>(page, pageSize); |
| | | |
| | | public PaginationData<MediaFileEntity> mediaQuery(Integer page, Integer pageSize, Long updateStart, Long updateEnd, Long photoStart, Long photoEnd, String jobName, String workspaceId, String type) { |
| | | // 创建查询条件对象 |
| | | LambdaQueryWrapper<MediaFileEntity> queryWrapper = new LambdaQueryWrapper<>(); |
| | | |
| | |
| | | |
| | | if (jobName != null && !jobName.isEmpty()) { |
| | | List<String> jobIds = waylineJobService.getJobIds(jobName); |
| | | // 检查 jobIds 列表是否为空 |
| | | if (jobIds.isEmpty()) { |
| | | // 如果为空,则直接返回空的分页数据 |
| | | return new PaginationData<>(Collections.emptyList(), new Pagination(pageObj)); |
| | | return new PaginationData<>(Collections.emptyList(), new Pagination(new Page<>(page, pageSize))); |
| | | } |
| | | |
| | | queryWrapper.in(MediaFileEntity::getJobId, jobIds); |
| | | } |
| | | |
| | | if (type != null && !type.isEmpty()) { |
| | | if ("图片".equals(type)) { |
| | | queryWrapper.likeLeft(MediaFileEntity::getFileName, ".jpeg"); |
| | |
| | | queryWrapper.likeLeft(MediaFileEntity::getFileName, ".mp4"); |
| | | } |
| | | } |
| | | queryWrapper.last("ORDER BY JSON_EXTRACT(metadata, '$.createdTime') DESC"); |
| | | // 执行分页查询 |
| | | Page<MediaFileEntity> resultPage = mapper.selectPage(pageObj, queryWrapper); |
| | | |
| | | // 处理查询结果 |
| | | List<MediaFileEntity> records = resultPage.getRecords() |
| | | .stream() |
| | | queryWrapper.last("ORDER BY JSON_EXTRACT(metadata, '$.createdTime') DESC"); |
| | | |
| | | // 执行查询获取所有结果 |
| | | List<MediaFileEntity> allResults = mapper.selectList(queryWrapper); |
| | | |
| | | // 处理结果去重并设置任务名称 |
| | | Map<String, MediaFileEntity> uniqueFileMap = new LinkedHashMap<>(); |
| | | List<MediaFileEntity> uniqueResults = allResults.stream() |
| | | .peek(mediaFile -> { |
| | | // 获取任务名称并设置到fileId |
| | | String taskNameResult = waylineJobService.getName(mediaFile.getJobId()); |
| | | mediaFile.setJobName(taskNameResult); |
| | | }) |
| | | .collect(Collectors.toList() |
| | | ); |
| | | .filter(mediaFile -> uniqueFileMap.putIfAbsent(mediaFile.getFileName(), mediaFile) == null) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 返回分页数据 |
| | | return new PaginationData<>(records, new Pagination(resultPage)); |
| | | // 计算分页信息 |
| | | int total = uniqueResults.size(); |
| | | int start = (page - 1) * pageSize; |
| | | int end = Math.min(start + pageSize, total); |
| | | |
| | | // 获取当前页的结果 |
| | | List<MediaFileEntity> pageResults = uniqueResults.subList(start, end); |
| | | |
| | | // 创建临时的 Page 对象 |
| | | Page<MediaFileEntity> resultPage = new Page<>(page, pageSize); |
| | | resultPage.setRecords(pageResults); |
| | | resultPage.setTotal(total); |
| | | |
| | | // 返回分页数据 |
| | | return new PaginationData<>(pageResults, new Pagination(resultPage)); |
| | | } |
| | | |
| | | @Override |
| | | public PaginationData<MediaFileNailEntity> mediaNailQuery(Integer page, Integer pageSize, Long updateStart, Long updateEnd, Long photoStart, Long photoEnd, String jobName, String workspaceId, String type) { |
| | | // 创建查询条件对象 |
| | | LambdaQueryWrapper<MediaFileNailEntity> queryWrapper = new LambdaQueryWrapper<>(); |
| | | |
| | | // 添加查询条件 |
| | | queryWrapper.eq(MediaFileNailEntity::getWorkspaceId, workspaceId); |
| | | |
| | | if (updateStart != null && updateEnd != null) { |
| | | queryWrapper.between(MediaFileNailEntity::getCreateTime, updateStart, updateEnd); |
| | | } |
| | | |
| | | if (photoStart != null && photoEnd != null) { |
| | | queryWrapper.apply("JSON_UNQUOTE(JSON_EXTRACT(metadata, '$.createdTime')) BETWEEN {0} AND {1}", photoStart, photoEnd); |
| | | } |
| | | |
| | | if (jobName != null && !jobName.isEmpty()) { |
| | | List<String> jobIds = waylineJobService.getJobIds(jobName); |
| | | if (jobIds.isEmpty()) { |
| | | return new PaginationData<>(Collections.emptyList(), new Pagination(new Page<>(page, pageSize))); |
| | | } |
| | | queryWrapper.in(MediaFileNailEntity::getJobId, jobIds); |
| | | } |
| | | |
| | | if (type != null && !type.isEmpty()) { |
| | | if ("图片".equals(type)) { |
| | | queryWrapper.likeLeft(MediaFileNailEntity::getFileName, ".jpeg"); |
| | | } else if ("视频".equals(type)) { |
| | | queryWrapper.likeLeft(MediaFileNailEntity::getFileName, ".mp4"); |
| | | } |
| | | } |
| | | |
| | | queryWrapper.last("ORDER BY JSON_EXTRACT(metadata, '$.createdTime') DESC"); |
| | | |
| | | // 执行查询获取所有结果 |
| | | List<MediaFileNailEntity> allResults = nailMapper.selectList(queryWrapper); |
| | | |
| | | // 处理结果去重并设置任务名称 |
| | | Map<String, MediaFileNailEntity> uniqueFileMap = new LinkedHashMap<>(); |
| | | List<MediaFileNailEntity> uniqueResults = allResults.stream() |
| | | .peek(mediaFile -> { |
| | | String taskNameResult = waylineJobService.getName(mediaFile.getJobId()); |
| | | mediaFile.setJobName(taskNameResult); |
| | | }) |
| | | .filter(mediaFile -> uniqueFileMap.putIfAbsent(mediaFile.getFileName(), mediaFile) == null) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 计算分页信息 |
| | | int total = uniqueResults.size(); |
| | | int start = (page - 1) * pageSize; |
| | | int end = Math.min(start + pageSize, total); |
| | | |
| | | // 获取当前页的结果 |
| | | List<MediaFileNailEntity> pageResults = uniqueResults.subList(start, end); |
| | | |
| | | // 创建临时的 Page 对象 |
| | | Page<MediaFileNailEntity> resultPage = new Page<>(page, pageSize); |
| | | resultPage.setRecords(pageResults); |
| | | resultPage.setTotal(total); |
| | | |
| | | // 返回分页数据 |
| | | return new PaginationData<>(pageResults, new Pagination(resultPage)); |
| | | } |
| | | |
| | | |
| | |
| | | return builder.build(); |
| | | } |
| | | |
| | | private MediaFileNailEntity fileUploadConvertToNailEntity(FileUploadDTO file) { |
| | | MediaFileNailEntity.MediaFileNailEntityBuilder builder = MediaFileNailEntity.builder(); |
| | | |
| | | if (file != null) { |
| | | builder.fileName(file.getName()) |
| | | .fingerprint(file.getFingerprint()) |
| | | .objectKey(file.getObjectKey()) |
| | | .subFileType(file.getSubFileType()) |
| | | .isOriginal(file.getExt().getIsOriginal()) |
| | | .jobId(file.getExt().getFlightId()) |
| | | .drone(file.getExt().getSn()).metadata(file.getMetadata()) |
| | | .tinnyFingerprint(file.getExt().getTinnyFingerprint()); |
| | | |
| | | // domain-type-subType |
| | | int[] payloadModel = Arrays.stream(file.getExt().getPayloadModelKey().split("-")) |
| | | .map(Integer::valueOf) |
| | | .mapToInt(Integer::intValue) |
| | | .toArray(); |
| | | Optional<DeviceDictionaryDTO> payloadDict = deviceDictionaryService |
| | | .getOneDictionaryInfoByTypeSubType(DeviceDomainEnum.PAYLOAD.getVal(), payloadModel[1], payloadModel[2]); |
| | | payloadDict.ifPresent(payload -> builder.payload(payload.getDeviceName())); |
| | | } |
| | | return builder.build(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Convert database entity objects into file data transfer object. |
| | |
| | | return builder.build(); |
| | | } |
| | | |
| | | public static void uploadFile(String endpoint, String accessKey, String secretKey, String bucketName, String objectName, File file) { |
| | | public static void uploadFile(String endpoint, String accessKey, String secretKey, String bucketName, String objectName, File file, String type) { |
| | | try { |
| | | // 创建MinIO客户端实例 |
| | | MinioClient minioClient = MinioClient.builder() |
| | |
| | | .bucket(bucketName) |
| | | .object(objectName) |
| | | .stream(fileInputStream, file.length(), -1) |
| | | .contentType("image/jpeg") |
| | | .contentType(type) |
| | | .build() |
| | | ); |
| | | fileInputStream.close(); |
| | |
| | | public void updateMediaFileNames(String jobId) { |
| | | // 查询符合条件的数据 |
| | | List<MediaFileEntity> mediaFiles = mapper.selectList(new LambdaQueryWrapper<MediaFileEntity>() |
| | | .eq(MediaFileEntity::getJobId, jobId) |
| | | // .eq(MediaFileMarkEntity::getIsadd, 0) |
| | | ); |
| | | .eq(MediaFileEntity::getJobId, jobId)); |
| | | boolean allContainTilde = mediaFiles.stream().allMatch(file -> file.getFileName().contains("~")); |
| | | boolean noneContainTilde = mediaFiles.stream().noneMatch(file -> file.getFileName().contains("~")); |
| | | |
| | |
| | | closestFileOpt.ifPresent(closestFile -> { |
| | | String closestName = closestFile.getFileName(); |
| | | int startIndex = closestName.indexOf("V"); |
| | | if (closestName.contains("W")) { |
| | | startIndex = closestName.indexOf("W"); |
| | | } |
| | | if (closestName.contains("Z")) { |
| | | startIndex = closestName.indexOf("Z"); |
| | | if (startIndex == -1) startIndex = closestName.indexOf("W"); |
| | | if (startIndex == -1) startIndex = closestName.indexOf("Z"); |
| | | if (startIndex == -1) startIndex = closestName.indexOf("T"); |
| | | if (startIndex == -1) { |
| | | return; |
| | | } |
| | | int endIndex = closestName.indexOf(".", startIndex); |
| | | if (endIndex == -1) { |
| | | return; |
| | | } |
| | | String replacement = closestName.substring(startIndex, endIndex); |
| | | int currentStartIndex = currentName.indexOf("V"); |
| | | if (currentName.contains("W")) { |
| | | currentStartIndex = closestName.indexOf("W"); |
| | | } |
| | | if (currentName.contains("Z")) { |
| | | currentStartIndex = closestName.indexOf("Z"); |
| | | if (currentStartIndex == -1) currentStartIndex = currentName.indexOf("W"); |
| | | if (currentStartIndex == -1) currentStartIndex = currentName.indexOf("Z"); |
| | | if (currentStartIndex == -1) currentStartIndex = currentName.indexOf("T"); |
| | | if (currentStartIndex == -1) { |
| | | return; |
| | | } |
| | | int currentEndIndex = currentName.indexOf(".", currentStartIndex); |
| | | if (currentEndIndex == -1) { |
| | | return; |
| | | } |
| | | String newName = currentName.substring(0, currentStartIndex) |
| | | + replacement |
| | | + currentName.substring(currentEndIndex); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void updateMarkMediaFileNames(String jobId) { |
| | | try { |
| | | |
| | | |
| | | // 查询符合条件的数据 |
| | | List<MediaFileMarkEntity> mediaFiles = markMapper.selectList(new LambdaQueryWrapper<MediaFileMarkEntity>() |
| | | .eq(MediaFileMarkEntity::getJobId, jobId) |
| | | // .eq(MediaFileMarkEntity::getIsadd, 0) |
| | | ); |
| | | .eq(MediaFileMarkEntity::getJobId, jobId)); |
| | | |
| | | // 判断所有 fileName 是否都包含 '~' 或者都不包含 '~' |
| | | boolean allContainTilde = mediaFiles.stream().allMatch(file -> file.getFileName().contains("~")); |
| | | boolean noneContainTilde = mediaFiles.stream().noneMatch(file -> file.getFileName().contains("~")); |
| | |
| | | file.setIsadd(1); |
| | | updateById(file.getId(), file); |
| | | }); |
| | | return; |
| | | |
| | | return; |
| | | } |
| | | |
| | | // 筛选出name字段不包含'~'的数据 |
| | | List<MediaFileMarkEntity> filteredFiles = mediaFiles.stream() |
| | | .filter(file -> !file.getFileName().contains("~")) |
| | |
| | | String currentName = currentFile.getFileName(); |
| | | Map<String, Object> currentMetadata = JSON.parseObject(JSON.toJSONString(currentFile.getMetadata()), Map.class); |
| | | Long currentCreatedTime = (Long) currentMetadata.get("createdTime"); |
| | | |
| | | // 找到metadata中的createdTime小于当前数据的createdTime且最接近的那条数据 |
| | | Optional<MediaFileMarkEntity> closestFileOpt = mediaFiles.stream() |
| | | .filter(file -> { |
| | |
| | | Long time2 = (Long) metadata2.get("createdTime"); |
| | | return Long.compare(currentCreatedTime - time1, currentCreatedTime - time2); |
| | | }); |
| | | |
| | | if (closestFileOpt.isEmpty()) { |
| | | // 找不到小于的文件,尝试找大于且最接近的文件 |
| | | closestFileOpt = mediaFiles.stream() |
| | |
| | | return Long.compare(time1 - currentCreatedTime, time2 - currentCreatedTime); |
| | | }); |
| | | } |
| | | |
| | | // 提取并替换name字段 |
| | | closestFileOpt.ifPresent(closestFile -> { |
| | | String closestName = closestFile.getFileName(); |
| | | int startIndex = closestName.indexOf("V"); |
| | | if (closestName.contains("W")) { |
| | | startIndex = closestName.indexOf("W"); |
| | | } |
| | | if (closestName.contains("Z")) { |
| | | startIndex = closestName.indexOf("Z"); |
| | | if (startIndex == -1) startIndex = closestName.indexOf("W"); |
| | | if (startIndex == -1) startIndex = closestName.indexOf("Z"); |
| | | if (startIndex == -1) startIndex = closestName.indexOf("T"); |
| | | if (startIndex == -1) { |
| | | return; |
| | | } |
| | | int endIndex = closestName.indexOf(".", startIndex); |
| | | String replacement = closestName.substring(startIndex, endIndex); |
| | | int currentStartIndex = currentName.indexOf("V"); |
| | | if (currentName.contains("W")) { |
| | | currentStartIndex = closestName.indexOf("W"); |
| | | if (endIndex == -1) { |
| | | return; |
| | | } |
| | | if (currentName.contains("Z")) { |
| | | currentStartIndex = closestName.indexOf("Z"); |
| | | String replacement = closestName.substring(startIndex, endIndex); |
| | | |
| | | int currentStartIndex = currentName.indexOf("V"); |
| | | if (currentStartIndex == -1) currentStartIndex = currentName.indexOf("W"); |
| | | if (currentStartIndex == -1) currentStartIndex = currentName.indexOf("Z"); |
| | | if (currentStartIndex == -1) currentStartIndex = currentName.indexOf("T"); |
| | | if (currentStartIndex == -1) { |
| | | return; |
| | | } |
| | | int currentEndIndex = currentName.indexOf(".", currentStartIndex); |
| | | if (currentEndIndex == -1) { |
| | | return; |
| | | } |
| | | String newName = currentName.substring(0, currentStartIndex) |
| | | + replacement |
| | | + currentName.substring(currentEndIndex); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | public void updateById(Integer id, MediaFileMarkEntity entity) { |
| | | entity.setIsadd(1); |
| | | UpdateWrapper<MediaFileMarkEntity> updateWrapper = new UpdateWrapper<>(); |