Commit 778969f1eb3739dfd13d0b53fae93401015450f4
Merge remote-tracking branch 'origin/wvp-28181-2.0' into wvp-28181-2.0
Showing
3 changed files
with
22 additions
and
39 deletions
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java
src/main/java/com/genersoft/iot/vmp/service/StreamGPSSubscribeTask.java deleted
100644 → 0
| 1 | -package com.genersoft.iot.vmp.service; | |
| 2 | - | |
| 3 | -import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; | |
| 4 | -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | |
| 5 | -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | |
| 6 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | -import org.springframework.scheduling.annotation.Scheduled; | |
| 8 | -import org.springframework.stereotype.Component; | |
| 9 | - | |
| 10 | -import java.util.List; | |
| 11 | - | |
| 12 | - | |
| 13 | -/** | |
| 14 | - * 定时查找redis中的GPS推送消息,并保存到对应的流中 | |
| 15 | - */ | |
| 16 | -@Component | |
| 17 | -public class StreamGPSSubscribeTask { | |
| 18 | - | |
| 19 | - @Autowired | |
| 20 | - private IRedisCatchStorage redisCatchStorage; | |
| 21 | - | |
| 22 | - @Autowired | |
| 23 | - private IVideoManagerStorage storager; | |
| 24 | - | |
| 25 | - | |
| 26 | - @Scheduled(fixedRate = 30 * 1000) //每30秒执行一次 | |
| 27 | - public void execute(){ | |
| 28 | - List<GPSMsgInfo> gpsMsgInfo = redisCatchStorage.getAllGpsMsgInfo(); | |
| 29 | - if (gpsMsgInfo.size() > 0) { | |
| 30 | - storager.updateStreamGPS(gpsMsgInfo); | |
| 31 | - for (GPSMsgInfo msgInfo : gpsMsgInfo) { | |
| 32 | - msgInfo.setStored(true); | |
| 33 | - redisCatchStorage.updateGpsMsgInfo(msgInfo); | |
| 34 | - } | |
| 35 | - } | |
| 36 | - | |
| 37 | - } | |
| 38 | -} |
src/main/java/com/genersoft/iot/vmp/service/impl/RedisGpsMsgListener.java
| ... | ... | @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.HandlerCatchData; |
| 5 | 5 | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
| 6 | 6 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 7 | +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | |
| 7 | 8 | import org.jetbrains.annotations.NotNull; |
| 8 | 9 | import org.slf4j.Logger; |
| 9 | 10 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -11,9 +12,11 @@ import org.springframework.beans.factory.annotation.Autowired; |
| 11 | 12 | import org.springframework.beans.factory.annotation.Qualifier; |
| 12 | 13 | import org.springframework.data.redis.connection.Message; |
| 13 | 14 | import org.springframework.data.redis.connection.MessageListener; |
| 15 | +import org.springframework.scheduling.annotation.Scheduled; | |
| 14 | 16 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| 15 | 17 | import org.springframework.stereotype.Component; |
| 16 | 18 | |
| 19 | +import java.util.List; | |
| 17 | 20 | import java.util.concurrent.ConcurrentLinkedQueue; |
| 18 | 21 | |
| 19 | 22 | /** |
| ... | ... | @@ -30,6 +33,9 @@ public class RedisGpsMsgListener implements MessageListener { |
| 30 | 33 | @Autowired |
| 31 | 34 | private IRedisCatchStorage redisCatchStorage; |
| 32 | 35 | |
| 36 | + @Autowired | |
| 37 | + private IVideoManagerStorage storager; | |
| 38 | + | |
| 33 | 39 | private final ConcurrentLinkedQueue<Message> taskQueue = new ConcurrentLinkedQueue<>(); |
| 34 | 40 | |
| 35 | 41 | @Qualifier("taskExecutor") |
| ... | ... | @@ -46,10 +52,26 @@ public class RedisGpsMsgListener implements MessageListener { |
| 46 | 52 | while (!taskQueue.isEmpty()) { |
| 47 | 53 | Message msg = taskQueue.poll(); |
| 48 | 54 | GPSMsgInfo gpsMsgInfo = JSON.parseObject(msg.getBody(), GPSMsgInfo.class); |
| 55 | + // 只是放入redis缓存起来 | |
| 49 | 56 | redisCatchStorage.updateGpsMsgInfo(gpsMsgInfo); |
| 50 | 57 | } |
| 51 | 58 | taskQueueHandlerRun = false; |
| 52 | 59 | }); |
| 53 | 60 | } |
| 54 | 61 | } |
| 62 | + | |
| 63 | + /** | |
| 64 | + * 定时将经纬度更新到数据库 | |
| 65 | + */ | |
| 66 | + @Scheduled(fixedRate = 2 * 1000) //每2秒执行一次 | |
| 67 | + public void execute(){ | |
| 68 | + List<GPSMsgInfo> gpsMsgInfo = redisCatchStorage.getAllGpsMsgInfo(); | |
| 69 | + if (gpsMsgInfo.size() > 0) { | |
| 70 | + storager.updateStreamGPS(gpsMsgInfo); | |
| 71 | + for (GPSMsgInfo msgInfo : gpsMsgInfo) { | |
| 72 | + msgInfo.setStored(true); | |
| 73 | + redisCatchStorage.updateGpsMsgInfo(msgInfo); | |
| 74 | + } | |
| 75 | + } | |
| 76 | + } | |
| 55 | 77 | } | ... | ... |