diff --git a/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java index fe535bfa..fa126794 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.conf; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.utils.DateUtil; +import org.junit.jupiter.api.Order; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -14,6 +15,7 @@ import java.util.regex.Pattern; @Configuration("mediaConfig") +@Order(0) public class MediaConfig{ private final static Logger logger = LoggerFactory.getLogger(MediaConfig.class); diff --git a/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java index c4086b9e..d24380a3 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java @@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.service.IMediaServerService; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; +import org.junit.jupiter.api.Order; import org.mitre.dsmiley.httpproxy.ProxyServlet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,6 +26,7 @@ import java.net.ConnectException; */ @SuppressWarnings(value = {"rawtypes", "unchecked"}) @Configuration +@Order(1) public class ProxyServletConfig { private final static Logger logger = LoggerFactory.getLogger(ProxyServletConfig.class); diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java index 4790fa4a..d4c7b83a 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java @@ -1,12 +1,14 @@ package com.genersoft.iot.vmp.conf; +import org.junit.jupiter.api.Order; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; import org.springframework.util.ObjectUtils; @Component @ConfigurationProperties(prefix = "sip", ignoreInvalidFields = true) +@Order(0) public class SipConfig { private String ip; diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java b/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java index 15e38aea..b3f144a7 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java @@ -18,7 +18,7 @@ import java.util.List; * @author lin */ @Component -@Order(value=3) +@Order(value=13) public class SipPlatformRunner implements CommandLineRunner { @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java index 2cc74959..b3ae3efe 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java @@ -1,14 +1,11 @@ package com.genersoft.iot.vmp.conf; -import io.swagger.v3.oas.models.ExternalDocumentation; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Contact; import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.media.StringSchema; -import io.swagger.v3.oas.models.parameters.HeaderParameter; +import org.junit.jupiter.api.Order; import org.springdoc.core.GroupedOpenApi; -import org.springdoc.core.SpringDocConfigProperties; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -17,6 +14,7 @@ import org.springframework.context.annotation.Configuration; * @author lin */ @Configuration +@Order(1) public class SpringDocConfig { @Value("${doc.enabled: true}") diff --git a/src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java index 7377702f..2f9921c7 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.conf; +import org.junit.jupiter.api.Order; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableAsync; @@ -12,6 +13,7 @@ import java.util.concurrent.ThreadPoolExecutor; * @author lin */ @Configuration +@Order(1) @EnableAsync(proxyTargetClass = true) public class ThreadPoolTaskConfig { diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java index a0956cc8..1e7fd368 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.conf; +import org.junit.jupiter.api.Order; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; @@ -11,6 +12,7 @@ import java.util.List; */ @Component @ConfigurationProperties(prefix = "user-settings", ignoreInvalidFields = true) +@Order(0) public class UserSetting { private Boolean savePositionHistory = Boolean.FALSE; diff --git a/src/main/java/com/genersoft/iot/vmp/conf/VersionConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/VersionConfig.java index a24ade41..902e41b7 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/VersionConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/VersionConfig.java @@ -1,10 +1,12 @@ package com.genersoft.iot.vmp.conf; +import org.junit.jupiter.api.Order; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; @Component @ConfigurationProperties(prefix = "version") +@Order(0) public class VersionConfig { private String version; diff --git a/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java index 1eca1319..a2dca631 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java @@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.listener.PatternTopic; @@ -23,6 +24,7 @@ import com.genersoft.iot.vmp.utils.redis.FastJsonRedisSerializer; * */ @Configuration +@Order(value=1) public class RedisConfig extends CachingConfigurerSupport { @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java index 0d3a7d6e..cce0d11c 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.conf.security; import com.genersoft.iot.vmp.conf.UserSetting; +import org.junit.jupiter.api.Order; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -25,6 +26,7 @@ import java.util.List; @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) +@Order(1) public class WebSecurityConfig extends WebSecurityConfigurerAdapter { private final static Logger logger = LoggerFactory.getLogger(WebSecurityConfig.class); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java b/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java index cfac446d..d452771e 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java @@ -19,7 +19,7 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; @Component -@Order(value=1) +@Order(value=10) public class SipLayer implements CommandLineRunner { private final static Logger logger = LoggerFactory.getLogger(SipLayer.class); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java index 2ffec099..cdba4454 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java @@ -28,7 +28,7 @@ import java.util.Map; * @author lin */ @Component -@Order(value=4) +@Order(value=14) public class SipRunner implements CommandLineRunner { @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java index db922f98..b79b8002 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java @@ -38,6 +38,7 @@ import javax.sip.header.FromHeader; import javax.sip.message.Response; import java.text.ParseException; import java.util.Iterator; +import java.util.List; import java.util.concurrent.ConcurrentLinkedQueue; /** @@ -150,6 +151,17 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements Element deviceIdElement = rootElement.element("DeviceID"); String channelId = deviceIdElement.getTextTrim().toString(); Device device = redisCatchStorage.getDevice(deviceId); + + if (device == null) { + // 根据通道id查询设备Id + List deviceList = deviceChannelService.getDeviceByChannelId(channelId); + if (deviceList.size() > 0) { + device = deviceList.get(0); + }else { + logger.warn("[mobilePosition移动位置Notify] 未找到通道{}所属的设备", channelId); + return; + } + } if (device != null) { if (!ObjectUtils.isEmpty(device.getName())) { mobilePosition.setDeviceName(device.getName()); 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 f4ab70ef..9b41786f 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 @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; -import com.genersoft.iot.vmp.conf.ServiceInfo; import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper; @@ -92,7 +91,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen // } // } - System.out.println(ServiceInfo.getServerPort()); +// System.out.println(ServiceInfo.getServerPort()); SIPRequest request = (SIPRequest)evt.getRequest(); Response response = null; boolean passwordCorrect = false; diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java index a4b4cb7e..afbbafa8 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java @@ -25,7 +25,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @Component -@Order(value=2) +@Order(value=12) public class ZLMRunner implements CommandLineRunner { private final static Logger logger = LoggerFactory.getLogger(ZLMRunner.class); diff --git a/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java index 57605bb1..c192dd5a 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java @@ -51,4 +51,9 @@ public interface IDeviceChannelService { * 数据位置信息格式处理 */ boolean updateAllGps(Device device); + + /** + * 查询通道所属的设备 + */ + List getDeviceByChannelId(String channelId); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java index 3c423c06..336082f5 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java @@ -204,4 +204,9 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { return true; } + + @Override + public List getDeviceByChannelId(String channelId) { + return channelMapper.getDeviceByChannelId(channelId); + } } 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 dd3659d5..83f93343 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 @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.storager.dao; +import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannelInPlatform; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; @@ -371,4 +372,7 @@ public interface DeviceChannelMapper { "and longitude != 0 " + "and (latitudeGcj02 = 0 or latitudeWgs84 = 0 or longitudeWgs84 = 0 or longitudeGcj02 = 0)") List getChannelsWithoutTransform(String deviceId); + + @Select("select de.* from device de left join device_channel dc on de.deviceId = dc.deviceId where dc.channelId=#{channelId}") + List getDeviceByChannelId(String channelId); } diff --git a/src/main/resources/logback-spring-local.xml b/src/main/resources/logback-spring-local.xml index 80d1803b..dfda37e2 100644 --- a/src/main/resources/logback-spring-local.xml +++ b/src/main/resources/logback-spring-local.xml @@ -4,7 +4,7 @@ - +