diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java index 82b75497..8f4586d3 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java @@ -85,7 +85,10 @@ public interface DeviceChannelMapper { int update(DeviceChannel channel); @SelectProvider(type = DeviceChannelProvider.class, method = "queryChannels") - List queryChannels(@Param("deviceDbId") int deviceDbId, @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, @Param("channelIds") List channelIds); + List queryChannels(@Param("deviceDbId") int deviceDbId, @Param("civilCode") String civilCode, + @Param("parentChannelId") String parentChannelId, @Param("query") String query, + @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, + @Param("channelIds") List channelIds); @SelectProvider(type = DeviceChannelProvider.class, method = "queryChannelsByDeviceDbId") List queryChannelsByDeviceDbId(@Param("deviceDbId") int deviceDbId); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/DeviceChannelProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/DeviceChannelProvider.java index e21b7729..e96fa29c 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/DeviceChannelProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/DeviceChannelProvider.java @@ -1,5 +1,7 @@ package com.genersoft.iot.vmp.gb28181.dao.provider; +import org.springframework.util.ObjectUtils; + import java.util.List; import java.util.Map; @@ -58,14 +60,18 @@ public class DeviceChannelProvider { public String queryChannels(Map params ){ StringBuilder sqlBuild = new StringBuilder(); sqlBuild.append(getBaseSelectSql()); - sqlBuild.append(" where dc.device_db_id = #{deviceDbId}"); - if (params.get("query") != null) { - sqlBuild.append(" AND coalesce(dc.gb_device_id, dc.device_id) LIKE concat('%',#{query},'%')" + - " OR coalesce(dc.gb_name, dc.name) LIKE concat('%',#{query},'%')") - ; - } + sqlBuild.append(" where dc.device_db_id = #{deviceDbId} "); if (params.get("parentChannelId") != null ) { - sqlBuild.append(" AND (dc.parent_id=#{parentChannelId} OR coalesce(dc.gb_civil_code, dc.civil_code) = #{parentChannelId})"); + sqlBuild.append(" AND coalesce(dc.gb_parent_id, dc.parent_id)=#{parentChannelId}"); + } + if (params.get("civilCode") != null ) { + sqlBuild.append(" AND (coalesce(dc.gb_civil_code, dc.civil_code) = #{civilCode} " + + "OR (LENGTH(coalesce(dc.gb_device_id, dc.device_id))=LENGTH(#{civilCode}) + 2) AND coalesce(dc.gb_device_id, dc.device_id) LIKE concat(#{civilCode},'%'))"); + } + if (params.get("query") != null && !ObjectUtils.isEmpty(params.get("query"))) { + sqlBuild.append(" AND (coalesce(dc.gb_device_id, dc.device_id) LIKE concat('%',#{query},'%')" + + " OR coalesce(dc.gb_name, dc.name) LIKE concat('%',#{query},'%'))") + ; } if (params.get("online") != null && (Boolean)params.get("online")) { sqlBuild.append(" AND coalesce(gb_status, status) = 'ON'"); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java index b1b861ac..17bdb7b1 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java @@ -599,7 +599,14 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { @Override public PageInfo getSubChannels(int deviceDbId, String channelId, String query, Boolean channelType, Boolean online, int page, int count) { PageHelper.startPage(page, count); - List all = channelMapper.queryChannels(deviceDbId, channelId, query, channelType, online,null); + String civilCode = null; + String parentId = null; + if (channelId.length() <= 8) { + civilCode = channelId; + }else { + parentId = channelId; + } + List all = channelMapper.queryChannels(deviceDbId, civilCode, parentId, query, channelType, online,null); return new PageInfo<>(all); } @@ -616,7 +623,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { } // 获取到所有正在播放的流 PageHelper.startPage(page, count); - List all = channelMapper.queryChannels(device.getId(), null, query, hasSubChannel, online,null); + List all = channelMapper.queryChannels(device.getId(), null,null, query, hasSubChannel, online,null); return new PageInfo<>(all); } diff --git a/web_src/src/components/channelList.vue b/web_src/src/components/channelList.vue index 7304ec32..d3b23a81 100755 --- a/web_src/src/components/channelList.vue +++ b/web_src/src/components/channelList.vue @@ -129,10 +129,10 @@ 查看 - + 更多功能