Browse Source

自车渲染

wangzhiqiang 2 years ago
parent
commit
3158752ab5

+ 13 - 0
simulation-resource-video/src/main/java/com/css/simulation/resource/video/mapper/DictMapper.java

@@ -0,0 +1,13 @@
+package com.css.simulation.resource.video.mapper;
+
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+
+@Mapper
+public interface DictMapper {
+    @Select("select dict_name \n" +
+            "from system_dict\n" +
+            "where dict_code= #{dictCode} and dict_type='carType' and is_deleted='0'")
+    String getCarPath(String dictCode);
+}

+ 12 - 8
simulation-resource-video/src/main/java/com/css/simulation/resource/video/service/VideoService.java

@@ -6,6 +6,7 @@ import api.common.util.FileUtil;
 import api.common.util.LinuxUtil;
 import api.common.util.LinuxUtil;
 import api.common.util.StringUtil;
 import api.common.util.StringUtil;
 import com.css.simulation.resource.video.mapper.ConfigMapper;
 import com.css.simulation.resource.video.mapper.ConfigMapper;
+import com.css.simulation.resource.video.mapper.DictMapper;
 import com.css.simulation.resource.video.mapper.SimulationAutomaticProjectMapper;
 import com.css.simulation.resource.video.mapper.SimulationAutomaticProjectMapper;
 import com.css.simulation.resource.video.mapper.VehicleMapper;
 import com.css.simulation.resource.video.mapper.VehicleMapper;
 import com.css.simulation.resource.video.pojo.po.VehiclePO;
 import com.css.simulation.resource.video.pojo.po.VehiclePO;
@@ -31,6 +32,7 @@ import java.math.RoundingMode;
 import java.nio.file.Files;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.nio.file.Paths;
 import java.util.Iterator;
 import java.util.Iterator;
+import java.util.Map;
 
 
 @Service
 @Service
 @Slf4j
 @Slf4j
@@ -43,8 +45,8 @@ public class VideoService {
     SimulationAutomaticProjectMapper simulationAutomaticProjectMapper;
     SimulationAutomaticProjectMapper simulationAutomaticProjectMapper;
     @Resource
     @Resource
     MinioClient minioClient;
     MinioClient minioClient;
-
-
+    @Resource
+    DictMapper dictMapper;
     //* -------------------------------- Comment --------------------------------
     //* -------------------------------- Comment --------------------------------
 
 
     public static final String oldXoscName = "simulation_my0.xosc";
     public static final String oldXoscName = "simulation_my0.xosc";
@@ -135,7 +137,7 @@ public class VideoService {
      * 修改 xosc 文件
      * 修改 xosc 文件
      */
      */
     @SneakyThrows
     @SneakyThrows
-    private String modifyXosc(String oldXoscPath, String xodrPath, String osgbPath, String projectId, String projectType) {
+    public String modifyXosc(String oldXoscPath, String xodrPath, String osgbPath, String projectId, String projectType) {
         String newXoscPath = oldXoscPath.replace(oldXoscName, newXoscName);
         String newXoscPath = oldXoscPath.replace(oldXoscName, newXoscName);
         //获取三维自车对象
         //获取三维自车对象
         VehicleTypePO po = vehicleById(projectId, projectType);
         VehicleTypePO po = vehicleById(projectId, projectType);
@@ -167,7 +169,7 @@ public class VideoService {
                                     Attribute vehicleCategory = node3.attribute("vehicleCategory");
                                     Attribute vehicleCategory = node3.attribute("vehicleCategory");
                                     vehicleCategory.setText(po.getVehicleCategory());
                                     vehicleCategory.setText(po.getVehicleCategory());
                                     //node3.addAttribute("model3d", po.getModel3d());//自车渲染
                                     //node3.addAttribute("model3d", po.getModel3d());//自车渲染
-                                    if(po.getModel3d().equals("")||po.getModel3d()==null){
+                                    if(po.getModel3d()==null||po.getModel3d().equals("")){
                                         node3.addAttribute("model3d", "/root/disk1/simulation-cloud/esmini/resources/models/car_red.osgb");//自车渲染
                                         node3.addAttribute("model3d", "/root/disk1/simulation-cloud/esmini/resources/models/car_red.osgb");//自车渲染
                                     }else{
                                     }else{
                                         log.info(" 车辆类型为 为:"+po.getVehicleCategory()+" 渲染文件为:" + po.getModel3d());
                                         log.info(" 车辆类型为 为:"+po.getVehicleCategory()+" 渲染文件为:" + po.getModel3d());
@@ -314,14 +316,16 @@ public class VideoService {
             po.setVehicleCategory("bicycle");
             po.setVehicleCategory("bicycle");
         } else if (car.contains("train")) {
         } else if (car.contains("train")) {
             po.setVehicleCategory("train");
             po.setVehicleCategory("train");
-        } else if(car.contains("suv")) {
+        } else if(car.equalsIgnoreCase("suv")) {
             po.setVehicleCategory("suv");
             po.setVehicleCategory("suv");
-            po.setModel3d("/root/disk1/simulation-cloud/esmini/resources/models/audiq5.osgb");
+           // po.setModel3d("/root/disk1/simulation-cloud/esmini/resources/models/audiq5.osgb");
         }else {
         }else {
             po.setVehicleCategory("car");
             po.setVehicleCategory("car");
-            po.setModel3d("/root/disk1/simulation-cloud/esmini/resources/models/audia8.osgb");
+           // po.setModel3d("/root/disk1/simulation-cloud/esmini/resources/models/audia8.osgb");
         }
         }
-
+        //从字段取自车渲染osgb
+        String carPath=dictMapper.getCarPath(po.getVehicleCategory());
+        po.setModel3d(carPath);
         //车前距
         //车前距
         BigDecimal frontDistance = vehicleInfo.getFrontDistance();
         BigDecimal frontDistance = vehicleInfo.getFrontDistance();
         //车后距
         //车后距