From 77f1dfb6d618f3a34346b9b6ecee43569987d169 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 19 Sep 2024 17:21:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DREDIS=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=8E=A8=E6=B5=81=E8=AE=BE=E5=A4=87=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/dao/CommonGBChannelMapper.java | 4 ++++ .../gb28181/dao/provider/ChannelProvider.java | 20 +++++++++++++++++++ .../gb28181/service/IGbChannelService.java | 3 +++ .../service/impl/GbChannelServiceImpl.java | 6 ++++++ .../service/impl/StreamPushServiceImpl.java | 11 ++-------- 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java index c48a1878..1561d9b2 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.dao; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.dao.provider.ChannelProvider; +import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; @@ -571,4 +572,7 @@ public interface CommonGBChannelMapper { " "}) int updateCivilCodeByChannelList(@Param("civilCode") String civilCode, List channelList); + @SelectProvider(type = ChannelProvider.class, method = "queryListByStreamPushList") + List queryListByStreamPushList(List streamPushList); + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java index 18756565..1a148cf3 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.dao.provider; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.Group; +import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import java.util.Collection; import java.util.List; @@ -240,4 +241,23 @@ public class ChannelProvider { return sqlBuild.toString() ; } + + public String queryListByStreamPushList(Map params ){ + StringBuilder sqlBuild = new StringBuilder(); + sqlBuild.append(getBaseSelectSql()); + + sqlBuild.append(" where channel_type = 0 and stream_push_id in ( "); + Collection ids = (Collection)params.get("streamPushList"); + boolean first = true; + for (StreamPush streamPush : ids) { + if (!first) { + sqlBuild.append(","); + } + sqlBuild.append(streamPush.getId()); + first = false; + } + sqlBuild.append(" )"); + + return sqlBuild.toString() ; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java index f5cfe887..ac13ffa0 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.gb28181.service; import com.genersoft.iot.vmp.gb28181.bean.*; +import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import com.github.pagehelper.PageInfo; import java.util.Collection; @@ -78,4 +79,6 @@ public interface IGbChannelService { void updateCivilCode(String oldCivilCode, String newCivilCode); + List queryListByStreamPushList(List streamPushList); + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java index 960d0795..62be902b 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java @@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService; +import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.github.pagehelper.PageHelper; @@ -675,4 +676,9 @@ public class GbChannelServiceImpl implements IGbChannelService { } } } + + @Override + public List queryListByStreamPushList(List streamPushList) { + return commonGBChannelMapper.queryListByStreamPushList(streamPushList); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java index a24e4f8c..0b41086e 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java @@ -451,10 +451,7 @@ public class StreamPushServiceImpl implements IStreamPushService { public void offline(List offlineStreams) { // 更新部分设备离线 List streamPushList = streamPushMapper.getListFromRedis(offlineStreams); - List commonGBChannelList = new ArrayList<>(); - for (StreamPush onlinePusher : streamPushList) { - commonGBChannelList.add(onlinePusher.buildCommonGBChannel()); - } + List commonGBChannelList = gbChannelService.queryListByStreamPushList(streamPushList); gbChannelService.offline(commonGBChannelList); } @@ -462,16 +459,12 @@ public class StreamPushServiceImpl implements IStreamPushService { public void online(List onlineStreams) { // 更新部分设备上线streamPushService List streamPushList = streamPushMapper.getListFromRedis(onlineStreams); - List commonGBChannelList = new ArrayList<>(); - for (StreamPush onlinePusher : streamPushList) { - commonGBChannelList.add(onlinePusher.buildCommonGBChannel()); - } + List commonGBChannelList = gbChannelService.queryListByStreamPushList(streamPushList); gbChannelService.online(commonGBChannelList); } @Override public List getAllAppAndStream() { - return streamPushMapper.getAllAppAndStream(); }