Forráskód Böngészése

Merge remote-tracking branch 'origin/master'

martin 3 éve
szülő
commit
1e3536294e

+ 3 - 0
api-common/src/main/java/api/common/pojo/param/project/SimulationManualProjectParam.java

@@ -115,5 +115,8 @@ public class SimulationManualProjectParam extends PageVO {
     //是否打包报告pdf
     private Boolean isPagePdf;
 
+    //创建人
+    private String createUserId;
+
 
 }

+ 4 - 0
api-common/src/main/java/api/common/pojo/vo/project/ProjectTaskDetailsVo.java

@@ -3,6 +3,7 @@ package api.common.pojo.vo.project;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -93,5 +94,8 @@ public class ProjectTaskDetailsVo {
     //变化曲线
     private Map CurveData;
 
+    //视频地址
+    private List<String> videoUrl;
+
 
 }

+ 1 - 0
simulation-resource-common/src/main/java/com/css/simulation/resource/common/SimulationResourceCommonApplication.java

@@ -11,6 +11,7 @@ public class SimulationResourceCommonApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(SimulationResourceCommonApplication.class, args);
+        System.out.println("-------------启动成功----------------");
     }
 
 }

+ 12 - 1
simulation-resource-common/src/main/java/com/css/simulation/resource/common/controller/MinioController.java

@@ -118,7 +118,18 @@ public class MinioController {
     }
 
     @RequestMapping("/preview")
-    public ResponseBodyVO<String> preview(@RequestBody @Validated MinioParameter minioParameter) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
+    public void preview(@RequestParam("objectName") String objectName, HttpServletResponse response ) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
+        InputStream inputStream = MinioUtil.downloadToStream(
+                minioClient,
+                bucketName,
+                objectName
+        );
+        String fileName = FileUtil.getFileName(objectName);
+        FileUtil.downloadForHttp(fileName, inputStream, response, 1024);
+    }
+
+    @RequestMapping("/getPreviewUrl")
+    public ResponseBodyVO<String> getPreviewUrl(@RequestBody @Validated MinioParameter minioParameter) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
         String previewUrl = MinioUtil.getPreviewUrl(minioClient, Method.GET, bucketName, minioParameter.getObjectName());
         return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS,"请求成功!", previewUrl);
     }

+ 1 - 0
simulation-resource-common/src/main/java/com/css/simulation/resource/common/util/MinioUtil.java

@@ -76,6 +76,7 @@ public class MinioUtil {
                 .method(method)
                 .bucket(bucket)
                 .object(object)
+                .expiry(3600)
                 .build());
     }
 

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

@@ -9,12 +9,11 @@ import feign.Response;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.http.MediaType;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RequestPart;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.util.List;
+
 
 //@FeignClient(name = "test", url = "http://10.15.12.72:8001",path = "/simulation/resource/common", fallback = FileDownServiceFallback.class, configuration = FeignConfiguration.class)
 @FeignClient(
@@ -32,9 +31,16 @@ public interface FileDownService {
 
     @PostMapping(value = "/minio/uploadProcessBar", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
     ResponseBodyVO<String> uploadProcessBar(@RequestPart("file") MultipartFile file,
-                                  @RequestParam("objectName") String objectName,  @RequestParam("objectPath") String objectPath);
+                                            @RequestParam("objectName") String objectName,
+                                            @RequestParam("objectPath") String objectPath);
 
     @PostMapping("/minio/download")
     Response download(@RequestBody @Validated MinioParameter minioParameter);
 
+    @PostMapping("/minio/list")
+    ResponseBodyVO<List<String>> list( @RequestBody @Validated MinioParameter minioParameter );
+
+    @RequestMapping("/minio/getPreviewUrl")
+    ResponseBodyVO<String> getPreviewUrl(@RequestBody @Validated MinioParameter minioParameter);
+
 }

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

@@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RequestPart;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.util.List;
+
 @Slf4j
 @Service
 public class FileDownServiceFallback implements FileDownService {
@@ -39,4 +41,14 @@ public class FileDownServiceFallback implements FileDownService {
         return null;
     }
 
+    @Override
+    public ResponseBodyVO<List<String>> list(@RequestBody @Validated MinioParameter minioParameter) {
+        return null;
+    }
+
+    @Override
+    public ResponseBodyVO<String> getPreviewUrl(@RequestBody @Validated MinioParameter minioParameter) {
+        return null;
+    }
+
 }

+ 64 - 3
simulation-resource-server/src/main/java/com/css/simulation/resource/project/impl/SimulationProjectServiceImpl.java

@@ -148,6 +148,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
     @Override
     public ResponseBodyVO selectProject(SimulationManualProjectParam param) {
 
+        //当前用户id
+        param.setCreateUserId(AuthUtil.getCurrentUserId());
+
         if(!isEmpty(param.getCreateStartDate())){
             String createStartDate = param.getCreateStartDate();
             Date startDate = getDate(createStartDate + " 00:00:00",1);
@@ -937,6 +940,24 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                 velocity_list.add(d);
             }
 
+            //获取视频预览路径
+            List<String> list1 = new ArrayList<>();
+            String runResultFilePath = po.getRunResultFilePath();
+            MinioParameter minioParameter1 = new MinioParameter();
+            minioParameter1.setObjectName(runResultFilePath);
+            ResponseBodyVO<List<String>> list = fileDownService.list(minioParameter1);
+            List<String> info = list.getInfo();
+            for(String s : info){
+                String substring = s.substring(s.lastIndexOf(".") + 1);
+                if("mp4".equals(substring)){
+                    //mp4视频文件
+                    minioParameter1.setObjectName(s);
+                    ResponseBodyVO<String> preview = fileDownService.getPreviewUrl(minioParameter1);
+                    list1.add(preview.getMessage());
+                }
+
+            }
+
             //任务详情信息
             resultVo.setMileage(lc.toString());
             resultVo.setAverageVelocity(pjsd.toString());
@@ -950,6 +971,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
             resultVo.setSwingSpeedMeanSquareRoot(zchbjsdjfg);
 //            resultVo.setSwingComfortLevel(po.getSwingComfortLevel());
+            resultVo.setVideoUrl(list1);
 
             HashMap<String, List> CurveData = new HashMap<>();
             CurveData.put("time",time_list);
@@ -3244,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);
 
 
@@ -3259,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);
 
                     //任务文件路径
