panlinlin
2021-01-08 7e581e9d3a0e32be5e90e453f4283d70d895a634
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
@@ -4,6 +4,8 @@
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper;
@@ -31,6 +33,11 @@
   @Autowired
    private ParentPlatformMapper platformMapper;
   @Autowired
    private IRedisCatchStorage redisCatchStorage;
   /**
@@ -86,6 +93,16 @@
      }
   }
   @Override
   public void startPlay(String deviceId, String channelId, String streamId) {
      deviceChannelMapper.startPlay(deviceId, channelId, streamId);
   }
   @Override
   public void stopPlay(String deviceId, String channelId) {
      deviceChannelMapper.stopPlay(deviceId, channelId);
   }
   /**
    * 获取设备
    *
@@ -104,8 +121,6 @@
      List<DeviceChannel> all = deviceChannelMapper.queryChannelsByDeviceId(deviceId, null, query, hasSubChannel, online);
      return new PageInfo<>(all);
   }
   @Override
   public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) {
@@ -210,11 +225,21 @@
   @Override
   public boolean updateParentPlatform(ParentPlatform parentPlatform) {
      int result = 0;
      ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getDeviceGBId());
      if ( platformMapper.getParentPlatById(parentPlatform.getDeviceGBId()) == null) {
         result = platformMapper.addParentPlatform(parentPlatform);
         if (parentPlatformCatch == null) {
            parentPlatformCatch = new ParentPlatformCatch();
            parentPlatformCatch.setParentPlatform(parentPlatform);
            parentPlatformCatch.setId(parentPlatform.getDeviceGBId());
         }
      }else {
         result = platformMapper.updateParentPlatform(parentPlatform);
      }
      // 更新缓存
      parentPlatformCatch.setParentPlatform(parentPlatform);
      redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
      return result > 0;
   }
@@ -236,5 +261,13 @@
      return platformMapper.getParentPlatById(platformGbId);
   }
   @Override
   public List<ParentPlatform> queryEnableParentPlatformList(boolean enable) {
      return platformMapper.getEnableParentPlatformList(enable);
   }
   @Override
   public void outlineForAllParentPlatform() {
      platformMapper.outlineForAllParentPlatform();
   }
}