|
@@ -1,14 +1,20 @@
|
|
|
package com.css.simulation.resource.scene.service;
|
|
|
|
|
|
+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;
|
|
|
import com.css.simulation.resource.common.utils.AuthUtil;
|
|
|
+import com.css.simulation.resource.feign.FileDownService;
|
|
|
import com.css.simulation.resource.scene.mapper.SceneNaturalMapper;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.github.pagehelper.util.StringUtil;
|
|
|
+import feign.Response;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -28,35 +34,20 @@ public class SceneNaturalService {
|
|
|
private SceneNaturalMapper sceneNaturalMapper;
|
|
|
|
|
|
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private FileDownService fileDownService;
|
|
|
/**
|
|
|
* 获取自然驾驶场景数据:包括切分数据和标注数据
|
|
|
*/
|
|
|
@SneakyThrows
|
|
|
public void importZrjsSceneCicv(SceneNaturalParam param) {
|
|
|
- //1 获取所有目录下所有场景
|
|
|
- // String dataUrl0 ="C:\\Users\\CSS\\Desktop\\GQ\\仿真云平台\\场景数据样例\\测试\\2021-08-06-08-40-47_2"; // 场景数据根路径
|
|
|
- String dataUrl0 = param.getPath();
|
|
|
-
|
|
|
- File[] scenes = FileUtil.getDirectory(dataUrl0).listFiles();
|
|
|
- if (scenes == null) {
|
|
|
- throw new RuntimeException("目录:" + dataUrl0 + " 下没有文件!");
|
|
|
- }
|
|
|
-
|
|
|
- String fileName = null;
|
|
|
- try {
|
|
|
-
|
|
|
- for (File scene : scenes) {
|
|
|
- String dataUrl = scene.getAbsolutePath();
|
|
|
- if(dataUrl.indexOf(".json")!=-1){
|
|
|
- //获取文件名
|
|
|
- File tempFile =new File( dataUrl.trim());
|
|
|
- fileName = tempFile.getName();
|
|
|
- fileName= fileName.substring(0,fileName.lastIndexOf("."));
|
|
|
- // -------------------------------- 读取结构化数据文件 --------------------------------
|
|
|
- List<String> exceptionList = new ArrayList<>(); // 异常列表
|
|
|
- // -------------------------------- label.json --------------------------------
|
|
|
- String json = FileUtil.readFile(dataUrl);
|
|
|
+ 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);
|
|
|
+ Response download = fileDownService.download(MI);
|
|
|
+ String json =download.body().toString();
|
|
|
ObjectMapper objMap = new ObjectMapper();
|
|
|
JsonNode root = objMap.readTree(json);
|
|
|
// -------------------------------- 自然环境 --------------------------------
|
|
@@ -134,17 +125,12 @@ public class SceneNaturalService {
|
|
|
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);
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("场景" + fileName + " 解析出错:", e);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public String getSequenceNew(JsonNode jsonObject, String field) throws Exception {
|
|
@@ -193,8 +179,41 @@ public class SceneNaturalService {
|
|
|
else
|
|
|
return s;
|
|
|
}
|
|
|
- public List<SceneNaturalPO> querySceneNaturalList(SceneNaturalParam params) {
|
|
|
- List<SceneNaturalPO> list = sceneNaturalMapper.querySceneNaturalList(params);
|
|
|
+ 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)) {
|
|
|
+ po.setNaturalName(naturalName);
|
|
|
+ }
|
|
|
+ if(naturalEnvironment!=null&&naturalEnvironment.length>0) {
|
|
|
+ ParamUtil.arrConvertObj(naturalEnvironment, po);
|
|
|
+ }
|
|
|
+ if(road!=null&&road.length>0) {
|
|
|
+ ParamUtil.arrConvertObj(road, po);
|
|
|
+ }
|
|
|
+ if(infrastructure!=null&&infrastructure.length>0) {
|
|
|
+ ParamUtil.arrConvertObj(infrastructure, po);
|
|
|
+ }
|
|
|
+ if(temporaryOperation!=null&&temporaryOperation.length>0) {
|
|
|
+ ParamUtil.arrConvertObj(temporaryOperation, po);
|
|
|
+ }
|
|
|
+ if(trafficCondition!=null&&trafficCondition.length>0) {
|
|
|
+ ParamUtil.arrConvertObj(trafficCondition, po);
|
|
|
+ }
|
|
|
+ if(selfBehavior!=null&&selfBehavior.length>0) {
|
|
|
+ ParamUtil.arrConvertObj(selfBehavior, po);
|
|
|
+ }
|
|
|
+ if(targetBehavior!=null&&targetBehavior.length>0) {
|
|
|
+ ParamUtil.arrConvertObj(targetBehavior, po);
|
|
|
+ }
|
|
|
+ List<SceneNaturalPO> list = sceneNaturalMapper.querySceneNaturalList(po);
|
|
|
return list;
|
|
|
}
|
|
|
}
|