Commit 2d2832dbe98967a661323dd0a3fdc1607106b983

Authored by 648540858
1 parent 4446218f

优化各个配置启动顺序

src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
... ... @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.conf;
2 2  
3 3 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
4 4 import com.genersoft.iot.vmp.utils.DateUtil;
  5 +import org.junit.jupiter.api.Order;
5 6 import org.slf4j.Logger;
6 7 import org.slf4j.LoggerFactory;
7 8 import org.springframework.beans.factory.annotation.Value;
... ... @@ -14,6 +15,7 @@ import java.util.regex.Pattern;
14 15  
15 16  
16 17 @Configuration("mediaConfig")
  18 +@Order(0)
17 19 public class MediaConfig{
18 20  
19 21 private final static Logger logger = LoggerFactory.getLogger(MediaConfig.class);
... ...
src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java
... ... @@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.service.IMediaServerService;
5 5 import org.apache.http.HttpHost;
6 6 import org.apache.http.HttpRequest;
7 7 import org.apache.http.HttpResponse;
  8 +import org.junit.jupiter.api.Order;
8 9 import org.mitre.dsmiley.httpproxy.ProxyServlet;
9 10 import org.slf4j.Logger;
10 11 import org.slf4j.LoggerFactory;
... ... @@ -25,6 +26,7 @@ import java.net.ConnectException;
25 26 */
26 27 @SuppressWarnings(value = {"rawtypes", "unchecked"})
27 28 @Configuration
  29 +@Order(1)
28 30 public class ProxyServletConfig {
29 31  
30 32 private final static Logger logger = LoggerFactory.getLogger(ProxyServletConfig.class);
... ...
src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java
1 1 package com.genersoft.iot.vmp.conf;
2 2  
3 3  
  4 +import org.junit.jupiter.api.Order;
4 5 import org.springframework.boot.context.properties.ConfigurationProperties;
5 6 import org.springframework.stereotype.Component;
6 7 import org.springframework.util.ObjectUtils;
7 8  
8 9 @Component
9 10 @ConfigurationProperties(prefix = "sip", ignoreInvalidFields = true)
  11 +@Order(0)
10 12 public class SipConfig {
11 13  
12 14 private String ip;
... ...
src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java
... ... @@ -18,7 +18,7 @@ import java.util.List;
18 18 * @author lin
19 19 */
20 20 @Component
21   -@Order(value=3)
  21 +@Order(value=13)
22 22 public class SipPlatformRunner implements CommandLineRunner {
23 23  
24 24 @Autowired
... ...
src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java
1 1 package com.genersoft.iot.vmp.conf;
2 2  
3   -import io.swagger.v3.oas.models.ExternalDocumentation;
4 3 import io.swagger.v3.oas.models.OpenAPI;
5 4 import io.swagger.v3.oas.models.info.Contact;
6 5 import io.swagger.v3.oas.models.info.Info;
7 6 import io.swagger.v3.oas.models.info.License;
8   -import io.swagger.v3.oas.models.media.StringSchema;
9   -import io.swagger.v3.oas.models.parameters.HeaderParameter;
  7 +import org.junit.jupiter.api.Order;
10 8 import org.springdoc.core.GroupedOpenApi;
11   -import org.springdoc.core.SpringDocConfigProperties;
12 9 import org.springframework.beans.factory.annotation.Value;
13 10 import org.springframework.context.annotation.Bean;
14 11 import org.springframework.context.annotation.Configuration;
... ... @@ -17,6 +14,7 @@ import org.springframework.context.annotation.Configuration;
17 14 * @author lin
18 15 */
19 16 @Configuration
  17 +@Order(1)
20 18 public class SpringDocConfig {
21 19  
22 20 @Value("${doc.enabled: true}")
... ...
src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java
1 1 package com.genersoft.iot.vmp.conf;
2 2  
  3 +import org.junit.jupiter.api.Order;
3 4 import org.springframework.context.annotation.Bean;
4 5 import org.springframework.context.annotation.Configuration;
5 6 import org.springframework.scheduling.annotation.EnableAsync;
... ... @@ -12,6 +13,7 @@ import java.util.concurrent.ThreadPoolExecutor;
12 13 * @author lin
13 14 */
14 15 @Configuration
  16 +@Order(1)
15 17 @EnableAsync(proxyTargetClass = true)
16 18 public class ThreadPoolTaskConfig {
17 19  
... ...
src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
1 1 package com.genersoft.iot.vmp.conf;
2 2  
  3 +import org.junit.jupiter.api.Order;
3 4 import org.springframework.boot.context.properties.ConfigurationProperties;
4 5 import org.springframework.stereotype.Component;
5 6  
... ... @@ -11,6 +12,7 @@ import java.util.List;
11 12 */
12 13 @Component
13 14 @ConfigurationProperties(prefix = "user-settings", ignoreInvalidFields = true)
  15 +@Order(0)
14 16 public class UserSetting {
15 17  
16 18 private Boolean savePositionHistory = Boolean.FALSE;
... ...
src/main/java/com/genersoft/iot/vmp/conf/VersionConfig.java
1 1 package com.genersoft.iot.vmp.conf;
2 2  
  3 +import org.junit.jupiter.api.Order;
3 4 import org.springframework.boot.context.properties.ConfigurationProperties;
4 5 import org.springframework.stereotype.Component;
5 6  
6 7 @Component
7 8 @ConfigurationProperties(prefix = "version")
  9 +@Order(0)
8 10 public class VersionConfig {
9 11  
10 12 private String version;
... ...
src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java
... ... @@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
7 7 import org.springframework.cache.annotation.CachingConfigurerSupport;
8 8 import org.springframework.context.annotation.Bean;
9 9 import org.springframework.context.annotation.Configuration;
  10 +import org.springframework.core.annotation.Order;
10 11 import org.springframework.data.redis.connection.RedisConnectionFactory;
11 12 import org.springframework.data.redis.core.RedisTemplate;
12 13 import org.springframework.data.redis.listener.PatternTopic;
... ... @@ -23,6 +24,7 @@ import com.genersoft.iot.vmp.utils.redis.FastJsonRedisSerializer;
23 24 *
24 25 */
25 26 @Configuration
  27 +@Order(value=1)
26 28 public class RedisConfig extends CachingConfigurerSupport {
27 29  
28 30 @Autowired
... ...
src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java
1 1 package com.genersoft.iot.vmp.conf.security;
2 2  
3 3 import com.genersoft.iot.vmp.conf.UserSetting;
  4 +import org.junit.jupiter.api.Order;
4 5 import org.slf4j.Logger;
5 6 import org.slf4j.LoggerFactory;
6 7 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -25,6 +26,7 @@ import java.util.List;
25 26 @Configuration
26 27 @EnableWebSecurity
27 28 @EnableGlobalMethodSecurity(prePostEnabled = true)
  29 +@Order(1)
28 30 public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
29 31  
30 32 private final static Logger logger = LoggerFactory.getLogger(WebSecurityConfig.class);
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
... ... @@ -19,7 +19,7 @@ import java.util.*;
19 19 import java.util.concurrent.ConcurrentHashMap;
20 20  
21 21 @Component
22   -@Order(value=1)
  22 +@Order(value=10)
23 23 public class SipLayer implements CommandLineRunner {
24 24  
25 25 private final static Logger logger = LoggerFactory.getLogger(SipLayer.class);
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java
... ... @@ -28,7 +28,7 @@ import java.util.Map;
28 28 * @author lin
29 29 */
30 30 @Component
31   -@Order(value=4)
  31 +@Order(value=14)
32 32 public class SipRunner implements CommandLineRunner {
33 33  
34 34 @Autowired
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
... ... @@ -38,6 +38,7 @@ import javax.sip.header.FromHeader;
38 38 import javax.sip.message.Response;
39 39 import java.text.ParseException;
40 40 import java.util.Iterator;
  41 +import java.util.List;
41 42 import java.util.concurrent.ConcurrentLinkedQueue;
42 43  
43 44 /**
... ... @@ -150,6 +151,17 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
150 151 Element deviceIdElement = rootElement.element("DeviceID");
151 152 String channelId = deviceIdElement.getTextTrim().toString();
152 153 Device device = redisCatchStorage.getDevice(deviceId);
  154 +
  155 + if (device == null) {
  156 + // 根据通道id查询设备Id
  157 + List<Device> deviceList = deviceChannelService.getDeviceByChannelId(channelId);
  158 + if (deviceList.size() > 0) {
  159 + device = deviceList.get(0);
  160 + }else {
  161 + logger.warn("[mobilePosition移动位置Notify] 未找到通道{}所属的设备", channelId);
  162 + return;
  163 + }
  164 + }
153 165 if (device != null) {
154 166 if (!ObjectUtils.isEmpty(device.getName())) {
155 167 mobilePosition.setDeviceName(device.getName());
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java
1 1 package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
2 2  
3   -import com.genersoft.iot.vmp.conf.ServiceInfo;
4 3 import com.genersoft.iot.vmp.conf.SipConfig;
5 4 import com.genersoft.iot.vmp.conf.UserSetting;
6 5 import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper;
... ... @@ -92,7 +91,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
92 91 // }
93 92 // }
94 93  
95   - System.out.println(ServiceInfo.getServerPort());
  94 +// System.out.println(ServiceInfo.getServerPort());
96 95 SIPRequest request = (SIPRequest)evt.getRequest();
97 96 Response response = null;
98 97 boolean passwordCorrect = false;
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
... ... @@ -25,7 +25,7 @@ import java.util.Set;
25 25 import java.util.concurrent.ConcurrentHashMap;
26 26  
27 27 @Component
28   -@Order(value=2)
  28 +@Order(value=12)
29 29 public class ZLMRunner implements CommandLineRunner {
30 30  
31 31 private final static Logger logger = LoggerFactory.getLogger(ZLMRunner.class);
... ...
src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java
... ... @@ -51,4 +51,9 @@ public interface IDeviceChannelService {
51 51 * 数据位置信息格式处理
52 52 */
53 53 boolean updateAllGps(Device device);
  54 +
  55 + /**
  56 + * 查询通道所属的设备
  57 + */
  58 + List<Device> getDeviceByChannelId(String channelId);
54 59 }
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java
... ... @@ -204,4 +204,9 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
204 204  
205 205 return true;
206 206 }
  207 +
  208 + @Override
  209 + public List<Device> getDeviceByChannelId(String channelId) {
  210 + return channelMapper.getDeviceByChannelId(channelId);
  211 + }
207 212 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
1 1 package com.genersoft.iot.vmp.storager.dao;
2 2  
  3 +import com.genersoft.iot.vmp.gb28181.bean.Device;
3 4 import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
4 5 import com.genersoft.iot.vmp.gb28181.bean.DeviceChannelInPlatform;
5 6 import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo;
... ... @@ -371,4 +372,7 @@ public interface DeviceChannelMapper {
371 372 "and longitude != 0 " +
372 373 "and (latitudeGcj02 = 0 or latitudeWgs84 = 0 or longitudeWgs84 = 0 or longitudeGcj02 = 0)")
373 374 List<DeviceChannel> getChannelsWithoutTransform(String deviceId);
  375 +
  376 + @Select("select de.* from device de left join device_channel dc on de.deviceId = dc.deviceId where dc.channelId=#{channelId}")
  377 + List<Device> getDeviceByChannelId(String channelId);
374 378 }
... ...
src/main/resources/logback-spring-local.xml
... ... @@ -4,7 +4,7 @@
4 4 <springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
5 5 <property name="LOG_HOME" value="logs" />
6 6  
7   - <substitutionProperty name="log.pattern" value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr(%-80.80logger{79}){cyan} %clr(:){faint} %m%n%wEx"/>
  7 + <substitutionProperty name="log.pattern" value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr(%-1.30logger{0}){cyan} %clr(:){faint} %m%n%wEx"/>
8 8  
9 9 <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
10 10 <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
... ...