|
@@ -8,6 +8,7 @@ import api.common.util.*;
|
|
|
import com.css.simulation.resource.common.utils.AuthUtil;
|
|
|
import com.css.simulation.resource.common.utils.PageUtil;
|
|
|
import com.css.simulation.resource.model.mapper.ConfigMapper;
|
|
|
+import com.css.simulation.resource.model.mapper.RelationConfigSensorMapper;
|
|
|
import com.css.simulation.resource.model.mapper.VehicleMapper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -37,6 +38,8 @@ public class ConfigService {
|
|
|
private OgtService ogtService;
|
|
|
@Resource
|
|
|
private GpsService gpsService;
|
|
|
+ @Resource
|
|
|
+ private RelationConfigSensorMapper relationConfigSensorMapper;
|
|
|
|
|
|
//* -------------------------------- Comment --------------------------------
|
|
|
|
|
@@ -214,38 +217,41 @@ public class ConfigService {
|
|
|
}
|
|
|
|
|
|
public ConfigPO shareConfigByInfo(ConfigVO configVO) {
|
|
|
- //构建主表对象
|
|
|
+ // 构建主表对象
|
|
|
ConfigPO configPO = new ConfigPO();
|
|
|
ObjectUtil.voToPo(configVO, configPO);
|
|
|
- configPO.setShare(DictConstants.YES);//转公有
|
|
|
+ configPO.setShare(DictConstants.IS_SHARED); // 私有转公有
|
|
|
configPO.setCreateUserId(null);
|
|
|
|
|
|
String currentUserId = AuthUtil.getCurrentUserId();
|
|
|
Timestamp currentTime = TimeUtil.getNowForMysql();
|
|
|
- //名称校验
|
|
|
- List<ConfigVO> list = configMapper.checkConfigName(configPO);
|
|
|
- if (ObjectUtil.isNotNull(list)) {
|
|
|
+ // 车辆配置名称相同则覆盖,名称不同则新增
|
|
|
+ // 车辆模型名称相同则覆盖,名称不同则新增
|
|
|
+ // 传感器模型名称相同则覆盖,名称不同则新增
|
|
|
+ List<ConfigVO> list = configMapper.checkConfigName(configPO); // 查询公有车辆配置是否有重名
|
|
|
+ if (ObjectUtil.isNotNull(list)) { // 不为空说明有重名,则将参数覆盖,同时需要删除配置传感器关联表
|
|
|
+ String configId = list.get(0).getId();
|
|
|
configPO.setModifyUserId(currentUserId);
|
|
|
configPO.setModifyTime(currentTime);
|
|
|
configPO.setIsDeleted(DictConstants.NO);
|
|
|
configMapper.updateConfig(configPO);
|
|
|
+ relationConfigSensorMapper.deleteByConfigId(configId); // 删除配置与传感器关联关系,方便后面重新添加
|
|
|
LogUtil.update();
|
|
|
-
|
|
|
- } else {
|
|
|
+ } 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);
|
|
|
}
|
|
|
- //复制车辆表旧数据
|
|
|
+ // 复制车辆表旧数据
|
|
|
if (configPO.getVehicleId() != null) {
|
|
|
VehicleParam vehicleParam = new VehicleParam();
|
|
|
vehicleParam.setId(configPO.getVehicleId());
|
|
@@ -254,9 +260,9 @@ public class ConfigService {
|
|
|
VehiclePO po = vehicleService.shareVehicle(vehicleInfo);
|
|
|
}
|
|
|
|
|
|
- //复制传感器表数据
|
|
|
+ // 复制传感器表数据
|
|
|
|
|
|
- //构建字表新数据
|
|
|
+ // 构建字表新数据
|
|
|
Map<String, List<ConfigSensorVO>> configSensors = configVO.getConfigSensors();
|
|
|
System.out.println(" //构建字表新数据---------" + configSensors);
|
|
|
List<ConfigSensorPO> configSensorPOs = new ArrayList<>();
|
|
@@ -268,7 +274,7 @@ public class ConfigService {
|
|
|
ConfigSensorPO po = new ConfigSensorPO();
|
|
|
ObjectUtil.voToPo(vo, po);
|
|
|
po.setId(StringUtil.getRandomUUID());
|
|
|
- //子表外键
|
|
|
+ // 子表外键
|
|
|
po.setConfigId(configPO.getId());
|
|
|
po.setCreateUserId(currentUserId);
|
|
|
po.setCreateTime(currentTime);
|