|
@@ -1,10 +1,10 @@
|
|
|
package com.css.simulation.resource.scene.service;
|
|
|
|
|
|
+import api.common.pojo.common.ResponseBodyVO;
|
|
|
import api.common.pojo.param.MinioParameter;
|
|
|
import api.common.pojo.param.scene.SceneNaturalNewParam;
|
|
|
import api.common.pojo.param.scene.SceneNaturalParam;
|
|
|
import api.common.pojo.po.scene.SceneNaturalPO;
|
|
|
-import api.common.util.FileUtil;
|
|
|
import api.common.util.ObjectUtil;
|
|
|
import api.common.util.ParamUtil;
|
|
|
import api.common.util.TimeUtil;
|
|
@@ -20,11 +20,8 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
-import java.util.stream.IntStream;
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
@@ -37,101 +34,107 @@ public class SceneNaturalService {
|
|
|
|
|
|
@Resource
|
|
|
private FileDownService fileDownService;
|
|
|
+
|
|
|
/**
|
|
|
* 获取自然驾驶场景数据:包括切分数据和标注数据
|
|
|
*/
|
|
|
@SneakyThrows
|
|
|
- public void importZrjsSceneCicv(SceneNaturalParam param) {
|
|
|
- MinioParameter MI=new MinioParameter();
|
|
|
+ public ResponseBodyVO<String> importZrjsSceneCicv(SceneNaturalParam param) {
|
|
|
+ MinioParameter MI = new MinioParameter();
|
|
|
MI.setObjectName(param.getJsonAddress());
|
|
|
- int idx=param.getJsonAddress().lastIndexOf("/");
|
|
|
- int end=param.getJsonAddress().lastIndexOf(".");
|
|
|
- String fileName=param.getJsonAddress().substring(idx+1,end);
|
|
|
+ int idx = param.getJsonAddress().lastIndexOf("/");
|
|
|
+ int end = param.getJsonAddress().lastIndexOf(".");
|
|
|
+ String fileName = param.getJsonAddress().substring(idx + 1, end);
|
|
|
+ param.setNaturalName(fileName);
|
|
|
+ List<SceneNaturalPO> list = sceneNaturalMapper.querySceneNaturaByName(param);
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "该场景编号" + fileName + "已存在,请检查");
|
|
|
+ }
|
|
|
Response download = fileDownService.download(MI);
|
|
|
- String json =download.body().toString();
|
|
|
- ObjectMapper objMap = new ObjectMapper();
|
|
|
- JsonNode root = objMap.readTree(json);
|
|
|
- // -------------------------------- 自然环境 --------------------------------
|
|
|
- JsonNode naturalEnvironment = root.path("自然环境");
|
|
|
- // -------------------------------- 道路 --------------------------------
|
|
|
- JsonNode road = root.path("道路");
|
|
|
- // -------------------------------- 基础设施 --------------------------------
|
|
|
- JsonNode infrastructure = root.path("基础设施");
|
|
|
- // -------------------------------- 临时性操纵 --------------------------------
|
|
|
- JsonNode temporaryManipulation = root.path("临时性操纵");
|
|
|
- // -------------------------------- 交通状况 --------------------------------
|
|
|
- JsonNode traffic = root.path("交通状况");
|
|
|
- // -------------------------------- 自车行为 --------------------------------
|
|
|
- JsonNode selfDrivingBehavior = root.path("自车行为");
|
|
|
- // -------------------------------- 目标行为 --------------------------------
|
|
|
- JsonNode targetBehavior = root.path("目标行为");
|
|
|
- SceneNaturalPO sceneNaturalPO = null;
|
|
|
- sceneNaturalPO = sceneNaturalPO.builder()
|
|
|
- .naturalId(api.common.util.StringUtil.getRandomUUID())
|
|
|
- .naturalName(fileName)
|
|
|
- .weather(getSequenceNew(naturalEnvironment, "天气情况"))
|
|
|
- .backlight(getSequenceNew(naturalEnvironment, "逆光"))
|
|
|
- .lightChange(getSequenceNew(naturalEnvironment, "隧道光线变化"))
|
|
|
- .roadType(getSequenceNew(road, "道路类型"))
|
|
|
- .roadMatrrial(getSequenceNew(road, "路面材质"))
|
|
|
- .drivewayNum(getSequenceNew(road, "车道数量"))
|
|
|
- .drivewayType(getSequenceNew(road, "车道类型"))
|
|
|
- .roadFlatness(getSequenceNew(road, "道路平坦程度"))
|
|
|
- .roadCurvature(getSequenceNew(road, "道路弯曲度"))
|
|
|
- .ramp(getSequenceNew(road, "匝道"))
|
|
|
- .intersectionType(getSequenceNew(road, "路口类型"))
|
|
|
- .planeIntersection(getSequenceNew(road, "道路与铁路平面交叉"))
|
|
|
- .bridge(getSequenceNew(road, "桥梁"))
|
|
|
- .tunnel(getSequenceNew(road, "隧道"))
|
|
|
- .speedLimit(getSequenceNew(infrastructure, "限速标志"))
|
|
|
- .minSpeedLimit(getSequenceNew(infrastructure, "最低限速标志"))
|
|
|
- .noEntry(getSequenceNew(infrastructure, "禁止通行"))
|
|
|
- .noStopping(getSequenceNew(infrastructure, "禁止停车"))
|
|
|
- .leftLaneLine(getSequenceNew(infrastructure, "左侧车道线"))
|
|
|
- .rightLaneLine(getSequenceNew(infrastructure, "右侧车道线"))
|
|
|
- .conductorMarking(getSequenceNew(infrastructure, "导线标线及标志"))
|
|
|
- .pedestrianCrossing(getSequenceNew(infrastructure, "人行横道"))
|
|
|
- .trafficLight(getSequenceNew(infrastructure, "交通信号灯"))
|
|
|
- .decelerationMarking(getSequenceNew(infrastructure, "减速标线"))
|
|
|
- .pavementCondition(getSequenceNew(temporaryManipulation, "路面状况"))
|
|
|
- .naturalDisaster(getSequenceNew(temporaryManipulation, "自然灾害"))
|
|
|
- .roadSafetySigns(getSequenceNew(temporaryManipulation, "道路施工安全标识"))
|
|
|
- .safetyWarningBoard(getSequenceNew(temporaryManipulation, "三角安全警示牌"))
|
|
|
- .trafficAccident(getSequenceNew(traffic, "交通事故"))
|
|
|
- .violation(getSequenceNew(traffic, "违规"))
|
|
|
- .specialVehicleYield(getSequenceNew(traffic, "特种车辆让行"))
|
|
|
- .patency(getSequenceNew(traffic, "通畅情况"))
|
|
|
- .doubleFlashingCar(getSequenceNew(traffic, "双闪车辆"))
|
|
|
- .selfBehavior(getSequenceNew(selfDrivingBehavior))
|
|
|
- .targetBehavior(getSequenceNew(targetBehavior))
|
|
|
- .isDeleted("0")
|
|
|
- .build();
|
|
|
- // -------------------------------- 保存数据到 mysql --------------------------------
|
|
|
- sceneNaturalPO.setCreateTime(TimeUtil.getNowForMysql());
|
|
|
- sceneNaturalPO.setCreateUserId(AuthUtil.getCurrentUserId());
|
|
|
- sceneNaturalPO.setModifyTime(TimeUtil.getNowForMysql());
|
|
|
-
|
|
|
- if(null!=param.getJsonAddress()&&!param.getJsonAddress().equals("")){
|
|
|
- sceneNaturalPO.setJsonAddress(param.getJsonAddress());
|
|
|
- }
|
|
|
- if(null!=param.getXoscAddress()&&!param.getXoscAddress().equals("")){
|
|
|
- sceneNaturalPO.setXoscAddress(param.getXoscAddress());
|
|
|
- }
|
|
|
- if(null!=param.getXodrAddress()&&!param.getXodrAddress().equals("")){
|
|
|
- sceneNaturalPO.setXodrAddress(param.getXodrAddress());
|
|
|
- }
|
|
|
- if(null!=param.getOsgbAddress()&&!param.getOsgbAddress().equals("")){
|
|
|
- sceneNaturalPO.setOsgbAddress(param.getOsgbAddress());
|
|
|
- }
|
|
|
- if(null!=param.getVideoAddress()&&!param.getVideoAddress().equals("")){
|
|
|
- sceneNaturalPO.setVideoAddress(param.getVideoAddress());
|
|
|
- }
|
|
|
- if(null!=param.getVideoPreview()&&!param.getVideoPreview().equals("")){
|
|
|
- sceneNaturalPO.setVideoPreview(param.getVideoPreview());
|
|
|
- }
|
|
|
-
|
|
|
- sceneNaturalMapper.saveSceneNatural(sceneNaturalPO);
|
|
|
+ String json = download.body().toString();
|
|
|
+ ObjectMapper objMap = new ObjectMapper();
|
|
|
+ JsonNode root = objMap.readTree(json);
|
|
|
+ // -------------------------------- 自然环境 --------------------------------
|
|
|
+ JsonNode naturalEnvironment = root.path("自然环境");
|
|
|
+ // -------------------------------- 道路 --------------------------------
|
|
|
+ JsonNode road = root.path("道路");
|
|
|
+ // -------------------------------- 基础设施 --------------------------------
|
|
|
+ JsonNode infrastructure = root.path("基础设施");
|
|
|
+ // -------------------------------- 临时性操纵 --------------------------------
|
|
|
+ JsonNode temporaryManipulation = root.path("临时性操纵");
|
|
|
+ // -------------------------------- 交通状况 --------------------------------
|
|
|
+ JsonNode traffic = root.path("交通状况");
|
|
|
+ // -------------------------------- 自车行为 --------------------------------
|
|
|
+ JsonNode selfDrivingBehavior = root.path("自车行为");
|
|
|
+ // -------------------------------- 目标行为 --------------------------------
|
|
|
+ JsonNode targetBehavior = root.path("目标行为");
|
|
|
+ SceneNaturalPO sceneNaturalPO = null;
|
|
|
+ sceneNaturalPO = sceneNaturalPO.builder()
|
|
|
+ .naturalId(api.common.util.StringUtil.getRandomUUID())
|
|
|
+ .naturalName(fileName)
|
|
|
+ .weather(getSequenceNew(naturalEnvironment, "天气情况"))
|
|
|
+ .backlight(getSequenceNew(naturalEnvironment, "逆光"))
|
|
|
+ .lightChange(getSequenceNew(naturalEnvironment, "隧道光线变化"))
|
|
|
+ .roadType(getSequenceNew(road, "道路类型"))
|
|
|
+ .roadMatrrial(getSequenceNew(road, "路面材质"))
|
|
|
+ .drivewayNum(getSequenceNew(road, "车道数量"))
|
|
|
+ .drivewayType(getSequenceNew(road, "车道类型"))
|
|
|
+ .roadFlatness(getSequenceNew(road, "道路平坦程度"))
|
|
|
+ .roadCurvature(getSequenceNew(road, "道路弯曲度"))
|
|
|
+ .ramp(getSequenceNew(road, "匝道"))
|
|
|
+ .intersectionType(getSequenceNew(road, "路口类型"))
|
|
|
+ .planeIntersection(getSequenceNew(road, "道路与铁路平面交叉"))
|
|
|
+ .bridge(getSequenceNew(road, "桥梁"))
|
|
|
+ .tunnel(getSequenceNew(road, "隧道"))
|
|
|
+ .speedLimit(getSequenceNew(infrastructure, "限速标志"))
|
|
|
+ .minSpeedLimit(getSequenceNew(infrastructure, "最低限速标志"))
|
|
|
+ .noEntry(getSequenceNew(infrastructure, "禁止通行"))
|
|
|
+ .noStopping(getSequenceNew(infrastructure, "禁止停车"))
|
|
|
+ .leftLaneLine(getSequenceNew(infrastructure, "左侧车道线"))
|
|
|
+ .rightLaneLine(getSequenceNew(infrastructure, "右侧车道线"))
|
|
|
+ .conductorMarking(getSequenceNew(infrastructure, "导线标线及标志"))
|
|
|
+ .pedestrianCrossing(getSequenceNew(infrastructure, "人行横道"))
|
|
|
+ .trafficLight(getSequenceNew(infrastructure, "交通信号灯"))
|
|
|
+ .decelerationMarking(getSequenceNew(infrastructure, "减速标线"))
|
|
|
+ .pavementCondition(getSequenceNew(temporaryManipulation, "路面状况"))
|
|
|
+ .naturalDisaster(getSequenceNew(temporaryManipulation, "自然灾害"))
|
|
|
+ .roadSafetySigns(getSequenceNew(temporaryManipulation, "道路施工安全标识"))
|
|
|
+ .safetyWarningBoard(getSequenceNew(temporaryManipulation, "三角安全警示牌"))
|
|
|
+ .trafficAccident(getSequenceNew(traffic, "交通事故"))
|
|
|
+ .violation(getSequenceNew(traffic, "违规"))
|
|
|
+ .specialVehicleYield(getSequenceNew(traffic, "特种车辆让行"))
|
|
|
+ .patency(getSequenceNew(traffic, "通畅情况"))
|
|
|
+ .doubleFlashingCar(getSequenceNew(traffic, "双闪车辆"))
|
|
|
+ .selfBehavior(getSequenceNew(selfDrivingBehavior))
|
|
|
+ .targetBehavior(getSequenceNew(targetBehavior))
|
|
|
+ .isDeleted("0")
|
|
|
+ .build();
|
|
|
+ // -------------------------------- 保存数据到 mysql --------------------------------
|
|
|
+ sceneNaturalPO.setCreateTime(TimeUtil.getNowForMysql());
|
|
|
+ sceneNaturalPO.setCreateUserId(AuthUtil.getCurrentUserId());
|
|
|
+ sceneNaturalPO.setModifyTime(TimeUtil.getNowForMysql());
|
|
|
+
|
|
|
+ if (null != param.getJsonAddress() && !param.getJsonAddress().equals("")) {
|
|
|
+ sceneNaturalPO.setJsonAddress(param.getJsonAddress());
|
|
|
+ }
|
|
|
+ if (null != param.getXoscAddress() && !param.getXoscAddress().equals("")) {
|
|
|
+ sceneNaturalPO.setXoscAddress(param.getXoscAddress());
|
|
|
+ }
|
|
|
+ if (null != param.getXodrAddress() && !param.getXodrAddress().equals("")) {
|
|
|
+ sceneNaturalPO.setXodrAddress(param.getXodrAddress());
|
|
|
+ }
|
|
|
+ if (null != param.getOsgbAddress() && !param.getOsgbAddress().equals("")) {
|
|
|
+ sceneNaturalPO.setOsgbAddress(param.getOsgbAddress());
|
|
|
+ }
|
|
|
+ if (null != param.getVideoAddress() && !param.getVideoAddress().equals("")) {
|
|
|
+ sceneNaturalPO.setVideoAddress(param.getVideoAddress());
|
|
|
+ }
|
|
|
+ if (null != param.getVideoPreview() && !param.getVideoPreview().equals("")) {
|
|
|
+ sceneNaturalPO.setVideoPreview(param.getVideoPreview());
|
|
|
+ }
|
|
|
|
|
|
+ sceneNaturalMapper.saveSceneNatural(sceneNaturalPO);
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
}
|
|
|
|
|
|
public String getSequenceNew(JsonNode jsonObject, String field) throws Exception {
|
|
@@ -180,58 +183,67 @@ public class SceneNaturalService {
|
|
|
else
|
|
|
return s;
|
|
|
}
|
|
|
- public List<SceneNaturalPO> querySceneNaturalList(SceneNaturalNewParam params) {
|
|
|
- SceneNaturalParam po=new SceneNaturalParam();
|
|
|
- String naturalName=params.getNaturalName(); // 场景编号
|
|
|
- String[][] naturalEnvironment=params.getNaturalEnvironment() ; //自然环境
|
|
|
- String[][] road =params.getRoad(); //道路
|
|
|
- String[][] infrastructure =params.getInfrastructure(); //基础设施
|
|
|
- String[][] temporaryOperation =params.getTemporaryOperation(); //临时性操作
|
|
|
- String[][] trafficCondition =params.getTrafficCondition(); //交通状况
|
|
|
- String[][] selfBehavior =params.getSelfBehavior() ;//自车行为
|
|
|
- String[][] targetBehavior =params.getTargetBehavior(); //目标行为
|
|
|
- if(ObjectUtil.isNotNull(naturalName)) {
|
|
|
+
|
|
|
+ public List<SceneNaturalPO> querySceneNaturalList(SceneNaturalNewParam params) {
|
|
|
+ SceneNaturalParam po = new SceneNaturalParam();
|
|
|
+ String naturalName = params.getNaturalName(); // 场景编号
|
|
|
+ String[][] naturalEnvironment = params.getNaturalEnvironment(); //自然环境
|
|
|
+ String[][] road = params.getRoad(); //道路
|
|
|
+ String[][] infrastructure = params.getInfrastructure(); //基础设施
|
|
|
+ String[][] temporaryOperation = params.getTemporaryOperation(); //临时性操作
|
|
|
+ String[][] trafficCondition = params.getTrafficCondition(); //交通状况
|
|
|
+ String[][] selfBehavior = params.getSelfBehavior();//自车行为
|
|
|
+ String[][] targetBehavior = params.getTargetBehavior(); //目标行为
|
|
|
+ if (ObjectUtil.isNotNull(params.getIds())) {
|
|
|
+ po.setIds(params.getIds());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotNull(naturalName)) {
|
|
|
po.setNaturalName(naturalName);
|
|
|
}
|
|
|
- if(naturalEnvironment!=null&&naturalEnvironment.length>0) {
|
|
|
+ if (naturalEnvironment != null && naturalEnvironment.length > 0) {
|
|
|
ParamUtil.arrConvertObj(naturalEnvironment, po);
|
|
|
}
|
|
|
- if(road!=null&&road.length>0) {
|
|
|
+ if (road != null && road.length > 0) {
|
|
|
ParamUtil.arrConvertObj(road, po);
|
|
|
}
|
|
|
- if(infrastructure!=null&&infrastructure.length>0) {
|
|
|
+ if (infrastructure != null && infrastructure.length > 0) {
|
|
|
ParamUtil.arrConvertObj(infrastructure, po);
|
|
|
}
|
|
|
- if(temporaryOperation!=null&&temporaryOperation.length>0) {
|
|
|
+ if (temporaryOperation != null && temporaryOperation.length > 0) {
|
|
|
ParamUtil.arrConvertObj(temporaryOperation, po);
|
|
|
}
|
|
|
- if(trafficCondition!=null&&trafficCondition.length>0) {
|
|
|
+ if (trafficCondition != null && trafficCondition.length > 0) {
|
|
|
ParamUtil.arrConvertObj(trafficCondition, po);
|
|
|
}
|
|
|
- if(selfBehavior!=null&&selfBehavior.length>0) {
|
|
|
+ if (selfBehavior != null && selfBehavior.length > 0) {
|
|
|
ParamUtil.arrConvertObj(selfBehavior, po);
|
|
|
- for (String [] arr : selfBehavior) {
|
|
|
- if(arr != null && arr.length ==1 ){
|
|
|
- List list=po.getSelfBehavior();
|
|
|
- if(list==null){
|
|
|
- List newList=new ArrayList();
|
|
|
+ for (String[] arr : selfBehavior) {
|
|
|
+ if (arr != null && arr.length == 1) {
|
|
|
+ List list = po.getSelfBehavior();
|
|
|
+ if (list == null) {
|
|
|
+ List newList = new ArrayList();
|
|
|
newList.add(arr[0]);
|
|
|
- po.setSelfBehavior(newList); ;
|
|
|
- }else{
|
|
|
+ po.setSelfBehavior(newList);
|
|
|
+ ;
|
|
|
+ } else {
|
|
|
|
|
|
list.add(arr[0]);
|
|
|
- po.setSelfBehavior(list); ;
|
|
|
+ po.setSelfBehavior(list);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- if(targetBehavior!=null&&targetBehavior.length>0) {
|
|
|
+ if (targetBehavior != null && targetBehavior.length > 0) {
|
|
|
ParamUtil.arrConvertObj(targetBehavior, po);
|
|
|
}
|
|
|
List<SceneNaturalPO> list = sceneNaturalMapper.querySceneNaturalList(po);
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+ public void deleteSceneNatural(SceneNaturalPO params) {
|
|
|
+ params.setIsDeleted("1");
|
|
|
+ params.setModifyTime(TimeUtil.getNowForMysql());
|
|
|
+ params.setModifyUserId(AuthUtil.getCurrentUserId());
|
|
|
+ sceneNaturalMapper.deleteSceneNatural(params);
|
|
|
+ }
|
|
|
}
|