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 文件
+
+
+
+
+
+
+
+