From 369ffc450cdce43ba1a28465e9efdc2f0ac1368e Mon Sep 17 00:00:00 2001 From: huangfeng Date: Tue, 9 Jan 2024 15:06:08 +0800 Subject: [PATCH] =?UTF-8?q?pert:=20=E4=BC=98=E5=8C=96=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cac/controller/ParamBindController.java | 5 +-- .../java/com/xydl/cac/model/BindDetail.java | 2 + .../xydl/cac/service/ParamBindService.java | 4 +- .../service/impl/ParamBindServiceImpl.java | 39 ++++++++++++++----- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/xydl/cac/controller/ParamBindController.java b/src/main/java/com/xydl/cac/controller/ParamBindController.java index be82afa..caffa82 100644 --- a/src/main/java/com/xydl/cac/controller/ParamBindController.java +++ b/src/main/java/com/xydl/cac/controller/ParamBindController.java @@ -43,9 +43,8 @@ public class ParamBindController extends BasicController { @PostMapping("preview") @ApiOperation("预览") - public Response> preview(@Validated @RequestBody BindingModel item) throws Exception { - List result = bindService.preview(item); - return Response.success(result); + public Response preview(@Validated @RequestBody BindingModel item) throws Exception { + return bindService.preview(item); } @PostMapping("bind") diff --git a/src/main/java/com/xydl/cac/model/BindDetail.java b/src/main/java/com/xydl/cac/model/BindDetail.java index 1b8197d..c416bde 100644 --- a/src/main/java/com/xydl/cac/model/BindDetail.java +++ b/src/main/java/com/xydl/cac/model/BindDetail.java @@ -14,6 +14,8 @@ public class BindDetail { Integer eqmid; @ApiModelProperty("逻辑设备实例的Id") Integer icdid; + @ApiModelProperty("iedName") + String iedName; @ApiModelProperty("表字段名") List columnList; @ApiModelProperty("绑定关系") diff --git a/src/main/java/com/xydl/cac/service/ParamBindService.java b/src/main/java/com/xydl/cac/service/ParamBindService.java index 1c3d419..90edd34 100644 --- a/src/main/java/com/xydl/cac/service/ParamBindService.java +++ b/src/main/java/com/xydl/cac/service/ParamBindService.java @@ -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 instList(String iedName); - List preview(BindingModel item) throws Exception; + Response preview(BindingModel item) throws Exception; void bind(BindingModel item) throws Exception; diff --git a/src/main/java/com/xydl/cac/service/impl/ParamBindServiceImpl.java b/src/main/java/com/xydl/cac/service/impl/ParamBindServiceImpl.java index c873528..ebec30f 100644 --- a/src/main/java/com/xydl/cac/service/impl/ParamBindServiceImpl.java +++ b/src/main/java/com/xydl/cac/service/impl/ParamBindServiceImpl.java @@ -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 preview(BindingModel item) throws Exception { + public Response preview(BindingModel item) throws Exception { + Optional optionalModev = modevRepository.findById(item.getEqmid()); + if (!optionalModev.isPresent()) { + throw new Exception("未找到该监测装置, eqmid=" + item.getEqmid()); + } + Modev modev = optionalModev.get(); + Optional optionalModevType = modevTypeRepository.findById(modev.getModevtid()); + if (!optionalModevType.isPresent()) { + throw new Exception("该监测装置类型不正确, 请先修正"); + } + ModevType modevType = optionalModevType.get(); Optional 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 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 optionalModev = modevRepository.findById(item.getEqmid()); + if (!optionalModev.isPresent()) { + throw new Exception("未找到该监测装置, eqmid=" + item.getEqmid()); + } + Modev modev = optionalModev.get(); + Optional 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 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 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 optionalInst = instRepository.findById(modev.getIcdid()); if (optionalInst.isPresent()) { IcdConfigTypeInst inst = optionalInst.get(); Optional 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 rptList = new ArrayList<>();