root 2 years ago
parent
commit
acb469f6c1

+ 6 - 6
api-common/src/main/java/api/common/pojo/constants/DictConstants.java

@@ -2,6 +2,12 @@ package api.common.pojo.constants;
 
 public class DictConstants {
 
+    public static final String SENSOR_CAMERA = "camera"; // 摄像头
+    public static final String SENSOR_OGT = "ogt"; // 完美传感器
+    public static final String SENSOR_LIDAR = "lidar"; // 激光雷达表
+    public static final String SENSOR_RADAR = "radar"; // 毫米波雷达表
+    public static final String SENSOR_GPS = "gps"; // GPS 传感器表
+
     // 场景测试包是否被禁用
     public static final String IS_AVAILABLE = "0";
     public static final String IS_UNAVAILABLE = "1";
@@ -61,12 +67,6 @@ public class DictConstants {
     public static final String SCENE_ACCIDENT = "3";    // 交通事故
     public static final String SCENE_GENERAL = "4";    // 泛化场景
 
-    public static final String SENSOR_CAMERA = "camera"; // 摄像头
-    public static final String SENSOR_OGT = "ogt"; // 完美传感器
-    public static final String SENSOR_LIDAR = "lidar"; // 激光雷达表
-    public static final String SENSOR_RADAR = "radar"; // 毫米波雷达表
-    public static final String SENSOR_GPS = "gps"; // GPS 传感器表
-
 
 //    当前运行状态(10:未执行,20:执行中,30:执行完成,40:已终止 50 执行出错)
 

+ 2 - 0
api-common/src/main/java/api/common/pojo/po/model/ConfigSensorPO.java

@@ -2,9 +2,11 @@ package api.common.pojo.po.model;
 
 import api.common.pojo.common.CommonPO;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
 
 import java.math.BigDecimal;
 
+@EqualsAndHashCode(callSuper = true)
 @Data
 public class ConfigSensorPO extends CommonPO {
 

+ 1 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/model/controller/ModelConfigController.java

@@ -107,7 +107,7 @@ public class ModelConfigController {
         if (ObjectUtil.isNull(configVO)) {
             return new ResponseBodyVO<>(false, 500, "参数必传!", null);
         }
-        ResponseBodyVO<ConfigPO> response = new ResponseBodyVO<ConfigPO>(ResponseBodyVO.Response.SUCCESS);
+        ResponseBodyVO<ConfigPO> response = new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
         ConfigPO po = configService.shareConfigByInfo(configVO);
         if (ObjectUtil.isNull(po.getId())) {
             return new ResponseBodyVO<>(false, 500, "配置名称重复!", null);

+ 38 - 53
simulation-resource-server/src/main/java/com/css/simulation/resource/model/service/ConfigService.java

@@ -229,7 +229,7 @@ public class ConfigService {
 
         final String isUnavailable = modelConfigMapper.selectIsUnavailableByModelConfigId(configVO.getId());
         if (DictConstants.IS_UNAVAILABLE.equals(isUnavailable)) {
-            throw new RuntimeException("车辆配置处于禁用状态,请先保存。");
+            throw new RuntimeException("车辆配置处于禁用状态,请编辑后重试。");
         }
 
         // 构建新的车辆配置对象
@@ -259,8 +259,6 @@ public class ConfigService {
         }
 
         // 复制传感器表数据
-
-        // 构建字表新数据
         Map<String, List<ConfigSensorVO>> configSensors = configVO.getConfigSensors();
         log.info("该车辆配置的所有传感器信息为:" + configSensors);
         List<ConfigSensorPO> configSensorPOs = new ArrayList<>();
@@ -279,51 +277,44 @@ public class ConfigService {
                         po.setModifyUserId(currentUserId);
                         po.setModifyTime(currentTime);
                         po.setIsDeleted(DictConstants.NO);
-                        configSensorPOs.add(po);
-
-                        switch (sensorType) {
-                            case "camera": {
-                                CameraParam cameraParam = new CameraParam();
-                                cameraParam.setId(vo.getSensorId());
-                                CameraVO cameraVO = cameraService.getCameraInfo(cameraParam);
-                                CameraPO cameraPO = new CameraPO();
-                                ObjectUtil.voToPo(cameraVO, cameraPO);
-                                CameraPO cameraPO1 = cameraService.shareCamera(cameraPO);
-                                break;
-                            }
-                            case "lidar": {
-                                LidarParam lidarParam = new LidarParam();
-                                lidarParam.setId(vo.getSensorId());
-                                LidarVO lidarVO = lidarService.getLidarInfo(lidarParam);
-                                LidarPO lidarPO = new LidarPO();
-                                ObjectUtil.voToPo(lidarVO, lidarPO);
-                                LidarPO lidarPO1 = lidarService.shareLidar(lidarPO);
-                                break;
-                            }
-                            case "ogt": {
-                                OgtParam ogtParam = new OgtParam();
-                                ogtParam.setId(vo.getSensorId());
-                                OgtVO ogtVO = ogtService.getOgtInfo(ogtParam);
-                                OgtPO ogtPO = new OgtPO();
-                                ObjectUtil.voToPo(ogtVO, ogtPO);
-                                OgtPO ogtPO1 = ogtService.shareOgt(ogtPO);
-                                break;
-                            }
-                            case "gps": {
-                                GpsParam gpsParam = new GpsParam();
-                                gpsParam.setId(vo.getSensorId());
-                                GpsVO gpsVO = gpsService.getGpsInfo(gpsParam);
-                                GpsPO gpsPO = new GpsPO();
-                                ObjectUtil.voToPo(gpsVO, gpsPO);
-                                GpsPO gpsPO1 = gpsService.shareGps(gpsPO);
-                                break;
-                            }
-                            case "radar": {
-                                break;
-                            }
-                            default:
-                                break;
+                        String sensorId = "";
+                        if (DictConstants.SENSOR_CAMERA.equals(sensorType)) {
+                            CameraParam cameraParam = new CameraParam();
+                            cameraParam.setId(vo.getSensorId());
+                            CameraVO cameraVO = cameraService.getCameraInfo(cameraParam);
+                            CameraPO cameraPO = new CameraPO();
+                            ObjectUtil.voToPo(cameraVO, cameraPO);
+                            CameraPO publicCamera = cameraService.shareCamera(cameraPO);
+                            sensorId = publicCamera.getId();
+                        } else if (DictConstants.SENSOR_LIDAR.equals(sensorType)) {
+                            LidarParam lidarParam = new LidarParam();
+                            lidarParam.setId(vo.getSensorId());
+                            LidarVO lidarVO = lidarService.getLidarInfo(lidarParam);
+                            LidarPO lidarPO = new LidarPO();
+                            ObjectUtil.voToPo(lidarVO, lidarPO);
+                            LidarPO publicLidar = lidarService.shareLidar(lidarPO);
+                            sensorId = publicLidar.getId();
+                        } else if (DictConstants.SENSOR_OGT.equals(sensorType)) {
+                            OgtParam ogtParam = new OgtParam();
+                            ogtParam.setId(vo.getSensorId());
+                            OgtVO ogtVO = ogtService.getOgtInfo(ogtParam);
+                            OgtPO ogtPO = new OgtPO();
+                            ObjectUtil.voToPo(ogtVO, ogtPO);
+                            OgtPO publicOgt = ogtService.shareOgt(ogtPO);
+                            sensorId = publicOgt.getId();
+                        } else if (DictConstants.SENSOR_GPS.equals(sensorType)) {
+                            GpsParam gpsParam = new GpsParam();
+                            gpsParam.setId(vo.getSensorId());
+                            GpsVO gpsVO = gpsService.getGpsInfo(gpsParam);
+                            GpsPO gpsPO = new GpsPO();
+                            ObjectUtil.voToPo(gpsVO, gpsPO);
+                            GpsPO publicGps = gpsService.shareGps(gpsPO);
+                            sensorId = publicGps.getId();
+                        } else {
+                            throw new RuntimeException("传感器类型错误。");
                         }
+                        po.setSensorId(sensorId);
+                        configSensorPOs.add(po);
                     });
                 }
             });
@@ -376,12 +367,6 @@ public class ConfigService {
     }
 
     public ConfigPO shareConfigById(ConfigVO configVO) {
-        //1 已禁用配置不允许删除
-        final String isUnavailable = modelConfigMapper.selectIsUnavailableByModelConfigId(configVO.getId());
-        if (DictConstants.IS_UNAVAILABLE.equals(isUnavailable)) {
-            throw new RuntimeException("车辆配置处于禁用状态。");
-        }
-        //2 获取配置信息
         configVO = getConfigInfo(configVO);
         ConfigPO configPO = shareConfigByInfo(configVO);
         LogUtil.share();