648540858
2023-10-12 298a9f4280458062ed0fc32084d5bcce8bbf196c
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) {