Commit 458e7d18b77f0f47be2969491b42de9b6d8b27f0

Authored by lin
1 parent cea7d511

添加接收redis订阅的GPS消息,为GPS订阅发送到级联平台做准备

Too many changes to show.

To preserve performance only 6 of 8 files are displayed.

src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
@@ -60,7 +60,9 @@ public class VideoManagerConstants { @@ -60,7 +60,9 @@ public class VideoManagerConstants {
60 60
61 //************************** redis 消息********************************* 61 //************************** redis 消息*********************************
62 public static final String WVP_MSG_STREAM_CHANGE_PREFIX = "WVP_MSG_STREAM_CHANGE_"; 62 public static final String WVP_MSG_STREAM_CHANGE_PREFIX = "WVP_MSG_STREAM_CHANGE_";
  63 + public static final String WVP_MSG_GPS_PREFIX = "WVP_MSG_GPS_";
63 64
64 //************************** 第三方 **************************************** 65 //************************** 第三方 ****************************************
65 public static final String WVP_STREAM_GB_ID_PREFIX = "memberNo_"; 66 public static final String WVP_STREAM_GB_ID_PREFIX = "memberNo_";
  67 + public static final String WVP_STREAM_GPS_MSG_PREFIX = "WVP_STREAM_GPS_MSG_";
66 } 68 }
src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java
1 package com.genersoft.iot.vmp.conf; 1 package com.genersoft.iot.vmp.conf;
2 2
  3 +import com.genersoft.iot.vmp.common.VideoManagerConstants;
  4 +import com.genersoft.iot.vmp.service.impl.RedisGPSMsgListener;
3 import org.apache.commons.lang3.StringUtils; 5 import org.apache.commons.lang3.StringUtils;
  6 +import org.springframework.beans.factory.annotation.Autowired;
4 import org.springframework.beans.factory.annotation.Value; 7 import org.springframework.beans.factory.annotation.Value;
5 import org.springframework.cache.annotation.CachingConfigurerSupport; 8 import org.springframework.cache.annotation.CachingConfigurerSupport;
6 import org.springframework.context.annotation.Bean; 9 import org.springframework.context.annotation.Bean;
7 import org.springframework.context.annotation.Configuration; 10 import org.springframework.context.annotation.Configuration;
8 import org.springframework.data.redis.connection.RedisConnectionFactory; 11 import org.springframework.data.redis.connection.RedisConnectionFactory;
9 import org.springframework.data.redis.core.RedisTemplate; 12 import org.springframework.data.redis.core.RedisTemplate;
  13 +import org.springframework.data.redis.listener.PatternTopic;
