diff --git a/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java b/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java index a48bfb50..0effa431 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java @@ -43,4 +43,5 @@ public interface IGbStreamService { DeviceChannel getDeviceChannelListByStream(GbStream gbStream, String catalogId, String deviceGBId); void sendCatalogMsg(GbStream gbStream, String type); + void sendCatalogMsgs(List gbStreams, String type); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java b/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java index c52c325b..53ca6c41 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java @@ -66,4 +66,6 @@ public interface IStreamPushService { boolean saveToRandomGB(); void batchAdd(List streamPushExcelDtoList); + + boolean batchStop(List streamPushItems); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java index ee7a80b1..64f49ac6 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java @@ -20,6 +20,7 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.stereotype.Service; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionStatus; +import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.List; @@ -144,8 +145,16 @@ public class GbStreamServiceImpl implements IGbStreamService { gbStreams.add(streamProxyItem); } } + sendCatalogMsgs(gbStreams, type); + } + + @Override + public void sendCatalogMsgs(List gbStreams, String type) { if (gbStreams.size() > 0) { for (GbStream gs : gbStreams) { + if (StringUtils.isEmpty(gs.getGbId())){ + continue; + } List parentPlatforms = platformGbStreamMapper.selectByAppAndStream(gs.getApp(), gs.getStream()); if (parentPlatforms.size() > 0) { for (ParentPlatform parentPlatform : parentPlatforms) { diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java index c8a4f46d..2ce9234a 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java @@ -355,8 +355,26 @@ public class StreamPushServiceImpl implements IStreamPushService { } } } + } + } + + @Override + public boolean batchStop(List gbStreams) { + if (gbStreams == null || gbStreams.size() == 0) { + return false; + } + gbStreamService.sendCatalogMsgs(gbStreams, CatalogEvent.DEL); + int delStream = streamPushMapper.delAllForGbStream(gbStreams); + gbStreamMapper.batchDelForGbStream(gbStreams); + platformGbStreamMapper.delByGbStreams(gbStreams); + if (delStream > 0) { + for (GbStream gbStream : gbStreams) { + MediaServerItem mediaServerItem = mediaServerService.getOne(gbStream.getMediaServerId()); + zlmresTfulUtils.closeStreams(mediaServerItem, gbStream.getApp(), gbStream.getStream()); + } } + return true; } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java index fade54bb..1bcececf 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java @@ -84,6 +84,14 @@ public interface GbStreamMapper { "") void batchDel(List streamProxyItemList); + @Delete("") + void batchDelForGbStream(List gbStreams); + @Insert("") + void delByGbStreams(List gbStreams); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java index 3c43a9db..3379c9fd 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.storager.dao; +import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; @@ -48,7 +49,13 @@ public interface StreamPushMapper { "") int delAll(List streamPushItems); - + @Delete("") + int delAllForGbStream(List gbStreams); @Select(value = {"