lawrencehj
2021-06-23 0acf13445a2e3120f3d3599238401c9f2885d711
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
@@ -1,8 +1,8 @@
package com.genersoft.iot.vmp.storager.impl;
import java.text.SimpleDateFormat;
import java.util.*;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
@@ -70,6 +70,8 @@
   @Autowired
    private VideoStreamSessionManager streamSession;
   private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   /**
    * 根据设备ID判断设备是否存在
@@ -103,8 +105,11 @@
    */
   @Override
   public synchronized boolean updateDevice(Device device) {
      String now = this.format.format(new Date(System.currentTimeMillis()));
      device.setUpdateTime(now);
      Device deviceByDeviceId = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
      if (deviceByDeviceId == null) {
         device.setCreateTime(now);
         return deviceMapper.add(device) > 0;
      }else {
         return deviceMapper.update(device) > 0;
@@ -117,8 +122,11 @@
      String channelId = channel.getChannelId();
      channel.setDeviceId(deviceId);
      channel.setStreamId(streamSession.getStreamId(deviceId, channel.getChannelId()));
      String now = this.format.format(new Date(System.currentTimeMillis()));
      channel.setUpdateTime(now);
      DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(deviceId, channelId);
      if (deviceChannel == null) {
         channel.setCreateTime(now);
         deviceChannelMapper.add(channel);
      }else {
         deviceChannelMapper.update(channel);
@@ -254,6 +262,18 @@
      if (device == null) return false;
      device.setOnline(0);
      return deviceMapper.update(device) > 0;
   }
   /**
    * 更新所有设备离线
    *
    * @return true:更新成功  false:更新失败
    */
   @Override
   public synchronized boolean outlineForAll() {
      logger.info("更新所有设备离线");
      int result = deviceMapper.outlineForAll();
      return result > 0;
   }
   /**
@@ -575,5 +595,8 @@
      gbStreamMapper.setStatus(app, streamId, false);
   }
   @Override
   public void updateParentPlatformStatus(String platformGbID, boolean online) {
      platformMapper.updateParentPlatformStatus(platformGbID, online);
   }
}