Просмотр исходного кода

修复REDIS更新推流设备状态

648540858 1 год назад
Родитель
Сommit
77f1dfb6d6

+ 4 - 0
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 {
             " </script>"})
     int updateCivilCodeByChannelList(@Param("civilCode") String civilCode, List<CommonGBChannel> channelList);
 
+    @SelectProvider(type = ChannelProvider.class, method = "queryListByStreamPushList")
+    List<CommonGBChannel> queryListByStreamPushList(List<StreamPush> streamPushList);
+
 }

+ 20 - 0
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<String, Object> params ){
+        StringBuilder sqlBuild = new StringBuilder();
+        sqlBuild.append(getBaseSelectSql());
+
+        sqlBuild.append(" where channel_type = 0 and stream_push_id in ( ");
+        Collection<StreamPush> ids = (Collection<StreamPush>)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() ;
+    }
 }

+ 3 - 0
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<CommonGBChannel> queryListByStreamPushList(List<StreamPush> streamPushList);
+
 }

+ 6 - 0
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<CommonGBChannel> queryListByStreamPushList(List<StreamPush> streamPushList) {
+        return commonGBChannelMapper.queryListByStreamPushList(streamPushList);
+    }
 }

+ 2 - 9
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<StreamPushItemFromRedis> offlineStreams) {
         // 更新部分设备离线
         List<StreamPush> streamPushList = streamPushMapper.getListFromRedis(offlineStreams);
-        List<CommonGBChannel> commonGBChannelList = new ArrayList<>();
-        for (StreamPush onlinePusher : streamPushList) {
-            commonGBChannelList.add(onlinePusher.buildCommonGBChannel());
-        }
+        List<CommonGBChannel> commonGBChannelList = gbChannelService.queryListByStreamPushList(streamPushList);
         gbChannelService.offline(commonGBChannelList);
     }
 
@@ -462,16 +459,12 @@ public class StreamPushServiceImpl implements IStreamPushService {
     public void online(List<StreamPushItemFromRedis> onlineStreams) {
         // 更新部分设备上线streamPushService
         List<StreamPush> streamPushList = streamPushMapper.getListFromRedis(onlineStreams);
-        List<CommonGBChannel> commonGBChannelList = new ArrayList<>();
-        for (StreamPush onlinePusher : streamPushList) {
-            commonGBChannelList.add(onlinePusher.buildCommonGBChannel());
-        }
+        List<CommonGBChannel> commonGBChannelList = gbChannelService.queryListByStreamPushList(streamPushList);
         gbChannelService.online(commonGBChannelList);
     }
 
     @Override
     public List<String> getAllAppAndStream() {
-
         return streamPushMapper.getAllAppAndStream();
     }