|
@@ -1,11 +1,9 @@
|
|
|
package com.css.simulation.resource.model.service;
|
|
|
|
|
|
import api.common.pojo.constants.DictConstants;
|
|
|
-import api.common.pojo.param.model.ConfigPageParam;
|
|
|
-import api.common.pojo.po.model.ConfigPO;
|
|
|
-import api.common.pojo.po.model.ConfigSensorPO;
|
|
|
-import api.common.pojo.vo.model.ConfigSensorVO;
|
|
|
-import api.common.pojo.vo.model.ConfigVO;
|
|
|
+import api.common.pojo.param.model.*;
|
|
|
+import api.common.pojo.po.model.*;
|
|
|
+import api.common.pojo.vo.model.*;
|
|
|
import api.common.util.LogUtil;
|
|
|
import api.common.util.ObjectUtil;
|
|
|
import api.common.util.StringUtil;
|
|
@@ -14,7 +12,9 @@ import com.css.simulation.resource.common.utils.AuthUtil;
|
|
|
import com.css.simulation.resource.common.utils.PageUtil;
|
|
|
import com.css.simulation.resource.model.mapper.CameraMapper;
|
|
|
import com.css.simulation.resource.model.mapper.ConfigMapper;
|
|
|
+import com.css.simulation.resource.model.mapper.VehicleMapper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import org.checkerframework.checker.units.qual.C;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -29,6 +29,24 @@ public class ConfigService {
|
|
|
@Autowired
|
|
|
ConfigMapper configMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ VehicleMapper vehicleMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ VehicleService vehicleService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ CameraService cameraService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ LidarService lidarService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ OgtService ogtService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ GpsService gpsService;
|
|
|
+
|
|
|
public PageInfo<ConfigVO> getConfigPageList(ConfigPageParam pageParam) {
|
|
|
PageUtil.setPageInfo(pageParam);
|
|
|
pageParam.setCreateUserId(AuthUtil.getCurrentUserId());
|
|
@@ -120,6 +138,66 @@ public class ConfigService {
|
|
|
return configPO;
|
|
|
}
|
|
|
|
|
|
+ public ConfigPO saveAnotherConfig(ConfigVO configVO) {
|
|
|
+ //构建主表对象
|
|
|
+ ConfigPO configPO = new ConfigPO();
|
|
|
+ String currentUserId = AuthUtil.getCurrentUserId();
|
|
|
+ Timestamp currentTime = TimeUtil.getNowForMysql();
|
|
|
+ ObjectUtil.voToPo(configVO,configPO);
|
|
|
+ configPO.setCreateUserId(currentUserId);
|
|
|
+ configPO.setCreateTime(currentTime);
|
|
|
+ configPO.setModifyUserId(currentUserId);
|
|
|
+ configPO.setModifyTime(currentTime);
|
|
|
+ configPO.setIsDeleted(DictConstants.NO);
|
|
|
+ configPO.setShare(DictConstants.NO);//私有
|
|
|
+ //单独处理配置描述
|
|
|
+ configPO.setDescription(configVO.getConfigDescription());
|
|
|
+ //名称校验
|
|
|
+ List<ConfigVO> list = configMapper.checkConfigName(configPO);
|
|
|
+ if(ObjectUtil.isNotNull(list)){
|
|
|
+ configMapper.updateConfig(configPO);
|
|
|
+ LogUtil.update();
|
|
|
+ }else {
|
|
|
+ //主表主键
|
|
|
+ String configId = configPO.getId();
|
|
|
+ configId = StringUtil.getRandomUUID();
|
|
|
+ configPO.setId(configId);
|
|
|
+ configPO.setConfigCode(StringUtil.getRandomCode());
|
|
|
+ configMapper.insertConfig(configPO);
|
|
|
+ LogUtil.insert();
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除子表旧数据
|
|
|
+ configMapper.delConfigSensors(configPO);
|
|
|
+ //构建字表新数据
|
|
|
+ //List<ConfigSensorVO> configSensorVOs = configVO.getConfigSensors();
|
|
|
+ Map<String, List<ConfigSensorVO>> configSensors = configVO.getConfigSensors();
|
|
|
+ List<ConfigSensorPO> configSensorPOs = new ArrayList<>();
|
|
|
+ if(ObjectUtil.isNotNull(configSensors)){
|
|
|
+ configSensors.forEach((sensorType,configSensorVOs)->{
|
|
|
+ if(ObjectUtil.isNotNull(configSensorVOs)){
|
|
|
+ configSensorVOs.forEach(vo -> {
|
|
|
+ ConfigSensorPO po = new ConfigSensorPO();
|
|
|
+ ObjectUtil.voToPo(vo,po);
|
|
|
+ po.setId(StringUtil.getRandomUUID());
|
|
|
+ //子表外键
|
|
|
+ po.setConfigId(configPO.getId());
|
|
|
+ po.setCreateUserId(currentUserId);
|
|
|
+ po.setCreateTime(currentTime);
|
|
|
+ po.setModifyUserId(currentUserId);
|
|
|
+ po.setModifyTime(currentTime);
|
|
|
+ po.setIsDeleted(DictConstants.NO);
|
|
|
+ configSensorPOs.add(po);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNotNull(configSensorPOs)){
|
|
|
+ configMapper.insertConfigSensors(configSensorPOs);
|
|
|
+ }
|
|
|
+ return configPO;
|
|
|
+ }
|
|
|
+
|
|
|
public int delConfigById(ConfigVO vo) {
|
|
|
ConfigPO po = new ConfigPO();
|
|
|
ObjectUtil.voToPo(vo,po);
|
|
@@ -137,33 +215,48 @@ public class ConfigService {
|
|
|
ObjectUtil.voToPo(configVO,configPO);
|
|
|
configPO.setShare(DictConstants.YES);//转公有
|
|
|
configPO.setCreateUserId(null);
|
|
|
+
|
|
|
+ String currentUserId = AuthUtil.getCurrentUserId();
|
|
|
+ Timestamp currentTime = TimeUtil.getNowForMysql();
|
|
|
//名称校验
|
|
|
List<ConfigVO> list = configMapper.checkConfigName(configPO);
|
|
|
if(ObjectUtil.isNotNull(list)){
|
|
|
- configPO.setId(null);
|
|
|
- return configPO;
|
|
|
+ configPO.setModifyUserId(currentUserId);
|
|
|
+ configPO.setModifyTime(currentTime);
|
|
|
+ configPO.setIsDeleted(DictConstants.NO);
|
|
|
+ configMapper.updateConfig(configPO);
|
|
|
+ LogUtil.update();
|
|
|
+
|
|
|
+ }else {
|
|
|
+ configPO.setCreateUserId(currentUserId);
|
|
|
+ configPO.setCreateTime(currentTime);
|
|
|
+ configPO.setModifyUserId(currentUserId);
|
|
|
+ configPO.setModifyTime(currentTime);
|
|
|
+ configPO.setIsDeleted(DictConstants.NO);
|
|
|
+ //单独处理配置描述
|
|
|
+ configPO.setDescription(configVO.getConfigDescription());
|
|
|
+ //主表主键
|
|
|
+ String configId = StringUtil.getRandomUUID();
|
|
|
+ configPO.setId(configId);
|
|
|
+ configPO.setConfigCode(StringUtil.getRandomCode());
|
|
|
+ configMapper.insertConfig(configPO);
|
|
|
}
|
|
|
- String currentUserId = AuthUtil.getCurrentUserId();
|
|
|
- Timestamp currentTime = TimeUtil.getNowForMysql();
|
|
|
- configPO.setCreateUserId(currentUserId);
|
|
|
- configPO.setCreateTime(currentTime);
|
|
|
- configPO.setModifyUserId(currentUserId);
|
|
|
- configPO.setModifyTime(currentTime);
|
|
|
- configPO.setIsDeleted(DictConstants.NO);
|
|
|
- //单独处理配置描述
|
|
|
- configPO.setDescription(configVO.getConfigDescription());
|
|
|
- //主表主键
|
|
|
- String configId = StringUtil.getRandomUUID();
|
|
|
- configPO.setId(configId);
|
|
|
- configPO.setConfigCode(StringUtil.getRandomCode());
|
|
|
- configMapper.insertConfig(configPO);
|
|
|
- //删除子表旧数据
|
|
|
- configMapper.delConfigSensors(configPO);
|
|
|
+ //复制车辆表旧数据
|
|
|
+ if(configPO.getVehicleId() != null){
|
|
|
+ VehicleParam vehicleParam = new VehicleParam();
|
|
|
+ vehicleParam.setId(configPO.getVehicleId());
|
|
|
+ VehicleVO vehicleInfo = vehicleMapper.getVehicleInfo(vehicleParam);
|
|
|
+ VehiclePO po = vehicleService.shareVehicle(vehicleInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ //复制传感器表数据
|
|
|
+
|
|
|
//构建字表新数据
|
|
|
Map<String, List<ConfigSensorVO>> configSensors = configVO.getConfigSensors();
|
|
|
List<ConfigSensorPO> configSensorPOs = new ArrayList<>();
|
|
|
if(ObjectUtil.isNotNull(configSensors)){
|
|
|
configSensors.forEach((sensorType,configSensorVOs)->{
|
|
|
+
|
|
|
if(ObjectUtil.isNotNull(configSensorVOs)){
|
|
|
configSensorVOs.forEach(vo -> {
|
|
|
ConfigSensorPO po = new ConfigSensorPO();
|
|
@@ -177,6 +270,50 @@ public class ConfigService {
|
|
|
po.setModifyTime(currentTime);
|
|
|
po.setIsDeleted(DictConstants.NO);
|
|
|
configSensorPOs.add(po);
|
|
|
+
|
|
|
+ switch (sensorType) {
|
|
|
+ case "camera": {
|
|
|
+ CameraParam cameraParam = new CameraParam();
|
|
|
+ cameraParam.setId(vo.getId());
|
|
|
+ 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.getId());
|
|
|
+ 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.getId());
|
|
|
+ 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.getId());
|
|
|
+ GpsVO gpsVO = gpsService.getGpsInfo(gpsParam);
|
|
|
+ GpsPO gpsPO = new GpsPO();
|
|
|
+ ObjectUtil.voToPo(gpsVO,gpsPO);
|
|
|
+ GpsPO gpsPO1 = gpsService.shareGps(gpsPO);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "radar":{
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:break;
|
|
|
+ }
|
|
|
+
|
|
|
});
|
|
|
}
|
|
|
});
|