LingxinMeng 2 жил өмнө
parent
commit
85925b5dc1
13 өөрчлөгдсөн 262 нэмэгдсэн , 74 устгасан
  1. 6 0
      api-common/src/main/java/api/common/pojo/vo/project/ProjectReportVO.java
  2. 18 0
      api-common/src/main/java/api/common/pojo/vo/project/ProjectResultWithAlgorithmVO.java
  3. 69 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/api/controller/job_manage/AlgorithmPlatformResultController.java
  4. 0 55
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/api/controller/job_manage/ReportController.java
  5. 14 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/api/parameter/ProjectParam.java
  6. 1 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/application/SimulationProjectService.java
  7. 2 6
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/application/impl/SimulationProjectServiceImpl.java
  8. 15 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/application/job_manage/JobManageApplication.java
  9. 50 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/application/job_manage/impl/JobManageApplicationImpl.java
  10. 64 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/domain/ProjectDomain.java
  11. 1 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/infrastructure/mysql/mapper/SimulationProjectMapper.java
  12. 6 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/server/infrastructure/mysql/mapper/SimulationProjectTaskMapper.java
  13. 16 10
      simulation-resource-server/src/main/resources/mapper/project/SimulationProjectMapper.xml

+ 6 - 0
api-common/src/main/java/api/common/pojo/vo/project/ProjectReportVO.java

@@ -1,6 +1,9 @@
 package api.common.pojo.vo.project;
 
+import lombok.AllArgsConstructor;
+import lombok.Builder;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import java.util.List;
 import java.util.Map;
@@ -9,6 +12,9 @@ import java.util.Map;
  * 工作报告
  */
 @Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
 public class ProjectReportVO {
     private String projectName; //项目名称
     private String projectId; //项目id

+ 18 - 0
api-common/src/main/java/api/common/pojo/vo/project/ProjectResultWithAlgorithmVO.java

@@ -0,0 +1,18 @@
+package api.common.pojo.vo.project;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class ProjectResultWithAlgorithmVO {
+    private String algorithmId;
+    private ProjectReportVO report;
+    private List<String> videos;
+}

+ 69 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/server/api/controller/job_manage/AlgorithmPlatformResultController.java

@@ -0,0 +1,69 @@
+package com.css.simulation.resource.server.api.controller.job_manage;
+
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.vo.project.ProjectReportVO;
+import api.common.pojo.vo.project.ProjectResultWithAlgorithmVO;
+import api.common.util.StringUtil;
+import com.css.simulation.resource.server.api.parameter.ProjectParam;
+import com.css.simulation.resource.server.application.job_manage.JobManageApplication;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 供算法平台使用
+ */
+@RestController
+@RequestMapping("/report")
+public class AlgorithmPlatformResultController {
+
+
+    @Resource
+    private JobManageApplication jobManageApplication;
+
+
+    /**
+     * 根据算法ID获取该算法最新执行的项目的报告
+     * 获取测试报告详情
+     */
+    @RequestMapping("/getSimulationReportById")
+    public ResponseBodyVO<List<ProjectResultWithAlgorithmVO>> getProjectReportByAlgorithmId(@RequestBody ProjectParam projectParam) {
+
+        if (projectParam == null || StringUtil.isEmpty(projectParam.getAlgorithmId())) {
+            return new ResponseBodyVO<>(false, 500, "参数必传!", null);
+        }
+        List<ProjectResultWithAlgorithmVO> result = new ArrayList<>();
+        String algorithmIds = projectParam.getAlgorithmId();
+        String[] algorithmIdArray = algorithmIds.split(",");
+        for (String algorithmId : algorithmIdArray) {
+            result.add(ProjectResultWithAlgorithmVO.builder()
+                    .algorithmId(algorithmId)
+                    .report(jobManageApplication.getLastProjectReportByAlgorithmId(algorithmId))
+                    .videos(jobManageApplication.getLastVideoListByAlgorithmId(algorithmId))
+                    .build());
+        }
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, result);
+    }
+
+    /**
+     * (未使用)
+     * 根据算法ID获取该算法最新执行的项目的报告
+     * 获取测试报告详情
+     */
+    @RequestMapping("/getProjectReportByOneAlgorithmId")
+    public ResponseBodyVO<ProjectReportVO> getProjectReportByOneAlgorithmId(@RequestBody ProjectParam projectParam) {
+
+        if (projectParam == null || StringUtil.isEmpty(projectParam.getAlgorithmId())) {
+            return new ResponseBodyVO<>(false, 500, "参数必传!", null);
+        }
+        String algorithmId = projectParam.getAlgorithmId();
+        ProjectReportVO projectReportVO = jobManageApplication.getLastProjectReportByAlgorithmId(algorithmId);
+
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, projectReportVO);
+    }
+
+}

