From 5743917439f3989a4aa6748d8498b129e0521643 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期三, 03 四月 2024 15:03:49 +0800
Subject: [PATCH] 添加idea logo
---
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java | 82 ++++++++++++++++++++++++++++++-----------
1 files changed, 60 insertions(+), 22 deletions(-)
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 a316a5c..509240f 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
@@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.storager.impl;
+import com.baomidou.dynamic.datasource.annotation.DS;
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.*;
@@ -38,6 +39,7 @@
*/
@SuppressWarnings("rawtypes")
@Component
+@DS("master")
public class VideoManagerStorageImpl implements IVideoManagerStorage {
private final Logger logger = LoggerFactory.getLogger(VideoManagerStorageImpl.class);
@@ -74,6 +76,9 @@
private PlatformChannelMapper platformChannelMapper;
@Autowired
+ private PlatformCatalogMapper platformCatalogMapper;
+
+ @Autowired
private StreamProxyMapper streamProxyMapper;
@Autowired
@@ -90,12 +95,6 @@
@Autowired
private PlatformGbStreamMapper platformGbStreamMapper;
-
- @Autowired
- private IGbStreamService gbStreamService;
-
- @Autowired
- private ParentPlatformMapper parentPlatformMapper;
/**
* 鏍规嵁璁惧ID鍒ゆ柇璁惧鏄惁瀛樺湪
@@ -126,6 +125,7 @@
List<DeviceChannel> updateChannels = new ArrayList<>();
List<DeviceChannel> addChannels = new ArrayList<>();
+ List<DeviceChannel> deleteChannels = new ArrayList<>();
StringBuilder stringBuilder = new StringBuilder();
Map<String, Integer> subContMap = new HashMap<>();
@@ -156,6 +156,7 @@
deviceChannel.setUpdateTime(DateUtil.getNow());
addChannels.add(deviceChannel);
}
+ allChannelMap.remove(deviceChannel.getChannelId());
channels.add(deviceChannel);
if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) {
if (subContMap.get(deviceChannel.getParentId()) == null) {
@@ -166,7 +167,8 @@
}
}
}
- if (channels.size() > 0) {
+ deleteChannels.addAll(allChannelMap.values());
+ if (!channels.isEmpty()) {
for (DeviceChannel channel : channels) {
if (subContMap.get(channel.getChannelId()) != null){
Integer count = subContMap.get(channel.getChannelId());
@@ -187,20 +189,8 @@
}
try {
int limitCount = 50;
- int cleanChannelsResult = 0;
- if (channels.size() > limitCount) {
- for (int i = 0; i < channels.size(); i += limitCount) {
- int toIndex = i + limitCount;
- if (i + limitCount > channels.size()) {
- toIndex = channels.size();
- }
- cleanChannelsResult += this.deviceChannelMapper.cleanChannelsNotInList(deviceId, channels.subList(i, toIndex));
- }
- } else {
- cleanChannelsResult = this.deviceChannelMapper.cleanChannelsNotInList(deviceId, channels);
- }
- boolean result = cleanChannelsResult < 0;
- if (!result && addChannels.size() > 0) {
+ boolean result = false;
+ if (!result && !addChannels.isEmpty()) {
if (addChannels.size() > limitCount) {
for (int i = 0; i < addChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
@@ -213,7 +203,7 @@
result = result || deviceChannelMapper.batchAdd(addChannels) < 0;
}
}
- if (!result && updateChannels.size() > 0) {
+ if (!result && !updateChannels.isEmpty()) {
if (updateChannels.size() > limitCount) {
for (int i = 0; i < updateChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
@@ -224,6 +214,20 @@
}
}else {
result = result || deviceChannelMapper.batchUpdate(updateChannels) < 0;
+ }
+ }
+ if (!result && !deleteChannels.isEmpty()) {
+ System.out.println("鍒犻櫎锛� " + deleteChannels.size());
+ if (deleteChannels.size() > limitCount) {
+ for (int i = 0; i < deleteChannels.size(); i += limitCount) {
+ int toIndex = i + limitCount;
+ if (i + limitCount > deleteChannels.size()) {
+ toIndex = deleteChannels.size();
+ }
+ result = result || deviceChannelMapper.batchDel(deleteChannels.subList(i, toIndex)) < 0;
+ }
+ }else {
+ result = result || deviceChannelMapper.batchDel(deleteChannels) < 0;
}
}
@@ -910,9 +914,43 @@
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
}
int delChannelresult = platformChannelMapper.delByCatalogId(platformId, id);
+ // 鏌ョ湅鏄惁瀛樺湪瀛愮洰褰曪紝濡傛灉瀛樺湪涓�骞跺垹闄�
+ List<String> allChildCatalog = getAllChildCatalog(id, platformId);
+ if (!allChildCatalog.isEmpty()) {
+ int limitCount = 50;
+ if (allChildCatalog.size() > limitCount) {
+ for (int i = 0; i < allChildCatalog.size(); i += limitCount) {
+ int toIndex = i + limitCount;
+ if (i + limitCount > allChildCatalog.size()) {
+ toIndex = allChildCatalog.size();
+ }
+ delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog.subList(i, toIndex));
+ }
+ }else {
+ delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog);
+ }
+ }
return delresult + delChannelresult + delStreamresult;
}
+ private List<String> getAllChildCatalog(String id, String platformId) {
+ List<String> catalogList = platformCatalogMapper.queryCatalogFromParent(id, platformId);
+ List<String> catalogListChild = new ArrayList<>();
+ if (catalogList != null && !catalogList.isEmpty()) {
+ for (String childId : catalogList) {
+ List<String> allChildCatalog = getAllChildCatalog(childId, platformId);
+ if (allChildCatalog != null && !allChildCatalog.isEmpty()) {
+ catalogListChild.addAll(allChildCatalog);
+ }
+
+ }
+ }
+ if (!catalogListChild.isEmpty()) {
+ catalogList.addAll(catalogListChild);
+ }
+ return catalogList;
+ }
+
@Override
public int updateCatalog(PlatformCatalog platformCatalog) {
--
Gitblit v1.8.0