648540858
2022-04-20 7145ce07e6a84854fc1e5afd65b664c54a47bffd
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
@@ -238,12 +238,15 @@
   @Override
   public boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList) {
      if (deviceChannelList == null) {
         return false;
      }
      TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
      // 数据去重
      List<DeviceChannel> channels = new ArrayList<>();
      StringBuilder stringBuilder = new StringBuilder();
      Map<String, Integer> subContMap = new HashMap<>();
      if (deviceChannelList.size() > 1) {
      if (deviceChannelList != null && deviceChannelList.size() > 1) {
         // 数据去重
         Set<String> gbIdSet = new HashSet<>();
         for (DeviceChannel deviceChannel : deviceChannelList) {
@@ -274,7 +277,7 @@
         channels = deviceChannelList;
      }
      if (stringBuilder.length() > 0) {
         logger.debug("[目录查询]收到的数据存在重复: {}" , stringBuilder);
         logger.info("[目录查询]收到的数据存在重复: {}" , stringBuilder);
      }
      try {
         int cleanChannelsResult = deviceChannelMapper.cleanChannelsNotInList(deviceId, channels);
@@ -300,6 +303,7 @@
         dataSourceTransactionManager.commit(transactionStatus);     //手动提交
         return true;
      }catch (Exception e) {
         e.printStackTrace();
         dataSourceTransactionManager.rollback(transactionStatus);
         return false;
      }
@@ -415,10 +419,9 @@
      TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
      boolean result = false;
      try {
         if (platformChannelMapper.delChannelForDeviceId(deviceId) <0  // 删除与国标平台的关联
               || deviceChannelMapper.cleanChannelsByDeviceId(deviceId) < 0 // 删除他的通道
               || deviceMapper.del(deviceId) < 0 // 移除设备信息
         ) {
         platformChannelMapper.delChannelForDeviceId(deviceId);
         deviceChannelMapper.cleanChannelsByDeviceId(deviceId);
         if ( deviceMapper.del(deviceId) < 0 ) {
            //事务回滚
            dataSourceTransactionManager.rollback(transactionStatus);
         }
@@ -445,8 +448,6 @@
      device.setOnline(1);
      logger.info("更新设备在线: " + deviceId);
      redisCatchStorage.updateDevice(device);
      List<DeviceChannel> deviceChannelList = deviceChannelMapper.queryOnlineChannelsByDeviceId(deviceId);
      eventPublisher.catalogEventPublish(null, deviceChannelList, CatalogEvent.ON);
      return deviceMapper.update(device) > 0;
   }
@@ -519,6 +520,12 @@
   @Override
   public boolean updateParentPlatform(ParentPlatform parentPlatform) {
      int result = 0;
      if (parentPlatform.getCatalogGroup() == 0) {
         parentPlatform.setCatalogGroup(1);
      }
      if (parentPlatform.getAdministrativeDivision() == null) {
         parentPlatform.setAdministrativeDivision(parentPlatform.getAdministrativeDivision());
      }
      ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); // .getDeviceGBId());
      if (parentPlatform.getId() == null ) {
         if (parentPlatform.getCatalogId() == null) {
@@ -538,6 +545,7 @@
            parentPlatformCatch.setId(parentPlatform.getServerGBId());
            redisCatchStorage.delPlatformCatchInfo(parentPlatById.getServerGBId());
         }
         result = platformMapper.updateParentPlatform(parentPlatform);
      }
      // 更新缓存
@@ -911,8 +919,8 @@
   }
   @Override
   public List<StreamProxyItem> getStreamProxyListForEnableInMediaServer(String id, boolean enable, boolean status) {
      return streamProxyMapper.selectForEnableInMediaServer(id, enable, status);
   public List<StreamProxyItem> getStreamProxyListForEnableInMediaServer(String id, boolean enable) {
      return streamProxyMapper.selectForEnableInMediaServer(id, enable);
   }
@@ -1073,7 +1081,7 @@
      deviceChannel.setParentId(catalog.getParentId());
      deviceChannel.setRegisterWay(1);
      // 行政区划应该是Domain的前八位
      deviceChannel.setCivilCode(parentPlatByServerGBId.getDeviceGBId().substring(0,6));
      deviceChannel.setCivilCode(parentPlatByServerGBId.getAdministrativeDivision());
      deviceChannel.setModel("live");
      deviceChannel.setOwner("wvp-pro");
      deviceChannel.setSecrecy("0");