+ 0 - 55
simulation-resource-server/src/main/java/com/css/simulation/resource/server/api/controller/job_manage/ReportController.java

@@ -1,55 +0,0 @@
-package com.css.simulation.resource.server.api.controller.job_manage;
-
-import api.common.pojo.common.ResponseBodyVO;
-import api.common.pojo.param.project.SimulationManualProjectParam;
-import api.common.pojo.vo.project.ProjectReportVO;
-import api.common.util.ObjectUtil;
-import api.common.util.StringUtil;
-import com.css.simulation.resource.server.application.SimulationProjectService;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.Map;
-
-/**
- * 供算法平台使用
- */
-@RestController
-@RequestMapping("/report")
-public class ReportController {
-
-
-    @Resource
-    private SimulationProjectService simulationProjectService;
-
-
-    /**
-     * 获取测试报告详情
-     *
-     */
-    @RequestMapping("/getSimulationReportById")
-    public ResponseBodyVO<ProjectReportVO> getSimulationReportById(@RequestBody Map<String, String> paramMap) {
-        if (ObjectUtil.isNull(paramMap) || ObjectUtil.isNull(paramMap.get("algorithmId"))) {
-            return new ResponseBodyVO(false, 500, "参数必传!", null);
-        }
-
-        //获取最新的报告id
-        String projectId = simulationProjectService.selectProjectReportIdByAlgorithmId(paramMap.get("algorithmId"));
-        if (StringUtil.isEmpty(projectId)) {
-            return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "报告不存在");
-        }
-
-        //获取报告详情
-        SimulationManualProjectParam projectParam = new SimulationManualProjectParam();
-        projectParam.setId(projectId);
-        //TODO 此处需要添加项目类型,通过项目ID判断
-        ResponseBodyVO<ProjectReportVO> vo = simulationProjectService.selectProjectReportById(projectParam);
-
-        //ProjectReportVo reportVo = reportService.getSimulationReportById(paramMap);
-        ResponseBodyVO<ProjectReportVO> response = new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
-        response.setInfo(vo.getInfo());
-        return response;
-    }
-}

+ 14 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/server/api/parameter/ProjectParam.java

@@ -0,0 +1,14 @@
+package com.css.simulation.resource.server.api.parameter;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class ProjectParam {
+    private String algorithmId;
+}

+ 1 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/server/application/SimulationProjectService.java

@@ -49,7 +49,7 @@ public interface SimulationProjectService {
 
   void exportProjectReport(SimulationManualProjectParam param);
 
-  String selectProjectReportIdByAlgorithmId(String algorithmId);
+  String selectLastProjectIdByAlgorithmId(String algorithmId);
 
   ResponseBodyVO<String> saveEvaluationLevel(String id);
 

+ 2 - 6
simulation-resource-server/src/main/java/com/css/simulation/resource/server/application/impl/SimulationProjectServiceImpl.java

@@ -4004,12 +4004,8 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
     }
 
     @Override
