From 0781d9bc2803713d227d8a1965298dde6d96d838 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 12 May 2022 17:48:52 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=BA=E5=A4=B1?= =?UTF-8?q?=E7=9A=84=E8=AE=BE=E5=A4=87=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/request/impl/RegisterRequestProcessor.java | 2 ++ .../message/notify/cmd/KeepaliveNotifyMessageHandler.java | 1 + .../genersoft/iot/vmp/service/impl/DeviceServiceImpl.java | 7 +------ 3 files changed, 4 insertions(+), 6 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 4f5f96a7..594c41a1 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.gb28181.transmit.event.request.SIPRequestProcessorP 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 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen // 保存到redis 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 56a4c49b..a6280831 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 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp 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 2bf1b276..9ac4d316 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 @@ public class DeviceServiceImpl implements IDeviceService { redisCatchStorage.clearCatchByDeviceId(device.getDeviceId()); } - if (device.getRegisterTime() == null) { - device.setRegisterTime(now); - } - if(device.getUpdateTime() == null) { - device.setUpdateTime(now); - } + device.setUpdateTime(now); device.setOnline(1); // 第一次上线 From 4199650c20e48cd3cb897a413aec13fa518c81cd Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 12 May 2022 18:15:35 +0800 Subject: [PATCH 2/3] #471 --- .../iot/vmp/storager/dao/DeviceChannelMapper.java | 4 ++++ .../vmp/storager/impl/VideoManagerStorageImpl.java | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) 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 312d3e03..c3b94f68 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 @@ public interface DeviceChannelMapper { @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 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 eea07e94..1f359114 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.transaction.annotation.Transactional; import org.springframework.util.StringUtils; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; /** * 视频设备数据存储-jdbc实现 @@ -197,17 +198,27 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { if (deviceChannelList == null) { return false; } + List allChannelInPlay = deviceChannelMapper.getAllChannelInPlay(); + Map allChannelMapInPlay = new ConcurrentHashMap<>(); + if (allChannelInPlay.size() > 0) { + for (DeviceChannel deviceChannel : allChannelInPlay) { + allChannelMapInPlay.put(deviceChannel.getChannelId(), deviceChannel); + } + } TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); // 数据去重 List channels = new ArrayList<>(); StringBuilder stringBuilder = new StringBuilder(); Map subContMap = new HashMap<>(); - if (deviceChannelList != null && deviceChannelList.size() > 1) { + if (deviceChannelList.size() > 1) { // 数据去重 Set 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) { From ec749de7c114aa6bc47d9766ff2242d7a4d553f7 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 12 May 2022 18:17:15 +0800 Subject: [PATCH 3/3] #470 --- web_src/src/components/control.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/src/components/control.vue b/web_src/src/components/control.vue index a0b2834f..b8b3e344 100644 --- a/web_src/src/components/control.vue +++ b/web_src/src/components/control.vue @@ -576,7 +576,7 @@ export default { 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({