|
|
|
@ -134,9 +134,9 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Response preview(BindingModel item) throws Exception {
|
|
|
|
|
Optional<NSensor> optionalNSensor = sensorRepository.findById(item.getEqmid());
|
|
|
|
|
Optional<NSensor> optionalNSensor = sensorRepository.findById(item.getSensorId());
|
|
|
|
|
if (!optionalNSensor.isPresent()) {
|
|
|
|
|
throw new BusinessException("未找到该监测装置, eqmid=" + item.getEqmid());
|
|
|
|
|
throw new BusinessException("未找到该监测装置, sensorId=" + item.getSensorId());
|
|
|
|
|
}
|
|
|
|
|
NSensor sensor = optionalNSensor.get();
|
|
|
|
|
if (sensor.getTypeId() == null) {
|
|
|
|
@ -187,9 +187,9 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void bind(BindingModel item) throws Exception {
|
|
|
|
|
Optional<NSensor> optionalNSensor = sensorRepository.findById(item.getEqmid());
|
|
|
|
|
Optional<NSensor> optionalNSensor = sensorRepository.findById(item.getSensorId());
|
|
|
|
|
if (!optionalNSensor.isPresent()) {
|
|
|
|
|
throw new BusinessException("未找到该监测装置, eqmid=" + item.getEqmid());
|
|
|
|
|
throw new BusinessException("未找到该监测装置, sensorId=" + item.getSensorId());
|
|
|
|
|
}
|
|
|
|
|
NSensor sensor = optionalNSensor.get();
|
|
|
|
|
|
|
|
|
@ -204,7 +204,7 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
}
|
|
|
|
|
IcdConfigType type = optionalType.get();
|
|
|
|
|
|
|
|
|
|
List<NSensor> list = sensorRepository.findByIcdIdAndIdIsNot(item.getIcdid(), item.getEqmid());
|
|
|
|
|
List<NSensor> list = sensorRepository.findByIcdIdAndIdIsNot(item.getIcdid(), item.getSensorId());
|
|
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
|
|
throw new BusinessException("该逻辑设备实例已被" + list.get(0).getName() + "绑定");
|
|
|
|
|
}
|
|
|
|
@ -235,10 +235,10 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void unbind(Integer eqmid) throws Exception {
|
|
|
|
|
Optional<NSensor> optionalNSensor = sensorRepository.findById(eqmid);
|
|
|
|
|
public void unbind(Integer sensorId) throws Exception {
|
|
|
|
|
Optional<NSensor> optionalNSensor = sensorRepository.findById(sensorId);
|
|
|
|
|
if (!optionalNSensor.isPresent()) {
|
|
|
|
|
throw new BusinessException("未找到该监测装置, eqmid=" + eqmid);
|
|
|
|
|
throw new BusinessException("未找到该监测装置, sensorId=" + sensorId);
|
|
|
|
|
}
|
|
|
|
|
NSensor sensor = optionalNSensor.get();
|
|
|
|
|
sensor.setIcdId(null);
|
|
|
|
@ -246,8 +246,8 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BindDetail getBind(Integer eqmid) throws Exception {
|
|
|
|
|
Optional<NSensor> optionalNSensor = sensorRepository.findById(eqmid);
|
|
|
|
|
public BindDetail getBind(Integer sensorId) throws Exception {
|
|
|
|
|
Optional<NSensor> optionalNSensor = sensorRepository.findById(sensorId);
|
|
|
|
|
if (!optionalNSensor.isPresent()) {
|
|
|
|
|
throw new BusinessException("未找到该监测装置");
|
|
|
|
|
}
|
|
|
|
@ -256,7 +256,7 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
sensor.setTableName(modevType.getTablename());
|
|
|
|
|
|
|
|
|
|
BindDetail result = new BindDetail();
|
|
|
|
|
result.setEqmid(eqmid);
|
|
|
|
|
result.setSensorId(sensorId);
|
|
|
|
|
if (StringUtils.isNotBlank(sensor.getTableName())) {
|
|
|
|
|
List<ColumnModel> columnList = dataService.getDataTableColumns(sensor.getTableName());
|
|
|
|
|
result.setColumnList(columnList);
|
|
|
|
@ -297,7 +297,7 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
private void generateOne(NSensor item) throws Exception {
|
|
|
|
|
Optional<IcdConfigTypeInst> optionalInst = instRepository.findById(item.getIcdId());
|
|
|
|
|
if (!optionalInst.isPresent()) {
|
|
|
|
|
throw new BusinessException("未找到该ICD逻辑设备实例, eqmid=" + item.getId() + ", icdid=" + item.getIcdId());
|
|
|
|
|
throw new BusinessException("未找到该ICD逻辑设备实例, sensorId=" + item.getId() + ", icdid=" + item.getIcdId());
|
|
|
|
|
}
|
|
|
|
|
IcdConfigTypeInst inst = optionalInst.get();
|
|
|
|
|
Optional<IcdConfigType> optionalType = typeRepository.findById(inst.getIcdConfigTypeId());
|
|
|
|
@ -319,7 +319,7 @@ public class ParamBindServiceImpl implements ParamBindService {
|
|
|
|
|
Rptparamindex rpt = optionalRpt.get();
|
|
|
|
|
rpt.setTablename(type.getTableName());
|
|
|
|
|
rpt.setColname(att.getColName());
|
|
|
|
|
rpt.setEqmid(item.getId());
|
|
|
|
|
rpt.setEqmid(item.getDevId());
|
|
|
|
|
rptparamindexRepository.save(rpt);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|