From 7d6aaf3bb0a4bdcc319eaec1840c78ab32cfa81e Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: Thu, 12 Oct 2023 16:36:07 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=BD=E6=A0=87?=
=?UTF-8?q?=E6=8E=A5=E8=BF=9E=E9=80=89=E6=8B=A9=E9=80=9A=E9=81=93=E7=9B=B8?=
=?UTF-8?q?=E5=85=B3=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../impl/PlatformChannelServiceImpl.java | 2 +-
.../storager/dao/PlatformCatalogMapper.java | 16 +++++++-
.../storager/dao/PlatformChannelMapper.java | 3 +-
.../impl/VideoManagerStorageImpl.java | 37 +++++++++++++++++++
4 files changed, 54 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java
index 7ede0921..9f2b5e05 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java
@@ -162,7 +162,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
return 0;
}
if (ObjectUtils.isEmpty(catalogId)) {
- catalogId = platform.getDeviceGBId();
+ catalogId = null;
}
if ((result = platformChannelMapper.delChannelForGBByCatalogId(platformId, catalogId)) > 0) {
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java
index edd34e5d..62d61019 100755
--- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java
@@ -31,8 +31,8 @@ public interface PlatformCatalogMapper {
@Update(value = {" "})
int update(@Param("platformCatalog") PlatformCatalog platformCatalog);
@@ -51,4 +51,16 @@ public interface PlatformCatalogMapper {
" from wvp_platform_catalog pc " +
" WHERE pc.id=#{id} and pc.platform_id=#{platformId}")
PlatformCatalog selectByPlatFormAndCatalogId(@Param("platformId") String platformId, @Param("id") String id);
+
+
+ @Delete("")
+ int deleteAll(String platformId, List ids);
+
+ @Select("SELECT id from wvp_platform_catalog WHERE platform_id=#{platformId} and parent_id = #{id}")
+ List queryCatalogFromParent(@Param("id") String id, @Param("platformId") String platformId);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
index 38263506..f363f66f 100755
--- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
@@ -105,7 +105,8 @@ public interface PlatformChannelMapper {
void delByPlatformId(String serverGBId);
@Delete("")
int delChannelForGBByCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
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 a316a5cb..e96e09b2 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
@@ -73,6 +73,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
@Autowired
private PlatformChannelMapper platformChannelMapper;
+ @Autowired
+ private PlatformCatalogMapper platformCatalogMapper;
+
@Autowired
private StreamProxyMapper streamProxyMapper;
@@ -910,9 +913,43 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
}
int delChannelresult = platformChannelMapper.delByCatalogId(platformId, id);
+ // 查看是否存在子目录,如果存在一并删除
+ List 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 getAllChildCatalog(String id, String platformId) {
+ List catalogList = platformCatalogMapper.queryCatalogFromParent(id, platformId);
+ List catalogListChild = new ArrayList<>();
+ if (catalogList != null && !catalogList.isEmpty()) {
+ for (String childId : catalogList) {
+ List 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) {
From 78f628dd6fca9be675376a20a753b6f4556e9844 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: Thu, 12 Oct 2023 17:01:25 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8C=E6=AD=A5?=
=?UTF-8?q?=E7=9B=AE=E5=BD=95=E6=97=B6=E6=89=B9=E9=87=8F=E6=8F=90=E4=BA=A4?=
=?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../storager/impl/VideoManagerStorageImpl.java | 16 ++--------------
1 file changed, 2 insertions(+), 14 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 e96e09b2..d4062255 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
@@ -169,7 +169,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
}
}
}
- if (channels.size() > 0) {
+ if (!channels.isEmpty()) {
for (DeviceChannel channel : channels) {
if (subContMap.get(channel.getChannelId()) != null){
Integer count = subContMap.get(channel.getChannelId());
@@ -190,19 +190,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
}
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;
+ boolean result = false;
if (!result && addChannels.size() > 0) {
if (addChannels.size() > limitCount) {
for (int i = 0; i < addChannels.size(); i += limitCount) {