Pārlūkot izejas kodu

王耀栋--工作台模块代码:新增文件解析测试接口

wangyaodong 3 gadi atpakaļ
vecāks
revīzija
e45a30d889

+ 11 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/project/ctrl/SimulationProjectCtrl.java

@@ -141,5 +141,16 @@ public class SimulationProjectCtrl {
     }
 
 
+    /**
+     * 解析车辆坐标文件
+     * @return
+     */
+    @RequestMapping("analysisVehicleCoord")
+    @ResponseBody
+    public ResponseBodyVO analysisVehicleCoord() throws Exception {
+        return service.analysisVehicleCoord();
+    }
+
+
 
 }

+ 41 - 14
simulation-resource-server/src/main/java/com/css/simulation/resource/project/impl/SimulationProjectServiceImpl.java

@@ -27,6 +27,8 @@ import com.github.pagehelper.PageInfo;
 import lombok.SneakyThrows;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.io.*;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.text.ParseException;
@@ -583,28 +585,53 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         return "";
     }
 
+    @Override
+    public ResponseBodyVO analysisVehicleCoord() throws Exception {
+
+        analysisCsvFile("E:\\仿真云平台\\三维还原视频说明\\360ogt.csv",new int[]{6,7,9});
+
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,null);
+
+    }
+
+    private void analysisCsvFile(String filePath, int[] analysisFields) throws Exception {
+
+        File file = new File(filePath);
+        InputStream fileInputStream = new FileInputStream(file);
+        InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream,"utf-8");
+        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
+        String line;
+        while((line = bufferedReader.readLine()) != null){
+            String[] split = line.split(",");
+            for(int fs : analysisFields){
+                System.out.println(split[fs]);
+            }
+
+        }
+    }
+
     /**
      * 根据场景id和场景类型获取场景名
      * @return
      */
     private SceneBaseInfoVo getsceneNameAndOther(String sceneId, String sceneType){
         SceneBaseInfoVo resultVo = new SceneBaseInfoVo();
-        if("1".equals(sceneType)){
+        if(DictConstants.SCENE_NATURAL.equals(sceneType)){
             SceneBaseInfoVo sceneBaseInfoVo = simulationProjectMapper.selectSceneNatural(sceneId);
             if(sceneBaseInfoVo != null){
                 resultVo.setCommonSceneName(sceneBaseInfoVo.getNaturalName());
             }
-        }else if("2".equals(sceneType)){
+        }else if(DictConstants.SCENE_STANDARD.equals(sceneType)){
             SceneBaseInfoVo sceneBaseInfoVo = simulationProjectMapper.selectSceneStandardsRegulations(sceneId);
             if(sceneBaseInfoVo != null){
                 resultVo.setCommonSceneName(sceneBaseInfoVo.getSceneName());
             }
-        }else if("3".equals(sceneType)){
+        }else if(DictConstants.SCENE_ACCIDENT.equals(sceneType)){
             SceneBaseInfoVo sceneBaseInfoVo = simulationProjectMapper.selectSceneAccidentById(sceneId);
             if(sceneBaseInfoVo != null){
                 resultVo.setCommonSceneName(sceneBaseInfoVo.getSceneName());
             }
-        }else if("4".equals(sceneType)){
+        }else if(DictConstants.SCENE_GENERAL.equals(sceneType)){
             ///TODO 泛化场景暂不支持
 
         }
@@ -792,25 +819,25 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         String sceneType = vo.getSceneType();
         String sceneId = vo.getSceneId();
         SceneBaseInfoVo sceneBaseInfoVo;
-        if("1".equals(sceneType)){
+        if(DictConstants.SCENE_NATURAL.equals(sceneType)){
             //自然驾驶
             sceneBaseInfoVo = simulationProjectMapper.selectSceneNatural(sceneId);
             if(sceneBaseInfoVo != null){
                 vo.setSceneName(sceneBaseInfoVo.getNaturalName());
             }
-        }else if("2".equals(sceneType)){
+        }else if(DictConstants.SCENE_STANDARD.equals(sceneType)){
             //标准法规
             sceneBaseInfoVo = simulationProjectMapper.selectSceneStandardsRegulations(sceneId);
             if(sceneBaseInfoVo != null){
                 vo.setSceneName(sceneBaseInfoVo.getSceneName());
             }
-        }else if("3".equals(sceneType)){
+        }else if(DictConstants.SCENE_ACCIDENT.equals(sceneType)){
             //交通事故
             sceneBaseInfoVo = simulationProjectMapper.selectSceneAccidentById(sceneId);
             if(sceneBaseInfoVo != null){
                 vo.setSceneName(sceneBaseInfoVo.getSceneName());
             }
-        }else if("4".equals(sceneType)){
+        }else if(DictConstants.SCENE_GENERAL.equals(sceneType)){
             /// TODO 泛化场景暂不支持
 
         }
@@ -856,7 +883,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                     SimulationMptSceneScorePo simulationMptSceneScorePo = new SimulationMptSceneScorePo();
                     simulationMptSceneScorePo.setPId(id);
                     simulationMptSceneScorePo.setSceneId(s);
-                    simulationMptSceneScorePo.setSceneType("1");
+                    simulationMptSceneScorePo.setSceneType(DictConstants.SCENE_NATURAL);
                     simulationMptSceneScorePo.createPo(AuthUtil.getCurrentUserId());
                     simulationProjectMapper.insertSimulationMptSceneScorePo(simulationMptSceneScorePo);
                 }
@@ -869,7 +896,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                     SimulationMptSceneScorePo simulationMptSceneScorePo = new SimulationMptSceneScorePo();
                     simulationMptSceneScorePo.setPId(id);
                     simulationMptSceneScorePo.setSceneId(s);
-                    simulationMptSceneScorePo.setSceneType("3");
+                    simulationMptSceneScorePo.setSceneType(DictConstants.SCENE_ACCIDENT);
                     simulationMptSceneScorePo.createPo(AuthUtil.getCurrentUserId());
                     simulationProjectMapper.insertSimulationMptSceneScorePo(simulationMptSceneScorePo);
                 }
@@ -881,7 +908,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                     SimulationMptSceneScorePo simulationMptSceneScorePo = new SimulationMptSceneScorePo();
                     simulationMptSceneScorePo.setPId(id);
                     simulationMptSceneScorePo.setSceneId(s);
-                    simulationMptSceneScorePo.setSceneType("2");
+                    simulationMptSceneScorePo.setSceneType(DictConstants.SCENE_STANDARD);
                     simulationMptSceneScorePo.createPo(AuthUtil.getCurrentUserId());
                     simulationProjectMapper.insertSimulationMptSceneScorePo(simulationMptSceneScorePo);
                 }
