lawrencehj
2021-06-22 f92a5da7c2d7deceaba9b5accdc900977e41564b
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);