From c8a6ad283cbd1341fdbfecf9750505dc88386f5f Mon Sep 17 00:00:00 2001 From: zxb <919411476@qq.com> Date: Tue, 15 Aug 2023 14:46:41 +0800 Subject: [PATCH] =?UTF-8?q?SipRequest=20fromHeader=20=E4=B8=BA=20channelId?= =?UTF-8?q?=20=E6=97=B6=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=20DeviceChannelMapper=20getDeviceByChannelId=20?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=AF=AD=E5=8F=A5=E9=94=99=E8=AF=AF=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/message/MessageRequestProcessor.java | 14 ++++++++++++++ .../iot/vmp/storager/dao/DeviceChannelMapper.java | 2 +- ...plication-dev241.yml => application-dev312.yml} | 7 +++++-- src/test/resources/application.yml | 2 ++ 4 files changed, 22 insertions(+), 3 deletions(-) rename src/test/resources/{application-dev241.yml => application-dev312.yml} (97%) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java index 0c23acea..4e5f75d8 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java @@ -12,6 +12,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorP import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; +import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; import gov.nist.javax.sip.message.SIPRequest; import org.dom4j.DocumentException; import org.dom4j.Element; @@ -27,6 +28,7 @@ import javax.sip.SipException; import javax.sip.header.CallIdHeader; import javax.sip.message.Response; import java.text.ParseException; +import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -54,6 +56,9 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement @Autowired private VideoStreamSessionManager sessionManager; + @Autowired + private DeviceChannelMapper deviceChannelMapper; + @Override public void afterPropertiesSet() throws Exception { // 添加消息处理的订阅 @@ -79,6 +84,15 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement SIPRequest request = (SIPRequest) evt.getRequest(); // 查询设备是否存在 Device device = redisCatchStorage.getDevice(deviceId); + + if(device == null){ + String sendBy = sipRequest.getTopmostVia().getSentBy().toString(); + List devicesByChannelId = deviceChannelMapper.getDeviceByChannelId(deviceId); + device = devicesByChannelId.parallelStream().filter((deviceByChannelId)->{ + return deviceByChannelId.getHostAddress().equals(sendBy); + }).findFirst().orElse(null); + } + // 查询上级平台是否存在 ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(deviceId); try { 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 bdc45bf2..d9b01ebe 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 @@ -419,7 +419,7 @@ public interface DeviceChannelMapper { "and(latitude_gcj02=0 or latitude_wgs84=0 or longitude_wgs84= 0 or longitude_gcj02 = 0)") List getChannelsWithoutTransform(String deviceId); - @Select("select de.* from wvp_device de left join wvp_device_channel dc on de.device_id = dc.deviceId where dc.channel_id=#{channelId}") + @Select("select de.* from wvp_device de left join wvp_device_channel dc on de.device_id = dc.device_id where dc.channel_id=#{channelId}") List getDeviceByChannelId(String channelId); diff --git a/src/test/resources/application-dev241.yml b/src/test/resources/application-dev312.yml similarity index 97% rename from src/test/resources/application-dev241.yml rename to src/test/resources/application-dev312.yml index 26317a42..46dc622a 100644 --- a/src/test/resources/application-dev241.yml +++ b/src/test/resources/application-dev312.yml @@ -36,6 +36,9 @@ spring: minimum-idle: 5 # 连接池最小空闲连接数 idle-timeout: 300000 # 允许连接在连接池中空闲的最长时间(以毫秒为单位) max-lifetime: 1200000 # 是池中连接关闭后的最长生命周期(以毫秒为单位) + config: + activate: + on-profile: dev312 #[可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口 server: port: 18978 @@ -56,7 +59,7 @@ sip: # 如果要监听多张网卡,可以使用逗号分隔多个IP, 例如: 192.168.1.4,10.0.0.4 # 如果不明白,就使用0.0.0.0,大部分情况都是可以的 # 请不要使用127.0.0.1,任何包括localhost在内的域名都是不可以的。 - ip: 192.168.1.241 + ip: 192.168.3.12 # [可选] 28181服务监听的端口 port: 5060 # 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007) @@ -116,4 +119,4 @@ user-settings: - http://127.0.0.1:8080 # [可选] 日志配置, 一般不需要改 logging: - config: logback-spring-local.xml \ No newline at end of file + config: classpath:logback-spring-local.xml \ No newline at end of file diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index 8e368799..dfe23969 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -36,6 +36,8 @@ spring: minimum-idle: 5 # 连接池最小空闲连接数 idle-timeout: 300000 # 允许连接在连接池中空闲的最长时间(以毫秒为单位) max-lifetime: 1200000 # 是池中连接关闭后的最长生命周期(以毫秒为单位) + profiles: + active: dev312 #[可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口 server: port: 18978