瀏覽代碼

王耀栋--新增需求开发,bug修改

wangyaodong 3 年之前
父節點
當前提交
c9628a8a9c

+ 2 - 0
api-common/src/main/java/api/common/pojo/param/project/ProjectTaskParam.java

@@ -15,4 +15,6 @@ public class ProjectTaskParam {
     private String pId;
 
     private String sceneId;
+
+    private String taskId;
 }

+ 5 - 0
api-common/src/main/java/api/common/pojo/vo/project/ProjectDetailsVo.java

@@ -75,6 +75,9 @@ public class ProjectDetailsVo {
     //运行结果统计
     private List<ProjectRunResultRatioNumVo> resultList;
 
+    //运行得分统计
+    private List<ProjectRunResultRatioNumVo> resultScoreList;
+
     //并行度
     private String parallelism;
 
@@ -90,5 +93,7 @@ public class ProjectDetailsVo {
     //场景包名
     private String packageName;
 
+    //算法测试得分
+    private List<AlgorithmScoreVo> algorithmScoreList;
 
 }

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

@@ -97,5 +97,9 @@ public class ProjectTaskDetailsVo {
     //视频地址
     private List<String> videoUrl;
 
+    private List<Map> sceneScoreLiTitle;
+
+    private List<SceneScListVo> sceneScoreLi;
+
 
 }

+ 9 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/project/ctrl/SimulationProjectCtrl.java

@@ -4,6 +4,7 @@ import api.common.pojo.common.ResponseBodyVO;
 import api.common.pojo.param.project.DictParam;
 import api.common.pojo.param.project.SimulationManualProjectParam;
 import com.css.simulation.resource.project.service.SimulationProjectService;
+import com.css.simulation.resource.system.service.ClusterService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
@@ -18,6 +19,9 @@ public class SimulationProjectCtrl {
     @Autowired
     private SimulationProjectService service;
 
+    @Autowired
+    private ClusterService clusterService;
+
 
     /**
      * 创建/修改工作
@@ -123,7 +127,11 @@ public class SimulationProjectCtrl {
     @RequestMapping("selectMaxParallelism")
     @ResponseBody
     public ResponseBodyVO selectMaxParallelism(){
-        return service.selectMaxParallelism();
+
+        Integer licenseNum = clusterService.getLicenseNum();
+
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,null,licenseNum);
+//        return service.selectMaxParallelism();
     }
 
     /**

+ 138 - 6
simulation-resource-server/src/main/java/com/css/simulation/resource/project/impl/SimulationProjectServiceImpl.java

@@ -404,6 +404,11 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         //算法配置
         AlgorithmPO algorithmBaseInfoVo = getAlgorithmInfo(poParam);
 
+
+        //获取测试得分列表
+        List<AlgorithmScoreVo> firstTargetScore = getFirstTargetScore(param.getId());
+        projectDetailsVo.setAlgorithmScoreList(firstTargetScore);
+
         //车辆配置
         VehiclePO vehicleBaseInfoVo = null;
         String vehicleConfigId = poParam.getVehicle();
@@ -469,15 +474,21 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
         //任务运行状态统计
         List<ProjectRunStateNumVo> projectRunStateNumVos = null;
+
+        //任务运行结果统计
+        List<ProjectRunResultRatioNumVo> resultScoreList = null;
+
         Integer size = simulationProjectTaskMapper.selectProjectTaskNumByProjectId(projectTaskParam);
         if(size > 0){
             projectRunStateNumVos = simulationProjectTaskMapper.selectRunStateCount(poParam.getId());
             taskRunState(projectRunStateNumVos, size);
 
-
             projectRunResultRatioNumVos = simulationProjectTaskMapper.selectRunResultCount(poParam.getId());
             taskResultState(projectRunResultRatioNumVos, size);
 
+            resultScoreList = simulationProjectTaskMapper.selectScoreCount(poParam.getId());
+            taskScore(resultScoreList,size);
+
         }
 
         projectDetailsVo.setProjectId(poParam.getProjectId());
@@ -506,6 +517,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         projectDetailsVo.setSensorGpsList(sensorGpsList);
         projectDetailsVo.setStateList(projectRunStateNumVos);
         projectDetailsVo.setResultList(projectRunResultRatioNumVos);
+        projectDetailsVo.setResultScoreList(resultScoreList);
 
         projectDetailsVo.setParallelism(poParam.getParallelism());
         projectDetailsVo.setMaxSimulationTime(poParam.getMaxSimulationTime());
@@ -596,6 +608,18 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         }
     }
 
+    /**
+     * 得分统计
+     */
+    private void taskScore(List<ProjectRunResultRatioNumVo> vos,Integer size){
+        for(ProjectRunResultRatioNumVo rv : vos){
+            Integer num = rv.getNum();
+            Double d = (double)num/size;
+            d = saveTwoDecimalPlaces(d);
+            rv.setRatio(d);
+        }
+    }
+
     private void setVehicleConfig(SensorBaseInfoVo vo, ConfigSensorPO vs){
         vo.setConfigId(vs.getConfigId());
         vo.setSensorId(vs.getSensorId());
@@ -800,7 +824,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
         //场景得分列表
 //        Map<String, Object> maps = selectSceneScore(pos, po.getId());
-        Map<String, Object> maps = selectSceneScore(poParam.getScene(), poParam.getId());
+        Map<String, Object> maps = selectSceneScore(poParam.getScene(), poParam.getId(), null);
         projectReportVo.setSceneScoreLiTitle((List<Map>) maps.get("cloums"));
         projectReportVo.setSceneScoreLi((List<SceneScListVo>) maps.get("result"));
 
@@ -883,6 +907,40 @@ 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())){
+            //项目基本信息
+            SimulationManualProjectPo spo = simulationProjectMapper.selectProjectBaseById(param);
+            if(spo == null){
+                return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "没有获取到数据");
+            }
+            poParam = spo;
+        }else if("2".equals(param.getProjectType())){
+            SimulationManualProjectVo spo = simulationAutomaticSubProjectMapper.selectProjectInfo(param);
+            if(spo == null){
+                return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "没有获取到数据");
+            }
+
+            BeanUtils.copyProperties(po, poParam);
+
+        }
+
+        Map<String, Object> stringObjectMap = selectSceneScore(poParam.getScene(), poParam.getId(), taskId);
+        resultVo.setSceneScoreLiTitle((List<Map>) stringObjectMap.get("cloums"));
+        resultVo.setSceneScoreLi((List<SceneScListVo>) stringObjectMap.get("result"));
+
 
         //1.获取仿真结果文件
         InputStream fileInputStream = null;
