|
@@ -0,0 +1,1032 @@
|
|
|
+package com.css.simulation.resource.project.impl;
|
|
|
+
|
|
|
+import api.common.pojo.common.PageVO;
|
|
|
+import api.common.pojo.common.ResponseBodyVO;
|
|
|
+import api.common.pojo.constants.DictConstants;
|
|
|
+import api.common.pojo.param.KafkaParameter;
|
|
|
+import api.common.pojo.param.project.ProjectTaskParam;
|
|
|
+import api.common.pojo.param.project.SceneScoreParam;
|
|
|
+import api.common.pojo.param.project.SimulationManualProjectKafkaParam;
|
|
|
+import api.common.pojo.param.project.SimulationManualProjectParam;
|
|
|
+import api.common.pojo.po.project.*;
|
|
|
+import api.common.pojo.vo.project.*;
|
|
|
+import api.common.util.JsonUtil;
|
|
|
+import com.css.simulation.resource.common.utils.AuthUtil;
|
|
|
+import com.css.simulation.resource.common.utils.PageUtil;
|
|
|
+import com.css.simulation.resource.project.constants.ProjectConstants;
|
|
|
+import com.css.simulation.resource.project.enums.EvaluationLevelEnum;
|
|
|
+import com.css.simulation.resource.project.enums.ProjectRunStateEnum;
|
|
|
+import com.css.simulation.resource.project.enums.SceneTypeEnum;
|
|
|
+import com.css.simulation.resource.project.feign.KafkaService;
|
|
|
+import com.css.simulation.resource.project.mapper.SimulationProjectMapper;
|
|
|
+import com.css.simulation.resource.project.service.SimulationProjectService;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import lombok.SneakyThrows;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SimulationProjectMapper simulationProjectMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private KafkaService kafkaService;
|
|
|
+
|
|
|
+ private String[] dateFmtArr= new String[]{"yyyyMMdd", "yyyy-MM-dd HH:mm:ss","yyyy-MM-dd"};
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBodyVO addOrUpdateProject(SimulationManualProjectParam param) {
|
|
|
+
|
|
|
+ if(isEmpty(param.getProjectName())){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE,"工作名称不能为空");
|
|
|
+ }
|
|
|
+ SimulationManualProjectPo po = convertParamToPo(param);
|
|
|
+
|
|
|
+ if(isEmpty(param.getId())){
|
|
|
+
|
|
|
+ //工作名称一样的的不能创建
|
|
|
+ List<SimulationManualProjectPo> simulationManualProjectPos = simulationProjectMapper.selectProjectByName(param);
|
|
|
+ if(!isEmpty(simulationManualProjectPos)){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE,"工作名称已经存在,请修改后再保存");
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加
|
|
|
+// ResponseBodyVO vo = new ResponseBodyVO();
|
|
|
+
|
|
|
+ po.createPo(AuthUtil.getCurrentUserId());
|
|
|
+ //生成id
|
|
|
+ createProjectId(po);
|
|
|
+
|
|
|
+ int add = simulationProjectMapper.add(po);
|
|
|
+ if(add > 0){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
+ }
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
|
|
|
+ }else{
|
|
|
+ //TODO 删除逻辑有待商议
|
|
|
+ //获取工作状态,仅未开始的才可以修改信息
|
|
|
+ SimulationManualProjectPo simulationManualProjectPo = simulationProjectMapper.selectProjectById(param);
|
|
|
+ if(!ProjectRunStateEnum.NOT_START.getCode().equals(simulationManualProjectPo.getNowRunState())){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"当前状态不支持修改");
|
|
|
+ }
|
|
|
+
|
|
|
+ po.updatePo(AuthUtil.getCurrentUserId());
|
|
|
+ int update = simulationProjectMapper.update(po);
|
|
|
+ if(update > 0){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"修改失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBodyVO selectProject(SimulationManualProjectParam param) {
|
|
|
+
|
|
|
+ if(!isEmpty(param.getCreateStartDate())){
|
|
|
+ String createStartDate = param.getCreateStartDate();
|
|
|
+ Date startDate = getDate(createStartDate + " 00:00:00",1);
|
|
|
+ if(startDate == null){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
|
|
|
+ }
|
|
|
+ param.setCreateTimeStart(startDate);
|
|
|
+ }
|
|
|
+ if(!isEmpty(param.getCreateEndDate())){
|
|
|
+ String createEndDate = param.getCreateEndDate();
|
|
|
+ Date endDate = getDate(createEndDate + " 11:59:59",1);
|
|
|
+ if(endDate == null){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
|
|
|
+ }
|
|
|
+ param.setCreateTimeEnd(endDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!isEmpty(param.getFinishDateStart())){
|
|
|
+ String finishDateStart = param.getFinishDateStart();
|
|
|
+ Date startDate = getDate(finishDateStart + " 00:00:00",1);
|
|
|
+ if(startDate == null){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
|
|
|
+ }
|
|
|
+ param.setFinishTimeStart(startDate);
|
|
|
+
|
|
|
+ }
|
|
|
+ if(!isEmpty(param.getFinishDateEnd())){
|
|
|
+ String finishDateEnd = param.getFinishDateEnd();
|
|
|
+ Date enddate = getDate(finishDateEnd + " 11:59:59",1);
|
|
|
+ if(enddate == null){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
|
|
|
+ }
|
|
|
+ param.setFinishTimeEnd(enddate);
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询有效数据
|
|
|
+ param.setIsDeleted("0");
|
|
|
+
|
|
|
+ setPage(param.getCurrentPage()==null?1:param.getCurrentPage(), param.getPageSize()==null?10:param.getPageSize());
|
|
|
+ List<SimulationManualProjectVo> vos = simulationProjectMapper.selectProjectList(param);
|
|
|
+ PageInfo<SimulationManualProjectVo> pageInfo = new PageInfo(vos);
|
|
|
+
|
|
|
+ for(SimulationManualProjectVo p : pageInfo.getList()){
|
|
|
+ convertPoToVo(p);
|
|
|
+ }
|
|
|
+
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,pageInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBodyVO selectProjectById(SimulationManualProjectParam param) {
|
|
|
+ if(isEmpty(param.getId())){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
|
|
|
+ }
|
|
|
+ SimulationManualProjectPo po = simulationProjectMapper.selectProjectById(param);
|
|
|
+ if(po == null){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"没有获取到数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ SimulationManualProjectSingleVo vo = new SimulationManualProjectSingleVo();
|
|
|
+ convertPoToVo(po, vo);
|
|
|
+
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,vo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBodyVO deleteProjectByids(SimulationManualProjectParam param) {
|
|
|
+
|
|
|
+ String ids = param.getIds();
|
|
|
+ if(isEmpty(ids)){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] idArr = ids.split(",");
|
|
|
+
|
|
|
+ //执行中的不允许删除
|
|
|
+ List<SimulationManualProjectPo> pos = simulationProjectMapper.selectProjectNowRunState(idArr);
|
|
|
+ for(SimulationManualProjectPo p : pos){
|
|
|
+ if(!isEmpty(p.getNowRunState()) && !ProjectRunStateEnum.NOT_START.getCode().equals(p.getNowRunState())){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"数据不支持删除");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ int i = simulationProjectMapper.deleteProject(idArr);
|
|
|
+ if(i > 0){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"删除失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @SneakyThrows
|
|
|
+ @Override
|
|
|
+ public ResponseBodyVO updateProjectNowRunState(SimulationManualProjectParam param) {
|
|
|
+
|
|
|
+ SimulationManualProjectPo po = simulationProjectMapper.selectProjectById(param);
|
|
|
+
|
|
|
+ if(po == null){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"数据没有找到");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isEmpty(param.getId()) || isEmpty(param.getNowRunState())){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
|
|
|
+ }
|
|
|
+ if("20".equals(param.getNowRunState())){
|
|
|
+ //设置开始时间
|
|
|
+ param.setStartTime(new Date());
|
|
|
+
|
|
|
+ //创建项目最后一级指标信息和场景信息(生成得分时创建数据)
|
|
|
+// createProjectSceneAndTarget(param.getId());
|
|
|
+ ///TODO Kafka推送消息
|
|
|
+ projectRunToKafka(po);
|
|
|
+
|
|
|
+
|
|
|
+ }else if("30".equals(param.getNowRunState())){
|
|
|
+ //设置完成时间
|
|
|
+ param.setFinishTime(new Date());
|
|
|
+
|
|
|
+ }
|
|
|
+ int i = simulationProjectMapper.updateProjectNowRunState(param);
|
|
|
+ if(i > 0){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
+ }
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void projectRunToKafka(SimulationManualProjectPo po) throws JsonProcessingException {
|
|
|
+ SimulationManualProjectKafkaParam kafkaParam = new SimulationManualProjectKafkaParam();
|
|
|
+ kafkaParam.setProjectId(po.getId());
|
|
|
+ kafkaParam.setAlgorithmId(po.getAlgorithm());
|
|
|
+ kafkaParam.setVehicleConfigId(po.getVehicle());
|
|
|
+ kafkaParam.setScenePackageId(po.getScene());
|
|
|
+ kafkaParam.setMaxSimulationTime(po.getMaxSimulationTime());
|
|
|
+ kafkaParam.setParallelism(Integer.valueOf(po.getParallelism()));
|
|
|
+ KafkaParameter kafkaParameter = new KafkaParameter();
|
|
|
+ kafkaParameter.setTopic(ProjectConstants.RUN_TASK_TOPIC);
|
|
|
+ String data = JsonUtil.beanToJson(kafkaParam);
|
|
|
+ kafkaParameter.setData(data);
|
|
|
+ kafkaService.send(kafkaParameter);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBodyVO selectProjectDetailsById(SimulationManualProjectParam param) {
|
|
|
+
|
|
|
+ if(isEmpty(param.getId())){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
|
|
|
+ }
|
|
|
+ ProjectDetailsVo projectDetailsVo = new ProjectDetailsVo();
|
|
|
+ //项目基本信息
|
|
|
+ SimulationManualProjectPo po = simulationProjectMapper.selectProjectById(param);
|
|
|
+ if(po == null){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "没有获取到数据");
|
|
|
+ }
|
|
|
+ //算法配置
|
|
|
+ String algorithmId = po.getAlgorithm();
|
|
|
+ AlgorithmBaseInfoVo algorithmBaseInfoVo = simulationProjectMapper.selectAlgorithmBaseInfoById(algorithmId).get(0);
|
|
|
+
|
|
|
+ //车辆配置
|
|
|
+ VehicleBaseInfoVo vehicleBaseInfoVo = null;
|
|
|
+ String vehicleConfigId = po.getVehicle();
|
|
|
+ List<ConfigVehicleVO> configVehicleVOS = simulationProjectMapper.selectConfigVehicle(vehicleConfigId);
|
|
|
+ if(!isEmpty(configVehicleVOS)){
|
|
|
+ ConfigVehicleVO configVehicleVO = configVehicleVOS.get(0);
|
|
|
+ vehicleBaseInfoVo = simulationProjectMapper.selectVehicleBaseInfoById(configVehicleVO.getVehicleId()).get(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<VehicleSensorVo> vehicleSensorVos = simulationProjectMapper.selectVehicleSensor(vehicleConfigId);
|
|
|
+
|
|
|
+ List<SensorBaseInfoVo> sensorCameraList = new ArrayList<>();
|
|
|
+ List<SensorBaseInfoVo> sensorOgtList = new ArrayList<>();
|
|
|
+ List<SensorBaseInfoVo> sensorLidarList = new ArrayList<>();
|
|
|
+ List<SensorBaseInfoVo> sensorRadarList = new ArrayList<>();
|
|
|
+ List<SensorBaseInfoVo> sensorGpsList = new ArrayList<>();
|
|
|
+ for(VehicleSensorVo vs : vehicleSensorVos){
|
|
|
+ String sensorType = vs.getSensorType();
|
|
|
+ String sensorId = vs.getSensorId();
|
|
|
+ if(DictConstants.SENSOR_CAMERA.equals(sensorType)){
|
|
|
+ //摄像头
|
|
|
+ SensorBaseInfoVo sensorBaseInfoVo = simulationProjectMapper.selectSensorCamera(sensorId);
|
|
|
+ sensorCameraList.add(sensorBaseInfoVo);
|
|
|
+ }else if(DictConstants.SENSOR_OGT.equals(sensorType)){
|
|
|
+ //完美传感器
|
|
|
+ SensorBaseInfoVo sensorBaseInfoVo = simulationProjectMapper.selectSensorOgt(sensorId);
|
|
|
+ sensorOgtList.add(sensorBaseInfoVo);
|
|
|
+ }else if(DictConstants.SENSOR_LIDAR.equals(sensorType)){
|
|
|
+ //激光雷达
|
|
|
+ SensorBaseInfoVo sensorBaseInfoVo = simulationProjectMapper.selectSensorLidar(sensorId);
|
|
|
+ sensorLidarList.add(sensorBaseInfoVo);
|
|
|
+ }else if(DictConstants.SENSOR_RADAR.equals(sensorType)){
|
|
|
+ //毫米波雷达
|
|
|
+ SensorBaseInfoVo sensorBaseInfoVo = simulationProjectMapper.selectSensorRadar(sensorId);
|
|
|
+ sensorRadarList.add(sensorBaseInfoVo);
|
|
|
+ }else if(DictConstants.SENSOR_GPS.equals(sensorType)){
|
|
|
+ //gps
|
|
|
+ SensorBaseInfoVo sensorBaseInfoVo = simulationProjectMapper.selectSensorGps(sensorId);
|
|
|
+ sensorGpsList.add(sensorBaseInfoVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //任务信息
|
|
|
+ ProjectTaskParam projectTaskParam = new ProjectTaskParam();
|
|
|
+ projectTaskParam.setPId(po.getId());
|
|
|
+ List<ManualProjectTaskPo> manualProjectTaskPos = simulationProjectMapper.selectprojectTaskByQuery(projectTaskParam);
|
|
|
+ List<ManualProjectTaskVo> ManualProjectTaskVoList = new ArrayList<>();
|
|
|
+ List<ProjectRunStateNumVo> projectRunStateNumVoList = new ArrayList<>();
|
|
|
+ List<ProjectRunResultRatioNumVo> projectRunResultRatioNumVoList = new ArrayList<>();
|
|
|
+ if(manualProjectTaskPos != null){
|
|
|
+ for(ManualProjectTaskPo task : manualProjectTaskPos){
|
|
|
+ ManualProjectTaskVo manualProjectTaskVo = convertManualProjectTaskPoToVo(task);
|
|
|
+ setUpSceneInfo(manualProjectTaskVo);
|
|
|
+ ManualProjectTaskVoList.add(manualProjectTaskVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ //任务运行状态统计
|
|
|
+ int size = manualProjectTaskPos.size();
|
|
|
+// List<ProjectRunStateNumVo> projectRunStateNumVos = simulationProjectMapper.selectRunStateCount(po.getId());
|
|
|
+ projectRunStateNumVoList = simulationProjectMapper.selectRunStateCount(po.getId());
|
|
|
+
|
|
|
+ /*状态统计统计数字,不统计比率
|
|
|
+ for(ProjectRunStateNumVo pv : projectRunStateNumVos){
|
|
|
+ Integer num = pv.getNum();
|
|
|
+ Double d = (double)num/size;
|
|
|
+ d = saveTwoDecimalPlaces(d);
|
|
|
+ pv.setRatio(d);
|
|
|
+ projectRunStateNumVoList.add(pv);
|
|
|
+ }*/
|
|
|
+
|
|
|
+ //结果状态统计
|
|
|
+ List<ProjectRunResultRatioNumVo> projectRunResultRatioNumVos = simulationProjectMapper.selectRunResultCount(po.getId());
|
|
|
+ for(ProjectRunResultRatioNumVo rv : projectRunResultRatioNumVos){
|
|
|
+ Integer num = rv.getNum();
|
|
|
+ Double d = (double)num/size;
|
|
|
+ d = saveTwoDecimalPlaces(d);
|
|
|
+ rv.setRatio(d);
|
|
|
+ projectRunResultRatioNumVoList.add(rv);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ projectDetailsVo.setProjectId(po.getProjectId());
|
|
|
+ projectDetailsVo.setProjectName(po.getProjectName());
|
|
|
+ projectDetailsVo.setProjectDescribe(po.getProjectDescribe());
|
|
|
+ projectDetailsVo.setStartTime(getRqStr(po.getStartTime(),1));
|
|
|
+ projectDetailsVo.setFinishTime(getRqStr(po.getFinishTime(),1));
|
|
|
+ projectDetailsVo.setNowRunState(ProjectRunStateEnum.getState(po.getNowRunState()));
|
|
|
+ projectDetailsVo.setEvaluationLevel(EvaluationLevelEnum.getState(po.getEvaluationLevel()));
|
|
|
+ if(algorithmBaseInfoVo != null){
|
|
|
+ projectDetailsVo.setAlgorithmName(algorithmBaseInfoVo.getAlgorithmName());
|
|
|
+ projectDetailsVo.setAlgorithmDescribe(algorithmBaseInfoVo.getDescription());
|
|
|
+ }
|
|
|
+ if(vehicleBaseInfoVo != null){
|
|
|
+ projectDetailsVo.setVehicleName(vehicleBaseInfoVo.getVehicleName());
|
|
|
+ projectDetailsVo.setVehicleDescribe(vehicleBaseInfoVo.getDescription());
|
|
|
+
|
|
|
+ }
|
|
|
+ projectDetailsVo.setSensorCameraList(sensorCameraList);
|
|
|
+ projectDetailsVo.setSensorOgtList(sensorOgtList);
|
|
|
+ projectDetailsVo.setSensorLidarList(sensorLidarList);
|
|
|
+ projectDetailsVo.setSensorRadarList(sensorRadarList);
|
|
|
+ projectDetailsVo.setSensorGpsList(sensorGpsList);
|
|
|
+ projectDetailsVo.setTaskList(ManualProjectTaskVoList);
|
|
|
+ projectDetailsVo.setStateList(projectRunStateNumVoList);
|
|
|
+ projectDetailsVo.setResultList(projectRunResultRatioNumVoList);
|
|
|
+
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, projectDetailsVo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBodyVO selectProjectReportById(SimulationManualProjectParam param) {
|
|
|
+ if(isEmpty(param.getId())){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
|
|
|
+ }
|
|
|
+ //项目基本信息
|
|
|
+ SimulationManualProjectPo po = simulationProjectMapper.selectProjectBaseById(param);
|
|
|
+ if(po == null){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "没有获取到数据");
|
|
|
+ }
|
|
|
+ //算法配置
|
|
|
+ String algorithmId = po.getAlgorithm();
|
|
|
+ AlgorithmBaseInfoVo algorithmBaseInfoVo = simulationProjectMapper.selectAlgorithmBaseInfoById(algorithmId).get(0);
|
|
|
+
|
|
|
+
|
|
|
+ ProjectReportVo projectReportVo = new ProjectReportVo();
|
|
|
+ projectReportVo.setAlgorithmName(algorithmBaseInfoVo.getAlgorithmName());
|
|
|
+// Double algorithmScore = po.getAlgorithmScore();
|
|
|
+// projectReportVo.setAlgorithmScore(algorithmScore);
|
|
|
+ projectReportVo.setAlgorithmDescribe(algorithmBaseInfoVo.getDescription());
|
|
|
+
|
|
|
+// String evaluationLevelReport = getEvaluationLevelReport(algorithmScore);
|
|
|
+// projectReportVo.setEvaluationLevel(evaluationLevelReport);
|
|
|
+
|
|
|
+
|
|
|
+ String sceneNames = "";
|
|
|
+
|
|
|
+ //算法测试得分表
|
|
|
+ /*
|
|
|
+ 汇总测试得分计算方法:(每一项一级指标的测试得分*测试权重)累加
|
|
|
+ 得分率计算方法:每一项一级指标的所有场景得分不为0的数量/每一项一级指标的场景数量
|
|
|
+ 汇总得分率计算方法:每一项一级指标的所有场景得分不为0的数量_累加/每一项一级指标的场景数量_累加
|
|
|
+ */
|
|
|
+ List<ScenePackageSubListVO> scenePackageSubListVOS = simulationProjectMapper.selectSubSceneByPid(po.getScene());
|
|
|
+
|
|
|
+ List<AlgorithmScoreVo> algorithmScoreVoList = new ArrayList();
|
|
|
+ String evaluationLevelReport = "";
|
|
|
+ if(!isEmpty(scenePackageSubListVOS)){
|
|
|
+ StringBuffer stringBuffer = new StringBuffer("");
|
|
|
+
|
|
|
+ //汇总数据初始化
|
|
|
+ Integer totalSceneNum = 0;
|
|
|
+// Double totalWeight = 0D;
|
|
|
+ Double totalScore = 0D;
|
|
|
+ Double totalScoreRatio=0D;
|
|
|
+ Integer totalSceneScoreNum = 0;
|
|
|
+
|
|
|
+ for(ScenePackageSubListVO v : scenePackageSubListVOS){
|
|
|
+ stringBuffer.append(v+"、");
|
|
|
+ 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);
|
|
|
+ SimulationMptFirstTargetScorePo simulationMptFirstTargetScorePo = new SimulationMptFirstTargetScorePo();
|
|
|
+ simulationMptFirstTargetScorePo.setPId(po.getId());
|
|
|
+ simulationMptFirstTargetScorePo.setTarget(v.getSublistId());
|
|
|
+ SimulationMptFirstTargetScorePo simulationMptFirstTargetScorePo1 = simulationProjectMapper.selectFirstTargetScore(simulationMptFirstTargetScorePo);
|
|
|
+ Double score = simulationMptFirstTargetScorePo1.getScore();
|
|
|
+ totalScore += score*weightDouble;
|
|
|
+ algorithmScoreVo.setScore(saveTwoDecimalPlaces(score));
|
|
|
+// totalWeight +=aDouble;
|
|
|
+ Integer num = v.getSceneNum();
|
|
|
+ Integer scoreNum = getSetScoreNum(po.getId());
|
|
|
+ totalSceneScoreNum += scoreNum;
|
|
|
+ algorithmScoreVo.setScoreRatio(saveTwoDecimalPlaces(Double.valueOf(num/scoreNum)));
|
|
|
+ algorithmScoreVoList.add(algorithmScoreVo);
|
|
|
+ }
|
|
|
+ //汇总
|
|
|
+ AlgorithmScoreVo algorithmScoreVo = new AlgorithmScoreVo();
|
|
|
+ algorithmScoreVo.setProjectName("汇总");
|
|
|
+ algorithmScoreVo.setSceneNum(totalSceneNum);
|
|
|
+// algorithmScoreVo.setWeight(saveTwoDecimalPlaces(totalWeight).toString());
|
|
|
+ //指标权重总和默认是1
|
|
|
+ algorithmScoreVo.setWeight("1");
|
|
|
+ algorithmScoreVo.setScore(saveTwoDecimalPlaces(totalScore));
|
|
|
+ totalScoreRatio = Double.valueOf(totalSceneScoreNum/totalSceneNum);
|
|
|
+ algorithmScoreVo.setScoreRatio(saveTwoDecimalPlaces(totalScoreRatio));
|
|
|
+ algorithmScoreVoList.add(algorithmScoreVo);
|
|
|
+
|
|
|
+ projectReportVo.setScoreRatio(saveTwoDecimalPlaces(totalScoreRatio));
|
|
|
+
|
|
|
+ projectReportVo.setAlgorithmScore(saveTwoDecimalPlaces(totalScore));
|
|
|
+ evaluationLevelReport = getEvaluationLevelReport(saveTwoDecimalPlaces(totalScore));
|
|
|
+ projectReportVo.setEvaluationLevel(evaluationLevelReport);
|
|
|
+
|
|
|
+ sceneNames = stringBuffer.substring(0,stringBuffer.lastIndexOf("、"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ projectReportVo.setAlgorithmEvaluation(algorithmBaseInfoVo.getAlgorithmName()+"经测试获得"+evaluationLevelReport+"级评价,"+
|
|
|
+ "("+sceneNames+")得分率达到了"+projectReportVo.getScoreRatio()+"。");
|
|
|
+
|
|
|
+ projectReportVo.setAlgorithmScoreList(algorithmScoreVoList);
|
|
|
+ projectReportVo.setEvaluationGrade(evaluationLevelReport);
|
|
|
+
|
|
|
+ //算法测试评分细则、详细得分情况
|
|
|
+ List<ScenePackageSubListVO> scenePackageSubListVOS1 = selectScenePackageSubListTreeAndSetScore(null, true, po.getScene(), po.getId(), 1);
|
|
|
+ projectReportVo.setSceneScoreList(scenePackageSubListVOS1);
|
|
|
+
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, projectReportVo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBodyVO selectDropDownByType(SimulationManualProjectParam param) {
|
|
|
+ List<DropDownTypeVo> result = new ArrayList<>();
|
|
|
+ if(isEmpty(param.getDropDownType())){
|
|
|
+ //获取全部(算法,车辆,场景)
|
|
|
+ setAlgorithmDropDown(result);
|
|
|
+ setVehicleDropDown(result);
|
|
|
+ setScenePackageDropDown(result);
|
|
|
+ }else if("1".equals(param.getDropDownType())){
|
|
|
+ setAlgorithmDropDown(result);
|
|
|
+ }else if("2".equals(param.getDropDownType())){
|
|
|
+ setVehicleDropDown(result);
|
|
|
+ }else if("3".equals(param.getDropDownType())){
|
|
|
+ setScenePackageDropDown(result);
|
|
|
+ }
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBodyVO selectProjectTaskById(SimulationManualProjectParam param) {
|
|
|
+ String id = param.getId();
|
|
|
+ String taskId = param.getTaskId();
|
|
|
+ if(isEmpty(id) || isEmpty(taskId)){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
|
|
|
+ }
|
|
|
+
|
|
|
+ ProjectTaskDetailsVo resultVo = new ProjectTaskDetailsVo();
|
|
|
+
|
|
|
+ //基本信息
|
|
|
+ ProjectTaskParam projectTaskParam = new ProjectTaskParam();
|
|
|
+ projectTaskParam.setPId(id);
|
|
|
+ projectTaskParam.setId(taskId);
|
|
|
+ List<ManualProjectTaskPo> pos = simulationProjectMapper.selectprojectTaskByQuery(projectTaskParam);
|
|
|
+ if(isEmpty(pos)){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"没有获取到任务信息");
|
|
|
+ }
|
|
|
+ ManualProjectTaskPo po = pos.get(0);
|
|
|
+ resultVo.setTaskId(po.getId());
|
|
|
+ String sceneId = po.getSceneId();
|
|
|
+ String sceneType = po.getSceneType();
|
|
|
+ SceneBaseInfoVo sceneBaseInfoVo = getsceneNameAndOther(sceneId, sceneType);
|
|
|
+ resultVo.setSceneName(sceneBaseInfoVo.getCommonSceneName());
|
|
|
+ resultVo.setRunStartTime(getRqStr(po.getRunStartTime(),1));
|
|
|
+ resultVo.setRunEndTime(getRqStr(po.getRunEndTime(),1));
|
|
|
+ resultVo.setRunState(po.getRunState());
|
|
|
+ resultVo.setFinishState(po.getRunResult());
|
|
|
+ resultVo.setSceneDescribe("");
|
|
|
+ ///TODO 任务详情信息
|
|
|
+ resultVo.setMileage(po.getMileage());
|
|
|
+ resultVo.setAverageVelocity(po.getAverageVelocity());
|
|
|
+ resultVo.setMaximunSpeed(po.getMaximunSpeed());
|
|
|
+ resultVo.setMinimunVelocity(po.getMinimunVelocity());
|
|
|
+ resultVo.setMaximumDeceleration(po.getMaximumDeceleration());
|
|
|
+ resultVo.setMaximumSwingSpeed(po.getMaximumSwingSpeed());
|
|
|
+ resultVo.setSpeedVariance(saveTwoDecimalPlaces(po.getSpeedVariance()));
|
|
|
+ resultVo.setSpeedComfortLevel(po.getSpeedComfortLevel());
|
|
|
+ resultVo.setSwingSpeedMeanSquareRoot(saveTwoDecimalPlaces(po.getSwingSpeedMeanSquareRoot()));
|
|
|
+ resultVo.setSwingComfortLevel(po.getSwingComfortLevel());
|
|
|
+ resultVo.setAcceleration(po.getAcceleration());
|
|
|
+ resultVo.setLaneOffset(po.getLaneOffset());
|
|
|
+ resultVo.setBrake(po.getBrake());
|
|
|
+ resultVo.setSteetingWheel(po.getSteetingWheel());
|
|
|
+ resultVo.setThrottle(po.getThrottle());
|
|
|
+ resultVo.setYawRate(po.getYawRate());
|
|
|
+ resultVo.setVelocity(po.getVelocity());
|
|
|
+ resultVo.setOtherCurve(po.getOtherCurve());
|
|
|
+
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,resultVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseBodyVO selectMaxParallelism() {
|
|
|
+ String currentUserId = AuthUtil.getCurrentUserId();
|
|
|
+ SystemUserVo systemUserVo = simulationProjectMapper.selectUserById(currentUserId);
|
|
|
+ if(systemUserVo == null){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"没有获取到用户信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,null,systemUserVo.getCpuAvailableNumber());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据场景id和场景类型获取场景名
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private SceneBaseInfoVo getsceneNameAndOther(String sceneId, String sceneType){
|
|
|
+ SceneBaseInfoVo resultVo = new SceneBaseInfoVo();
|
|
|
+ if("1".equals(sceneType)){
|
|
|
+ SceneBaseInfoVo sceneBaseInfoVo = simulationProjectMapper.selectSceneNatural(sceneId);
|
|
|
+ if(sceneBaseInfoVo != null){
|
|
|
+ resultVo.setCommonSceneName(sceneBaseInfoVo.getNaturalName());
|
|
|
+ }
|
|
|
+ }else if("2".equals(sceneType)){
|
|
|
+ SceneBaseInfoVo sceneBaseInfoVo = simulationProjectMapper.selectSceneStandardsRegulations(sceneId);
|
|
|
+ if(sceneBaseInfoVo != null){
|
|
|
+ resultVo.setCommonSceneName(sceneBaseInfoVo.getSceneName());
|
|
|
+ }
|
|
|
+ }else if("3".equals(sceneType)){
|
|
|
+ SceneBaseInfoVo sceneBaseInfoVo = simulationProjectMapper.selectSceneAccidentById(sceneId);
|
|
|
+ if(sceneBaseInfoVo != null){
|
|
|
+ resultVo.setCommonSceneName(sceneBaseInfoVo.getSceneName());
|
|
|
+ }
|
|
|
+ }else if("4".equals(sceneType)){
|
|
|
+ ///TODO 泛化场景暂不支持
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultVo;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setAlgorithmDropDown(List<DropDownTypeVo> result){
|
|
|
+ List<AlgorithmBaseInfoVo> algorithmBaseInfoVo = simulationProjectMapper.selectAlgorithmBaseInfoById(null);
|
|
|
+ List<DropDownVo> algorithmList = new ArrayList<>();
|
|
|
+ for(AlgorithmBaseInfoVo v : algorithmBaseInfoVo){
|
|
|
+ DropDownVo dropDownVo = new DropDownVo();
|
|
|
+ dropDownVo.setId(v.getId());
|
|
|
+ dropDownVo.setName(v.getAlgorithmName());
|
|
|
+ algorithmList.add(dropDownVo);
|
|
|
+ }
|
|
|
+ DropDownTypeVo algorithmDropDown = new DropDownTypeVo();
|
|
|
+ algorithmDropDown.setDropDownList(algorithmList);
|
|
|
+ algorithmDropDown.setType("1");
|
|
|
+ result.add(algorithmDropDown);
|
|
|
+ }
|
|
|
+ private void setVehicleDropDown(List<DropDownTypeVo> result){
|
|
|
+ List<ConfigVehicleVO> vehicleBaseInfoVo = simulationProjectMapper.selectConfigVehicle(null);
|
|
|
+ List<DropDownVo> vehicleList = new ArrayList<>();
|
|
|
+ for(ConfigVehicleVO v : vehicleBaseInfoVo){
|
|
|
+ DropDownVo dropDownVo = new DropDownVo();
|
|
|
+ dropDownVo.setId(v.getId());
|
|
|
+ dropDownVo.setName(v.getConfigName());
|
|
|
+
|
|
|
+ //获取传感器信息
|
|
|
+ List<ConfigSensorVo> configSensorVos = simulationProjectMapper.selectConfigSensor(v.getId());
|
|
|
+ String sensor = "";
|
|
|
+ if(!isEmpty(configSensorVos) && configSensorVos.get(0) != null){
|
|
|
+ StringBuffer stringBuffer = new StringBuffer();
|
|
|
+ for(ConfigSensorVo cv : configSensorVos){
|
|
|
+ stringBuffer.append(cv.getSensorType()+",");
|
|
|
+ }
|
|
|
+ sensor = stringBuffer.substring(0,stringBuffer.lastIndexOf(","));
|
|
|
+
|
|
|
+ }
|
|
|
+ dropDownVo.setSensor(sensor);
|
|
|
+
|
|
|
+ vehicleList.add(dropDownVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ DropDownTypeVo vehicleDropDown = new DropDownTypeVo();
|
|
|
+ vehicleDropDown.setDropDownList(vehicleList);
|
|
|
+ vehicleDropDown.setType("2");
|
|
|
+ result.add(vehicleDropDown);
|
|
|
+ }
|
|
|
+ private void setScenePackageDropDown(List<DropDownTypeVo> result){
|
|
|
+ List<ScenePackageBaseVo> scenePackageBaseVo = simulationProjectMapper.selectScenePackageBaseById(null);
|
|
|
+ List<DropDownVo> scenePackageList = new ArrayList<>();
|
|
|
+ for(ScenePackageBaseVo v : scenePackageBaseVo){
|
|
|
+ DropDownVo dropDownVo = new DropDownVo();
|
|
|
+ dropDownVo.setId(v.getPackageId());
|
|
|
+ dropDownVo.setName(v.getPackageName());
|
|
|
+ dropDownVo.setSceneNum(v.getSceneNum());
|
|
|
+ scenePackageList.add(dropDownVo);
|
|
|
+ }
|
|
|
+ DropDownTypeVo scenePackageDropDown = new DropDownTypeVo();
|
|
|
+ scenePackageDropDown.setDropDownList(scenePackageList);
|
|
|
+ scenePackageDropDown.setType("3");
|
|
|
+ result.add(scenePackageDropDown);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private SimulationManualProjectPo convertParamToPo(SimulationManualProjectParam param){
|
|
|
+ SimulationManualProjectPo po = new SimulationManualProjectPo();
|
|
|
+ po.setId(param.getId());
|
|
|
+ po.setProjectName(param.getProjectName());
|
|
|
+ po.setProjectDescribe(param.getProjectDescribe());
|
|
|
+ po.setAlgorithm(param.getAlgorithm());
|
|
|
+ po.setVehicle(param.getVehicle());
|
|
|
+ po.setScene(param.getScene());
|
|
|
+ //po.setOperationCycle(param.getOperationCycle());
|
|
|
+ po.setMaxSimulationTime(param.getMaxSimulationTime());
|
|
|
+ po.setParallelism(param.getParallelism());
|
|
|
+ //po.setRuleView(param.getRuleView());
|
|
|
+ po.setIsChoiceGpu(param.getIsChoiceGpu());
|
|
|
+ po.setNowRunState(param.getNowRunState());
|
|
|
+ return po;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private SimulationManualProjectVo convertPoToVo(SimulationManualProjectVo vo){
|
|
|
+ Date createTime = vo.getCreateTime();
|
|
|
+ vo.setCreateTimeFmt(getRqStr(createTime, 2));
|
|
|
+ String algorithm = vo.getAlgorithm();
|
|
|
+ List<AlgorithmBaseInfoVo> algorithmBaseInfoVos = simulationProjectMapper.selectAlgorithmBaseInfoById(algorithm);
|
|
|
+ if(!isEmpty(algorithmBaseInfoVos)){
|
|
|
+ AlgorithmBaseInfoVo algorithmBaseInfoVo = algorithmBaseInfoVos.get(0);
|
|
|
+ vo.setAlgorithm(algorithmBaseInfoVo.getAlgorithmName());
|
|
|
+ }
|
|
|
+ vo.setNowRunStateDict(ProjectRunStateEnum.getState(vo.getNowRunState()));
|
|
|
+ vo.setEvaluationLevelDict(EvaluationLevelEnum.getState(vo.getEvaluationLevel()));
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void convertPoToVo (SimulationManualProjectPo po, SimulationManualProjectSingleVo vo){
|
|
|
+ vo.setId(po.getId());
|
|
|
+ vo.setProjectName(po.getProjectName());
|
|
|
+ vo.setProjectDescribe(po.getProjectDescribe());
|
|
|
+ vo.setAlgorithm(po.getAlgorithm());
|
|
|
+ vo.setVehicle(po.getVehicle());
|
|
|
+ vo.setScene(po.getScene());
|
|
|
+ vo.setMaxSimulationTime(po.getMaxSimulationTime());
|
|
|
+ vo.setParallelism(po.getParallelism());
|
|
|
+ vo.setIsChoiceGpu(po.getIsChoiceGpu());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void createProjectId(SimulationManualProjectPo po){
|
|
|
+ Integer nowRq = getRq(null,0);
|
|
|
+ po.setProjectDate(nowRq);
|
|
|
+ SimulationManualProjectPo po1 = simulationProjectMapper.selectLastProjectId(nowRq);
|
|
|
+ if(po1 == null){
|
|
|
+ //生成新id
|
|
|
+ po.setProjectNum(1);
|
|
|
+ }else{
|
|
|
+ po.setProjectNum(po1.getProjectNum()+1);
|
|
|
+ }
|
|
|
+ po.setProjectId(po.getProjectDate()+"-"+po.getProjectNum());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private Integer getRq(Date date, int index){
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat(dateFmtArr[index]);
|
|
|
+ if(date == null){
|
|
|
+ date = new Date();
|
|
|
+ }
|
|
|
+ return Integer.valueOf(sdf.format(date));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getRqStr(Date date, int index){
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat(dateFmtArr[index]);
|
|
|
+ if(date == null){
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ return sdf.format(date);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private Date getDate(String dateFmt, int index){
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat(dateFmtArr[index]);
|
|
|
+ try {
|
|
|
+ return sdf.parse(dateFmt);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isEmpty(String value){
|
|
|
+ if(value == null){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ value = value.trim();
|
|
|
+ if(value.length() == 0){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ private boolean isEmpty(List list){
|
|
|
+ if(list == null || list.size() <= 0){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setPage(Integer pageNum, Integer pageSize){
|
|
|
+ PageVO pageVO = new PageVO();
|
|
|
+ pageVO.setCurrentPage(pageNum);
|
|
|
+ pageVO.setPageSize(pageSize);
|
|
|
+ PageUtil.setPageInfo(pageVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Double saveTwoDecimalPlaces(Double d){
|
|
|
+ if(d == null){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return new BigDecimal(d).setScale(2, RoundingMode.UP).doubleValue();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置场景基本字段
|
|
|
+ */
|
|
|
+ private void setUpSceneInfo(ManualProjectTaskVo vo){
|
|
|
+ String sceneType = vo.getSceneType();
|
|
|
+ String sceneId = vo.getSceneId();
|
|
|
+ SceneBaseInfoVo sceneBaseInfoVo;
|
|
|
+ if("1".equals(sceneType)){
|
|
|
+ //自然驾驶
|
|
|
+ sceneBaseInfoVo = simulationProjectMapper.selectSceneNatural(sceneId);
|
|
|
+ if(sceneBaseInfoVo != null){
|
|
|
+ vo.setSceneName(sceneBaseInfoVo.getNaturalName());
|
|
|
+ }
|
|
|
+ }else if("2".equals(sceneType)){
|
|
|
+ //标准法规
|
|
|
+ sceneBaseInfoVo = simulationProjectMapper.selectSceneStandardsRegulations(sceneId);
|
|
|
+ if(sceneBaseInfoVo != null){
|
|
|
+ vo.setSceneName(sceneBaseInfoVo.getSceneName());
|
|
|
+ }
|
|
|
+ }else if("3".equals(sceneType)){
|
|
|
+ //交通事故
|
|
|
+ sceneBaseInfoVo = simulationProjectMapper.selectSceneAccidentById(sceneId);
|
|
|
+ if(sceneBaseInfoVo != null){
|
|
|
+ vo.setSceneName(sceneBaseInfoVo.getSceneName());
|
|
|
+ }
|
|
|
+ }else if("4".equals(sceneType)){
|
|
|
+ /// TODO 泛化场景暂不支持
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private ManualProjectTaskVo convertManualProjectTaskPoToVo(ManualProjectTaskPo po){
|
|
|
+ ManualProjectTaskVo manualProjectTaskVo = new ManualProjectTaskVo();
|
|
|
+ manualProjectTaskVo.setId(po.getPId());
|
|
|
+ manualProjectTaskVo.setPId(po.getPId());
|
|
|
+ manualProjectTaskVo.setSceneId(po.getSceneId());
|
|
|
+// manualProjectTaskVo.setSceneName(po.getSceneName());
|
|
|
+ manualProjectTaskVo.setSceneType(po.getSceneType());
|
|
|
+ manualProjectTaskVo.setRunStartTime(getRqStr(po.getRunStartTime(), 2));
|
|
|
+ manualProjectTaskVo.setRunEndTime(getRqStr(po.getRunEndTime(), 2));
|
|
|
+ manualProjectTaskVo.setRunState(po.getRunState());
|
|
|
+ manualProjectTaskVo.setRunResult(po.getRunResult());
|
|
|
+ return manualProjectTaskVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成项目场景信息和最后一级指标信息
|
|
|
+ */
|
|
|
+ private void createProjectSceneAndTarget(String id){
|
|
|
+ //1.查询场景包下最后一级指标和指标下所有场景
|
|
|
+ List<ScenePackageSubListVO> scenePackageSubListVOS = simulationProjectMapper.selectSubListByPid(id);
|
|
|
+
|
|
|
+ //2.保存最后一级指标
|
|
|
+ for(ScenePackageSubListVO v : scenePackageSubListVOS){
|
|
|
+ SimulationMptLastTargetScorePo simulationMptTargetScorePo = new SimulationMptLastTargetScorePo();
|
|
|
+ simulationMptTargetScorePo.setPId(id);
|
|
|
+ simulationMptTargetScorePo.setTarget(v.getSublistId());
|
|
|
+ simulationMptTargetScorePo.createPo(AuthUtil.getCurrentUserId());
|
|
|
+ simulationProjectMapper.insertSimulationMptLastTargetScorePo(simulationMptTargetScorePo);
|
|
|
+
|
|
|
+ //3.保存场景
|
|
|
+ String sceneNaturalIds = v.getSceneNaturalIds();
|
|
|
+ String sceneTrafficIds = v.getSceneTrafficIds();
|
|
|
+ String sceneStatueIds = v.getSceneStatueIds();
|
|
|
+ if(!isEmpty(sceneNaturalIds)){
|
|
|
+ String[] split = sceneNaturalIds.split(",");
|
|
|
+ for(String s : split){
|
|
|
+ SceneBaseInfoVo sceneBaseInfoVo = simulationProjectMapper.selectSceneNatural(s);
|
|
|
+ SimulationMptSceneScorePo simulationMptSceneScorePo = new SimulationMptSceneScorePo();
|
|
|
+ simulationMptSceneScorePo.setPId(id);
|
|
|
+ simulationMptSceneScorePo.setSceneId(s);
|
|
|
+ simulationMptSceneScorePo.setSceneType("1");
|
|
|
+ simulationMptSceneScorePo.createPo(AuthUtil.getCurrentUserId());
|
|
|
+ simulationProjectMapper.insertSimulationMptSceneScorePo(simulationMptSceneScorePo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if(!isEmpty(sceneTrafficIds)){
|
|
|
+ String[] split = sceneTrafficIds.split(",");
|
|
|
+ for(String s : split){
|
|
|
+ SceneBaseInfoVo sceneBaseInfoVo = simulationProjectMapper.selectSceneAccidentById(s);
|
|
|
+ SimulationMptSceneScorePo simulationMptSceneScorePo = new SimulationMptSceneScorePo();
|
|
|
+ simulationMptSceneScorePo.setPId(id);
|
|
|
+ simulationMptSceneScorePo.setSceneId(s);
|
|
|
+ simulationMptSceneScorePo.setSceneType("3");
|
|
|
+ simulationMptSceneScorePo.createPo(AuthUtil.getCurrentUserId());
|
|
|
+ simulationProjectMapper.insertSimulationMptSceneScorePo(simulationMptSceneScorePo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!isEmpty(sceneStatueIds)){
|
|
|
+ String[] split = sceneStatueIds.split(",");
|
|
|
+ for(String s : split){
|
|
|
+ SceneBaseInfoVo sceneBaseInfoVo = simulationProjectMapper.selectSceneStandardsRegulations(s);
|
|
|
+ SimulationMptSceneScorePo simulationMptSceneScorePo = new SimulationMptSceneScorePo();
|
|
|
+ simulationMptSceneScorePo.setPId(id);
|
|
|
+ simulationMptSceneScorePo.setSceneId(s);
|
|
|
+ simulationMptSceneScorePo.setSceneType("2");
|
|
|
+ simulationMptSceneScorePo.createPo(AuthUtil.getCurrentUserId());
|
|
|
+ simulationProjectMapper.insertSimulationMptSceneScorePo(simulationMptSceneScorePo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ///TODO 泛化场景暂不支持
|
|
|
+ }
|
|
|
+
|
|
|
+ //4.查询第一级指标
|
|
|
+
|
|
|
+ //5.保存第一级指标
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 级联获取场景指标得分数据
|
|
|
+ * @param parentVoList 首次传null
|
|
|
+ * @param isRoot 首次传true
|
|
|
+ * @param scenePackageId 场景包id
|
|
|
+ * @param pId 项目表id,用于统计得分使用
|
|
|
+ * @param level 指标级别
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<ScenePackageSubListVO> selectScenePackageSubListTreeAndSetScore(List<ScenePackageSubListVO> parentVoList,
|
|
|
+ boolean isRoot,String scenePackageId, String pId, Integer level){
|
|
|
+
|
|
|
+ if(isRoot){
|
|
|
+ //查找一级节点
|
|
|
+ parentVoList = simulationProjectMapper.selectSubSceneByPid(scenePackageId);
|
|
|
+ if(!isEmpty(parentVoList)){
|
|
|
+ selectScenePackageSubListTreeAndSetScore(parentVoList, false, null,pId,level);
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+
|
|
|
+ //获取子节点集合
|
|
|
+ for(ScenePackageSubListVO pvo : parentVoList){
|
|
|
+ //二级指标获取总分
|
|
|
+ if(level == 2){
|
|
|
+ setFirstTargetScore(pvo,pId);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ScenePackageSubListVO> cvoList = simulationProjectMapper.selectSubSceneByPid(pvo.getSublistId());
|
|
|
+ if(!isEmpty(cvoList)){
|
|
|
+ //存入父节点集合中
|
|
|
+ pvo.setChildScenePackageSubListVOList(cvoList);
|
|
|
+ pvo.setLevel(level);
|
|
|
+ //继续查找下一节点
|
|
|
+ selectScenePackageSubListTreeAndSetScore(cvoList,false, null, pId, level+1);
|
|
|
+ }else{
|
|
|
+ //没有子节点;最后一级,获取指标得分和指标下场景得分
|
|
|
+ setScore(pvo,pId);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return parentVoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setScore(ScenePackageSubListVO vo, String pId){
|
|
|
+ setLastTargetScore(vo,pId);
|
|
|
+ setSceneScore(vo,pId);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setSceneScore(ScenePackageSubListVO vo, String pId){
|
|
|
+ String sceneNaturalIds = vo.getSceneNaturalIds();
|
|
|
+ String sceneTrafficIds = vo.getSceneTrafficIds();
|
|
|
+ String sceneStatueIds = vo.getSceneStatueIds();
|
|
|
+ List<SceneScoreVo> NaturalSceneScoreVos = setSceneScore(vo, sceneNaturalIds, "1", pId);
|
|
|
+ List<SceneScoreVo> StatueSceneScoreVos = setSceneScore(vo, sceneStatueIds, "2", pId);
|
|
|
+ List<SceneScoreVo> TrafficSceneScoreVos = setSceneScore(vo, sceneTrafficIds, "3", pId);
|
|
|
+ ///TODO 暂不支持泛化场景
|
|
|
+
|
|
|
+ //合成一个list
|
|
|
+ NaturalSceneScoreVos.addAll(StatueSceneScoreVos);
|
|
|
+ NaturalSceneScoreVos.addAll(TrafficSceneScoreVos);
|
|
|
+ vo.setSceneScoreList(NaturalSceneScoreVos);
|
|
|
+ }
|
|
|
+ private void setLastTargetScore(ScenePackageSubListVO vo, String pId){
|
|
|
+ SimulationMptLastTargetScorePo poParam = new SimulationMptLastTargetScorePo();
|
|
|
+ poParam.setPId(pId);
|
|
|
+ poParam.setTarget(vo.getSublistId());
|
|
|
+ SimulationMptLastTargetScorePo po = simulationProjectMapper.selectLastTargetScore(poParam);
|
|
|
+ if(po != null){
|
|
|
+ vo.setNotStandardSceneNum(po.getNotStandardSceneNum());
|
|
|
+ vo.setScore(po.getScore());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setFirstTargetScore(ScenePackageSubListVO vo, String pId){
|
|
|
+ SimulationMptFirstTargetScorePo poParam = new SimulationMptFirstTargetScorePo();
|
|
|
+ poParam.setPId(pId);
|
|
|
+ poParam.setTarget(vo.getSublistId());
|
|
|
+ SimulationMptFirstTargetScorePo po = simulationProjectMapper.selectFirstTargetScore(poParam);
|
|
|
+ if(po != null){
|
|
|
+ vo.setScore(po.getScore());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<SceneScoreVo> setSceneScore(ScenePackageSubListVO vo,String sceneIds, String sceneType, String pId){
|
|
|
+ if(isEmpty(sceneIds)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String[] sceneIdArr = sceneIds.split(",");
|
|
|
+ SceneScoreParam sceneScoreParam = new SceneScoreParam();
|
|
|
+ sceneScoreParam.setPId(pId);
|
|
|
+ sceneScoreParam.setLastTargerId(vo.getSublistId());
|
|
|
+ sceneScoreParam.setSceneType(sceneType);
|
|
|
+ sceneScoreParam.setSceneIds(Arrays.asList(sceneIdArr));
|
|
|
+ List<SceneScoreVo> sceneScoreVos = simulationProjectMapper.selectSceneScoreByIds(sceneScoreParam);
|
|
|
+
|
|
|
+ for(SceneScoreVo s : sceneScoreVos){
|
|
|
+ /*if(SceneTypeEnum.SCENE_NATURAL.getCode().equals(sceneType)){
|
|
|
+ SceneBaseInfoVo sceneBaseInfoVo = simulationProjectMapper.selectSceneNatural(s.getSceneId());
|
|
|
+ if(sceneBaseInfoVo != null){
|
|
|
+ s.setSceneName(sceneBaseInfoVo.getNaturalName());
|
|
|
+ }
|
|
|
+ }else if(SceneTypeEnum.SCENE_STANDARD.getCode().equals(sceneType)){
|
|
|
+ SceneBaseInfoVo sceneBaseInfoVo = simulationProjectMapper.selectSceneStandardsRegulations(s.getSceneId());
|
|
|
+ if(sceneBaseInfoVo != null){
|
|
|
+ s.setSceneName(sceneBaseInfoVo.getSceneName());
|
|
|
+ }
|
|
|
+ }else if(SceneTypeEnum.SCENE_ACCIDENT.getCode().equals(sceneType)){
|
|
|
+ SceneBaseInfoVo sceneBaseInfoVo = simulationProjectMapper.selectSceneAccidentById(s.getSceneId());
|
|
|
+ if(sceneBaseInfoVo != null){
|
|
|
+ s.setSceneName(sceneBaseInfoVo.getSceneName());
|
|
|
+ }
|
|
|
+ }else if(SceneTypeEnum.SCENE_GENERAL.getCode().equals(sceneType)){
|
|
|
+ ///TODO 泛化场景暂不支持
|
|
|
+
|
|
|
+ }*/
|
|
|
+ s.setSceneType(SceneTypeEnum.getState(sceneType));
|
|
|
+ }
|
|
|
+
|
|
|
+ return sceneScoreVos;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getEvaluationLevelReport(Double algorithmScore){
|
|
|
+ String evaluationLevelReport = "";
|
|
|
+ if(algorithmScore >= 90){
|
|
|
+ evaluationLevelReport = "G";
|
|
|
+ }else if(algorithmScore >= 80 && algorithmScore < 90){
|
|
|
+ evaluationLevelReport = "A";
|
|
|
+ }else if(algorithmScore >= 70 && algorithmScore < 80){
|
|
|
+ evaluationLevelReport = "M";
|
|
|
+ }else if(algorithmScore < 70){
|
|
|
+ evaluationLevelReport = "P";
|
|
|
+ }
|
|
|
+ return evaluationLevelReport;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Integer getSetScoreNum(String pId){
|
|
|
+ SimulationMptSceneScorePo po = new SimulationMptSceneScorePo();
|
|
|
+ po.setPId(pId);
|
|
|
+ SceneScoreVo sceneScoreVo = simulationProjectMapper.selectSceneScoreNumQuery(po);
|
|
|
+ return sceneScoreVo.getNum();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|