From 95b1cbba657e0e871a8405dcd83fd0691587bf33 Mon Sep 17 00:00:00 2001
From: mk1990 <37614016+mk1990@users.noreply.github.com>
Date: 星期五, 13 五月 2022 10:58:33 +0800
Subject: [PATCH] Merge branch '648540858:wvp-28181-2.0' into wvp-28181-2.0

---
 src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java                                                       |    7 +------
 src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java                                                |   13 ++++++++++++-
 web_src/src/components/control.vue                                                                                            |    2 +-
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java                         |    2 ++
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java |    1 +
 src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java                                                     |    4 ++++
 6 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java
index 4f5f96a..594c41a 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java
@@ -12,6 +12,7 @@
 import com.genersoft.iot.vmp.service.IDeviceService;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
+import com.genersoft.iot.vmp.utils.DateUtil;
 import gov.nist.javax.sip.RequestEventExt;
 import gov.nist.javax.sip.address.AddressImpl;
 import gov.nist.javax.sip.address.SipUri;
@@ -176,6 +177,7 @@
             // 淇濆瓨鍒皉edis
             if (registerFlag) {
                 logger.info("[{}] 娉ㄥ唽鎴愬姛! deviceId:" + deviceId, requestAddress);
+                device.setRegisterTime(DateUtil.getNow());
                 deviceService.online(device);
             } else {
                 logger.info("[{}] 娉ㄩ攢鎴愬姛! deviceId:" + deviceId, requestAddress);
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java
index 56a4c49..a628083 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java
@@ -72,6 +72,7 @@
                         device.setPort(rPort);
                         device.setHostAddress(received.concat(":").concat(String.valueOf(rPort)));
                     }
+                    device.setKeepaliveTime(DateUtil.getNow());
                     deviceService.online(device);
                     // 鍥炲200 OK
                     responseAck(evt, Response.OK);
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
index 2bf1b27..9ac4d31 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
@@ -76,12 +76,7 @@
             redisCatchStorage.clearCatchByDeviceId(device.getDeviceId());
 
         }
-        if (device.getRegisterTime() == null) {
-            device.setRegisterTime(now);
-        }
-        if(device.getUpdateTime() == null) {
-            device.setUpdateTime(now);
-        }
+        device.setUpdateTime(now);
         device.setOnline(1);
 
         // 绗竴娆′笂绾�
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
index 312d3e0..c3b94f6 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
@@ -257,4 +257,8 @@
 
     @Update(value = {"UPDATE device_channel SET latitude=${latitude}, longitude=${longitude} WHERE deviceId=#{deviceId} AND channelId=#{channelId}"})
     void updatePotion(String deviceId, String channelId, double longitude, double latitude);
+
+    @Select("SELECT * FROM device_channel WHERE length(trim(streamId)) > 0")
+    List<DeviceChannel> getAllChannelInPlay();
+
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
index eea07e9..1f35911 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
@@ -28,6 +28,7 @@
 import org.springframework.util.StringUtils;
 
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**    
  * 瑙嗛璁惧鏁版嵁瀛樺偍-jdbc瀹炵幇
@@ -197,17 +198,27 @@
 		if (deviceChannelList == null) {
 			return false;
 		}
+		List<DeviceChannel> allChannelInPlay = deviceChannelMapper.getAllChannelInPlay();
+		Map<String,DeviceChannel> allChannelMapInPlay = new ConcurrentHashMap<>();
+		if (allChannelInPlay.size() > 0) {
+			for (DeviceChannel deviceChannel : allChannelInPlay) {
+				allChannelMapInPlay.put(deviceChannel.getChannelId(), deviceChannel);
+			}
+		}
 		TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
 		// 鏁版嵁鍘婚噸
 		List<DeviceChannel> channels = new ArrayList<>();
 		StringBuilder stringBuilder = new StringBuilder();
 		Map<String, Integer> subContMap = new HashMap<>();
-		if (deviceChannelList != null && deviceChannelList.size() > 1) {
+		if (deviceChannelList.size() > 1) {
 			// 鏁版嵁鍘婚噸
 			Set<String> gbIdSet = new HashSet<>();
 			for (DeviceChannel deviceChannel : deviceChannelList) {
 				if (!gbIdSet.contains(deviceChannel.getChannelId())) {
 					gbIdSet.add(deviceChannel.getChannelId());
+					if (allChannelMapInPlay.containsKey(deviceChannel.getChannelId())) {
+						deviceChannel.setStreamId(allChannelMapInPlay.get(deviceChannel.getChannelId()).getStreamId());
+					}
 					channels.add(deviceChannel);
 					if (!StringUtils.isEmpty(deviceChannel.getParentId())) {
 						if (subContMap.get(deviceChannel.getParentId()) == null) {
diff --git a/web_src/src/components/control.vue b/web_src/src/components/control.vue
index a0b2834..b8b3e34 100644
--- a/web_src/src/components/control.vue
+++ b/web_src/src/components/control.vue
@@ -576,7 +576,7 @@
       let that = this;
       this.$axios({
         method: 'get',
-        url: '/zlm/' + that.mediaServerChoose + '/index/api/kick_session&id=' + id
+        url: '/zlm/' + that.mediaServerChoose + '/index/api/kick_session?id=' + id
       }).then(function (res) {
         that.getAllSession();
         that.$message({

--
Gitblit v1.8.0