Kaynağa Gözat

王耀栋--工作台模块代码,导出任务包功能

wangyaodong 3 yıl önce
ebeveyn
işleme
eb974cb548

+ 1 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/feign/FileDownService.java

@@ -41,6 +41,6 @@ public interface FileDownService {
     ResponseBodyVO<List<String>> list( @RequestBody @Validated MinioParameter minioParameter );
 
     @RequestMapping("/minio/getPreviewUrl")
-    ResponseBodyVO<String> preview(@RequestBody @Validated MinioParameter minioParameter);
+    ResponseBodyVO<String> getPreviewUrl(@RequestBody @Validated MinioParameter minioParameter);
 
 }

+ 1 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/feign/fallback/FileDownServiceFallback.java

@@ -47,7 +47,7 @@ public class FileDownServiceFallback implements FileDownService {
     }
 
     @Override
-    public ResponseBodyVO<String> preview(@RequestBody @Validated MinioParameter minioParameter) {
+    public ResponseBodyVO<String> getPreviewUrl(@RequestBody @Validated MinioParameter minioParameter) {
         return null;
     }
 

+ 43 - 4
simulation-resource-server/src/main/java/com/css/simulation/resource/project/impl/SimulationProjectServiceImpl.java

@@ -952,7 +952,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                 if("mp4".equals(substring)){
                     //mp4视频文件
                     minioParameter1.setObjectName(s);
-                    ResponseBodyVO<String> preview = fileDownService.preview(minioParameter1);
+                    ResponseBodyVO<String> preview = fileDownService.getPreviewUrl(minioParameter1);
                     list1.add(preview.getMessage());
                 }
 
@@ -3266,7 +3266,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         SimulationManualProjectParam sp = new SimulationManualProjectParam();
         sp.setId(id);
         SimulationManualProjectPo spo = simulationProjectMapper.selectProjectBaseById(sp);
-        String rootPath = spo.getProjectName()+"_"+StringUtil.getRandomUUID();
+        String rootPath = spo.getProjectName();
 //        FileUtil.createDirectory(rootPath);
 
 
@@ -3281,21 +3281,24 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             response.setContentType("multipart/form-data");
             response.setHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode("运行任务包.zip", "UTF-8"));
             zos = new ZipOutputStream(response.getOutputStream());
+            int i = 1;
             for(ManualProjectTaskVo v : manualProjectTaskVos){
                 String runResultFilePath = v.getRunResultFilePath();
                 if(!isEmpty(runResultFilePath)){
+
                     MinioParameter minioParameter = new MinioParameter();
                     minioParameter.setObjectName(runResultFilePath+"/Ego.csv");
                     Response download = fileDownService.download(minioParameter);
                     Response.Body body = download.body();
                     inputStream = body.asInputStream();
+                    in =  new BufferedInputStream(inputStream);
 
                     //获取场景名
                     SceneBaseInfoVo sceneBaseInfoVo = getsceneNameAndOther(v.getSceneId(), v.getSceneType());
                     String sceneName = sceneBaseInfoVo.getCommonSceneName();
 
                     //任务包路径
-                    String taskPagePath = rootPath+File.separator+sceneName+"_"+StringUtil.getRandomUUID();
+                    String taskPagePath = rootPath+File.separator+sceneName+"("+i+")";
 //                    FileUtil.createDirectory(taskPagePath);
 
                     //任务文件路径
@@ -3308,6 +3311,41 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                     while ((len = in.read(buffer)) != -1 ) {
                         zos.write(buffer, 0, len);
                     }
+
+                    //视频文件路径
+                    MinioParameter minioParameter1 = new MinioParameter();
+                    minioParameter1.setObjectName(runResultFilePath);
+                    ResponseBodyVO<List<String>> list = fileDownService.list(minioParameter1);
+                    List<String> info = list.getInfo();
+                    for(String s : info){
+                        String videoPath = "";
+                        String substring = s.substring(s.lastIndexOf(".") + 1);
+                        if("mp4".equals(substring)){
+                            //mp4视频文件导出
+                            if(s.contains("/")){
+                                videoPath = taskPagePath + File.separator + s.substring(s.lastIndexOf("/")+1);
+                            }else{
+                                videoPath = taskPagePath + File.separator + s.substring(s.lastIndexOf("\\")+1);
+                            }
+
+                            MinioParameter minioParameter2 = new MinioParameter();
+                            minioParameter2.setObjectName(s);
+                            Response download2 = fileDownService.download(minioParameter2);
+                            Response.Body body2 = download2.body();
+                            inputStream = body2.asInputStream();
+                            in = new BufferedInputStream(inputStream);
+
+                            ZipEntry entry2 = new ZipEntry(videoPath);
+                            zos.putNextEntry(entry2);
+                            while ((len = in.read(buffer)) != -1 ) {
+                                zos.write(buffer, 0, len);
+                            }
+
+                        }
+
+                    }
+
+                    i ++;
                 }
             }
 
@@ -3319,7 +3357,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                 pdfFile = new File(param.getLocalPdfFilePath());
                 FileInputStream fileInputStream = new FileInputStream(pdfFile);
                 in = new BufferedInputStream(fileInputStream);
-                ZipEntry entry = new ZipEntry(rootPath+File.separator+p.getProjectName()+"_"+StringUtil.getRandomUUID()+".pdf");
+                ZipEntry entry = new ZipEntry(rootPath+File.separator+p.getProjectName()+".pdf");
                 zos.putNextEntry(entry);
                 while ((len = in.read(buffer)) != -1 ) {
                     zos.write(buffer, 0, len);
@@ -3351,6 +3389,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
     }
 
+
     @Override
     public void exportProjectReportAndTaskFileById(SimulationManualProjectParam param) {