From 06e22d980ee085f8cade1044bbb777e23040fe1c Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期日, 16 一月 2022 10:40:57 +0800
Subject: [PATCH] 支持推流通道预导入

---
 src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

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 c8bf191..ebfa124 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.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 @@
         }
         return true;
     }
+
+    @Override
+    public void batchAdd(List<StreamPushItem> streamPushItems) {
+        streamPushMapper.addAll(streamPushItems);
+        gbStreamMapper.batchAdd(streamPushItems);
+        // 鏌ユ壘寮�鍚簡鍏ㄩ儴鐩存挱娴佸叡浜殑涓婄骇骞冲彴
+        List<ParentPlatform> 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())) {
+                            // 姝ゆ祦浣跨敤鍙︿竴涓浗鏍嘔d宸茬粡涓庤骞冲彴鍏宠仈锛岀Щ闄ゆ璁板綍
+                            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);
+                        }
+                    }
+                }
+            }
+
+
+        }
+    }
 }

--
Gitblit v1.8.0