| | |
| | | } |
| | | } |
| | | |
| | | public void saveZipFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException { |
| | | updateStatue(file.getName()); |
| | | boolean endsWith = file.getObjectKey().endsWith(".mp4"); |
| | | if (endsWith) { |
| | | MediaFileZipEntity nailEntity = this.fileUploadConvertToZipEntity((file)); |
| | | nailEntity.setWorkspaceId(workspaceId); |
| | | nailEntity.setFileId(UUID.randomUUID().toString()); |
| | | zipMapper.insert(nailEntity); |
| | | } else { |
| | | String url = pojo.getEndpoint() + "/" + pojo.getBucket() + file.getObjectKey(); |
| | | File file1 = TbFjServiceImpl.downloadFile(url); |
| | | File nailFile = new File(ImgZipUtil.compressImageAndGetFile(file1, 0.5f).toURI()); |
| | | MediaFileZipEntity zipEntity = this.fileUploadConvertToZipEntity(file); |
| | | zipEntity.setIsOriginal(false); |
| | | zipEntity.setWorkspaceId(workspaceId); |
| | | zipEntity.setFileName("zip" + file.getName()); |
| | | zipEntity.setObjectKey("/zip" + file.getPath() + "/" + file.getName()); |
| | | zipEntity.setFilePath("zip" + file.getPath()); |
| | | String nailName = zipEntity.getObjectKey(); |
| | | zipEntity.setFileId(UUID.randomUUID().toString()); |
| | | uploadFile(pojo.getEndpoint(), pojo.getAccessKey(), pojo.getSecretKey(), pojo.getBucket(), nailName, nailFile, "image/jpeg"); |
| | | uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", nailName, nailFile, "image/jpeg"); |
| | | zipMapper.insert(zipEntity); |
| | | } |
| | | } |
| | | // public void saveZipFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException { |
| | | // updateStatue(file.getName()); |
| | | // boolean endsWith = file.getObjectKey().endsWith(".mp4"); |
| | | // if (endsWith) { |
| | | // MediaFileZipEntity nailEntity = this.fileUploadConvertToZipEntity((file)); |
| | | // nailEntity.setWorkspaceId(workspaceId); |
| | | // nailEntity.setFileId(UUID.randomUUID().toString()); |
| | | // zipMapper.insert(nailEntity); |
| | | // } else { |
| | | // String url = pojo.getEndpoint() + "/" + pojo.getBucket() + file.getObjectKey(); |
| | | // File file1 = TbFjServiceImpl.downloadFile(url); |
| | | // File nailFile = new File(ImgZipUtil.compressImageAndGetFile(file1, 0.5f).toURI()); |
| | | // MediaFileZipEntity zipEntity = this.fileUploadConvertToZipEntity(file); |
| | | // zipEntity.setIsOriginal(false); |
| | | // zipEntity.setWorkspaceId(workspaceId); |
| | | // zipEntity.setFileName("zip" + file.getName()); |
| | | // zipEntity.setObjectKey("/zip" + file.getPath() + "/" + file.getName()); |
| | | // zipEntity.setFilePath("zip" + file.getPath()); |
| | | // String nailName = zipEntity.getObjectKey(); |
| | | // zipEntity.setFileId(UUID.randomUUID().toString()); |
| | | // uploadFile(pojo.getEndpoint(), pojo.getAccessKey(), pojo.getSecretKey(), pojo.getBucket(), nailName, nailFile, "image/jpeg"); |
| | | // uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", nailName, nailFile, "image/jpeg"); |
| | | // zipMapper.insert(zipEntity); |
| | | // } |
| | | // } |
| | | |
| | | public void updateStatue(String filename) { |
| | | if (filename.contains("~")) { |
| | |
| | | builder.fileName(file.getName()) |
| | | .filePath(file.getPath()) |
| | | .examine(0) |
| | | .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(); |
| | | } |
| | | |
| | | private MediaFileMarkEntity fileUploadConvertToMarkEntity(FileUploadDTO file) { |
| | | MediaFileMarkEntity.MediaFileMarkEntityBuilder builder = MediaFileMarkEntity.builder(); |
| | | |
| | | if (file != null) { |
| | | builder.fileName(file.getName()) |
| | | .filePath(file.getPath()) |
| | | .fingerprint(file.getFingerprint()) |
| | | .objectKey(file.getObjectKey()) |
| | | .subFileType(file.getSubFileType()) |
| | |
| | | for (MediaFileNailEntity mark : markEntities) { |
| | | updateNailMediaFileNames(mark.getJobId()); |
| | | updateMediaFileNames(mark.getJobId()); |
| | | updateMediaZipFileNames(mark.getJobId()); |
| | | // updateMediaZipFileNames(mark.getJobId()); |
| | | } |
| | | } |
| | | |