From 249d316e0b8c79b71b779b5716bc488e1d08a9b3 Mon Sep 17 00:00:00 2001
From: aix <vip_xiaobin810@163.com>
Date: Tue, 30 Jul 2024 14:48:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/ht-dev' into ht-dev

---
 src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java       |    4 
 src/main/java/com/dji/sample/territory/service/impl/TbFjServiceImpl.java           |   20 ++++--
 src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java               |   61 +++++++++++---------
 src/main/java/com/dji/sample/patches/model/Param/PatchesParam.java                 |    2 
 src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java              |    2 
 src/main/java/com/dji/sample/speak/service/serviceImpl/SpeakVoiceServiceImpl.java  |   40 +++++++++----
 src/main/java/com/dji/sample/media/service/IFileService.java                       |    2 
 src/main/java/com/dji/sample/speak/service/SpeakVoiceService.java                  |    5 +
 src/main/java/com/dji/sample/speak/controller/SpeakVoiceController.java            |   10 +++
 src/main/java/com/dji/sample/wayline/plane/controller/CreateWayLineController.java |    9 +-
 src/main/java/com/dji/sample/patches/controller/PatchesController.java             |    4 
 11 files changed, 98 insertions(+), 61 deletions(-)

diff --git a/src/main/java/com/dji/sample/media/service/IFileService.java b/src/main/java/com/dji/sample/media/service/IFileService.java
index 1a102fa..b6e6b48 100644
--- a/src/main/java/com/dji/sample/media/service/IFileService.java
+++ b/src/main/java/com/dji/sample/media/service/IFileService.java
@@ -39,7 +39,7 @@
     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);
diff --git a/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java b/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
index 0d89bc5..919be81 100644
--- a/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
+++ b/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
@@ -130,6 +130,10 @@
             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);
@@ -145,37 +149,38 @@
             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("~")) {
@@ -451,11 +456,11 @@
     @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();
@@ -1051,7 +1056,7 @@
         for (MediaFileNailEntity mark : markEntities) {
             updateNailMediaFileNames(mark.getJobId());
             updateMediaFileNames(mark.getJobId());
-//            updateMediaZipFileNames(mark.getJobId());
+            updateMediaZipFileNames(mark.getJobId());
         }
     }
 
diff --git a/src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java b/src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java
index 7b2d29c..85367e0 100644
--- a/src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java
+++ b/src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java
@@ -228,7 +228,7 @@
         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;
     }
 
diff --git a/src/main/java/com/dji/sample/patches/controller/PatchesController.java b/src/main/java/com/dji/sample/patches/controller/PatchesController.java
index 1d4494e..f6e26b9 100644
--- a/src/main/java/com/dji/sample/patches/controller/PatchesController.java
+++ b/src/main/java/com/dji/sample/patches/controller/PatchesController.java
@@ -70,7 +70,7 @@
                                                         @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分页查询
@@ -84,7 +84,7 @@
                 .xmc(xmc)
                 .investigate(investigate)
                 .dkmj(dkmj)
-                .isPlan(isPlan)
+                .isPush(isPush)
                 .build();
         PaginationData<LotInfo> data = getPatchesService.limitGet(param);
         return ResponseResult.success(data);
diff --git a/src/main/java/com/dji/sample/patches/model/Param/PatchesParam.java b/src/main/java/com/dji/sample/patches/model/Param/PatchesParam.java
index 52cfe49..45c623b 100644
--- a/src/main/java/com/dji/sample/patches/model/Param/PatchesParam.java
+++ b/src/main/java/com/dji/sample/patches/model/Param/PatchesParam.java
@@ -20,7 +20,7 @@
 
     private String dkbh;
 
-    private Integer isPlan;
+    private Integer isPush;
 
     private String xzqdm;
 
diff --git a/src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java b/src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
index 26ce42f..82a1267 100644
--- a/src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
+++ b/src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
@@ -70,8 +70,8 @@
         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());
         }
 
         // 执行分页查询
diff --git a/src/main/java/com/dji/sample/speak/controller/SpeakVoiceController.java b/src/main/java/com/dji/sample/speak/controller/SpeakVoiceController.java
index 9663628..4db2966 100644
--- a/src/main/java/com/dji/sample/speak/controller/SpeakVoiceController.java
+++ b/src/main/java/com/dji/sample/speak/controller/SpeakVoiceController.java
@@ -7,6 +7,7 @@
 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;
@@ -33,7 +34,8 @@
                                     @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")
@@ -65,4 +67,10 @@
     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));
+    }
+
 }
diff --git a/src/main/java/com/dji/sample/speak/service/SpeakVoiceService.java b/src/main/java/com/dji/sample/speak/service/SpeakVoiceService.java
index 5fef21a..157e000 100644
--- a/src/main/java/com/dji/sample/speak/service/SpeakVoiceService.java
+++ b/src/main/java/com/dji/sample/speak/service/SpeakVoiceService.java
@@ -16,8 +16,9 @@
 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);
@@ -28,5 +29,7 @@
 
     int awayRiver (String sn);
 
+    int awayCar (String sn);
+
     PaginationData<SpeakVoiceEntity> getVoices(Integer pages,Integer page_size);
 }
diff --git a/src/main/java/com/dji/sample/speak/service/serviceImpl/SpeakVoiceServiceImpl.java b/src/main/java/com/dji/sample/speak/service/serviceImpl/SpeakVoiceServiceImpl.java
index f34049a..4a7a78f 100644
--- a/src/main/java/com/dji/sample/speak/service/serviceImpl/SpeakVoiceServiceImpl.java
+++ b/src/main/java/com/dji/sample/speak/service/serviceImpl/SpeakVoiceServiceImpl.java
@@ -39,27 +39,31 @@
     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();
     }
@@ -100,7 +104,17 @@
         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
diff --git a/src/main/java/com/dji/sample/territory/service/impl/TbFjServiceImpl.java b/src/main/java/com/dji/sample/territory/service/impl/TbFjServiceImpl.java
index 87b8024..4ccc300 100644
--- a/src/main/java/com/dji/sample/territory/service/impl/TbFjServiceImpl.java
+++ b/src/main/java/com/dji/sample/territory/service/impl/TbFjServiceImpl.java
@@ -195,18 +195,24 @@
      */
     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();
diff --git a/src/main/java/com/dji/sample/wayline/plane/controller/CreateWayLineController.java b/src/main/java/com/dji/sample/wayline/plane/controller/CreateWayLineController.java
index 26f7ef8..88b3bc8 100644
--- a/src/main/java/com/dji/sample/wayline/plane/controller/CreateWayLineController.java
+++ b/src/main/java/com/dji/sample/wayline/plane/controller/CreateWayLineController.java
@@ -64,11 +64,13 @@
         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();
 //         初始化模板对象
@@ -76,12 +78,11 @@
 //        生成航线文件
         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();
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3