fix: 修正icd绑定的eqmid改用sensorId

dev
huangfeng 12 months ago
parent 69f6c83d90
commit ccd33fa7b0

@ -2,7 +2,6 @@ package com.xydl.cac.controller;
import com.xydl.cac.entity.Bdz;
import com.xydl.cac.entity.IcdConfigTypeInst;
import com.xydl.cac.entity.Rptparamindex;
import com.xydl.cac.exception.BusinessException;
import com.xydl.cac.model.BindDetail;
import com.xydl.cac.model.BindingModel;
@ -57,21 +56,21 @@ public class ParamBindController extends BasicController {
@PostMapping("unbind")
@ApiOperation("解绑")
public Response<String> unbind(@Validated @NotNull(message = "eqmid不能为空!") @Param("eqmid") Integer eqmid) throws Exception {
if (eqmid == null) {
throw new BusinessException("eqmid不能为空!");
public Response<String> unbind(@Validated @NotNull(message = "sensorId不能为空!") @Param("sensorId") Integer sensorId) throws Exception {
if (sensorId == null) {
throw new BusinessException("sensorId不能为空!");
}
bindService.unbind(eqmid);
bindService.unbind(sensorId);
return Response.success("OK");
}
@GetMapping("getBind")
@ApiOperation("查询绑定信息")
public Response<BindDetail> getBind(@Validated @NotNull(message = "eqmid不能为空!") @Param("eqmid") Integer eqmid) throws Exception {
if (eqmid == null) {
throw new BusinessException("eqmid不能为空!");
public Response<BindDetail> getBind(@Validated @NotNull(message = "sensorId不能为空!") @Param("sensorId") Integer sensorId) throws Exception {
if (sensorId == null) {
throw new BusinessException("sensorId不能为空!");
}
BindDetail result = bindService.getBind(eqmid);
BindDetail result = bindService.getBind(sensorId);
return Response.success(result);
}

@ -8,8 +8,8 @@ import java.util.List;
@Data
public class BindDetail {
@ApiModelProperty("eqmid")
Integer eqmid;
@ApiModelProperty("sensorId")
Integer sensorId;
@ApiModelProperty("逻辑设备实例的Id")
Integer icdid;
@ApiModelProperty("iedName")

@ -7,9 +7,9 @@ import javax.validation.constraints.NotNull;
@Data
public class BindingModel {
@NotNull(message = "eqmid不能为空")
@ApiModelProperty("eqmid")
Integer eqmid;
@NotNull(message = "sensorId不能为空")
@ApiModelProperty("sensorId")
Integer sensorId;
@NotNull(message = "逻辑设备实例的Id不能为空")
@ApiModelProperty("逻辑设备实例的Id")
Integer icdid;

@ -20,9 +20,9 @@ public interface ParamBindService {
void bind(BindingModel item) throws Exception;
void unbind(Integer eqmid) throws Exception;
void unbind(Integer sensorId) throws Exception;
BindDetail getBind(Integer eqmid) throws Exception;
BindDetail getBind(Integer sensorId) throws Exception;
String generateParamindex() throws Exception;

@ -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);
}
}

Loading…
Cancel
Save