|
@@ -4,6 +4,7 @@ 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.MinioParameter;
|
|
|
import api.common.pojo.param.project.ProjectTaskParam;
|
|
|
import api.common.pojo.param.project.SceneScoreParam;
|
|
|
import api.common.pojo.param.project.SimulationManualProjectKafkaParam;
|
|
@@ -15,16 +16,13 @@ import api.common.pojo.po.model.ConfigSensorPO;
|
|
|
import api.common.pojo.po.model.VehiclePO;
|
|
|
import api.common.pojo.po.project.*;
|
|
|
import api.common.pojo.po.scene.ScenePackagePO;
|
|
|
-import api.common.pojo.vo.algorithm.AlgorithmVO;
|
|
|
import api.common.pojo.vo.project.*;
|
|
|
import api.common.pojo.vo.scene.RunProjectVO;
|
|
|
-import api.common.util.JsonUtil;
|
|
|
-import api.common.util.ObjectUtil;
|
|
|
-import api.common.util.StringUtil;
|
|
|
-import api.common.util.TimeUtil;
|
|
|
+import api.common.util.*;
|
|
|
import com.css.simulation.resource.common.utils.AuthUtil;
|
|
|
import com.css.simulation.resource.common.utils.PageUtil;
|
|
|
import com.css.simulation.resource.feign.AlgoPlatformService;
|
|
|
+import com.css.simulation.resource.feign.FileDownService;
|
|
|
import com.css.simulation.resource.project.constants.ProjectConstants;
|
|
|
import com.css.simulation.resource.project.enums.ProjectRunStateEnum;
|
|
|
import com.css.simulation.resource.project.enums.SceneTypeEnum;
|
|
@@ -42,6 +40,7 @@ import com.itextpdf.text.pdf.BaseFont;
|
|
|
import com.itextpdf.text.pdf.PdfPCell;
|
|
|
import com.itextpdf.text.pdf.PdfPTable;
|
|
|
import com.itextpdf.text.pdf.PdfWriter;
|
|
|
+import feign.Response;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -88,6 +87,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
@Resource
|
|
|
AlgoPlatformService algoPlatformService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ FileDownService fileDownService;
|
|
|
+
|
|
|
private String[] dateFmtArr= new String[]{"yyyyMMdd", "yyyy-MM-dd HH:mm:ss","yyyy-MM-dd"};
|
|
|
|
|
|
@Override
|
|
@@ -701,25 +703,225 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
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());
|
|
|
+
|
|
|
+
|
|
|
+ //1.获取仿真结果文件
|
|
|
+ InputStream fileInputStream = null;
|
|
|
+ InputStreamReader inputStreamReader = null;
|
|
|
+ BufferedReader bufferedReader = null;
|
|
|
+ File file = null;
|
|
|
+ try {
|
|
|
+ //2.解析仿真文件
|
|
|
+ //time
|
|
|
+ List<Double> time_list = new ArrayList<>();
|
|
|
+ //velocity
|
|
|
+ List<Double> velocity_list = new ArrayList<>();
|
|
|
+ List<Double> lateral_velocity_list = new ArrayList<>();//横 时间
|
|
|
+ List<Double> longitudinal_velocity_list = new ArrayList<>();//纵 速度
|
|
|
+ //acceleration
|
|
|
+ List<Double> acceleration_list = new ArrayList<>();
|
|
|
+ List<Double> lateral_acceleration = new ArrayList<>();//纵向加速度
|
|
|
+ List<Double> longitudinal_acceleration_list = new ArrayList<>();//纵向加速度
|
|
|
+ //lane_offset
|
|
|
+ List<Double> lane_offset_list = new ArrayList<>();
|
|
|
+ ///TODO brake
|
|
|
+ List<Double> brake_list = new ArrayList<>();
|
|
|
+ //steeting_wheel
|
|
|
+ List<Double> steeting_wheel_list = new ArrayList<>();
|
|
|
+ ///TODO throttle
|
|
|
+ List<Double> throttle_list = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+ List<Double> yawrate_list = new ArrayList<>();//摆角速度
|
|
|
+
|
|
|
+ /*File file = new File("E:\\仿真云平台\\任务详情界面数据\\Ego(1).csv");
|
|
|
+ fileInputStream = new FileInputStream(file);
|
|
|
+ inputStreamReader = new InputStreamReader(fileInputStream,"utf-8");*/
|
|
|
+
|
|
|
+ MinioParameter minioParameter = new MinioParameter();
|
|
|
+ minioParameter.setObjectName(po.getRunResultFilePath()+"/Ego.csv");
|
|
|
+ //minioParameter.setObjectName("test/ego.csv");
|
|
|
+ Response download = fileDownService.download(minioParameter);
|
|
|
+ Response.Body body = download.body();
|
|
|
+ fileInputStream = body.asInputStream();
|
|
|
+
|
|
|
+ /*String path = "/temp" + StringUtil.getRandomCode();
|
|
|
+ FileUtil.writeInputStreamToLocalFile(body.asInputStream(),path);
|
|
|
+ file = new File(path);
|
|
|
+ fileInputStream = new FileInputStream(file);*/
|
|
|
+
|
|
|
+ inputStreamReader = new InputStreamReader(fileInputStream,"utf-8");
|
|
|
+
|
|
|
+ bufferedReader = new BufferedReader(inputStreamReader);
|
|
|
+ String line;
|
|
|
+ int lineIndex = 0;
|
|
|
+ while((line = bufferedReader.readLine()) != null){
|
|
|
+ lineIndex++;
|
|
|
+ if(lineIndex == 1){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String[] split = line.split(",");
|
|
|
+
|
|
|
+ try {
|
|
|
+ time_list.add(Double.valueOf(split[1]));
|
|
|
+ }catch (NumberFormatException e){
|
|
|
+ time_list.add(0D);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ lateral_velocity_list.add(Double.valueOf(split[6]));
|
|
|
+ }catch (NumberFormatException e){
|
|
|
+ lateral_velocity_list.add(0D);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ longitudinal_velocity_list.add(Double.valueOf(split[7]));
|
|
|
+ }catch (NumberFormatException e){
|
|
|
+ longitudinal_velocity_list.add(0D);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ lateral_acceleration.add(Double.valueOf(split[8]));
|
|
|
+ }catch (NumberFormatException e){
|
|
|
+ lateral_acceleration.add(0D);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ longitudinal_acceleration_list.add(Double.valueOf(split[9]));
|
|
|
+ }catch (NumberFormatException e){
|
|
|
+ longitudinal_acceleration_list.add(0D);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ steeting_wheel_list.add(Double.valueOf(split[12]));//steering_angle
|
|
|
+ }catch (NumberFormatException e){
|
|
|
+ steeting_wheel_list.add(0D);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ yawrate_list.add(Double.valueOf(split[13]));
|
|
|
+ }catch (NumberFormatException e){
|
|
|
+ yawrate_list.add(0D);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ lane_offset_list.add(Double.valueOf(split[27]));//lane_center_offset
|
|
|
+ }catch (NumberFormatException e){
|
|
|
+ lane_offset_list.add(0D);
|
|
|
+ }
|
|
|
+
|
|
|
+// brake_list.add(Double.valueOf(split[7])); ///TODO 没有
|
|
|
+// throttle_list.add(Double.valueOf(split[7]));///TODO 没有
|
|
|
+
|
|
|
+ }
|
|
|
+ //里程
|
|
|
+ Double lc = 0D;
|
|
|
+ for(int i=0; i<time_list.size(); i++){
|
|
|
+ if(i == 0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ lc += (time_list.get(i)-time_list.get(i-1))*longitudinal_velocity_list.get(i-1);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //平均速度
|
|
|
+ Double pjsd = lc/time_list.get(time_list.size()-1);
|
|
|
+
|
|
|
+ //最大速度
|
|
|
+ Double zdsd = Collections.max(longitudinal_velocity_list);
|
|
|
+
|
|
|
+ //最小速度
|
|
|
+ Double zxsd = Collections.min(longitudinal_velocity_list);
|
|
|
+
|
|
|
+ //最大加速度
|
|
|
+ Double zdjiasd = Collections.max(longitudinal_acceleration_list);
|
|
|
+
|
|
|
+ //最大减速度
|
|
|
+ Double zdjiansd = Collections.min(longitudinal_acceleration_list);
|
|
|
+
|
|
|
+ //最大摆角速度
|
|
|
+ Double zdbjsd = Collections.max(yawrate_list);
|
|
|
+
|
|
|
+ //自车速度方差
|
|
|
+ Double zcsdfc = 0D;
|
|
|
+ for(Double d :longitudinal_velocity_list){
|
|
|
+ zcsdfc +=Math.pow(d-pjsd,2);
|
|
|
+ }
|
|
|
+ zcsdfc = zcsdfc/longitudinal_velocity_list.size();
|
|
|
+
|
|
|
+ //自车横摆角速度均方根
|
|
|
+ Double zchbjsdjfg = 0D;
|
|
|
+ for(Double d :yawrate_list){
|
|
|
+ zchbjsdjfg += Math.pow(d-pjsd,2);
|
|
|
+ }
|
|
|
+ zchbjsdjfg = Math.sqrt(zchbjsdjfg/yawrate_list.size());
|
|
|
+
|
|
|
+ for(int i=0; i<lateral_acceleration.size(); i++){
|
|
|
+ Double aDouble = lateral_acceleration.get(i);
|
|
|
+ Double aDouble1 = longitudinal_acceleration_list.get(i);
|
|
|
+ Double d = Math.pow(aDouble,2)+Math.pow(aDouble1,2);
|
|
|
+ acceleration_list.add(Math.sqrt(d));
|
|
|
+ }
|
|
|
+
|
|
|
+ for(int i=0; i<lateral_velocity_list.size(); i++){
|
|
|
+ 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(d);
|
|
|
+ }
|
|
|
+
|
|
|
+ //任务详情信息
|
|
|
+ resultVo.setMileage(lc.toString());
|
|
|
+ resultVo.setAverageVelocity(pjsd.toString());
|
|
|
+ resultVo.setMaximunSpeed(zdsd.toString());
|
|
|
+ resultVo.setMinimunVelocity(zxsd.toString());
|
|
|
+ resultVo.setMaximumAcceleration(zdjiasd.toString());
|
|
|
+ resultVo.setMaximumDeceleration(zdjiansd.toString());
|
|
|
+ resultVo.setMaximumSwingSpeed(zdbjsd.toString());
|
|
|
+ resultVo.setSpeedVariance(zcsdfc);
|
|
|
+// resultVo.setSpeedComfortLevel(po.getSpeedComfortLevel());
|
|
|
+
|
|
|
+ resultVo.setSwingSpeedMeanSquareRoot(zchbjsdjfg);
|
|
|
+// resultVo.setSwingComfortLevel(po.getSwingComfortLevel());
|
|
|
+
|
|
|
+ HashMap<String, List> CurveData = new HashMap<>();
|
|
|
+ CurveData.put("time",time_list);
|
|
|
+ CurveData.put("acceleration",acceleration_list);
|
|
|
+ CurveData.put("lane_offset",lane_offset_list);
|
|
|
+ CurveData.put("brake",brake_list);
|
|
|
+ CurveData.put("steeting",steeting_wheel_list);
|
|
|
+ CurveData.put("throttle",throttle_list);
|
|
|
+ CurveData.put("yaw_rate",yawrate_list);
|
|
|
+ CurveData.put("velocity",velocity_list);
|
|
|
+ resultVo.setCurveData(CurveData);
|
|
|
+
|
|
|
+
|
|
|
+ } catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+
|
|
|
+ }finally {
|
|
|
+ try {
|
|
|
+ if(fileInputStream != null){
|
|
|
+ fileInputStream.close();
|
|
|
+ }
|
|
|
+ if(inputStreamReader != null){
|
|
|
+ inputStreamReader.close();
|
|
|
+ }
|
|
|
+ if(bufferedReader != null){
|
|
|
+ bufferedReader.close();
|
|
|
+ }
|
|
|
+ if(file != null ){
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+ }catch (IOException e){
|
|
|
+ e.printStackTrace();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,resultVo);
|
|
|
}
|
|
@@ -2626,6 +2828,47 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ResponseBodyVO saveEvaluationLevel(SimulationManualProjectParam param) {
|
|
|
+
|
|
|
+ String id = param.getId();
|
|
|
+ if(StringUtil.isEmpty(id)){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE,"工作名称不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ SimulationManualProjectPo po = simulationProjectMapper.selectProjectBaseById(param);
|
|
|
+ if(StringUtil.isEmpty(id)){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE,"工作名称不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ScenePackageSubListVO> scenePackageSubListVOS = simulationProjectMapper.selectSubSceneByPid(po.getScene());
|
|
|
+
|
|
|
+ String evaluationLevelReport = "";
|
|
|
+
|
|
|
+ if(!isEmpty(scenePackageSubListVOS)){
|
|
|
+ Double totalScore = 0D;
|
|
|
+ for(ScenePackageSubListVO v : scenePackageSubListVOS){
|
|
|
+ Double weightDouble = Double.valueOf(v.getWeight());
|
|
|
+ //单个二级指标得分
|
|
|
+ SimulationMptFirstTargetScorePo simulationMptFirstTargetScorePo = new SimulationMptFirstTargetScorePo();
|
|
|
+ simulationMptFirstTargetScorePo.setPId(po.getId());
|
|
|
+ simulationMptFirstTargetScorePo.setTarget(v.getSublistId());
|
|
|
+ SimulationMptFirstTargetScorePo simulationMptFirstTargetScorePo1 = simulationMptFirstTargetScoreMapper.selectFirstTargetScore(simulationMptFirstTargetScorePo);
|
|
|
+ Double score = simulationMptFirstTargetScorePo1.getScore();
|
|
|
+
|
|
|
+ totalScore += score*(weightDouble/100);
|
|
|
+ }
|
|
|
+ evaluationLevelReport = getEvaluationLevelReport(saveTwoDecimalPlaces(totalScore));
|
|
|
+ }
|
|
|
+
|
|
|
+ SimulationManualProjectPo simulationManualProjectPo = new SimulationManualProjectPo();
|
|
|
+ simulationManualProjectPo.setId(id);
|
|
|
+ simulationManualProjectPo.setEvaluationLevel(evaluationLevelReport);
|
|
|
+ simulationProjectMapper.saveEvaluationLevel(simulationManualProjectPo);
|
|
|
+
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 换行
|
|
|
* @param lineNum 换行数量
|