From 098e1331ef83612eb12777f860863f66c126da95 Mon Sep 17 00:00:00 2001 From: huguanghan Date: Tue, 22 Oct 2024 16:38:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=8B=E5=8F=91=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../node/mapper/SysImptabmappingMapper.java | 4 ++- .../node/service/impl/DataServiceImpl.java | 35 +++++++++--------- .../mapper/SysImptabmappingMapper.xml | 36 ++++++++++++++----- 3 files changed, 50 insertions(+), 25 deletions(-) diff --git a/das/src/main/java/com/das/modules/node/mapper/SysImptabmappingMapper.java b/das/src/main/java/com/das/modules/node/mapper/SysImptabmappingMapper.java index b4e1a9ce..7bba68ef 100644 --- a/das/src/main/java/com/das/modules/node/mapper/SysImptabmappingMapper.java +++ b/das/src/main/java/com/das/modules/node/mapper/SysImptabmappingMapper.java @@ -28,7 +28,9 @@ public interface SysImptabmappingMapper extends BaseMapperPlus getEquipmentId(Long linkId); - List getIotModelFieldByEquipmentId(Long equipmentId); + List getIotModelFieldByDeviceId(@Param("deviceId") Long deviceId); + + List getIotModelServiceByDeviceId(@Param("deviceId") Long deviceId); List getIotModelServiceByEquipmentId(Long equipmentId); diff --git a/das/src/main/java/com/das/modules/node/service/impl/DataServiceImpl.java b/das/src/main/java/com/das/modules/node/service/impl/DataServiceImpl.java index a0e8cdb6..0dddbbbf 100644 --- a/das/src/main/java/com/das/modules/node/service/impl/DataServiceImpl.java +++ b/das/src/main/java/com/das/modules/node/service/impl/DataServiceImpl.java @@ -142,10 +142,11 @@ public class DataServiceImpl implements DataService { List newIotModelFieldList = new ArrayList<>(); List newIotModelServiceList = new ArrayList<>(); // 根据设备Id获取对应的物模型属性和动作 - List iotModelFieldList = sysImptabmappingMapper.getIotModelFieldByEquipmentId(equipmentId); + List iotModelFieldList = sysImptabmappingMapper.getIotModelFieldByDeviceId(equipmentId); + List iotModelServiceList = sysImptabmappingMapper.getIotModelServiceByDeviceId(equipmentId); if (!CollectionUtils.isEmpty(iotModelFieldList)) { for (IotModelVo info : iotModelFieldList) { - if (info.getServiceType() == null) { + NewIotModelVo newIotModelVo = new NewIotModelVo(); newIotModelVo.setName(info.getEquipmentAttribute()); newIotModelVo.setHighSpeed(info.getHighSpeed()); @@ -162,21 +163,23 @@ public class DataServiceImpl implements DataService { newIotModelVo.setType("yx"); } newIotModelFieldList.add(newIotModelVo); - } else if (info.getAttributeType() == null) { - NewIotModelVo newIotModelVo = new NewIotModelVo(); - newIotModelVo.setName(info.getEquipmentService()); - if (info.getParams() == null) { - newIotModelVo.setParams(equipJsonNode); - } else { - newIotModelVo.setParams(equipObjectMapper.readTree(info.getParams().toString())); - } - if (info.getServiceType() == BaseIotModelType.TYPE_PSR_SETPOINT) { - newIotModelVo.setType("yt"); - } else if (info.getServiceType() == BaseIotModelType.TYPE_PSR_CONTROL) { - newIotModelVo.setType("yk"); - } - newIotModelServiceList.add(newIotModelVo); + } + } + if (!CollectionUtils.isEmpty(iotModelServiceList)){ + for (IotModelVo info : iotModelServiceList) { + NewIotModelVo newIotModelVo = new NewIotModelVo(); + newIotModelVo.setName(info.getEquipmentService()); + if (info.getParams() == null) { + newIotModelVo.setParams(equipJsonNode); + } else { + newIotModelVo.setParams(equipObjectMapper.readTree(info.getParams().toString())); } + if (info.getServiceType() == BaseIotModelType.TYPE_PSR_SETPOINT) { + newIotModelVo.setType("yt"); + } else if (info.getServiceType() == BaseIotModelType.TYPE_PSR_CONTROL) { + newIotModelVo.setType("yk"); + } + newIotModelServiceList.add(newIotModelVo); } } EquipmentVo equipment = new EquipmentVo(); diff --git a/das/src/main/resources/mapper/SysImptabmappingMapper.xml b/das/src/main/resources/mapper/SysImptabmappingMapper.xml index 595e8290..af03a126 100644 --- a/das/src/main/resources/mapper/SysImptabmappingMapper.xml +++ b/das/src/main/resources/mapper/SysImptabmappingMapper.xml @@ -58,14 +58,6 @@ where sc.id = #{linkId} - - + +