From 06e22d980ee085f8cade1044bbb777e23040fe1c Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: Sun, 16 Jan 2022 10:40:57 +0800
Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8E=A8=E6=B5=81=E9=80=9A?=
=?UTF-8?q?=E9=81=93=E9=A2=84=E5=AF=BC=E5=85=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 9 +-
.../event/online/OnlineEventListener.java | 2 +-
.../iot/vmp/service/IStreamPushService.java | 3 +
.../service/impl/StreamPushServiceImpl.java | 34 ++++++++
.../impl/StreamPushUploadFileHandler.java | 50 +++++++++++
.../iot/vmp/storager/dao/GbStreamMapper.java | 4 +-
.../vmp/storager/dao/StreamPushMapper.java | 2 +-
.../vmp/vmanager/bean/StreamPushExcelDto.java | 50 +++++++++++
.../streamPush/StreamPushController.java | 38 ++++++++-
web_src/src/components/PushVideoList.vue | 18 +++-
.../src/components/dialog/importChannel.vue | 84 +++++++++++++++++++
11 files changed, 286 insertions(+), 8 deletions(-)
create mode 100644 src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java
create mode 100644 src/main/java/com/genersoft/iot/vmp/vmanager/bean/StreamPushExcelDto.java
create mode 100644 web_src/src/components/dialog/importChannel.vue
diff --git a/pom.xml b/pom.xml
index 2a67fb52..991abc68 100644
--- a/pom.xml
+++ b/pom.xml
@@ -161,7 +161,7 @@
2.1.3
-
+
com.alibaba
fastjson
@@ -203,6 +203,13 @@
1.12
+
+
+ com.alibaba
+ easyexcel
+ 3.0.4
+
+
org.springframework.session
spring-session-core
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
index 12a50e1d..5f0d14d1 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
@@ -85,7 +85,7 @@ public class OnlineEventListener implements ApplicationListener {
device.setOnline(1);
Device deviceInstore = storager.queryVideoDevice(device.getDeviceId());
- if (deviceInstore.getOnline() == 0) {
+ if (deviceInstore != null && deviceInstore.getOnline() == 0) {
List deviceChannelList = storager.queryOnlineChannelsByDeviceId(device.getDeviceId());
eventPublisher.catalogEventPublish(null, deviceChannelList, CatalogEvent.ON);
}
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 06c8b732..8a09de7b 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java
@@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
+import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto;
import com.github.pagehelper.PageInfo;
import java.util.List;
@@ -65,4 +66,6 @@ public interface IStreamPushService {
void clean();
boolean saveToRandomGB();
+
+ void batchAdd(List streamPushExcelDtoList);
}
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 c8bf1915..ebfa124b 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
@@ -22,6 +22,7 @@ import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper;
import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
import com.genersoft.iot.vmp.storager.dao.StreamPushMapper;
+import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
@@ -321,4 +322,37 @@ public class StreamPushServiceImpl implements IStreamPushService {
}
return true;
}
+
+ @Override
+ public void batchAdd(List streamPushItems) {
+ streamPushMapper.addAll(streamPushItems);
+ gbStreamMapper.batchAdd(streamPushItems);
+ // 查找开启了全部直播流共享的上级平台
+ List parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream();
+ if (parentPlatforms.size() > 0) {
+ for (StreamPushItem stream : streamPushItems) {
+ for (ParentPlatform parentPlatform : parentPlatforms) {
+ stream.setCatalogId(parentPlatform.getCatalogId());
+ stream.setPlatformId(parentPlatform.getServerGBId());
+ String streamId = stream.getStream();
+ StreamProxyItem streamProxyItem = platformGbStreamMapper.selectOne(stream.getApp(), streamId, parentPlatform.getServerGBId());
+ if (streamProxyItem == null) {
+ platformGbStreamMapper.add(stream);
+ eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), stream, CatalogEvent.ADD);
+ }else {
+ if (!streamProxyItem.getGbId().equals(stream.getGbId())) {
+ // 此流使用另一个国标Id已经与该平台关联,移除此记录
+ platformGbStreamMapper.delByAppAndStreamAndPlatform(stream.getApp(), streamId, parentPlatform.getServerGBId());
+ platformGbStreamMapper.add(stream);
+ eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), stream, CatalogEvent.ADD);
+ stream.setGbId(streamProxyItem.getGbId());
+ eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), stream, CatalogEvent.DEL);
+ }
+ }
+ }
+ }
+
+
+ }
+ }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java
new file mode 100644
index 00000000..de7307cb
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java
@@ -0,0 +1,50 @@
+package com.genersoft.iot.vmp.service.impl;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
+import com.genersoft.iot.vmp.service.IStreamPushService;
+import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class StreamPushUploadFileHandler extends AnalysisEventListener {
+
+ private IStreamPushService pushService;
+ private String defaultMediaServerId;
+ private List streamPushItems = new ArrayList<>();
+
+ public StreamPushUploadFileHandler(IStreamPushService pushService, String defaultMediaServerId) {
+ this.pushService = pushService;
+ this.defaultMediaServerId = defaultMediaServerId;
+ }
+
+ @Override
+ public void invoke(StreamPushExcelDto streamPushExcelDto, AnalysisContext analysisContext) {
+ StreamPushItem streamPushItem = new StreamPushItem();
+ streamPushItem.setApp(streamPushExcelDto.getApp());
+ streamPushItem.setStream(streamPushExcelDto.getStream());
+ streamPushItem.setGbId(streamPushExcelDto.getGbId());
+ streamPushItem.setStatus(false);
+ streamPushItem.setStreamType("push");
+ streamPushItem.setCreateStamp(System.currentTimeMillis());
+ streamPushItem.setMediaServerId(defaultMediaServerId);
+ streamPushItem.setName(streamPushExcelDto.getName());
+ streamPushItem.setOriginType(2);
+ streamPushItem.setOriginTypeStr("rtsp_push");
+ streamPushItem.setTotalReaderCount("0");
+ streamPushItems.add(streamPushItem);
+ if (streamPushItems.size() > 300) {
+ pushService.batchAdd(streamPushItems);
+ // 存储完成清理 list
+ streamPushItems.clear();
+ }
+ }
+
+ @Override
+ public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+ // 这里也要保存数据,确保最后遗留的数据也存储到数据库
+ pushService.batchAdd(streamPushItems);
+ }
+}
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 82df3318..15bb0f5d 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
@@ -4,6 +4,7 @@ import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
+import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
@@ -82,7 +83,7 @@ public interface GbStreamMapper {
void batchDel(List streamProxyItemList);
@Insert("")
void batchAdd(List subList);
-
@Update({"
diff --git a/web_src/src/components/dialog/importChannel.vue b/web_src/src/components/dialog/importChannel.vue
new file mode 100644
index 00000000..6d83819d
--- /dev/null
+++ b/web_src/src/components/dialog/importChannel.vue
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+ 将文件拖到此处,或点击上传
+ 只能上传 csv / xls / xlsx 文件
+
+
+
+
+
+
+
+