-    public String selectProjectReportIdByAlgorithmId(String algorithmId) {
-        SimulationManualProjectPO po = simulationProjectMapper.selectProjectReportIdByAlgorithmId(algorithmId);
-        if (StringUtil.isNotEmpty(po)) {
-            return po.getId();
-        }
-        return null;
+    public String selectLastProjectIdByAlgorithmId(String algorithmId) {
+        return  simulationProjectMapper.selectLastProjectIdByAlgorithmId(algorithmId);
     }
 
     @Override

+ 15 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/server/application/job_manage/JobManageApplication.java

@@ -0,0 +1,15 @@
+package com.css.simulation.resource.server.application.job_manage;
+
+
+import api.common.pojo.param.project.SimulationManualProjectParam;
+import api.common.pojo.vo.project.ProjectReportVO;
+
+import java.util.List;
+
+public interface JobManageApplication {
+
+    ProjectReportVO getLastProjectReportByAlgorithmId(String  algorithmId);
+
+
+    List<String> getLastVideoListByAlgorithmId(String algorithmId);
+}

+ 50 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/server/application/job_manage/impl/JobManageApplicationImpl.java

@@ -0,0 +1,50 @@
+package com.css.simulation.resource.server.application.job_manage.impl;
+
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.param.project.SimulationManualProjectParam;
+import api.common.pojo.vo.project.ProjectReportVO;
+import api.common.util.StringUtil;
+import com.css.simulation.resource.server.application.SimulationProjectService;
+import com.css.simulation.resource.server.application.job_manage.JobManageApplication;
+import com.css.simulation.resource.server.domain.ProjectDomain;
+import org.jvnet.hk2.annotations.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service
+public class JobManageApplicationImpl implements JobManageApplication {
+
+    @Resource
+    private ProjectDomain projectDomain;
+
+    @Override
+    public ProjectReportVO getLastProjectReportByAlgorithmId(String algorithmId) {
+        //1 获取最新的项目ID
+        String projectId = projectDomain.getLastProjectIdByAlgorithmId(algorithmId);
+        if (StringUtil.isEmpty(projectId)) {
+            throw new RuntimeException("该算法还未执行过项目。");
+        }
+        String projectType = projectDomain.getProjectTypeByProjectId(projectId);
+
+        //2 获取报告详情
+        return projectDomain.getProjectReport(SimulationManualProjectParam.builder()
+                .id(projectId)
+                .projectType(projectType)
+                .build());
+    }
+
+    @Override
+    public List<String> getLastVideoListByAlgorithmId(String algorithmId) {
+        String projectId = projectDomain.getLastProjectIdByAlgorithmId(algorithmId);
+        if (StringUtil.isEmpty(projectId)) {
+            throw new RuntimeException("该算法还未执行过项目。");
+        }
+        String projectType = projectDomain.getProjectTypeByProjectId(projectId);
+        return projectDomain.getVideoList(SimulationManualProjectParam.builder()
+                .id(projectId)
+                .projectType(projectType)
+                .build());
+    }
+
+}

+ 64 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/server/domain/ProjectDomain.java

@@ -0,0 +1,64 @@
+package com.css.simulation.resource.server.domain;
+
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.DictConstants;
+import api.common.pojo.param.MinioParameter;
+import api.common.pojo.param.project.SimulationManualProjectParam;
+import api.common.pojo.po.project.SimulationManualProjectPO;
+import api.common.pojo.vo.project.ProjectReportVO;
+import com.css.simulation.resource.server.acl.feign.FileDownService;
+import com.css.simulation.resource.server.application.SimulationProjectService;
+import com.css.simulation.resource.server.infrastructure.mysql.mapper.SimulationAutomaticSubProjectMapper;
+import com.css.simulation.resource.server.infrastructure.mysql.mapper.SimulationProjectMapper;
+import com.css.simulation.resource.server.infrastructure.mysql.mapper.SimulationProjectTaskMapper;
+import org.jvnet.hk2.annotations.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class ProjectDomain {
+
+    @Resource
+    private SimulationProjectService simulationProjectService;
+    @Resource
+    private SimulationProjectMapper simulationProjectMapper;
+    @Resource
+    private SimulationProjectTaskMapper simulationProjectTaskMapper;
+    @Resource
+    private FileDownService fileDownService;
+
+    public String getLastProjectIdByAlgorithmId(String algorithmId) {
+        return simulationProjectService.selectLastProjectIdByAlgorithmId(algorithmId);
+    }
+
+    public String getProjectTypeByProjectId(String projectId) {
+        SimulationManualProjectPO simulationManualProjectPO = simulationProjectMapper.selectProjectById(SimulationManualProjectParam.builder().id(projectId).build());
+        if (simulationManualProjectPO != null) {
+            return DictConstants.PROJECT_TYPE_MANUAL;
+        } else {
+            return DictConstants.PROJECT_TYPE_AUTO_SUB;
+        }
+    }
+
+    public ProjectReportVO getProjectReport(SimulationManualProjectParam simulationManualProjectParam) {
+        ResponseBodyVO<ProjectReportVO> vo = simulationProjectService.selectProjectReportById(simulationManualProjectParam);
+        return vo.getInfo();
+    }
+
+    public List<String> getVideoList(SimulationManualProjectParam simulationManualProjectParam) {
+        List<String> videoList = new ArrayList<>();
+        List<String> runResultPaths = simulationProjectTaskMapper.selectRunResultPathByProjectId(simulationManualProjectParam);
+        for (String runResultPath : runResultPaths) {
+            ResponseBodyVO<List<String>> list = fileDownService.list(MinioParameter.builder().objectName(runResultPath).build());
+            List<String> info = list.getInfo();
+            for (String s : info) {
+                if (s.contains(".mp4")) {
+                    videoList.add(s);
+                }
+            }
+        }
+        return videoList;
+    }
+}

+ 1 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/server/infrastructure/mysql/mapper/SimulationProjectMapper.java

@@ -132,7 +132,7 @@ public interface SimulationProjectMapper {
 
     AlgorithmPO selectAlgorithmByQuery(AlgorithmPO po);
 
-    SimulationManualProjectPO selectProjectReportIdByAlgorithmId(String algorithmId);
+    String selectLastProjectIdByAlgorithmId(String algorithmId);
 
     @Update("update simulation_manual_project\n" +
             "set details = #{details},now_run_state = #{nowRunState}\n" +

+ 6 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/server/infrastructure/mysql/mapper/SimulationProjectTaskMapper.java

@@ -2,6 +2,7 @@ package com.css.simulation.resource.server.infrastructure.mysql.mapper;
 
 import api.common.pojo.param.project.ProjectTaskParam;
 import api.common.pojo.param.project.SceneScoreParam;
+import api.common.pojo.param.project.SimulationManualProjectParam;
 import api.common.pojo.po.project.ManualProjectTaskPO;
 import api.common.pojo.po.project.SimulationMptSceneScorePO;
 import api.common.pojo.vo.project.ManualProjectTaskVo;
@@ -74,5 +75,9 @@ public interface SimulationProjectTaskMapper {
             ";")
     int selectTaskNumberOfCarsim();
 
-
+    @Select("select run_result_file_path\n" +
+            "from simulation_manual_project_task\n" +
+            "where is_deleted = '0'\n" +
+            "  and p_id = #{id}\n")
+    List<String> selectRunResultPathByProjectId(SimulationManualProjectParam simulationManualProjectParam);
 }

+ 16 - 10
simulation-resource-server/src/main/resources/mapper/project/SimulationProjectMapper.xml

@@ -96,8 +96,7 @@
         from simulation_manual_project
         where project_date = #{nowRq,jdbcType=INTEGER}
           and is_deleted = '0'
-        order by project_date desc, project_num desc
-        limit 1
+        order by project_date desc, project_num desc limit 1
     </select>
 
     <!--查询项目列表-->
@@ -678,15 +677,22 @@
     </select>
 
     <!--根据算法id获取最新的一条报告id-->
-    <select id="selectProjectReportIdByAlgorithmId" parameterType="string"
-            resultType="api.common.pojo.po.project.SimulationManualProjectPO">
+    <select id="selectLastProjectIdByAlgorithmId" resultType="java.lang.String">
         select id
-        from simulation_manual_project
-        where algorithm = #{algorithmId}
-          and is_deleted = '0'
-          and now_run_state = '30'
-        order by finish_time desc
-        limit 1
+        from (select id, finish_time
+              from simulation_manual_project
+              where algorithm = #{algorithmId}
+                and is_deleted = '0'
+                and now_run_state = '30'
+              union all
+              select sas.id, sas.finish_time
+              from simulation_automatic_subproject sas
+                       left join simulation_automatic_project sap on sas.parent_id = sap.id
+              where algorithm = #{algorithmId}
+                and sas.is_deleted = '0'
+                and sap.is_deleted = '0'
+                and now_run_state = '30') temp
+        order by finish_time desc limit 1
     </select>
 
     <!--获取算法基本信息 /*where a.share = '0' and a.is_deleted = '0'*/-->