@@ -3286,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 ++;
                 }
             }
 
@@ -3297,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);
@@ -3329,6 +3389,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
     }
 
+
     @Override
     public void exportProjectReportAndTaskFileById(SimulationManualProjectParam param) {
 

+ 14 - 3
simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/MenuCtrl.java

@@ -21,14 +21,25 @@ public class MenuCtrl {
     @Autowired
     MenuService menuService;
 
+    /**
+     * 获取所有菜单树
+     */
+    @RequestMapping("/getMenuTree")
+    @ResponseBody
+    public ResponseBodyVO getMenuTree() {
+        ResponseBodyVO<List<MenuVO>> response = new ResponseBodyVO<List<MenuVO>>(ResponseBodyVO.Response.SUCCESS);
+        response.setInfo(menuService.getMenuTree());
+        return response;
+    }
+
     /**
      * 获取当前登录人的菜单列表
      */
-    @RequestMapping("/getMenus")
+    @RequestMapping("/getMyMenuTree")
     @ResponseBody
-    public ResponseBodyVO getMenus() {
+    public ResponseBodyVO getMyMenuTree() {
         ResponseBodyVO<List<MenuVO>> response = new ResponseBodyVO<List<MenuVO>>(ResponseBodyVO.Response.SUCCESS);
-        response.setInfo(menuService.getMenus());
+        response.setInfo(menuService.getMyMenuTree());
         return response;
     }
 }

+ 3 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/MenuMapper.java

@@ -11,6 +11,8 @@ import java.util.List;
 @Repository
 public interface MenuMapper {
 
-    List<MenuVO> getMenus(@Param("userId") String userId);
+    List<MenuVO> getMyMenuTree(@Param("userId") String userId);
+
+    List<MenuVO> getMenuTree();
 
 }

+ 9 - 3
simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/MenuService.java

@@ -15,11 +15,17 @@ public class MenuService {
     @Autowired
     MenuMapper menuMapper;
 
-    public List<MenuVO> getMenus() {
-        String userId = AuthUtil.getCurrentUserId();
-        List<MenuVO> menus = menuMapper.getMenus(userId);
+    public List<MenuVO> getMenuTree() {
+        List<MenuVO> menus = menuMapper.getMenuTree();
         //List<MenuVO> treeList = ObjectUtil.listToTree(menus, "0", MenuVO::getId, MenuVO::getParentId, MenuVO::getChildren, MenuVO::setChildren);
         List<MenuVO> menuVOS = ObjectUtil.listToTree(menus);//注解方式转tree
         return menuVOS;
     }
+
+    public List<MenuVO> getMyMenuTree() {
+        String userId = AuthUtil.getCurrentUserId();
+        List<MenuVO> menus = menuMapper.getMyMenuTree(userId);
+        List<MenuVO> menuVOS = ObjectUtil.listToTree(menus);//注解方式转tree
+        return menuVOS;
+    }
 }

+ 3 - 0
simulation-resource-server/src/main/resources/mapper/project/SimulationProjectMapper.xml

@@ -161,6 +161,9 @@
             <if test="isDeleted != null and isDeleted != ''">
                 and is_deleted = #{isDeleted,jdbcType=VARCHAR}
             </if>
+            <if test="createUserId != null and createUserId != ''">
+                and create_user_id = #{createUserId,jdbcType=VARCHAR}
+            </if>
         </where>
         order by project_date desc, project_num desc, modify_time desc
     </select>

+ 15 - 1
simulation-resource-server/src/main/resources/mapper/system/MenuMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="com.css.simulation.resource.system.mapper.MenuMapper" >
 
 
-    <select id="getMenus" parameterType="java.lang.String" resultType="api.common.pojo.vo.system.MenuVO">
+    <select id="getMyMenuTree" parameterType="java.lang.String" resultType="api.common.pojo.vo.system.MenuVO">
         select
             m.id,
             m.name,
@@ -19,4 +19,18 @@
         WHERE ur.user_id = #{userId,jdbcType=VARCHAR}
         ORDER BY m.sort
     </select>
+
+    <select id="getMenuTree" parameterType="java.lang.String" resultType="api.common.pojo.vo.system.MenuVO">
+        select
+            m.id,
+            m.name,
+            m.router,
+            m.icon,
+            m.sort,
+            m.parent_id,
+            m.visible
+        FROM system_menu m
+        where m.visible='1' AND m.is_deleted='0'
+        ORDER BY m.sort
+    </select>
 </mapper>