pert: 优化预览信息

dev
huangfeng 1 year ago
parent abcb45858c
commit 369ffc450c

@ -43,9 +43,8 @@ public class ParamBindController extends BasicController {
@PostMapping("preview")
@ApiOperation("预览")
public Response<List<Rptparamindex>> preview(@Validated @RequestBody BindingModel item) throws Exception {
List<Rptparamindex> result = bindService.preview(item);
return Response.success(result);
public Response preview(@Validated @RequestBody BindingModel item) throws Exception {
return bindService.preview(item);
}
@PostMapping("bind")

@ -14,6 +14,8 @@ public class BindDetail {
Integer eqmid;
@ApiModelProperty("逻辑设备实例的Id")
Integer icdid;
@ApiModelProperty("iedName")
String iedName;
@ApiModelProperty("表字段名")
List<ColumnModel> columnList;
@ApiModelProperty("绑定关系")

@ -2,9 +2,9 @@ package com.xydl.cac.service;
import com.xydl.cac.entity.Bdz;
import com.xydl.cac.entity.IcdConfigTypeInst;
import com.xydl.cac.entity.Rptparamindex;
import com.xydl.cac.model.BindDetail;
import com.xydl.cac.model.BindingModel;
import com.xydl.cac.model.Response;
import java.util.List;
@ -14,7 +14,7 @@ public interface ParamBindService {
List<IcdConfigTypeInst> instList(String iedName);
List<Rptparamindex> preview(BindingModel item) throws Exception;
Response preview(BindingModel item) throws Exception;
void bind(BindingModel item) throws Exception;

@ -4,6 +4,7 @@ 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.model.Response;
import com.xydl.cac.repository.*;
import com.xydl.cac.service.DataService;
import com.xydl.cac.service.ParamBindService;
@ -82,10 +83,20 @@ public class ParamBindServiceImpl implements ParamBindService {
}
@Override
public List<Rptparamindex> preview(BindingModel item) throws Exception {
public Response preview(BindingModel item) throws Exception {
Optional<Modev> optionalModev = modevRepository.findById(item.getEqmid());
if (!optionalModev.isPresent()) {
throw new Exception("未找到该监测装置, eqmid=" + item.getEqmid());
}
Modev modev = optionalModev.get();
Optional<ModevType> optionalModevType = modevTypeRepository.findById(modev.getModevtid());
if (!optionalModevType.isPresent()) {
throw new Exception("该监测装置类型不正确, 请先修正");
}
ModevType modevType = optionalModevType.get();
Optional<IcdConfigTypeInst> optionalInst = instRepository.findById(item.getIcdid());
if (!optionalInst.isPresent()) {
throw new Exception("未找到该ICD配置类型实例, eqmid=" + item.getEqmid() + ", icdid=" + item.getIcdid());
throw new Exception("未找到该ICD逻辑设备实例, icdid=" + item.getIcdid());
}
IcdConfigTypeInst inst = optionalInst.get();
Optional<IcdConfigType> optionalType = typeRepository.findById(inst.getIcdConfigTypeId());
@ -110,11 +121,24 @@ public class ParamBindServiceImpl implements ParamBindService {
rpt.setEqmid(item.getEqmid());
result.add(rpt);
}
return result;
Response resp = Response.success(result);
if (StringUtils.isBlank(type.getTableName())) {
resp.setErrorMsg("该ICD配置类型还未设置对应的tableName");
} else if (!type.getTableName().equals(modevType.getTablename())) {
resp.setErrorMsg("该ICD配置类型的tableName和该监测装置类型的tableName不一致");
}
return resp;
}
@Override
public void bind(BindingModel item) throws Exception {
Optional<Modev> optionalModev = modevRepository.findById(item.getEqmid());
if (!optionalModev.isPresent()) {
throw new Exception("未找到该监测装置, eqmid=" + item.getEqmid());
}
Modev modev = optionalModev.get();
Optional<IcdConfigTypeInst> optionalInst = instRepository.findById(item.getIcdid());
if (!optionalInst.isPresent()) {
throw new Exception("未找到该ICD逻辑设备实例, icdid=" + item.getIcdid());
@ -130,11 +154,7 @@ public class ParamBindServiceImpl implements ParamBindService {
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);
}
@ -149,7 +169,6 @@ public class ParamBindServiceImpl implements ParamBindService {
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();
@ -159,12 +178,14 @@ public class ParamBindServiceImpl implements ParamBindService {
}
}
if (modev.getIcdid() != null) {
result.setIcdid(modev.getIcdid());
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();
result.setIedName(type.getIedName());
String param = type.getIedName() + type.getLdeviceInst() + "/" + type.getLnClass()
+ inst.getInst();
List<Rptparamindex> rptList = new ArrayList<>();

Loading…
Cancel
Save