648540858
2021-11-17 c23932eb00edfa5f734b0d17eced838c5c7577c0
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
@@ -1,14 +1,12 @@
package com.genersoft.iot.vmp.storager.impl;
import java.text.SimpleDateFormat;
import java.util.*;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.storager.dao.*;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.github.pagehelper.PageHelper;
@@ -18,14 +16,18 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Component;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**    
 * @Description:视频设备数据存储-jdbc实现
 * @description:视频设备数据存储-jdbc实现
 * @author: swwheihei
 * @date:   2020年5月6日 下午2:31:42
 */
@@ -109,7 +111,7 @@
    */
   @Override
   public synchronized boolean updateDevice(Device device) {
      String now = this.format.format(new Date(System.currentTimeMillis()));
      String now = this.format.format(System.currentTimeMillis());
      device.setUpdateTime(now);
      Device deviceByDeviceId = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
      if (deviceByDeviceId == null) {
@@ -126,7 +128,7 @@
      String channelId = channel.getChannelId();
      channel.setDeviceId(deviceId);
      channel.setStreamId(streamSession.getStreamId(deviceId, channel.getChannelId()));
      String now = this.format.format(new Date(System.currentTimeMillis()));
      String now = this.format.format(System.currentTimeMillis());
      channel.setUpdateTime(now);
      DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(deviceId, channelId);
      if (deviceChannel == null) {
@@ -135,6 +137,16 @@
      }else {
         deviceChannelMapper.update(channel);
      }
   }
   @Override
   public void deviceChannelOnline(String deviceId, String channelId) {
      deviceChannelMapper.online(deviceId, channelId);
   }
   @Override
   public void deviceChannelOffline(String deviceId, String channelId) {
      deviceChannelMapper.offline(deviceId, channelId);
   }
   @Override
@@ -183,6 +195,11 @@
      return deviceChannelMapper.queryChannel(deviceId, channelId);
   }
   @Override
   public int delChannel(String deviceId, String channelId) {
      return deviceChannelMapper.del(deviceId, channelId);
   }
   /**
    * 获取多个设备
@@ -463,7 +480,7 @@
      boolean result = false;
      streamProxyItem.setStreamType("proxy");
      streamProxyItem.setStatus(true);
      String now = this.format.format(new Date(System.currentTimeMillis()));
      String now = this.format.format(System.currentTimeMillis());
      streamProxyItem.setCreateTime(now);
      try {
         if (gbStreamMapper.add(streamProxyItem)<0 || streamProxyMapper.add(streamProxyItem) < 0) {
@@ -609,7 +626,7 @@
   @Override
   public void updateMediaServer(MediaServerItem mediaServerItem) {
      String now = this.format.format(new Date(System.currentTimeMillis()));
      String now = this.format.format(System.currentTimeMillis());
      mediaServerItem.setUpdateTime(now);
      if (mediaServerMapper.queryOne(mediaServerItem.getId()) != null) {
         mediaServerMapper.update(mediaServerItem);
@@ -623,4 +640,15 @@
   public List<StreamProxyItem> getStreamProxyListForEnableInMediaServer(String id, boolean enable) {
      return streamProxyMapper.selectForEnableInMediaServer(id, enable);
   }
   @Override
   public Device queryVideoDeviceByChannelId( String channelId) {
      Device result = null;
      List<DeviceChannel> channelList = deviceChannelMapper.queryChannelByChannelId(channelId);
      if (channelList.size() == 1) {
         result = deviceMapper.getDeviceByDeviceId(channelList.get(0).getDeviceId());
      }
      return result;
   }
}