martin 2 år sedan
förälder
incheckning
edb42d5f94

+ 5 - 31
api-common/src/main/java/api/common/pojo/vo/project/SimulationManualProjectVo.java

@@ -1,64 +1,38 @@
 package api.common.pojo.vo.project;
 
 
-import lombok.Getter;
-import lombok.Setter;
+import lombok.*;
 
 import java.util.Date;
 
-@Getter
-@Setter
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
 public class SimulationManualProjectVo {
-
     private String id;
-
     private String projectId;//项目id
-
     private String projectName;//项目名称
-
     private Date createTime;//创建时间
     private String createTimeFmt;//创建时间
-
     private String algorithm;//算法名称
-
     private Long automaticRunTimes;
-
     private Date lastRunTime;
-
     private String lastRunTimeFmt;
-
     private String automaticRunState;
-
     private String nowRunState;//进度(字典)
     private String nowRunStateDict;//进度(字典)
-
     private String evaluationLevel;//评测等级(字典)
     private String evaluationLevelDict;//评测等级(字典)
-
     private Long maxSimulationTime;
-
     private Date startTime;
-
     private String startTimeFmt;
-
     private Date finishTime;
-
     private String finishTimeFmt;
-
     private String scene;//场景测试包id
-
     private String algorithmType;//算法类型
-
     private String vehicle;//车俩配置id
-
     private String projectDescribe; //项目描述
-
     private String parallelism;
-
     private String isChoiceGpu;
-
-
-
-
-
 }

+ 0 - 3
simulation-resource-server/src/main/java/com/css/simulation/resource/project/ctrl/SimulationProjectCtrl.java

@@ -112,9 +112,6 @@ public class SimulationProjectCtrl {
 
     /**
      * 获取任务详情信息
-     *
-     * @param param
-     * @return
      */
     @RequestMapping("selectProjectTaskById")
     @ResponseBody

+ 16 - 30
simulation-resource-server/src/main/java/com/css/simulation/resource/project/impl/SimulationProjectServiceImpl.java

@@ -883,17 +883,20 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
     @Override
     public ResponseBodyVO<ProjectTaskDetailsVo> selectProjectTaskById(SimulationManualProjectParam param) {
+        ProjectTaskDetailsVo resultVo = new ProjectTaskDetailsVo();
+        //1 获取参数
+        Optional.ofNullable(param).orElseThrow(() -> new RuntimeException("参数不能为空"));
+        Optional.ofNullable(param.getId()).orElseThrow(() -> new RuntimeException("项目 id 不能为空"));
+        Optional.ofNullable(param.getTaskId()).orElseThrow(() -> new RuntimeException("任务 id 不能为空"));
+        Optional.ofNullable(param.getTaskId()).orElseThrow(() -> new RuntimeException("projectType 不能为空"));
         String id = param.getId();
         String taskId = param.getTaskId();
-        if (isEmpty(id) || isEmpty(taskId)) {
-            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE);
-        }
-        ProjectTaskDetailsVo resultVo = new ProjectTaskDetailsVo();
-        //基本信息
+        String projectType = param.getProjectType();
+        //2 查询任务信息,手动项目和自动项目共用一个任务表
         ProjectTaskParam projectTaskParam = new ProjectTaskParam();
         projectTaskParam.setPId(id);
         projectTaskParam.setId(taskId);
-        List<ManualProjectTaskPo> pos = simulationProjectTaskMapper.selectprojectTaskByQuery(projectTaskParam);
+        List<ManualProjectTaskPo> pos = simulationProjectTaskMapper.selectProjectTask(projectTaskParam);
         if (isEmpty(pos)) {
             return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "没有获取到任务信息");
         }
@@ -909,24 +912,15 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         resultVo.setFinishState(po.getRunResult());
         resultVo.setSceneDescribe("");
         // -------------------------------- 获取任务得分详情 --------------------------------
-        if (isEmpty(param.getProjectType())) {
-            param.setProjectType("1");//默认
-        }
-        //获取项目基本信息
-        //封装要使用到的数据
         SimulationManualProjectPo poParam = new SimulationManualProjectPo();
