panlinlin
2021-04-16 f1fae7aac6b125957f6795f692609f2a296aee1a
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
@@ -195,9 +195,22 @@
    */
   @Override
   public boolean delete(String deviceId) {
      int result = deviceMapper.del(deviceId);
      return result > 0;
      TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
      boolean result = false;
      try {
         if (platformChannelMapper.delChannelForDeviceId(deviceId) <0  // 删除与国标平台的关联
               || deviceChannelMapper.cleanChannelsByDeviceId(deviceId) < 0 // 删除他的通道
               || deviceMapper.del(deviceId) < 0 // 移除设备信息
         ) {
            //事务回滚
            dataSourceTransactionManager.rollback(transactionStatus);
         }
         result = true;
         dataSourceTransactionManager.commit(transactionStatus);     //手动提交
      }catch (Exception e) {
         dataSourceTransactionManager.rollback(transactionStatus);
      }
      return result;
   }
   /**
@@ -271,15 +284,21 @@
   public boolean updateParentPlatform(ParentPlatform parentPlatform) {
      int result = 0;
      ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); // .getDeviceGBId());
      if ( platformMapper.getParentPlatById(parentPlatform.getServerGBId()) == null) {
      if (parentPlatform.getId() == null ) {
         result = platformMapper.addParentPlatform(parentPlatform);
         if (parentPlatformCatch == null) {
            parentPlatformCatch = new ParentPlatformCatch();
            parentPlatformCatch.setParentPlatform(parentPlatform);
            parentPlatformCatch.setId(parentPlatform.getServerGBId());
         }
      }else {
         if (parentPlatformCatch == null) { // serverGBId 已变化
            ParentPlatform parentPlatById = platformMapper.getParentPlatById(parentPlatform.getId());
            // 使用旧的查出缓存ID
            parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatById.getServerGBId());
            parentPlatformCatch.setId(parentPlatform.getServerGBId());
            redisCatchStorage.delPlatformCatchInfo(parentPlatById.getServerGBId());
         }
         result = platformMapper.updateParentPlatform(parentPlatform);
      }
      // 更新缓存
@@ -305,8 +324,8 @@
   }
   @Override
   public ParentPlatform queryParentPlatById(String platformGbId) {
      return platformMapper.getParentPlatById(platformGbId);
   public ParentPlatform queryParentPlatByServerGBId(String platformGbId) {
      return platformMapper.getParentPlatByServerGBId(platformGbId);
   }
   @Override
@@ -544,4 +563,6 @@
   public void mediaOutline(String app, String streamId) {
      gbStreamMapper.setStatus(app, streamId, false);
   }
}