|
|
|
@ -1,10 +1,14 @@
|
|
|
|
|
package com.xydl.cac.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.xydl.cac.entity.*;
|
|
|
|
|
import com.xydl.cac.model.BindDetail;
|
|
|
|
|
import com.xydl.cac.model.BindingModel;
|
|
|
|
|
import com.xydl.cac.model.ColumnModel;
|
|
|
|
|
import com.xydl.cac.repository.*;
|
|
|
|
|
import com.xydl.cac.service.DataService;
|
|
|
|
|
import com.xydl.cac.service.ParamBindService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
@ -28,6 +32,8 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
@Resource
|
|
|
|
|
ModevRepository modevRepository;
|
|
|
|
|
@Resource
|
|
|
|
|
ModevTypeRepository modevTypeRepository;
|
|
|
|
|
@Resource
|
|
|
|
|
IcdConfigTypeRepository typeRepository;
|
|
|
|
|
@Resource
|
|
|
|
|
IcdConfigTypeInstRepository instRepository;
|
|
|
|
@ -35,6 +41,8 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
IcdConfigTypeAttRepository attRepository;
|
|
|
|
|
@Resource
|
|
|
|
|
RptparamindexRepository rptparamindexRepository;
|
|
|
|
|
@Resource
|
|
|
|
|
DataService dataService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Bdz> getTree() throws Exception {
|
|
|
|
@ -75,14 +83,14 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Rptparamindex> preview(BindingModel item) throws Exception {
|
|
|
|
|
Optional<IcdConfigTypeInst> optionalInst = instRepository.findById(item.getBindingId());
|
|
|
|
|
Optional<IcdConfigTypeInst> optionalInst = instRepository.findById(item.getIcdid());
|
|
|
|
|
if (!optionalInst.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该ICD配置类型实例, eqmid=" + item.getEqmid() + ", bindingId=" + item.getBindingId());
|
|
|
|
|
throw new Exception("未找到该ICD配置类型实例, eqmid=" + item.getEqmid() + ", icdid=" + item.getIcdid());
|
|
|
|
|
}
|
|
|
|
|
IcdConfigTypeInst inst = optionalInst.get();
|
|
|
|
|
Optional<IcdConfigType> optionalType = typeRepository.findById(inst.getIcdConfigTypeId());
|
|
|
|
|
if (!optionalType.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该实例对应的ICD配置类型, bindingId=" + item.getBindingId());
|
|
|
|
|
throw new Exception("未找到该实例对应的ICD配置类型, icdid=" + item.getIcdid());
|
|
|
|
|
}
|
|
|
|
|
IcdConfigType type = optionalType.get();
|
|
|
|
|
|
|
|
|
@ -105,15 +113,92 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bindOne(Integer eqmid, Integer bindingId) throws Exception {
|
|
|
|
|
Optional<IcdConfigTypeInst> optionalInst = instRepository.findById(bindingId);
|
|
|
|
|
@Override
|
|
|
|
|
public void bind(BindingModel item) throws Exception {
|
|
|
|
|
Optional<IcdConfigTypeInst> optionalInst = instRepository.findById(item.getIcdid());
|
|
|
|
|
if (!optionalInst.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该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());
|
|
|
|
|
}
|
|
|
|
|
IcdConfigType type = optionalType.get();
|
|
|
|
|
|
|
|
|
|
List<Modev> list = modevRepository.findByIcdidAndIdIsNot(item.getIcdid(), item.getEqmid());
|
|
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
|
|
throw new Exception("该逻辑设备实例已被" + list.get(0).getName() + "绑定");
|
|
|
|
|
}
|
|
|
|
|
Optional<Modev> optionalModev = modevRepository.findById(item.getEqmid());
|
|
|
|
|
if (!optionalModev.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该监测装置");
|
|
|
|
|
}
|
|
|
|
|
Modev modev = optionalModev.get();
|
|
|
|
|
modev.setIcdid(item.getIcdid());
|
|
|
|
|
modevRepository.save(modev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BindDetail getBind(Integer eqmid) throws Exception {
|
|
|
|
|
Optional<Modev> optionalModev = modevRepository.findById(eqmid);
|
|
|
|
|
if (!optionalModev.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该监测装置");
|
|
|
|
|
}
|
|
|
|
|
Modev modev = optionalModev.get();
|
|
|
|
|
|
|
|
|
|
BindDetail result = new BindDetail();
|
|
|
|
|
result.setEqmid(eqmid);
|
|
|
|
|
result.setIcdid(optionalModev.get().getIcdid());
|
|
|
|
|
Optional<ModevType> optionalModevType = modevTypeRepository.findById(modev.getModevtid());
|
|
|
|
|
if (optionalModevType.isPresent()) {
|
|
|
|
|
ModevType modevType = optionalModevType.get();
|
|
|
|
|
if (StringUtils.isNotBlank(modevType.getTablename())) {
|
|
|
|
|
List<ColumnModel> columnList = dataService.getDataTableColumns(modevType.getTablename());
|
|
|
|
|
result.setColumnList(columnList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (modev.getIcdid() != null) {
|
|
|
|
|
Optional<IcdConfigTypeInst> optionalInst = instRepository.findById(modev.getIcdid());
|
|
|
|
|
if (optionalInst.isPresent()) {
|
|
|
|
|
IcdConfigTypeInst inst = optionalInst.get();
|
|
|
|
|
Optional<IcdConfigType> optionalType = typeRepository.findById(inst.getIcdConfigTypeId());
|
|
|
|
|
if (optionalType.isPresent()) {
|
|
|
|
|
IcdConfigType type = optionalType.get();
|
|
|
|
|
String param = type.getIedName() + type.getLdeviceInst() + "/" + type.getLnClass()
|
|
|
|
|
+ inst.getInst();
|
|
|
|
|
List<Rptparamindex> rptList = new ArrayList<>();
|
|
|
|
|
List<IcdConfigTypeAtt> attList = attRepository.findByIcdConfigTypeId(type.getId());
|
|
|
|
|
for (IcdConfigTypeAtt att : attList) {
|
|
|
|
|
String paramindex = param + "$" + att.getLastName();
|
|
|
|
|
Rptparamindex rpt = new Rptparamindex();
|
|
|
|
|
Optional<Rptparamindex> optionalRpt = rptparamindexRepository.findById(paramindex);
|
|
|
|
|
if (optionalRpt.isPresent()) {
|
|
|
|
|
rpt = optionalRpt.get();
|
|
|
|
|
} else {
|
|
|
|
|
rpt.setParamindex(paramindex);
|
|
|
|
|
}
|
|
|
|
|
rpt.setTablename(type.getTableName());
|
|
|
|
|
rpt.setColname(att.getColName());
|
|
|
|
|
rpt.setEqmid(eqmid);
|
|
|
|
|
rptList.add(rpt);
|
|
|
|
|
}
|
|
|
|
|
result.setRptList(rptList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bindOne(Integer eqmid, Integer icdid) throws Exception {
|
|
|
|
|
Optional<IcdConfigTypeInst> optionalInst = instRepository.findById(icdid);
|
|
|
|
|
if (!optionalInst.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该ICD配置类型实例, eqmid=" + eqmid + ", bindingId=" + bindingId);
|
|
|
|
|
throw new Exception("未找到该ICD逻辑设备实例, eqmid=" + eqmid + ", icdid=" + icdid);
|
|
|
|
|
}
|
|
|
|
|
IcdConfigTypeInst inst = optionalInst.get();
|
|
|
|
|
Optional<IcdConfigType> optionalType = typeRepository.findById(inst.getIcdConfigTypeId());
|
|
|
|
|
if (!optionalType.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该实例对应的ICD配置类型, bindingId=" + bindingId);
|
|
|
|
|
throw new Exception("未找到该实例对应的ICD配置类型, icdid=" + icdid);
|
|
|
|
|
}
|
|
|
|
|
IcdConfigType type = optionalType.get();
|
|
|
|
|
String param = type.getIedName() + type.getLdeviceInst() + "/" + type.getLnClass()
|
|
|
|
|