-        if ("1".equals(param.getProjectType())) {
+        if (DictConstants.PROJECT_TYPE_MANUAL.equals(projectType)) {
             //项目基本信息
             SimulationManualProjectPo spo = simulationProjectMapper.selectProjectBaseById(param);
-            if (spo == null) {
-                return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "没有获取到数据");
-            }
+            Optional.ofNullable(spo).orElseThrow(() -> new RuntimeException("没有获取到数据。"));
             poParam = spo;
-        } else if ("2".equals(param.getProjectType())) {
+        } else if (DictConstants.PROJECT_TYPE_AUTO_SUB.equals(projectType)) {
             SimulationManualProjectVo spo = simulationAutomaticSubProjectMapper.selectProjectInfo(param);
-            if (spo == null) {
-                return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "没有获取到数据");
-            }
+            Optional.ofNullable(spo).orElseThrow(() -> new RuntimeException("没有获取到数据。"));
             BeanUtils.copyProperties(po, poParam);
         }
         Map<String, Object> stringObjectMap = selectSceneScore(poParam.getScene(), poParam.getId(), taskId);
@@ -1700,16 +1694,12 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
     private Map<String, Object> selectSceneScore(String scenePackageId, String projectId, String taskId) {
 
-        //查询场景包所有数据(包括得分信息)
+        //1 查询指定项目的所有指标得分结果
         SimulationManualProjectParam query = new SimulationManualProjectParam();
         query.setId(projectId);
         query.setPackageId(scenePackageId);
-//        List<SublistScoreVo> pos = simulationProjectMapper.selectSubScore(query);
         List<SublistScoreVo> pos = simulationProjectMapper.selectSubScore2(query);
-
-        HashMap<String, Object> hashMap = new HashMap<>();
-
-        //1 获取项目下所有场景得分
+        //2 查询指定项目的所有任务得分结果
         ProjectTaskParam param = new ProjectTaskParam();
         param.setPId(projectId);
         if (!isEmpty(taskId)) {
@@ -1756,16 +1746,11 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         }
         int size = 0;
         List<List<String>> result = new ArrayList<>();
-        //获取所有指标信息
-/*        SimulationManualProjectParam q = new SimulationManualProjectParam();
-        q.setPackageId(scenePackageId);
-        List<SublistScoreVo> sbs = simulationProjectMapper.selectsublistByRootId(q);*/
         //新增返回状态
         ArrayList<String> runStateList = new ArrayList<>();
         //末级指标
         for (SublistScoreVo sp : lastSubList) {
             setParentSub(sp, null, pos);
-//            setParentSub(sp, null, sbs);
             String sublistName = sp.getSublistName();
             //失败的任务没有数据,需要校验
             Double sceneScore = sp.getSceneScore();
@@ -1841,6 +1826,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         headerList.add(ImmutableMap.builder().put("label", "测试得分").put("prop", "sceneScore").build());
         headerList.add(ImmutableMap.builder().put("label", "指标评价").put("prop", "targetEvaluate").build());
         headerList.add(ImmutableMap.builder().put("label", "得分说明").put("prop", "scoreExplain").build());
+        HashMap<String, Object> hashMap = new HashMap<>();
         hashMap.put("headerList", headerList);
         hashMap.put("result", objects);
         return hashMap;

+ 7 - 5
simulation-resource-server/src/main/java/com/css/simulation/resource/project/mapper/SimulationProjectTaskMapper.java

@@ -2,10 +2,12 @@ package com.css.simulation.resource.project.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.algorithm.AlgorithmPO;
-import api.common.pojo.po.project.*;
-import api.common.pojo.vo.project.*;
+import api.common.pojo.po.project.ManualProjectTaskPo;
+import api.common.pojo.po.project.SimulationMptSceneScorePo;
+import api.common.pojo.vo.project.ManualProjectTaskVo;
+import api.common.pojo.vo.project.ProjectRunResultRatioNumVo;
+import api.common.pojo.vo.project.ProjectRunStateNumVo;
+import api.common.pojo.vo.project.SceneScoreVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.springframework.stereotype.Repository;
 
@@ -16,7 +18,7 @@ import java.util.Map;
 @Repository
 public interface SimulationProjectTaskMapper {
 
-    List<ManualProjectTaskPo> selectprojectTaskByQuery(ProjectTaskParam vo);
+    List<ManualProjectTaskPo> selectProjectTask(ProjectTaskParam vo);
 
     List<ManualProjectTaskVo>  selectProjectTaskByProjectId(ProjectTaskParam vo);
 

+ 17 - 5
simulation-resource-server/src/main/resources/mapper/project/SimulationAutomaticSubProjectMapper.xml

@@ -88,12 +88,24 @@
 
     <!--关联主表查询-->
     <select id="selectProjectInfo" parameterType="api.common.pojo.param.project.SimulationManualProjectParam" resultType="api.common.pojo.vo.project.SimulationManualProjectVo">
-        select s.id, p.scene, s.project_id, p.project_name, p.algorithm, p.algorithm_type,
-        p.vehicle, p.project_describe, s.start_time, s.finish_time, s.now_run_state,
-        p.parallelism, p.max_simulation_time, p.is_choice_gpu, s.evaluation_level
+        select s.id,
+               p.scene,
+               s.project_id,
+               p.project_name,
+               p.algorithm,
+               p.algorithm_type,
+               p.vehicle,
+               p.project_describe,
+               s.start_time,
+               s.finish_time,
+               s.now_run_state,
+               p.parallelism,
+               p.max_simulation_time,
+               p.is_choice_gpu,
+               s.evaluation_level
         from simulation_automatic_subproject s
-        left join simulation_automatic_project p on s.parent_id = p.id
-        where s.id=#{id,jdbcType=VARCHAR}
+                 left join simulation_automatic_project p on s.parent_id = p.id
+        where s.id = #{id,jdbcType=VARCHAR}
     </select>
 
     <!--修改任务运行状态-->

+ 27 - 8
simulation-resource-server/src/main/resources/mapper/project/SimulationProjectMapper.xml

@@ -182,8 +182,17 @@
 
     <!--根据id查询基本信息-->
     <select id="selectProjectBaseById" parameterType="api.common.pojo.param.project.SimulationManualProjectParam" resultType="api.common.pojo.po.project.SimulationManualProjectPo">
-        select id,algorithm,scene,algorithm_score,project_name,project_id,algorithm_type,evaluation_level
-        from simulation_manual_project where id = #{id,jdbcType=VARCHAR} and is_deleted = '0'
+        select id,
+               algorithm,
+               scene,
+               algorithm_score,
+               project_name,
+               project_id,
+               algorithm_type,
+               evaluation_level
+        from simulation_manual_project
+        where is_deleted = '0'
+          and id = #{id,jdbcType=VARCHAR}
     </select>
 
     <!--删除-->
@@ -494,14 +503,24 @@
 
     <!--查询所有指标得分-->
     <select id="selectSubScore2" parameterType="api.common.pojo.param.project.SimulationManualProjectParam" resultType="api.common.pojo.vo.project.SublistScoreVo">
-        select sub.sublist_id as id, sub.parent_id, sub.sublist_name,sub.scene_num,
-        fir.score as firScore,las.score as lasScore, sub.package_and_rules, las.not_standard_scene_num, las.score_explain,
-        fir.target as firTarget, las.target as lasTarget
+        select sub.sublist_id as id,
+               sub.parent_id,
+               sub.sublist_name,
+               sub.scene_num,
+               fir.score      as firScore,
+               las.score      as lasScore,
+               sub.package_and_rules,
+               las.not_standard_scene_num,
+               las.score_explain,
+               fir.target     as firTarget,
+               las.target     as lasTarget
         from scene_package_sublist sub
-				left JOIN simulation_mpt_first_target_score fir on fir.target=sub.sublist_id and fir.p_id=#{id,jdbcType=VARCHAR}
-				left JOIN simulation_mpt_last_target_score las on las.target = sub.sublist_id and las.p_id=#{id,jdbcType=VARCHAR}
+                 left join simulation_mpt_first_target_score fir
+                           on fir.target = sub.sublist_id and fir.p_id = #{id,jdbcType=VARCHAR}
+                 left join simulation_mpt_last_target_score las
+                           on las.target = sub.sublist_id and las.p_id = #{id,jdbcType=VARCHAR}
         where sub.root_id = #{packageId,jdbcType=VARCHAR}
-		order by sub.seq
+        order by sub.seq
     </select>
 
     <!--运行项目状态-->

+ 102 - 41
simulation-resource-server/src/main/resources/mapper/project/SimulationProjectTaskMapper.xml

@@ -1,11 +1,52 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
-<mapper namespace="com.css.simulation.resource.project.mapper.SimulationProjectTaskMapper" >
+<mapper namespace="com.css.simulation.resource.project.mapper.SimulationProjectTaskMapper">
 
 
     <!--查询任务列表-->
-    <select id="selectprojectTaskByQuery" parameterType="api.common.pojo.param.project.ProjectTaskParam" resultType="api.common.pojo.po.project.ManualProjectTaskPo">
-        select *
+    <select id="selectProjectTask" parameterType="api.common.pojo.param.project.ProjectTaskParam"
+            resultType="api.common.pojo.po.project.ManualProjectTaskPo">
+        select id,
+        p_id,
+        last_targer_id,
+        scene_id,
+        scene_name,
+        scene_type,
+        run_start_time,
+        run_end_time,
+        run_state,
+        run_result,
+        run_result_file_path,
+        score,
+        target_evaluate,
+        return_scene_id,
+        score_explain,
+        mileage,
+        average_velocity,
+        maximun_speed,
+        minimun_velocity,
+        maximum_acceleration,
+        maximum_deceleration,
+        maximum_swingSpeed,
+        speed_variance,
+        speed_comfort_level,
+        swing_speed_mean_square_root,
+        swing_comfort_level,
+        acceleration,
+        lane_offset,
+        brake,
+        steeting_wheel,
+        throttle,
+        yaw_rate,
+        velocity,
+        other_curve,
+        timer_shaft,
+        create_time,
+        create_user_id,
+        modify_time,
+        modify_user_id,
+        is_deleted,
+        retry_count
         from simulation_manual_project_task
         <where>
             is_deleted = '0'
@@ -21,7 +62,8 @@
         </where>
     </select>
     <!--根据项目id查询任务列表-->
-    <select id="selectProjectTaskByProjectId" parameterType="api.common.pojo.param.project.ProjectTaskParam" resultType="api.common.pojo.vo.project.ManualProjectTaskVo">
+    <select id="selectProjectTaskByProjectId" parameterType="api.common.pojo.param.project.ProjectTaskParam"
+            resultType="api.common.pojo.vo.project.ManualProjectTaskVo">
         select id,
         p_id,
         last_targer_id,
@@ -72,33 +114,43 @@
     </select>
 
     <!--根据项目id查询任务列表总数-->
-    <select id="selectProjectTaskNumByProjectId" parameterType="api.common.pojo.param.project.ProjectTaskParam" resultType="int">
+    <select id="selectProjectTaskNumByProjectId" parameterType="api.common.pojo.param.project.ProjectTaskParam"
+            resultType="int">
         select count(*) as num
         from simulation_manual_project_task
-        where is_deleted = '0' and p_id = #{pId,jdbcType=VARCHAR}
+        where is_deleted = '0'
+          and p_id = #{pId,jdbcType=VARCHAR}
     </select>
 
     <!--根据任务运行状态分组查询统计数量-->
-    <select id="selectRunStateCount" parameterType="string" resultType="api.common.pojo.vo.project.ProjectRunStateNumVo">
+    <select id="selectRunStateCount" parameterType="string"
+            resultType="api.common.pojo.vo.project.ProjectRunStateNumVo">
         select run_state as stateName, count(*) as num
         from simulation_manual_project_task
-        where p_id = #{id,jdbcType=VARCHAR} and is_deleted = '0'
+        where p_id = #{id,jdbcType=VARCHAR}
+          and is_deleted = '0'
         group by run_state
     </select>
 
     <!--根据任务运行状态分组查询统计数量-->
-    <select id="selectRunResultCount" parameterType="string" resultType="api.common.pojo.vo.project.ProjectRunResultRatioNumVo">
+    <select id="selectRunResultCount" parameterType="string"
+            resultType="api.common.pojo.vo.project.ProjectRunResultRatioNumVo">
         select run_result as resultName, count(*) as num
         from simulation_manual_project_task
-        where p_id = #{id,jdbcType=VARCHAR} and is_deleted = '0' and run_result is not null and run_result != ""
+        where p_id = #{id,jdbcType=VARCHAR}
+          and is_deleted = '0'
+          and run_result is not null
+          and run_result != ""
         group by run_result
     </select>
 
     <!--任务得分统计分组-->
-    <select id="selectScoreCount" parameterType="string" resultType="api.common.pojo.vo.project.ProjectRunResultRatioNumVo">
+    <select id="selectScoreCount" parameterType="string"
+            resultType="api.common.pojo.vo.project.ProjectRunResultRatioNumVo">
         select score as resultName, count(*) as num
         from simulation_manual_project_task
-        where p_id = #{id,jdbcType=VARCHAR} and is_deleted = '0'
+        where p_id = #{id,jdbcType=VARCHAR}
+          and is_deleted = '0'
         group by score
     </select>
 
@@ -114,18 +166,21 @@
     </select>
 
     <!--查询场景不等于0的得分的数量-->
-    <select id="selectSceneScoreNumQuery" parameterType="api.common.pojo.po.project.SimulationMptSceneScorePo" resultType="api.common.pojo.vo.project.SceneScoreVo">
+    <select id="selectSceneScoreNumQuery" parameterType="api.common.pojo.po.project.SimulationMptSceneScorePo"
+            resultType="api.common.pojo.vo.project.SceneScoreVo">
         select count(*) as num
         from simulation_manual_project_task
-        where p_id = #{pId,jdbcType=VARCHAR} and last_targer_id = #{lastTargerId}
-        and score != 0 and is_deleted = '0'
+        where p_id = #{pId,jdbcType=VARCHAR}
+          and last_targer_id = #{lastTargerId}
+          and score != 0 and is_deleted = '0'
     </select>
 
     <!--批量查询场景得分-->
-    <select id="selectSceneScoreByIds" parameterType="api.common.pojo.param.project.SceneScoreParam" resultType="api.common.pojo.vo.project.SceneScoreVo">
+    <select id="selectSceneScoreByIds" parameterType="api.common.pojo.param.project.SceneScoreParam"
+            resultType="api.common.pojo.vo.project.SceneScoreVo">
         select id, scene_id, scene_type,score, target_evaluate, return_scene_id, score_explain
         from simulation_manual_project_task
-        where p_id = #{pId,jdbcType=VARCHAR} and  scene_type = #{sceneType,jdbcType=VARCHAR}
+        where p_id = #{pId,jdbcType=VARCHAR} and scene_type = #{sceneType,jdbcType=VARCHAR}
         and last_targer_id = #{lastTargerId,jdbcType=VARCHAR} and is_deleted = '0'
         and scene_id in
         <foreach collection="sceneIds" open="(" separator="," close=")" item="id">
@@ -136,40 +191,46 @@
     <!--更新仿真结果到数据库-->
     <update id="updateTaksResult" parameterType="api.common.pojo.po.project.ManualProjectTaskPo">
         update simulation_manual_project_task
-        set
-        mileage = #{mileage, jdbcType=VARCHAR},
-        average_velocity = #{averageVelocity, jdbcType=VARCHAR},
-        maximun_speed = #{maximunSpeed, jdbcType=VARCHAR},
-        minimun_velocity = #{minimunVelocity, jdbcType=VARCHAR},
-        maximum_acceleration = #{maximumAcceleration, jdbcType=VARCHAR},
-        maximum_deceleration = #{maximumDeceleration, jdbcType=VARCHAR},
-        maximum_swingSpeed = #{maximumSwingSpeed, jdbcType=VARCHAR},
-        speed_variance = #{speedVariance, jdbcType=VARCHAR},
-        swing_speed_mean_square_root = #{swingSpeedMeanSquareRoot, jdbcType=VARCHAR},
-        acceleration = #{acceleration, jdbcType=LONGVARCHAR},
-        lane_offset = #{laneOffset, jdbcType=LONGVARCHAR},
-        brake = #{brake, jdbcType=LONGVARCHAR},
-        steeting_wheel = #{steetingWheel, jdbcType=LONGVARCHAR},
-        throttle =  #{throttle, jdbcType=LONGVARCHAR},
-        yaw_rate = #{yawRate, jdbcType=LONGVARCHAR},
-        velocity = #{velocity, jdbcType=LONGVARCHAR},
-        other_curve = #{otherCurve, jdbcType=LONGVARCHAR},
-        timer_shaft = #{timerShaft, jdbcType=LONGVARCHAR}
-        where id = #{id, jdbcType=VARCHAR} and p_id = #{pId, jdbcType=VARCHAR} and is_deleted = '0'
+        set mileage                      = #{mileage, jdbcType=VARCHAR},
+            average_velocity             = #{averageVelocity, jdbcType=VARCHAR},
+            maximun_speed                = #{maximunSpeed, jdbcType=VARCHAR},
+            minimun_velocity             = #{minimunVelocity, jdbcType=VARCHAR},
+            maximum_acceleration         = #{maximumAcceleration, jdbcType=VARCHAR},
+            maximum_deceleration         = #{maximumDeceleration, jdbcType=VARCHAR},
+            maximum_swingSpeed           = #{maximumSwingSpeed, jdbcType=VARCHAR},
+            speed_variance               = #{speedVariance, jdbcType=VARCHAR},
+            swing_speed_mean_square_root = #{swingSpeedMeanSquareRoot, jdbcType=VARCHAR},
+            acceleration                 = #{acceleration, jdbcType=LONGVARCHAR},
+            lane_offset                  = #{laneOffset, jdbcType=LONGVARCHAR},
+            brake                        = #{brake, jdbcType=LONGVARCHAR},
+            steeting_wheel               = #{steetingWheel, jdbcType=LONGVARCHAR},
+            throttle                     = #{throttle, jdbcType=LONGVARCHAR},
+            yaw_rate                     = #{yawRate, jdbcType=LONGVARCHAR},
+            velocity                     = #{velocity, jdbcType=LONGVARCHAR},
+            other_curve                  = #{otherCurve, jdbcType=LONGVARCHAR},
+            timer_shaft                  = #{timerShaft, jdbcType=LONGVARCHAR}
+        where id = #{id, jdbcType=VARCHAR}
+          and p_id = #{pId, jdbcType=VARCHAR}
+          and is_deleted = '0'
 
     </update>
 
 
     <!--查询Aborted的数量-->
-    <select id="selectRunStateByAborted" parameterType="api.common.pojo.po.project.SimulationMptSceneScorePo" resultType="api.common.pojo.vo.project.SceneScoreVo">
+    <select id="selectRunStateByAborted" parameterType="api.common.pojo.po.project.SimulationMptSceneScorePo"
+            resultType="api.common.pojo.vo.project.SceneScoreVo">
         select count(*) as num
         from simulation_manual_project_task
         where p_id = #{pId,jdbcType=VARCHAR}
-        and run_state = 'Aborted' and is_deleted = '0'
+          and run_state = 'Aborted'
+          and is_deleted = '0'
     </select>
 
-    <select id="selectProjectTaskById" parameterType="string" resultType="api.common.pojo.vo.project.ManualProjectTaskVo">
-        select * from simulation_manual_project_task where id=#{id}
+    <select id="selectProjectTaskById" parameterType="string"
+            resultType="api.common.pojo.vo.project.ManualProjectTaskVo">
+        select *
+        from simulation_manual_project_task
+        where id = #{id}
     </select>