From 400eef2d2e2a8e076b076ae0464f23f119896776 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 27 Jun 2024 16:02:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/bean/CommonGBChannel.java | 6 ++ .../request/impl/ByeRequestProcessor.java | 1 + .../request/impl/InviteRequestProcessor.java | 4 +- .../vmp/media/zlm/ZLMHttpHookListener.java | 1 + .../iot/vmp/service/IGbStreamService.java | 2 +- .../vmp/service/impl/GbStreamServiceImpl.java | 2 +- .../redisMsg/RedisCloseStreamMsgListener.java | 2 +- .../RedisPushStreamStatusListMsgListener.java | 4 +- .../RedisPushStreamStatusMsgListener.java | 2 +- .../iot/vmp/storager/IRedisCatchStorage.java | 1 - .../iot/vmp/storager/dao/GbStreamMapper.java | 2 +- .../storager/dao/PlatformGbStreamMapper.java | 2 +- .../storager/impl/RedisCatchStorageImpl.java | 2 +- .../impl/VideoManagerStorageImpl.java | 1 + .../dto => streamPush/bean}/StreamPush.java | 3 +- .../streamPush/bean/StreamPushExcelDto.java | 29 ++++++ .../bean/StreamPushInfoForUpdateLoad.java | 16 ++++ .../controller}/StreamPushController.java | 11 +-- .../dao/StreamPushMapper.java | 4 +- .../enent}/StreamPushUploadFileHandler.java | 50 +++++------ .../service/IStreamPushService.java | 11 ++- .../service/impl/StreamPushServiceImpl.java | 50 ++++++----- .../vmp/vmanager/bean/StreamPushExcelDto.java | 88 ------------------- .../gb28181/gbStream/GbStreamController.java | 2 +- .../vmp/vmanager/server/ServerController.java | 1 + 25 files changed, 135 insertions(+), 162 deletions(-) rename src/main/java/com/genersoft/iot/vmp/{media/zlm/dto => streamPush/bean}/StreamPush.java (97%) create mode 100755 src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPushExcelDto.java create mode 100644 src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPushInfoForUpdateLoad.java rename src/main/java/com/genersoft/iot/vmp/{vmanager/streamPush => streamPush/controller}/StreamPushController.java (96%) rename src/main/java/com/genersoft/iot/vmp/{storager => streamPush}/dao/StreamPushMapper.java (99%) rename src/main/java/com/genersoft/iot/vmp/{service/impl => streamPush/enent}/StreamPushUploadFileHandler.java (78%) rename src/main/java/com/genersoft/iot/vmp/{ => streamPush}/service/IStreamPushService.java (83%) rename src/main/java/com/genersoft/iot/vmp/{ => streamPush}/service/impl/StreamPushServiceImpl.java (95%) delete mode 100755 src/main/java/com/genersoft/iot/vmp/vmanager/bean/StreamPushExcelDto.java diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java index 816917d4..58fc471f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java @@ -196,5 +196,11 @@ public class CommonGBChannel { @Schema(description = "国标-国民经济行业分类代码(可选)") private String gbIndustrialClassification; + @Schema(description = "关联的推流Id(流来源是推流时有效)") + private Integer streamPushId; + + @Schema(description = "关联的拉流代理Id(流来源是拉流代理时有效)") + private Integer streamProxyId; + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java index 178186fd..03f0f034 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java @@ -19,6 +19,7 @@ import com.genersoft.iot.vmp.service.*; import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; +import com.genersoft.iot.vmp.streamPush.service.IStreamPushService; import gov.nist.javax.sip.message.SIPRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index 4763f0fe..82b145c6 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -26,13 +26,13 @@ import com.genersoft.iot.vmp.media.event.hook.HookSubscribe; import com.genersoft.iot.vmp.media.event.hook.HookType; import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxy; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPush; +import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; import com.genersoft.iot.vmp.service.IPlayService; import com.genersoft.iot.vmp.service.IStreamProxyService; -import com.genersoft.iot.vmp.service.IStreamPushService; +import com.genersoft.iot.vmp.streamPush.service.IStreamPushService; import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager; import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcService; import com.genersoft.iot.vmp.service.bean.ErrorCallback; diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java index 636b4bf1..de91ed69 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java @@ -24,6 +24,7 @@ import com.genersoft.iot.vmp.service.*; import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; +import com.genersoft.iot.vmp.streamPush.service.IStreamPushService; import com.genersoft.iot.vmp.utils.MediaServerUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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 f4477283..834c3dae 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java @@ -4,7 +4,7 @@ import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPush; +import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import com.github.pagehelper.PageInfo; import java.util.List; 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 0f199378..72916ba4 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java @@ -4,7 +4,7 @@ import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPush; +import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import com.genersoft.iot.vmp.service.IGbStreamService; import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisCloseStreamMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisCloseStreamMsgListener.java index d9c35e27..e0224839 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisCloseStreamMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisCloseStreamMsgListener.java @@ -2,7 +2,7 @@ package com.genersoft.iot.vmp.service.redisMsg; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.service.IStreamPushService; +import com.genersoft.iot.vmp.streamPush.service.IStreamPushService; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java index 842277a8..6b92fc4b 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java @@ -3,9 +3,9 @@ package com.genersoft.iot.vmp.service.redisMsg; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.media.service.IMediaServerService; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPush; +import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import com.genersoft.iot.vmp.service.IGbStreamService; -import com.genersoft.iot.vmp.service.IStreamPushService; +import com.genersoft.iot.vmp.streamPush.service.IStreamPushService; import com.genersoft.iot.vmp.utils.DateUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java index c8f4b2ae..c9bac16f 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java @@ -4,7 +4,7 @@ import com.alibaba.fastjson2.JSON; import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.service.IStreamPushService; +import com.genersoft.iot.vmp.streamPush.service.IStreamPushService; import com.genersoft.iot.vmp.service.bean.PushStreamStatusChangeFromRedisDto; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import org.slf4j.Logger; diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java index 383234b3..869d39bf 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java @@ -7,7 +7,6 @@ import com.genersoft.iot.vmp.media.bean.MediaInfo; import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent; import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPush; import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; 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 b7168c72..ab02a6d7 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java @@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.storager.dao; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxy; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPush; +import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.Param; diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java index 386ab3d5..0dad1174 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java @@ -5,7 +5,7 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxy; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPush; +import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java index 9fe7d112..5e05ca7c 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java @@ -12,7 +12,7 @@ import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent; import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPush; +import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index 3fb56479..12c72dcb 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -12,6 +12,7 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.dao.*; import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; +import com.genersoft.iot.vmp.streamPush.dao.StreamPushMapper; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPush.java b/src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPush.java similarity index 97% rename from src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPush.java rename to src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPush.java index eeb444dc..0a2da30b 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPush.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPush.java @@ -1,4 +1,4 @@ -package com.genersoft.iot.vmp.media.zlm.dto; +package com.genersoft.iot.vmp.streamPush.bean; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; @@ -110,6 +110,7 @@ public class StreamPush extends CommonGBChannel implements Comparable>> wvpResult = new WVPResult<>(); - if (errorStreams.size() == 0 && errorGBs.size() == 0) { + if (errorStreams.isEmpty() && errorGBs.isEmpty()) { wvpResult.setCode(0); wvpResult.setMsg("成功"); }else { diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java b/src/main/java/com/genersoft/iot/vmp/streamPush/dao/StreamPushMapper.java similarity index 99% rename from src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java rename to src/main/java/com/genersoft/iot/vmp/streamPush/dao/StreamPushMapper.java index 10372851..c88479c7 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/dao/StreamPushMapper.java @@ -1,7 +1,7 @@ -package com.genersoft.iot.vmp.storager.dao; +package com.genersoft.iot.vmp.streamPush.dao; import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPush; +import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java b/src/main/java/com/genersoft/iot/vmp/streamPush/enent/StreamPushUploadFileHandler.java similarity index 78% rename from src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java rename to src/main/java/com/genersoft/iot/vmp/streamPush/enent/StreamPushUploadFileHandler.java index 1d6e7730..ed597029 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/enent/StreamPushUploadFileHandler.java @@ -1,11 +1,11 @@ -package com.genersoft.iot.vmp.service.impl; +package com.genersoft.iot.vmp.streamPush.enent; import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPush; -import com.genersoft.iot.vmp.service.IStreamPushService; +import com.genersoft.iot.vmp.streamPush.bean.StreamPushExcelDto; +import com.genersoft.iot.vmp.streamPush.bean.StreamPushInfoForUpdateLoad; +import com.genersoft.iot.vmp.streamPush.service.IStreamPushService; import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import org.springframework.util.ObjectUtils; @@ -32,12 +32,12 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener streamPushItems = new ArrayList<>(); + private final List streamPushItems = new ArrayList<>(); /** * 用于存储更具APP+Stream过滤后的数据,可以直接存入stream_push表与gb_stream表 */ - private final Map streamPushItemForSave = new HashMap<>(); + private final Map streamPushItemForSave = new HashMap<>(); /** * 用于存储按照APP+Stream为KEY, 平台ID+目录Id 为value的数据,用于存储到gb_stream表后获取app+Stream对应的平台与目录信息,然后存入关联表 @@ -81,7 +81,7 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener allAppAndStreams = pushService.getAllAppAndStream(); - if (allAppAndStreams.size() > 0) { + if (!allAppAndStreams.isEmpty()) { for (String allAppAndStream : allAppAndStreams) { pushMapInDb.put(allAppAndStream, allAppAndStream); } @@ -126,31 +126,23 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener platformList = streamPushItemsForPlatform.get(streamPushItem.getApp() + streamPushItem.getStream()); - if (platformList == null) { - platformList = new ArrayList<>(); - streamPushItemsForPlatform.put(streamPushItem.getApp() + streamPushItem.getStream(), platformList); - } + List platformList = streamPushItemsForPlatform.computeIfAbsent(streamPushInfoForUpdateLoad.getApp() + streamPushInfoForUpdateLoad.getStream(), k -> new ArrayList<>()); String platformId = streamPushExcelDto.getPlatformId(); String catalogId = streamPushExcelDto.getCatalogId(); if (ObjectUtils.isEmpty(streamPushExcelDto.getCatalogId())) { @@ -184,7 +176,7 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener 0) { + if (!streamPushItemForSave.isEmpty()) { // 向数据库查询是否存在重复的app pushService.batchAddForUpload(new ArrayList<>(streamPushItemForSave.values()), streamPushItemsForPlatform); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java b/src/main/java/com/genersoft/iot/vmp/streamPush/service/IStreamPushService.java similarity index 83% rename from src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java rename to src/main/java/com/genersoft/iot/vmp/streamPush/service/IStreamPushService.java index 6520f605..196643fd 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/service/IStreamPushService.java @@ -1,11 +1,13 @@ -package com.genersoft.iot.vmp.service; +package com.genersoft.iot.vmp.streamPush.service; import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPush; import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; +import com.genersoft.iot.vmp.streamPush.bean.StreamPush; +import com.genersoft.iot.vmp.streamPush.bean.StreamPushInfoForUpdateLoad; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; import com.github.pagehelper.PageInfo; +import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.Map; @@ -72,6 +74,9 @@ public interface IStreamPushService { */ void batchAdd(List streamPushExcelDtoList); + @Transactional + void batchAddForUpload(List streamPushItems, Map> streamPushItemsForAll); + /** * 中止多个推流 */ @@ -80,7 +85,7 @@ public interface IStreamPushService { /** * 导入时批量增加 */ - void batchAddForUpload(List streamPushItems, Map> streamPushItemsForAll); + void batchAddForUpload(List streamPushItems, Map> streamPushItemsForAll); /** * 全部离线 diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java similarity index 95% rename from src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java rename to src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java index 31dfe4cc..ce714241 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java @@ -1,4 +1,4 @@ -package com.genersoft.iot.vmp.service.impl; +package com.genersoft.iot.vmp.streamPush.service.impl; import com.alibaba.fastjson2.JSONObject; import com.baomidou.dynamic.datasource.annotation.DS; @@ -20,20 +20,23 @@ import com.genersoft.iot.vmp.media.event.mediaServer.MediaServerOfflineEvent; import com.genersoft.iot.vmp.media.event.mediaServer.MediaServerOnlineEvent; import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPush; import com.genersoft.iot.vmp.media.zlm.dto.hook.OriginType; -import com.genersoft.iot.vmp.service.IStreamPushService; import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.dao.*; +import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; +import com.genersoft.iot.vmp.storager.dao.PlatformCatalogMapper; +import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; +import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper; +import com.genersoft.iot.vmp.streamPush.bean.StreamPush; +import com.genersoft.iot.vmp.streamPush.bean.StreamPushInfoForUpdateLoad; +import com.genersoft.iot.vmp.streamPush.dao.StreamPushMapper; +import com.genersoft.iot.vmp.streamPush.service.IStreamPushService; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; import com.genersoft.iot.vmp.vmanager.bean.StreamContent; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.jdbc.datasource.DataSourceTransactionManager; @@ -44,7 +47,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; import java.util.*; -import java.util.stream.Collectors; @Service @Slf4j @@ -95,6 +97,7 @@ public class StreamPushServiceImpl implements IStreamPushService { */ @Async("taskExecutor") @EventListener + @Transactional public void onApplicationEvent(MediaArrivalEvent event) { MediaInfo mediaInfo = event.getMediaInfo(); if (mediaInfo == null) { @@ -148,6 +151,7 @@ public class StreamPushServiceImpl implements IStreamPushService { */ @Async("taskExecutor") @EventListener + @Transactional public void onApplicationEvent(MediaDepartureEvent event) { // 兼容流注销时类型从redis记录获取 @@ -190,6 +194,7 @@ public class StreamPushServiceImpl implements IStreamPushService { */ @Async("taskExecutor") @EventListener + @Transactional public void onApplicationEvent(MediaServerOnlineEvent event) { zlmServerOnline(event.getMediaServerId()); } @@ -199,6 +204,7 @@ public class StreamPushServiceImpl implements IStreamPushService { */ @Async("taskExecutor") @EventListener + @Transactional public void onApplicationEvent(MediaServerOfflineEvent event) { zlmServerOffline(event.getMediaServerId()); } @@ -469,26 +475,28 @@ public class StreamPushServiceImpl implements IStreamPushService { @Override - public void batchAddForUpload(List streamPushItems, Map> streamPushItemsForAll ) { + @Transactional + public void batchAddForUpload(List streamPushItems, Map> streamPushItemsForAll ) { // 存储数据到stream_push表 streamPushMapper.addAll(streamPushItems); - List streamPushItemForGbStream = streamPushItems.stream() - .filter(streamPushItem-> streamPushItem.getGbId() != null) - .collect(Collectors.toList()); - // 存储数据到gb_stream表, id会返回到streamPushItemForGbStream里 - if (streamPushItemForGbStream.size() > 0) { - gbStreamMapper.batchAdd(streamPushItemForGbStream); - } - // 去除没有ID也就是没有存储到数据库的数据 - List streamPushItemsForPlatform = streamPushItemForGbStream.stream() - .filter(streamPushItem-> streamPushItem.getGbStreamId() != null) - .collect(Collectors.toList()); - if (streamPushItemsForPlatform.size() > 0) { + List channelList = new ArrayList<>(); + for (StreamPush streamPushItem : streamPushItems) { + if (streamPushItem.getGbDeviceId() != null && streamPushItem.getId() > 0) { + channelList.add(streamPushItem.getCommonGBChannel()); + } + } + // 存储数据到gb_stream表, id会返回到streamPushItemForGbStream里 + if (!channelList.isEmpty()) { + gbChannelService.batchAdd(channelList); + } + + + if (!streamPushItemsForPlatform.isEmpty()) { // 获取所有平台,平台和目录信息一般不会特别大量。 List parentPlatformList = parentPlatformMapper.getParentPlatformList(); Map> platformInfoMap = new HashMap<>(); - if (parentPlatformList.size() == 0) { + if (parentPlatformList.isEmpty()) { return; } for (ParentPlatform platform : parentPlatformList) { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/bean/StreamPushExcelDto.java b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/StreamPushExcelDto.java deleted file mode 100755 index dcec6076..00000000 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/bean/StreamPushExcelDto.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - -import com.alibaba.excel.annotation.ExcelProperty; - -public class StreamPushExcelDto { - - @ExcelProperty("名称") - private String name; - - @ExcelProperty("应用名") - private String app; - - @ExcelProperty("流ID") - private String stream; - - @ExcelProperty("国标ID") - private String gbId; - - @ExcelProperty("平台ID") - private String platformId; - - @ExcelProperty("目录ID") - private String catalogId; - - @ExcelProperty("在线状态") - private boolean status; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getGbId() { - return gbId; - } - - public void setGbId(String gbId) { - this.gbId = gbId; - } - - - public String getPlatformId() { - return platformId; - } - - public void setPlatformId(String platformId) { - this.platformId = platformId; - } - - public String getCatalogId() { - return catalogId; - } - - public void setCatalogId(String catalogId) { - this.catalogId = catalogId; - } - - public boolean isStatus() { - return status; - } - - public boolean getStatus() { - return status; - } - - public void setStatus(boolean status) { - this.status = status; - } -} diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java index e65a5795..cdb4975d 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java @@ -5,7 +5,7 @@ import com.genersoft.iot.vmp.conf.security.JwtUtils; import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.service.IGbStreamService; import com.genersoft.iot.vmp.service.IPlatformService; -import com.genersoft.iot.vmp.service.IStreamPushService; +import com.genersoft.iot.vmp.streamPush.service.IStreamPushService; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.gb28181.gbStream.bean.GbStreamParam; import com.github.pagehelper.PageInfo; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java index a7d60416..e46b2fd6 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java @@ -14,6 +14,7 @@ import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.service.*; import com.genersoft.iot.vmp.service.bean.MediaServerLoad; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; +import com.genersoft.iot.vmp.streamPush.service.IStreamPushService; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; import com.genersoft.iot.vmp.vmanager.bean.ResourceInfo;