diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index a6b9cc53..29b8bcb0 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -398,10 +398,10 @@ public class DeviceServiceImpl implements IDeviceService { return null; } // 使用行政区划展示树 - if (parentId.length() > 10) { - // TODO 可能是行政区划与业务分组混杂的情形 - return null; - } +// if (parentId.length() > 10) { +// // TODO 可能是行政区划与业务分组混杂的情形 +// return null; +// } if (parentId.length() == 10 ) { if (onlyCatalog) { @@ -416,7 +416,18 @@ public class DeviceServiceImpl implements IDeviceService { List channelsForCivilCode = deviceChannelMapper.getChannelsWithCivilCodeAndLength(deviceId, parentId, parentId.length() + 2); if (!onlyCatalog) { List channels = deviceChannelMapper.getChannelsByCivilCode(deviceId, parentId); - channelsForCivilCode.addAll(channels); + + for(DeviceChannel channel : channels) { + boolean flag = false; + for(DeviceChannel deviceChannel : channelsForCivilCode) { + if(channel.getChannelId().equals(deviceChannel.getChannelId())) { + flag = true; + } + } + if(!flag) { + channelsForCivilCode.add(channel); + } + } } List> trees = transportChannelsToTree(channelsForCivilCode, parentId); return trees; diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java index 3ef412d6..9b2a099d 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java @@ -71,7 +71,7 @@ public interface DeviceChannelMapper { "WHERE " + "dc.deviceId = #{deviceId} " + " AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%') " + - " AND dc.parentId=#{parentChannelId} " + + " AND (dc.parentId=#{parentChannelId} OR dc.civilCode = #{parentChannelId}) " + " AND dc.status=1" + " AND dc.status=0" + " AND dc.subCount > 0 " + @@ -309,8 +309,10 @@ public interface DeviceChannelMapper { "select * " + "from device_channel " + "where deviceId=#{deviceId}" + - " and left(channelId, ${parentId.length()}) = #{parentId}" + - " and length(channelId)=${length}" + + " and parentId = #{parentId} or left(channelId, ${parentId.length()}) = #{parentId} and length(channelId)=${length} " + + " and parentId = #{parentId} or length(channelId)=${length} " + + " and parentId = #{parentId} " + + " and parentId = #{parentId} or left(channelId, ${parentId.length()}) = #{parentId} " + " "}) List getChannelsWithCivilCodeAndLength(String deviceId, String parentId, Integer length);