From 2127cbeca3c2f2de31b7f70b2841cdb2ee259e1a Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 5 Jun 2024 22:45:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=94=B6=E5=88=B0?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E4=BD=8D=E7=BD=AE=E8=AE=A2=E9=98=85=E5=90=8E?= =?UTF-8?q?=E5=BC=80=E5=90=AF=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/bean/SubscribeHolder.java | 9 +++-- .../MobilePositionSubscribeHandlerTask.java | 33 ------------------- 2 files changed, 7 insertions(+), 35 deletions(-) delete mode 100755 src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java index 6557bbaa..6621276c 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java @@ -4,7 +4,7 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; -import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeHandlerTask; +import com.genersoft.iot.vmp.service.IPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -24,6 +24,9 @@ public class SubscribeHolder { @Autowired private UserSetting userSetting; + @Autowired + private IPlatformService platformService; + private final String taskOverduePrefix = "subscribe_overdue_"; private static ConcurrentHashMap catalogMap = new ConcurrentHashMap<>(); @@ -62,7 +65,9 @@ public class SubscribeHolder { mobilePositionMap.put(platformId, subscribeInfo); String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "MobilePosition_" + platformId; // 添加任务处理GPS定时推送 - dynamicTask.startCron(key, new MobilePositionSubscribeHandlerTask(platformId), + dynamicTask.startCron(key, ()->{ + platformService.sendNotifyMobilePosition(platformId); + }, subscribeInfo.getGpsInterval() * 1000); String taskOverdueKey = taskOverduePrefix + "MobilePosition_" + platformId; if (subscribeInfo.getExpires() > 0) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java deleted file mode 100755 index a4512f35..00000000 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.task.impl; - -import com.genersoft.iot.vmp.common.CommonCallback; -import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; -import com.genersoft.iot.vmp.service.IPlatformService; -import com.genersoft.iot.vmp.utils.SpringBeanFactory; - -/** - * 向已经订阅(移动位置)的上级发送MobilePosition消息 - * @author lin - */ -public class MobilePositionSubscribeHandlerTask implements ISubscribeTask { - - - private IPlatformService platformService; - private String platformId; - - - public MobilePositionSubscribeHandlerTask(String platformId) { - this.platformService = SpringBeanFactory.getBean("platformServiceImpl"); - this.platformId = platformId; - } - - @Override - public void run() { - platformService.sendNotifyMobilePosition(this.platformId); - } - - @Override - public void stop(CommonCallback callback) { - - } -} From 619a86e0ed6cdda88e2458b9ec4302d202d2215f Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 6 Jun 2024 19:59:48 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java | 9 ++------- .../event/request/impl/SubscribeRequestProcessor.java | 4 +++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java index 6621276c..8c00c49c 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java @@ -24,9 +24,6 @@ public class SubscribeHolder { @Autowired private UserSetting userSetting; - @Autowired - private IPlatformService platformService; - private final String taskOverduePrefix = "subscribe_overdue_"; private static ConcurrentHashMap catalogMap = new ConcurrentHashMap<>(); @@ -61,13 +58,11 @@ public class SubscribeHolder { dynamicTask.stop(taskOverdueKey); } - public void putMobilePositionSubscribe(String platformId, SubscribeInfo subscribeInfo) { + public void putMobilePositionSubscribe(String platformId, SubscribeInfo subscribeInfo, Runnable gpsTask) { mobilePositionMap.put(platformId, subscribeInfo); String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "MobilePosition_" + platformId; // 添加任务处理GPS定时推送 - dynamicTask.startCron(key, ()->{ - platformService.sendNotifyMobilePosition(platformId); - }, + dynamicTask.startCron(key, gpsTask, subscribeInfo.getGpsInterval() * 1000); String taskOverdueKey = taskOverduePrefix + "MobilePosition_" + platformId; if (subscribeInfo.getExpires() > 0) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java index 1580bafb..c392a129 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java @@ -147,7 +147,9 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme subscribeHolder.removeMobilePositionSubscribe(platformId); }else { subscribeInfo.setResponse(response); - subscribeHolder.putMobilePositionSubscribe(platformId, subscribeInfo); + subscribeHolder.putMobilePositionSubscribe(platformId, subscribeInfo, ()->{ + platformService.sendNotifyMobilePosition(platformId); + }); } } catch (SipException | InvalidArgumentException | ParseException e) { From f8ef14bfea43abd8716aab15f5e302e7c1f23f79 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 11 Jun 2024 10:08:13 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E4=BD=8D=E7=BD=AE=E8=AE=A2=E9=98=85=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5=E9=97=B4=E9=9A=94=E4=B8=BA0=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/bean/SubscribeHolder.java | 10 ++++++++-- .../vmp/gb28181/transmit/cmd/impl/SIPCommander.java | 7 ++----- .../iot/vmp/vmanager/gb28181/device/DeviceQuery.java | 3 +++ web_src/src/components/dialog/deviceEdit.vue | 3 +++ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java index 8c00c49c..a15de224 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java @@ -4,7 +4,6 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; -import com.genersoft.iot.vmp.service.IPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -62,8 +61,15 @@ public class SubscribeHolder { mobilePositionMap.put(platformId, subscribeInfo); String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "MobilePosition_" + platformId; // 添加任务处理GPS定时推送 + + int cycleForCatalog; + if (subscribeInfo.getGpsInterval() <= 0) { + cycleForCatalog = 5; + }else { + cycleForCatalog = subscribeInfo.getGpsInterval(); + } dynamicTask.startCron(key, gpsTask, - subscribeInfo.getGpsInterval() * 1000); + cycleForCatalog * 1000); String taskOverdueKey = taskOverduePrefix + "MobilePosition_" + platformId; if (subscribeInfo.getExpires() > 0) { // 添加任务处理订阅过期 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index 723c715f..c66eb0dd 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -7,10 +7,6 @@ import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; import com.genersoft.iot.vmp.gb28181.SipLayer; import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; @@ -44,7 +40,6 @@ import javax.sip.SipFactory; import javax.sip.header.CallIdHeader; import javax.sip.message.Request; import java.text.ParseException; -import java.util.ArrayList; import java.util.List; /** @@ -1249,6 +1244,8 @@ public class SIPCommander implements ISIPCommander { subscribePostitionXml.append("" + device.getDeviceId() + "\r\n"); if (device.getSubscribeCycleForMobilePosition() > 0) { subscribePostitionXml.append("" + device.getMobilePositionSubmissionInterval() + "\r\n"); + }else { + subscribePostitionXml.append("5\r\n"); } subscribePostitionXml.append("\r\n"); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java index 9dd4c3d8..8a2618bb 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java @@ -322,6 +322,9 @@ public class DeviceQuery { public void updateDevice(Device device){ if (device != null && device.getDeviceId() != null) { + if (device.getSubscribeCycleForMobilePosition() > 0 && device.getMobilePositionSubmissionInterval() <= 0) { + device.setMobilePositionSubmissionInterval(5); + } deviceService.updateCustomDevice(device); } } diff --git a/web_src/src/components/dialog/deviceEdit.vue b/web_src/src/components/dialog/deviceEdit.vue index d8e0b43b..d8092fae 100755 --- a/web_src/src/components/dialog/deviceEdit.vue +++ b/web_src/src/components/dialog/deviceEdit.vue @@ -128,6 +128,9 @@ export default { this.form.subscribeCycleForCatalog = this.form.subscribeCycleForCatalog||0 this.form.subscribeCycleForMobilePosition = this.form.subscribeCycleForMobilePosition||0 this.form.mobilePositionSubmissionInterval = this.form.mobilePositionSubmissionInterval||0 + if (this.form.mobilePositionSubmissionInterval === 0) { + this.form.mobilePositionSubmissionInterval = 5 + } this.$axios({ method: 'post', url:`/api/device/query/device/${this.isEdit?'update':'add'}/`,