|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.xydl.cac.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.xydl.cac.entity.*;
|
|
|
|
|
import com.xydl.cac.exception.BusinessException;
|
|
|
|
|
import com.xydl.cac.model.BindDetail;
|
|
|
|
|
import com.xydl.cac.model.BindingModel;
|
|
|
|
|
import com.xydl.cac.model.ColumnModel;
|
|
|
|
@ -87,22 +88,22 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
public Response preview(BindingModel item) throws Exception {
|
|
|
|
|
Optional<Modev> optionalModev = modevRepository.findById(item.getEqmid());
|
|
|
|
|
if (!optionalModev.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该监测装置, eqmid=" + item.getEqmid());
|
|
|
|
|
throw new BusinessException("未找到该监测装置, eqmid=" + item.getEqmid());
|
|
|
|
|
}
|
|
|
|
|
Modev modev = optionalModev.get();
|
|
|
|
|
Optional<ModevType> optionalModevType = modevTypeRepository.findById(modev.getModevtid());
|
|
|
|
|
if (!optionalModevType.isPresent()) {
|
|
|
|
|
throw new Exception("该监测装置类型不正确, 请先修正");
|
|
|
|
|
throw new BusinessException("该监测装置类型不正确, 请先修正");
|
|
|
|
|
}
|
|
|
|
|
ModevType modevType = optionalModevType.get();
|
|
|
|
|
Optional<IcdConfigTypeInst> optionalInst = instRepository.findById(item.getIcdid());
|
|
|
|
|
if (!optionalInst.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该ICD逻辑设备实例, icdid=" + item.getIcdid());
|
|
|
|
|
throw new BusinessException("未找到该ICD逻辑设备实例, icdid=" + item.getIcdid());
|
|
|
|
|
}
|
|
|
|
|
IcdConfigTypeInst inst = optionalInst.get();
|
|
|
|
|
Optional<IcdConfigType> optionalType = typeRepository.findById(inst.getIcdConfigTypeId());
|
|
|
|
|
if (!optionalType.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该实例对应的ICD配置类型, icdid=" + item.getIcdid());
|
|
|
|
|
throw new BusinessException("未找到该实例对应的ICD配置类型, icdid=" + item.getIcdid());
|
|
|
|
|
}
|
|
|
|
|
IcdConfigType type = optionalType.get();
|
|
|
|
|
|
|
|
|
@ -117,7 +118,7 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
// String paramindex = param + "$" + att.getParam();
|
|
|
|
|
// Optional<Rptparamindex> optionalRpt = rptparamindexRepository.findById(paramindex);
|
|
|
|
|
// if (!optionalRpt.isPresent()) {
|
|
|
|
|
// throw new Exception("未找到该Rptparamindex,对象参引=" + paramindex);
|
|
|
|
|
// throw new BusinessException("未找到该Rptparamindex,对象参引=" + paramindex);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -139,24 +140,24 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
public void bind(BindingModel item) throws Exception {
|
|
|
|
|
Optional<Modev> optionalModev = modevRepository.findById(item.getEqmid());
|
|
|
|
|
if (!optionalModev.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该监测装置, eqmid=" + item.getEqmid());
|
|
|
|
|
throw new BusinessException("未找到该监测装置, eqmid=" + item.getEqmid());
|
|
|
|
|
}
|
|
|
|
|
Modev modev = optionalModev.get();
|
|
|
|
|
|
|
|
|
|
Optional<IcdConfigTypeInst> optionalInst = instRepository.findById(item.getIcdid());
|
|
|
|
|
if (!optionalInst.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该ICD逻辑设备实例, icdid=" + item.getIcdid());
|
|
|
|
|
throw new BusinessException("未找到该ICD逻辑设备实例, icdid=" + item.getIcdid());
|
|
|
|
|
}
|
|
|
|
|
IcdConfigTypeInst inst = optionalInst.get();
|
|
|
|
|
Optional<IcdConfigType> optionalType = typeRepository.findById(inst.getIcdConfigTypeId());
|
|
|
|
|
if (!optionalType.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该实例对应的ICD配置类型, icdid=" + item.getIcdid());
|
|
|
|
|
throw new BusinessException("未找到该实例对应的ICD配置类型, icdid=" + item.getIcdid());
|
|
|
|
|
}
|
|
|
|
|
IcdConfigType type = optionalType.get();
|
|
|
|
|
|
|
|
|
|
List<Modev> list = modevRepository.findByIcdidAndIdIsNot(item.getIcdid(), item.getEqmid());
|
|
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
|
|
throw new Exception("该逻辑设备实例已被" + list.get(0).getName() + "绑定");
|
|
|
|
|
throw new BusinessException("该逻辑设备实例已被" + list.get(0).getName() + "绑定");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<IcdConfigTypeAtt> attList = attRepository.findByIcdConfigTypeId(type.getId());
|
|
|
|
@ -175,7 +176,7 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!found) {
|
|
|
|
|
throw new Exception("当前监控设备对应的表" + modevType.getTablename() + "里不存在配置属性"
|
|
|
|
|
throw new BusinessException("当前监控设备对应的表" + modevType.getTablename() + "里不存在配置属性"
|
|
|
|
|
+ att.getDoName() + "绑定的字段" + att.getColName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -191,7 +192,7 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
public void unbind(Integer eqmid) throws Exception {
|
|
|
|
|
Optional<Modev> optionalModev = modevRepository.findById(eqmid);
|
|
|
|
|
if (!optionalModev.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该监测装置, eqmid=" + eqmid);
|
|
|
|
|
throw new BusinessException("未找到该监测装置, eqmid=" + eqmid);
|
|
|
|
|
}
|
|
|
|
|
Modev modev = optionalModev.get();
|
|
|
|
|
modev.setIcdid(null);
|
|
|
|
@ -202,7 +203,7 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
public BindDetail getBind(Integer eqmid) throws Exception {
|
|
|
|
|
Optional<Modev> optionalModev = modevRepository.findById(eqmid);
|
|
|
|
|
if (!optionalModev.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该监测装置");
|
|
|
|
|
throw new BusinessException("未找到该监测装置");
|
|
|
|
|
}
|
|
|
|
|
Modev modev = optionalModev.get();
|
|
|
|
|
|
|
|
|
@ -248,12 +249,12 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
private void generateOne(Modev item) throws Exception {
|
|
|
|
|
Optional<IcdConfigTypeInst> optionalInst = instRepository.findById(item.getIcdid());
|
|
|
|
|
if (!optionalInst.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该ICD逻辑设备实例, eqmid=" + item.getId() + ", icdid=" + item.getIcdid());
|
|
|
|
|
throw new BusinessException("未找到该ICD逻辑设备实例, eqmid=" + item.getId() + ", icdid=" + item.getIcdid());
|
|
|
|
|
}
|
|
|
|
|
IcdConfigTypeInst inst = optionalInst.get();
|
|
|
|
|
Optional<IcdConfigType> optionalType = typeRepository.findById(inst.getIcdConfigTypeId());
|
|
|
|
|
if (!optionalType.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该实例对应的ICD配置类型, icdid=" + item.getIcdid());
|
|
|
|
|
throw new BusinessException("未找到该实例对应的ICD配置类型, icdid=" + item.getIcdid());
|
|
|
|
|
}
|
|
|
|
|
IcdConfigType type = optionalType.get();
|
|
|
|
|
String param = type.getIedName() + type.getLdeviceInst() + "/" + type.getLnClass()
|
|
|
|
@ -264,7 +265,7 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
String paramindex = param + "$" + att.getParam();
|
|
|
|
|
Optional<Rptparamindex> optionalRpt = rptparamindexRepository.findById(paramindex);
|
|
|
|
|
if (!optionalRpt.isPresent()) {
|
|
|
|
|
throw new Exception(item.getName() + "的字段" + att.getColName() + "对应的属性"
|
|
|
|
|
throw new BusinessException(item.getName() + "的字段" + att.getColName() + "对应的属性"
|
|
|
|
|
+ att.getDoName() + ",未找到该Rptparamindex,对象参引=" + paramindex);
|
|
|
|
|
}
|
|
|
|
|
Rptparamindex rpt = optionalRpt.get();
|
|
|
|
|