Merge remote-tracking branch 'origin/ht-dev' into ht-dev
| | |
| | | Integer saveFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException; |
| | | void saveNailFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException; |
| | | |
| | | // void saveZipFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException; |
| | | void saveZipFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException; |
| | | void updateNailMediaFileNames(String jobId); |
| | | PaginationData<MediaFileEntity> getJobId( int pageNum, int pageSize,String workspaceId); |
| | | PaginationData<MediaFileEntity> getPhotoByJobId(int page,int pageSize ,String workspaceId,String jobId); |
| | |
| | | nailEntity.setWorkspaceId(workspaceId); |
| | | nailEntity.setFileId(UUID.randomUUID().toString()); |
| | | nailMapper.insert(nailEntity); |
| | | MediaFileZipEntity zipEntity = this.fileUploadConvertToZipEntity((file)); |
| | | zipEntity.setWorkspaceId(workspaceId); |
| | | zipEntity.setFileId(UUID.randomUUID().toString()); |
| | | zipMapper.insert(zipEntity); |
| | | } else { |
| | | String url = pojo.getEndpoint() + "/" + pojo.getBucket() + file.getObjectKey(); |
| | | File file1 = TbFjServiceImpl.downloadFile(url); |
| | |
| | | nailEntity.setFilePath("nail" + file.getPath()); |
| | | String nailName = nailEntity.getObjectKey(); |
| | | nailEntity.setFileId(UUID.randomUUID().toString()); |
| | | uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", file.getObjectKey(), file1, "image/jpeg"); |
| | | 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"); |
| | | nailMapper.insert(nailEntity); |
| | | } |
| | | } |
| | | |
| | | // 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 zipEntity = this.fileUploadConvertToZipEntity((file)); |
| | | zipEntity.setWorkspaceId(workspaceId); |
| | | zipEntity.setFileId(UUID.randomUUID().toString()); |
| | | zipMapper.insert(zipEntity); |
| | | } 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("~")) { |
| | |
| | | @Override |
| | | public ResponseResult downloadImages(List<String> jobIds) { |
| | | try { |
| | | String bucketPath = "/data/software/minio-data/cloud-bucket/"; |
| | | String bucketPath = "/data/software/minio-data/cloud-bucket"; |
| | | List<String> prefixes = getUniqueFilePaths(jobIds); |
| | | MinioFileDownloader downloader = new MinioFileDownloader(bucketPath); |
| | | // 下载并压缩文件到本地目录 |
| | | String localSaveDir = "/data/software/minio-data/zip-bucket/"; // 修改为你想保存的本地目录 |
| | | String localSaveDir = "/data/software/minio-data/zip-bucket"; // 修改为你想保存的本地目录 |
| | | downloader.downloadAndZipFolders(prefixes, localSaveDir); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | for (MediaFileNailEntity mark : markEntities) { |
| | | updateNailMediaFileNames(mark.getJobId()); |
| | | updateMediaFileNames(mark.getJobId()); |
| | | // updateMediaZipFileNames(mark.getJobId()); |
| | | updateMediaZipFileNames(mark.getJobId()); |
| | | } |
| | | } |
| | | |
| | |
| | | callback.getFile().setPath(objectKey.substring(objectKey.indexOf("/") + 1, objectKey.lastIndexOf("/"))); |
| | | int count =fileService.saveFile(job.getWorkspaceId(), callback.getFile()); |
| | | fileService.saveNailFile(job.getWorkspaceId(), callback.getFile()); |
| | | // fileService.saveZipFile(job.getWorkspaceId(),callback.getFile()); |
| | | fileService.saveZipFile(job.getWorkspaceId(),callback.getFile()); |
| | | return count > 0; |
| | | } |
| | | |
| | |
| | | @RequestParam(name = "xmc", required = false) String xmc, |
| | | @RequestParam(name = "investigate", required = false) Integer investigate, |
| | | @RequestParam(name = "dkmj", required = false) Double dkmj, |
| | | @RequestParam(name = "isPlan",required = false) Integer isPlan |
| | | @RequestParam(name = "isPush",required = false) Integer isPush |
| | | ) { |
| | | fileService.getNoaddFile(); |
| | | //调用service分页查询 |
| | |
| | | .xmc(xmc) |
| | | .investigate(investigate) |
| | | .dkmj(dkmj) |
| | | .isPlan(isPlan) |
| | | .isPush(isPush) |
| | | .build(); |
| | | PaginationData<LotInfo> data = getPatchesService.limitGet(param); |
| | | return ResponseResult.success(data); |
| | |
| | | |
| | | private String dkbh; |
| | | |
| | | private Integer isPlan; |
| | | private Integer isPush; |
| | | |
| | | private String xzqdm; |
| | | |
| | |
| | | if (param.getDkmj()!=null){ |
| | | queryWrapper.eq(LotInfo::getDkmj,param.getDkmj()); |
| | | } |
| | | if (param.getIsPlan() != null) { |
| | | queryWrapper.eq(LotInfo::getIsPlan, param.getIsPlan()); |
| | | if (param.getIsPush() != null) { |
| | | queryWrapper.eq(LotInfo::getIsPush, param.getIsPush()); |
| | | } |
| | | |
| | | // 执行分页查询 |
| | |
| | | import com.dji.sample.speak.model.dto.PsdkModelDto; |
| | | import com.dji.sample.speak.model.dto.SpeakVoiceStartDto; |
| | | import com.dji.sample.speak.model.dto.SpeakVolumeDto; |
| | | import com.dji.sample.speak.model.entity.SpeakVoiceEntity; |
| | | import com.dji.sample.speak.model.enums.FormatEnum; |
| | | import com.dji.sample.speak.model.param.SpeakVoiceStartParam; |
| | | import com.dji.sample.speak.service.SpeakVoiceService; |
| | |
| | | @RequestParam Integer volumn, |
| | | @RequestParam MultipartFile file) throws UnsupportedAudioFileException, IOException { |
| | | File file1 = MultipartFileTOFileUtil.multipartFile2File(file, patchesConfigPojo.getUnzip()); |
| | | return ResponseResult.success(voiceServicel.takeVoice(sn, psdk_index, name, file1, volumn)); |
| | | SpeakVoiceEntity entity=voiceServicel.takeVoice(name, file1); |
| | | return ResponseResult.success(voiceServicel.takeVoicee(sn, psdk_index, name, file1, volumn,entity)); |
| | | } |
| | | |
| | | @PostMapping("/stopVoice") |
| | |
| | | public ResponseResult getVoices(@RequestParam Integer page, @RequestParam Integer page_size) { |
| | | return ResponseResult.success(voiceServicel.getVoices(page, page_size)); |
| | | } |
| | | |
| | | @PostMapping("/putVoice2") |
| | | public ResponseResult putVoices(@RequestParam String sn) { |
| | | return ResponseResult.success(voiceServicel.awayCar(sn)); |
| | | } |
| | | |
| | | } |
| | |
| | | import java.util.List; |
| | | |
| | | public interface SpeakVoiceService { |
| | | int takeVoice(String sn , Integer psdk_index, String name, File file,Integer volumn) throws UnsupportedAudioFileException, IOException; |
| | | SpeakVoiceEntity takeVoice(String name, File file) throws UnsupportedAudioFileException, IOException; |
| | | |
| | | int takeVoicee(String sn , Integer psdk_index, String name, File file,Integer volumn,SpeakVoiceEntity entity); |
| | | int restartVoice(String sn ,Integer psdk_index); |
| | | |
| | | int stopVoice(String sn,Integer psdk_index); |
| | |
| | | |
| | | int awayRiver (String sn); |
| | | |
| | | int awayCar (String sn); |
| | | |
| | | PaginationData<SpeakVoiceEntity> getVoices(Integer pages,Integer page_size); |
| | | } |
| | |
| | | private SpeakVoiceMapper voiceMapper; |
| | | |
| | | @Override |
| | | public int takeVoice(String sn, Integer psdk_index, String name, File file,Integer volumn) throws UnsupportedAudioFileException, IOException { |
| | | public SpeakVoiceEntity takeVoice(String name, File file) throws UnsupportedAudioFileException, IOException { |
| | | SpeakVoiceEntity voiceEntity = new SpeakVoiceEntity(); |
| | | SpeakVoiceStartDto dto = new SpeakVoiceStartDto(); |
| | | SpeakVoiceFileDto fileDto = new SpeakVoiceFileDto(); |
| | | SpeakVolumeDto volumeDto=new SpeakVolumeDto(); |
| | | volumeDto.setPsdk_index(psdk_index); |
| | | volumeDto.setPlay_volume(volumn); |
| | | String url = upMinio(file, name); |
| | | fileDto.setUrl(url); |
| | | String md5 = MD5Util.getMD5Checksum(file); |
| | | fileDto.setMd5(md5); |
| | | fileDto.setFormat(FormatEnum.PCM); |
| | | fileDto.setName(name); |
| | | dto.setPsdk_index(psdk_index); |
| | | dto.setFile(fileDto); |
| | | double time = getAudioDuration(file); |
| | | voiceEntity.setMd5(md5); |
| | | voiceEntity.setSecond(time); |
| | | voiceEntity.setUrl(url); |
| | | voiceEntity.setName(name); |
| | | voiceMapper.insert(voiceEntity); |
| | | return voiceEntity; |
| | | } |
| | | @Override |
| | | public int takeVoicee(String sn, Integer psdk_index, String name, File file,Integer volumn,SpeakVoiceEntity entity) { |
| | | SpeakVoiceStartDto dto = new SpeakVoiceStartDto(); |
| | | SpeakVoiceFileDto fileDto = new SpeakVoiceFileDto(); |
| | | SpeakVolumeDto volumeDto=new SpeakVolumeDto(); |
| | | volumeDto.setPsdk_index(psdk_index); |
| | | volumeDto.setPlay_volume(volumn); |
| | | fileDto.setUrl(entity.getUrl()); |
| | | fileDto.setMd5(entity.getMd5()); |
| | | fileDto.setFormat(FormatEnum.PCM); |
| | | fileDto.setName(entity.getName()); |
| | | dto.setPsdk_index(psdk_index); |
| | | dto.setFile(fileDto); |
| | | messageSenderService.publishServicesTopic(sn, VoiceEnums.SPEAKER_PLAY_VOLUME_SET.getMethod(), volumeDto); |
| | | return messageSenderService.publishServicesTopic(sn, VoiceEnums.SPEAKER_AUDIO_PLAY_START.getMethod(), dto).getResult(); |
| | | } |
| | |
| | | dto.setFile(fileDto); |
| | | return messageSenderService.publishServicesTopic(sn, VoiceEnums.SPEAKER_AUDIO_PLAY_START.getMethod(), dto).getResult(); |
| | | } |
| | | |
| | | public int awayCar(String sn) { |
| | | SpeakVoiceStartDto dto = new SpeakVoiceStartDto(); |
| | | SpeakVoiceFileDto fileDto = new SpeakVoiceFileDto(); |
| | | fileDto.setUrl("http://dev.jxpskj.com:9000/cloud-bucket/录音20240730112507301125"); |
| | | fileDto.setMd5("b4e738b1c5c97d4fa52f3918bab3f42d"); |
| | | fileDto.setFormat(FormatEnum.PCM); |
| | | fileDto.setName("违章停车"); |
| | | dto.setPsdk_index(2); |
| | | dto.setFile(fileDto); |
| | | return messageSenderService.publishServicesTopic(sn, VoiceEnums.SPEAKER_AUDIO_PLAY_START.getMethod(), dto).getResult(); |
| | | } |
| | | @Override |
| | | public PaginationData<SpeakVoiceEntity> getVoices(Integer pages,Integer page_size) { |
| | | // Paging Query |
| | |
| | | */ |
| | | public static File downloadFile(String fileUrl) { |
| | | File downloadedFile = null; |
| | | |
| | | try { |
| | | URL url = new URL(fileUrl); |
| | | HttpURLConnection connection = (HttpURLConnection) url.openConnection(); |
| | | connection.setRequestMethod("GET"); |
| | | downloadedFile = new File(File.createTempFile("temp", ".jpeg").toURI()); |
| | | InputStream inputStream = connection.getInputStream(); |
| | | OutputStream outputStream = new FileOutputStream(downloadedFile); |
| | | byte[] buffer = new byte[1024]; |
| | | int bytesRead; |
| | | while ((bytesRead = inputStream.read(buffer)) != -1) { |
| | | outputStream.write(buffer, 0, bytesRead); |
| | | |
| | | // 创建临时文件 |
| | | File tempFile = File.createTempFile("temp", ".jpeg"); |
| | | downloadedFile = tempFile; |
| | | |
| | | // 使用 try-with-resources 确保流被关闭 |
| | | try (InputStream inputStream = connection.getInputStream(); |
| | | OutputStream outputStream = new FileOutputStream(downloadedFile)) { |
| | | byte[] buffer = new byte[1024]; |
| | | int bytesRead; |
| | | while ((bytesRead = inputStream.read(buffer)) != -1) { |
| | | outputStream.write(buffer, 0, bytesRead); |
| | | } |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | |
| | | return ResponseResult.success(); |
| | | } |
| | | |
| | | @PutMapping("/{workspace_id}/updateWayLineFile/{id}") |
| | | @PostMapping("/{workspace_id}/updateWayLineFile") |
| | | public ResponseResult updateWayLineFile(@PathVariable(name = "workspace_id") String workspaceId, |
| | | @PathVariable(name = "id") String id, |
| | | @RequestBody CreateWaylineParam param, |
| | | HttpServletRequest request) throws IOException { |
| | | String kmz=param.getWaylineName()+".kmz"; |
| | | // 初始化模板对象 |
| | | MinioFileDownloader.deleteFileFromMinio(pojo.getEndpoint(), pojo.getAccessKey(), pojo.getSecretKey(), pojo.getBucket(), kmz); |
| | | CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM); |
| | | String creator = customClaim.getUsername(); |
| | | // 初始化模板对象 |
| | |
| | | // 生成航线文件 |
| | | CreateWaylineFileUtils.createWaylineFileByPolygon(xmlModel, patchesConfigPojo.getPlaneTemplate(), patchesConfigPojo.getPlaneTargetTemplate()); |
| | | CreateWaylineFileUtils.createWaylineFileByPolygon(xmlModel, patchesConfigPojo.getPlaneWaylines(), patchesConfigPojo.getPlaneTargetWaylines()); |
| | | MinioFileDownloader.deleteFileFromMinio(pojo.getEndpoint(), pojo.getAccessKey(), pojo.getSecretKey(), pojo.getBucket(), param.getWaylineName()); |
| | | // kmz、上传航线库 |
| | | String destKMZFile = patchesConfigPojo.getPlaneKMZFile() + param.getWaylineName() + ".kmz"; // 输出的KMZ文件路径 |
| | | ZipUtil.zipFolder(patchesConfigPojo.getSourceDir(), destKMZFile); |
| | | MultipartFile multipartFile = MultipartFileTOFileUtil.convert(new File(destKMZFile)); |
| | | waylineFileService.importPlaneKmzFile(multipartFile, workspaceId, creator, param.getWaylineName(), id); |
| | | waylineFileService.importPlaneKmzFile(multipartFile, workspaceId, creator, null, "1"); |
| | | return ResponseResult.success(); |
| | | } |
| | | } |