10 import org.springframework.data.redis.listener.RedisMessageListenerContainer; 14 import org.springframework.data.redis.listener.RedisMessageListenerContainer;
11 import org.springframework.data.redis.serializer.StringRedisSerializer; 15 import org.springframework.data.redis.serializer.StringRedisSerializer;
12 16
@@ -41,6 +45,9 @@ public class RedisConfig extends CachingConfigurerSupport { @@ -41,6 +45,9 @@ public class RedisConfig extends CachingConfigurerSupport {
41 @Value("${spring.redis.poolMaxWait:5}") 45 @Value("${spring.redis.poolMaxWait:5}")
42 private int poolMaxWait; 46 private int poolMaxWait;
43 47
  48 + @Autowired
  49 + private RedisGPSMsgListener redisGPSMsgListener;
  50 +
44 @Bean 51 @Bean
45 public JedisPool jedisPool() { 52 public JedisPool jedisPool() {
46 if (StringUtils.isBlank(password)) { 53 if (StringUtils.isBlank(password)) {
@@ -85,6 +92,7 @@ public class RedisConfig extends CachingConfigurerSupport { @@ -85,6 +92,7 @@ public class RedisConfig extends CachingConfigurerSupport {
85 92
86 RedisMessageListenerContainer container = new RedisMessageListenerContainer(); 93 RedisMessageListenerContainer container = new RedisMessageListenerContainer();
87 container.setConnectionFactory(connectionFactory); 94 container.setConnectionFactory(connectionFactory);
  95 + container.addMessageListener(redisGPSMsgListener, new PatternTopic(VideoManagerConstants.WVP_MSG_GPS_PREFIX));
88 return container; 96 return container;
89 } 97 }
90 98
src/main/java/com/genersoft/iot/vmp/service/bean/GPSMsgInfo.java 0 → 100644
  1 +package com.genersoft.iot.vmp.service.bean;
  2 +
  3 +public class GPSMsgInfo {
  4 +
  5 + /**
  6 + *
  7 + */
  8 + private String id;
  9 +
  10 + /**
  11 + * 经度 (必选)
  12 + */
  13 + private double lng;
  14 +
  15 + /**
  16 + * 纬度 (必选)
  17 + */
  18 + private double lat;
  19 +
  20 + /**
  21 + * 速度,单位:km/h (可选)
  22 + */
  23 + private double speed;
  24 +
  25 + /**
  26 + * 产生通知时间,
  27 + */
  28 + private String time;
  29 +
  30 + /**
  31 + * 方向,取值为当前摄像头方向与正北方的顺时针夹角,取值范围0°~360°,单位:(°)(可选)
  32 + */
  33 + private String direction;
  34 +
  35 + /**
  36 + * 海拔高度,单位:m(可选)
  37 + */
  38 + private String altitude;
  39 +
  40 +
  41 + public String getId() {
  42 + return id;
  43 + }
  44 +
  45 + public void setId(String id) {
  46 + this.id = id;
  47 + }
  48 +
  49 + public double getLng() {
  50 + return lng;
  51 + }
  52 +
  53 + public void setLng(double lng) {
  54 + this.lng = lng;
  55 + }
  56 +
  57 + public double getLat() {
  58 + return lat;
  59 + }
  60 +
  61 + public void setLat(double lat) {
  62 + this.lat = lat;
  63 + }
  64 +
  65 + public double getSpeed() {
  66 + return speed;
  67 + }
  68 +
  69 + public void setSpeed(double speed) {
  70 + this.speed = speed;
  71 + }
  72 +
  73 + public String getTime() {
  74 + return time;
  75 + }
  76 +
  77 + public void setTime(String time) {
  78 + this.time = time;
  79 + }
  80 +
  81 + public String getDirection() {
  82 + return direction;
  83 + }
  84 +
  85 + public void setDirection(String direction) {
  86 + this.direction = direction;
  87 + }
  88 +
  89 + public String getAltitude() {
  90 + return altitude;
  91 + }
  92 +
  93 + public void setAltitude(String altitude) {
  94 + this.altitude = altitude;
  95 + }
  96 +}
src/main/java/com/genersoft/iot/vmp/service/impl/RedisGPSMsgListener.java 0 → 100644
  1 +package com.genersoft.iot.vmp.service.impl;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
  5 +import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.data.redis.connection.Message;
  8 +import org.springframework.data.redis.connection.MessageListener;
  9 +import org.springframework.stereotype.Component;
  10 +
  11 +@Component
  12 +public class RedisGPSMsgListener implements MessageListener {
  13 +
  14 + @Autowired
  15 + private IRedisCatchStorage redisCatchStorage;
  16 +
  17 + @Override
  18 + public void onMessage(Message message, byte[] bytes) {
  19 + GPSMsgInfo gpsMsgInfo = JSON.parseObject(message.getBody(), GPSMsgInfo.class);
  20 + redisCatchStorage.updateGpsMsgInfo(gpsMsgInfo);
  21 + }
  22 +}
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
@@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; @@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
7 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; 7 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
8 import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; 8 import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
9 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; 9 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
  10 +import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
10 import com.genersoft.iot.vmp.service.bean.ThirdPartyGB; 11 import com.genersoft.iot.vmp.service.bean.ThirdPartyGB;
11 12
12 import java.util.List; 13 import java.util.List;
@@ -193,4 +194,6 @@ public interface IRedisCatchStorage { @@ -193,4 +194,6 @@ public interface IRedisCatchStorage {
193 Device getDevice(String deviceId); 194 Device getDevice(String deviceId);
194 195
195 void resetAllCSEQ(); 196 void resetAllCSEQ();
  197 +
  198 + void updateGpsMsgInfo(GPSMsgInfo gpsMsgInfo);
196 } 199 }
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
@@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants; @@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants;
6 import com.genersoft.iot.vmp.conf.UserSetup; 6 import com.genersoft.iot.vmp.conf.UserSetup;
7 import com.genersoft.iot.vmp.gb28181.bean.*; 7 import com.genersoft.iot.vmp.gb28181.bean.*;
8 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; 8 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
  9 +import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
9 import com.genersoft.iot.vmp.service.bean.ThirdPartyGB; 10 import com.genersoft.iot.vmp.service.bean.ThirdPartyGB;
10 import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 11 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
11 import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; 12 import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
@@ -426,4 +427,10 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @@ -426,4 +427,10 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
426 String key = VideoManagerConstants.DEVICE_PREFIX + userSetup.getServerId() + "_" + deviceId; 427 String key = VideoManagerConstants.DEVICE_PREFIX + userSetup.getServerId() + "_" + deviceId;
427 return (Device)redis.get(key); 428 return (Device)redis.get(key);
428 } 429 }
  430 +
  431 + @Override
  432 + public void updateGpsMsgInfo(GPSMsgInfo gpsMsgInfo) {
  433 + String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetup.getServerId() + "_" + gpsMsgInfo.getId();
  434 + redis.set(key, gpsMsgInfo);
  435 + }
429 } 436 }