From 4c497ef41144af212dabdd2cc3d248fc1c974745 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 22 Oct 2024 16:27:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=BD=E6=A0=87=E8=AE=BE?= =?UTF-8?q?=E5=A4=87/=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8=E4=B8=AD?= =?UTF-8?q?=E8=A1=8C=E6=94=BF=E5=8C=BA=E5=88=92=E7=9A=84=E5=AD=90=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/gb28181/dao/DeviceChannelMapper.java | 5 ++++- .../dao/provider/DeviceChannelProvider.java | 20 ++++++++++++------- .../impl/DeviceChannelServiceImpl.java | 11 ++++++++-- web_src/src/components/channelList.vue | 4 ++-- 4 files changed, 28 insertions(+), 12 deletions(-) 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 @@ 查看 - + 更多功能