Commit 124d83fc0c0db5b319b2ae2bdc623890556b932f

Authored by xu-bin-bin
Committed by GitHub
2 parents 4084080a 78f628dd

Merge branch '648540858:wvp-28181-2.0' into wvp-28181-2.0

src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java
@@ -162,7 +162,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { @@ -162,7 +162,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
162 return 0; 162 return 0;
163 } 163 }
164 if (ObjectUtils.isEmpty(catalogId)) { 164 if (ObjectUtils.isEmpty(catalogId)) {
165 - catalogId = platform.getDeviceGBId(); 165 + catalogId = null;
166 } 166 }
167 167
168 if ((result = platformChannelMapper.delChannelForGBByCatalogId(platformId, catalogId)) > 0) { 168 if ((result = platformChannelMapper.delChannelForGBByCatalogId(platformId, catalogId)) > 0) {
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java
@@ -31,8 +31,8 @@ public interface PlatformCatalogMapper { @@ -31,8 +31,8 @@ public interface PlatformCatalogMapper {
31 31
32 @Update(value = {" <script>" + 32 @Update(value = {" <script>" +
33 "UPDATE wvp_platform_catalog " + 33 "UPDATE wvp_platform_catalog " +
34 - "SET name=#{name}" +  
35 - "WHERE id=#{id} and platform_id=#{platformId}"+ 34 + "SET name=#{platformCatalog.name}" +
  35 + "WHERE id=#{platformCatalog.id} and platform_id=#{platformCatalog.platformId}"+
36 "</script>"}) 36 "</script>"})
37 int update(@Param("platformCatalog") PlatformCatalog platformCatalog); 37 int update(@Param("platformCatalog") PlatformCatalog platformCatalog);
38 38
@@ -51,4 +51,16 @@ public interface PlatformCatalogMapper { @@ -51,4 +51,16 @@ public interface PlatformCatalogMapper {
51 " from wvp_platform_catalog pc " + 51 " from wvp_platform_catalog pc " +
52 " WHERE pc.id=#{id} and pc.platform_id=#{platformId}") 52 " WHERE pc.id=#{id} and pc.platform_id=#{platformId}")
53 PlatformCatalog selectByPlatFormAndCatalogId(@Param("platformId") String platformId, @Param("id") String id); 53 PlatformCatalog selectByPlatFormAndCatalogId(@Param("platformId") String platformId, @Param("id") String id);
  54 +
  55 +
  56 + @Delete("<script> "+
  57 + "DELETE from wvp_platform_catalog where platform_id=#{platformId} and id in " +
  58 + "<foreach collection='ids' item='item' open='(' separator=',' close=')'>" +
  59 + "#{item} " +
  60 + "</foreach>" +
  61 + "</script>")
  62 + int deleteAll(String platformId, List<String> ids);
  63 +
  64 + @Select("SELECT id from wvp_platform_catalog WHERE platform_id=#{platformId} and parent_id = #{id}")
  65 + List<String> queryCatalogFromParent(@Param("id") String id, @Param("platformId") String platformId);
54 } 66 }
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
@@ -105,7 +105,8 @@ public interface PlatformChannelMapper { @@ -105,7 +105,8 @@ public interface PlatformChannelMapper {
105 void delByPlatformId(String serverGBId); 105 void delByPlatformId(String serverGBId);
106 106
107 @Delete("<script> " + 107 @Delete("<script> " +
108 - "DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} and catalog_id=#{catalogId}" + 108 + "DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} " +
  109 + " <if test=\"catalogId != null\" > and catalog_id=#{catalogId}</if>" +
109 "</script>") 110 "</script>")
110 int delChannelForGBByCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId); 111 int delChannelForGBByCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
111 112
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
@@ -74,6 +74,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -74,6 +74,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
74 private PlatformChannelMapper platformChannelMapper; 74 private PlatformChannelMapper platformChannelMapper;
75 75
76 @Autowired 76 @Autowired
  77 + private PlatformCatalogMapper platformCatalogMapper;
  78 +
  79 + @Autowired
77 private StreamProxyMapper streamProxyMapper; 80 private StreamProxyMapper streamProxyMapper;
78 81
79 @Autowired 82 @Autowired
@@ -166,7 +169,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -166,7 +169,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
166 } 169 }
167 } 170 }
168 } 171 }
169 - if (channels.size() > 0) { 172 + if (!channels.isEmpty()) {
170 for (DeviceChannel channel : channels) { 173 for (DeviceChannel channel : channels) {
171 if (subContMap.get(channel.getChannelId()) != null){ 174 if (subContMap.get(channel.getChannelId()) != null){
172 Integer count = subContMap.get(channel.getChannelId()); 175 Integer count = subContMap.get(channel.getChannelId());
@@ -187,19 +190,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -187,19 +190,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
187 } 190 }
188 try { 191 try {
189 int limitCount = 50; 192 int limitCount = 50;
190 - int cleanChannelsResult = 0;  
191 - if (channels.size() > limitCount) {  
192 - for (int i = 0; i < channels.size(); i += limitCount) {  
193 - int toIndex = i + limitCount;  
194 - if (i + limitCount > channels.size()) {  
195 - toIndex = channels.size();  
196 - }  
197 - cleanChannelsResult += this.deviceChannelMapper.cleanChannelsNotInList(deviceId, channels.subList(i, toIndex));  
198 - }  
199 - } else {  
200 - cleanChannelsResult = this.deviceChannelMapper.cleanChannelsNotInList(deviceId, channels);  
201 - }  
202 - boolean result = cleanChannelsResult < 0; 193 + boolean result = false;
203 if (!result && addChannels.size() > 0) { 194 if (!result && addChannels.size() > 0) {
204 if (addChannels.size() > limitCount) { 195 if (addChannels.size() > limitCount) {
205 for (int i = 0; i < addChannels.size(); i += limitCount) { 196 for (int i = 0; i < addChannels.size(); i += limitCount) {
@@ -910,9 +901,43 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -910,9 +901,43 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
910 eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); 901 eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
911 } 902 }
912 int delChannelresult = platformChannelMapper.delByCatalogId(platformId, id); 903 int delChannelresult = platformChannelMapper.delByCatalogId(platformId, id);
  904 + // 查看是否存在子目录,如果存在一并删除
  905 + List<String> allChildCatalog = getAllChildCatalog(id, platformId);
  906 + if (!allChildCatalog.isEmpty()) {
  907 + int limitCount = 50;
  908 + if (allChildCatalog.size() > limitCount) {
  909 + for (int i = 0; i < allChildCatalog.size(); i += limitCount) {
  910 + int toIndex = i + limitCount;
  911 + if (i + limitCount > allChildCatalog.size()) {
  912 + toIndex = allChildCatalog.size();
  913 + }
  914 + delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog.subList(i, toIndex));
  915 + }
  916 + }else {
  917 + delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog);
  918 + }
  919 + }
913 return delresult + delChannelresult + delStreamresult; 920 return delresult + delChannelresult + delStreamresult;
914 } 921 }
915 922
  923 + private List<String> getAllChildCatalog(String id, String platformId) {
  924 + List<String> catalogList = platformCatalogMapper.queryCatalogFromParent(id, platformId);
  925 + List<String> catalogListChild = new ArrayList<>();
  926 + if (catalogList != null && !catalogList.isEmpty()) {
  927 + for (String childId : catalogList) {
  928 + List<String> allChildCatalog = getAllChildCatalog(childId, platformId);
  929 + if (allChildCatalog != null && !allChildCatalog.isEmpty()) {
  930 + catalogListChild.addAll(allChildCatalog);
  931 + }
  932 +
  933 + }
  934 + }
  935 + if (!catalogListChild.isEmpty()) {
  936 + catalogList.addAll(catalogListChild);
  937 + }
  938 + return catalogList;
  939 + }
  940 +
916 941
917 @Override 942 @Override
918 public int updateCatalog(PlatformCatalog platformCatalog) { 943 public int updateCatalog(PlatformCatalog platformCatalog) {