Commit 458e7d18b77f0f47be2969491b42de9b6d8b27f0
1 parent
cea7d511
添加接收redis订阅的GPS消息,为GPS订阅发送到级联平台做准备
Showing
6 changed files
with
138 additions
and
0 deletions
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 | 60 | |
| 61 | 61 | //************************** redis 消息********************************* |
| 62 | 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 | 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 | 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 | 5 | import org.apache.commons.lang3.StringUtils; |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 4 | 7 | import org.springframework.beans.factory.annotation.Value; |
| 5 | 8 | import org.springframework.cache.annotation.CachingConfigurerSupport; |
| 6 | 9 | import org.springframework.context.annotation.Bean; |
| 7 | 10 | import org.springframework.context.annotation.Configuration; |
| 8 | 11 | import org.springframework.data.redis.connection.RedisConnectionFactory; |
| 9 | 12 | import org.springframework.data.redis.core.RedisTemplate; |
| 13 | +import org.springframework.data.redis.listener.PatternTopic; | |
| 10 | 14 | import org.springframework.data.redis.listener.RedisMessageListenerContainer; |
| 11 | 15 | import org.springframework.data.redis.serializer.StringRedisSerializer; |
| 12 | 16 | |
| ... | ... | @@ -41,6 +45,9 @@ public class RedisConfig extends CachingConfigurerSupport { |
| 41 | 45 | @Value("${spring.redis.poolMaxWait:5}") |
| 42 | 46 | private int poolMaxWait; |
| 43 | 47 | |
| 48 | + @Autowired | |
| 49 | + private RedisGPSMsgListener redisGPSMsgListener; | |
| 50 | + | |
| 44 | 51 | @Bean |
| 45 | 52 | public JedisPool jedisPool() { |
| 46 | 53 | if (StringUtils.isBlank(password)) { |
| ... | ... | @@ -85,6 +92,7 @@ public class RedisConfig extends CachingConfigurerSupport { |
| 85 | 92 | |
| 86 | 93 | RedisMessageListenerContainer container = new RedisMessageListenerContainer(); |
| 87 | 94 | container.setConnectionFactory(connectionFactory); |
| 95 | + container.addMessageListener(redisGPSMsgListener, new PatternTopic(VideoManagerConstants.WVP_MSG_GPS_PREFIX)); | |
| 88 | 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 | 7 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; |
| 8 | 8 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| 9 | 9 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 10 | +import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; | |
| 10 | 11 | import com.genersoft.iot.vmp.service.bean.ThirdPartyGB; |
| 11 | 12 | |
| 12 | 13 | import java.util.List; |
| ... | ... | @@ -193,4 +194,6 @@ public interface IRedisCatchStorage { |
| 193 | 194 | Device getDevice(String deviceId); |
| 194 | 195 | |
| 195 | 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 | import com.genersoft.iot.vmp.conf.UserSetup; |
| 7 | 7 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 8 | 8 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 9 | +import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; | |
| 9 | 10 | import com.genersoft.iot.vmp.service.bean.ThirdPartyGB; |
| 10 | 11 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 11 | 12 | import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; |
| ... | ... | @@ -426,4 +427,10 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { |
| 426 | 427 | String key = VideoManagerConstants.DEVICE_PREFIX + userSetup.getServerId() + "_" + deviceId; |
| 427 | 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 | } | ... | ... |