Commit 1af77ab5f7c11a4b3d59c1989b51b9fca29679ce

Authored by 648540858
Committed by GitHub
2 parents e9a7207e 58b9dab8

Merge pull request #645 from IKangXu/wvp-28181-2.0

优化 国标设备中通道内查看的逻辑,保证与分屏与电子地图中树结构的数据一致
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
... ... @@ -362,10 +362,10 @@ public class DeviceServiceImpl implements IDeviceService {
362 362 return null;
363 363 }
364 364 // 使用行政区划展示树
365   - if (parentId.length() > 10) {
366   - // TODO 可能是行政区划与业务分组混杂的情形
367   - return null;
368   - }
  365 +// if (parentId.length() > 10) {
  366 +// // TODO 可能是行政区划与业务分组混杂的情形
  367 +// return null;
  368 +// }
369 369  
370 370 if (parentId.length() == 10 ) {
371 371 if (onlyCatalog) {
... ... @@ -380,7 +380,18 @@ public class DeviceServiceImpl implements IDeviceService {
380 380 List<DeviceChannel> channelsForCivilCode = deviceChannelMapper.getChannelsWithCivilCodeAndLength(deviceId, parentId, parentId.length() + 2);
381 381 if (!onlyCatalog) {
382 382 List<DeviceChannel> channels = deviceChannelMapper.getChannelsByCivilCode(deviceId, parentId);
383   - channelsForCivilCode.addAll(channels);
  383 +
  384 + for(DeviceChannel channel : channels) {
  385 + boolean flag = false;
  386 + for(DeviceChannel deviceChannel : channelsForCivilCode) {
  387 + if(channel.getChannelId().equals(deviceChannel.getChannelId())) {
  388 + flag = true;
  389 + }
  390 + }
  391 + if(!flag) {
  392 + channelsForCivilCode.add(channel);
  393 + }
  394 + }
384 395 }
385 396 List<BaseTree<DeviceChannel>> trees = transportChannelsToTree(channelsForCivilCode, parentId);
386 397 return trees;
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
... ... @@ -71,7 +71,7 @@ public interface DeviceChannelMapper {
71 71 "WHERE " +
72 72 "dc.deviceId = #{deviceId} " +
73 73 " <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
74   - " <if test='parentChannelId != null'> AND dc.parentId=#{parentChannelId} </if> " +
  74 + " <if test='parentChannelId != null'> AND (dc.parentId=#{parentChannelId} OR dc.civilCode = #{parentChannelId}) </if> " +
75 75 " <if test='online == true' > AND dc.status=1</if>" +
76 76 " <if test='online == false' > AND dc.status=0</if>" +
77 77 " <if test='hasSubChannel == true' > AND dc.subCount > 0 </if>" +
... ... @@ -309,8 +309,10 @@ public interface DeviceChannelMapper {
309 309 "select * " +
310 310 "from device_channel " +
311 311 "where deviceId=#{deviceId}" +
312   - " <if test='parentId != null' > and left(channelId, ${parentId.length()}) = #{parentId}</if>" +
313   - " <if test='length != null' > and length(channelId)=${length}</if>" +
  312 + " <if test='parentId != null and length != null' > and parentId = #{parentId} or left(channelId, ${parentId.length()}) = #{parentId} and length(channelId)=${length} </if>" +
  313 + " <if test='parentId == null and length != null' > and parentId = #{parentId} or length(channelId)=${length} </if>" +
  314 + " <if test='parentId == null and length == null' > and parentId = #{parentId} </if>" +
  315 + " <if test='parentId != null and length == null' > and parentId = #{parentId} or left(channelId, ${parentId.length()}) = #{parentId} </if>" +
314 316 " </script>"})
315 317 List<DeviceChannel> getChannelsWithCivilCodeAndLength(String deviceId, String parentId, Integer length);
316 318  
... ...