@@ -957,9 +984,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         String sceneTrafficIds = vo.getSceneTrafficIds();
         String sceneStatueIds = vo.getSceneStatueIds();
         List<SceneScoreVo> sceneScoreVos = new ArrayList<>();
-        List<SceneScoreVo> NaturalSceneScoreVos = setSceneScore(vo, sceneNaturalIds, "1", pId);
-        List<SceneScoreVo> StatueSceneScoreVos = setSceneScore(vo, sceneStatueIds, "2", pId);
-        List<SceneScoreVo> TrafficSceneScoreVos = setSceneScore(vo, sceneTrafficIds, "3", pId);
+        List<SceneScoreVo> NaturalSceneScoreVos = setSceneScore(vo, sceneNaturalIds, DictConstants.SCENE_NATURAL, pId);
+        List<SceneScoreVo> StatueSceneScoreVos = setSceneScore(vo, sceneStatueIds, DictConstants.SCENE_STANDARD, pId);
+        List<SceneScoreVo> TrafficSceneScoreVos = setSceneScore(vo, sceneTrafficIds, DictConstants.SCENE_ACCIDENT, pId);
         ///TODO 暂不支持泛化场景
 
         //合成一个list

+ 3 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/project/service/SimulationProjectService.java

@@ -2,7 +2,7 @@ package com.css.simulation.resource.project.service;
 
 import api.common.pojo.common.ResponseBodyVO;
 import api.common.pojo.param.project.SimulationManualProjectParam;
-import com.fasterxml.jackson.core.JsonProcessingException;
+
 
 public interface SimulationProjectService {
 
@@ -28,4 +28,6 @@ public interface SimulationProjectService {
 
     String getDictName(String type, String code);
 
+    ResponseBodyVO analysisVehicleCoord() throws Exception;
+
 }