@@ -1094,7 +1152,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                 Double aDouble = lateral_velocity_list.get(i);
                 Double aDouble1 = longitudinal_velocity_list.get(i);
                 Double d = Math.pow(aDouble,2)+Math.pow(aDouble1,2);
-                velocity_list.add(Math.sqrt(d));
+                velocity_list.add(Math.sqrt(d)*3.6);
             }
 
             //获取视频预览路径
@@ -1117,7 +1175,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
 
             //任务详情信息
             resultVo.setMileage(lc.toString());
-            resultVo.setAverageVelocity(pjsd.toString());
+            resultVo.setAverageVelocity(saveTwoDecimalPlaces(pjsd*3.6, 4).toString());
             resultVo.setMaximunSpeed(zdsd.toString());
             resultVo.setMinimunVelocity(zxsd.toString());
             resultVo.setMaximumAcceleration(zdjiasd.toString());
@@ -1138,7 +1196,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             CurveData.put("steeting",steeting_wheel_list);
             CurveData.put("throttle",throttle_list);
             CurveData.put("yaw_rate",yawrate_list);
-            CurveData.put("velocity",velocity_list);
+            CurveData.put("velocity",velocity_list); //速度变化曲线
             resultVo.setCurveData(CurveData);
 
 
@@ -1640,7 +1698,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
     }
 
 
-    private Map<String, Object> selectSceneScore(String scenePackageId, String projectId) {
+    private Map<String, Object> selectSceneScore(String scenePackageId, String projectId, String taskId) {
 
         //查询场景包所有数据(包括得分信息)
         SimulationManualProjectParam query = new SimulationManualProjectParam();
@@ -1654,6 +1712,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         //1.获取项目下所有场景得分
         ProjectTaskParam param = new ProjectTaskParam();
         param.setPId(projectId);
+        if(!isEmpty(taskId)){
+            param.setTaskId(taskId);
+        }
         List<ManualProjectTaskVo> manualProjectTaskVos = simulationProjectTaskMapper.selectProjectTaskByProjectId(param);
 
         List<SublistScoreVo> lastSubList = new ArrayList<>();
@@ -4231,4 +4292,75 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             throw new RuntimeException("自动运行项目停止失败:"+po.getId());
         }
     }
