From 124d83fc0c0db5b319b2ae2bdc623890556b932f Mon Sep 17 00:00:00 2001
From: xu-bin-bin <34916924+xu-bin-bin@users.noreply.github.com>
Date: 星期五, 13 十月 2023 08:55:27 +0800
Subject: [PATCH] Merge branch '648540858:wvp-28181-2.0' into wvp-28181-2.0
---
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java | 53 +++++++++++++++++++-------
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java | 3 +
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java | 2
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java | 16 +++++++-
4 files changed, 56 insertions(+), 18 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 7ede092..9f2b5e0 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 @@
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 edd34e5..62d6101 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 @@
@Update(value = {" <script>" +
"UPDATE wvp_platform_catalog " +
- "SET name=#{name}" +
- "WHERE id=#{id} and platform_id=#{platformId}"+
+ "SET name=#{platformCatalog.name}" +
+ "WHERE id=#{platformCatalog.id} and platform_id=#{platformCatalog.platformId}"+
"</script>"})
int update(@Param("platformCatalog") PlatformCatalog platformCatalog);
@@ -51,4 +51,16 @@
" 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("<script> "+
+ "DELETE from wvp_platform_catalog where platform_id=#{platformId} and id in " +
+ "<foreach collection='ids' item='item' open='(' separator=',' close=')'>" +
+ "#{item} " +
+ "</foreach>" +
+ "</script>")
+ int deleteAll(String platformId, List<String> ids);
+
+ @Select("SELECT id from wvp_platform_catalog WHERE platform_id=#{platformId} and parent_id = #{id}")
+ List<String> 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 3826350..f363f66 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 @@
void delByPlatformId(String serverGBId);
@Delete("<script> " +
- "DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} and catalog_id=#{catalogId}" +
+ "DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} " +
+ " <if test=\"catalogId != null\" > and catalog_id=#{catalogId}</if>" +
"</script>")
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 a316a5c..d406225 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
@@ -74,6 +74,9 @@
private PlatformChannelMapper platformChannelMapper;
@Autowired
+ private PlatformCatalogMapper platformCatalogMapper;
+
+ @Autowired
private StreamProxyMapper streamProxyMapper;
@Autowired
@@ -166,7 +169,7 @@
}
}
}
- if (channels.size() > 0) {
+ if (!channels.isEmpty()) {
for (DeviceChannel channel : channels) {
if (subContMap.get(channel.getChannelId()) != null){
Integer count = subContMap.get(channel.getChannelId());
@@ -187,19 +190,7 @@
}
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) {
@@ -910,9 +901,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