+
+    /**
+     * 获取一级指标得分列表
+     * @return
+     */
+    private List<AlgorithmScoreVo> getFirstTargetScore(String id){
+        //算法测试得分表
+        /*
+        汇总测试得分计算方法:(每一项一级指标的测试得分*测试权重)累加
+        得分率计算方法:每一项一级指标的所有场景得分不为0的数量/每一项一级指标的场景数量
+        汇总得分率计算方法:(每一项一级指标的所有场景得分不为0的数量_累加/每一项一级指标的场景数量_累加)换成(得分累加取平均值)
+         */
+        //获取得分表一级指标信息
+        SimulationMptFirstTargetScorePo par = new SimulationMptFirstTargetScorePo();
+        par.setPId(id);
+        List<SimulationMptFirstTargetScorePo> pos = simulationMptFirstTargetScoreMapper.selectFirstTargetByPid(par);
+
+        List<AlgorithmScoreVo> algorithmScoreVoList = new ArrayList();
+        String evaluationLevelReport = "";
+        if(!isEmpty(pos)){
+            StringBuffer stringBuffer = new StringBuffer("");
+
+            //汇总数据初始化
+            Integer totalSceneNum = 0;
+            Double totalScore = 0D;
+            Double totalScoreRatio=0D;
+            Integer totalSceneScoreNum = 0;
+
+            for(SimulationMptFirstTargetScorePo v : pos){
+
+
+                stringBuffer.append(v.getSublistName()+"、");
+                AlgorithmScoreVo algorithmScoreVo = new AlgorithmScoreVo();
+                algorithmScoreVo.setProjectName(v.getSublistName());
+                Integer sceneNum = v.getSceneNum();
+                totalSceneNum += sceneNum;
+                algorithmScoreVo.setSceneNum(sceneNum);
+                String weight = v.getWeight();
+                Double weightDouble = Double.valueOf(weight);
+                algorithmScoreVo.setWeight(weight);
+                //单个二级指标得分
+                Double score = v.getScore();
+                totalScore += BigDecimal.valueOf(score).multiply(BigDecimal.valueOf(weightDouble).divide(BigDecimal.valueOf(100))).doubleValue();
+                algorithmScoreVo.setScore(saveTwoDecimalPlaces(score));
+                //获取得分不为0的场景数量
+                Integer scoreNum = getSetScoreNum(v.getSublistId(),id);
+                totalSceneScoreNum += scoreNum;
+                algorithmScoreVo.setScoreRatio(saveTwoDecimalPlaces(Double.valueOf(scoreNum)/Double.valueOf(sceneNum)*100));
+                algorithmScoreVoList.add(algorithmScoreVo);
+
+                totalScoreRatio += Double.valueOf(scoreNum)/Double.valueOf(sceneNum)*100;
+            }
+            //汇总
+            AlgorithmScoreVo algorithmScoreVo = new AlgorithmScoreVo();
+            algorithmScoreVo.setProjectName("汇总");
+            algorithmScoreVo.setSceneNum(totalSceneNum);
+            //指标权重总和默认是100%
+            algorithmScoreVo.setWeight("100");
+            algorithmScoreVo.setScore(saveTwoDecimalPlaces(totalScore));
+
+            totalScoreRatio = Double.valueOf(totalSceneScoreNum)/Double.valueOf(totalSceneNum)*100;
+
+            algorithmScoreVo.setScoreRatio(saveTwoDecimalPlaces(totalScoreRatio));
+            algorithmScoreVoList.add(algorithmScoreVo);
+
+
+        }
+
+        return algorithmScoreVoList;
+
+    }
 }

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

@@ -26,6 +26,8 @@ public interface SimulationProjectTaskMapper {
 
     List<ProjectRunResultRatioNumVo> selectRunResultCount(String id);
 
+    List<ProjectRunResultRatioNumVo> selectScoreCount(String id);
+
     List<SceneScoreVo> selectSceneScoreByIds(SceneScoreParam param);
 
     SceneScoreVo selectSceneScoreNumQuery(SimulationMptSceneScorePo po);
@@ -40,6 +42,9 @@ public interface SimulationProjectTaskMapper {
     SceneScoreVo selectRunStateByAborted(SimulationMptSceneScorePo po);
 
 
+    List<ManualProjectTaskVo> selectProjectTaskById(String id);
+
+
 
 
 

+ 15 - 0
simulation-resource-server/src/main/resources/mapper/project/SimulationProjectTaskMapper.xml

@@ -25,6 +25,9 @@
         select *
         from simulation_manual_project_task
         where is_deleted = '0' and p_id = #{pId,jdbcType=VARCHAR}
+        <if test="taskId != null and taskId != ''">
+            and id = #{taskId, jdbcType=VARCHAR}
+        </if>
         order by run_start_time desc
     </select>
 
@@ -51,6 +54,14 @@
         group by run_result
     </select>
 
+    <!--任务得分统计分组-->
+    <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'
+        group by score
+    </select>
+
     <!--运行任务状态-->
     <select id="selectRunTaskByState" parameterType="java.util.Map" resultType="java.util.Map">
         select count(run_state) num,run_state runState from simulation_manual_project_task
@@ -133,5 +144,9 @@
         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>
+
 
 </mapper>