Commit 778969f1eb3739dfd13d0b53fae93401015450f4

Authored by 648540858
2 parents fd091e54 34f2832b

Merge remote-tracking branch 'origin/wvp-28181-2.0' into wvp-28181-2.0

src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java
@@ -53,7 +53,6 @@ public class ZLMHttpHookSubscribe { @@ -53,7 +53,6 @@ public class ZLMHttpHookSubscribe {
53 } 53 }
54 result = result && key.getContent().getString(s).equals(hookResponse.getString(s)); 54 result = result && key.getContent().getString(s).equals(hookResponse.getString(s));
55 } 55 }
56 -  
57 } 56 }
58 if (null != result && result) { 57 if (null != result && result) {
59 event = eventMap.get(key); 58 event = eventMap.get(key);
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,6 +4,7 @@ import com.alibaba.fastjson.JSON;
4 import com.genersoft.iot.vmp.gb28181.bean.HandlerCatchData; 4 import com.genersoft.iot.vmp.gb28181.bean.HandlerCatchData;
5 import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; 5 import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
6 import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 6 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
  7 +import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
7 import org.jetbrains.annotations.NotNull; 8 import org.jetbrains.annotations.NotNull;
8 import org.slf4j.Logger; 9 import org.slf4j.Logger;
9 import org.slf4j.LoggerFactory; 10 import org.slf4j.LoggerFactory;
@@ -11,9 +12,11 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -11,9 +12,11 @@ import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.beans.factory.annotation.Qualifier; 12 import org.springframework.beans.factory.annotation.Qualifier;
12 import org.springframework.data.redis.connection.Message; 13 import org.springframework.data.redis.connection.Message;
13 import org.springframework.data.redis.connection.MessageListener; 14 import org.springframework.data.redis.connection.MessageListener;
  15 +import org.springframework.scheduling.annotation.Scheduled;
14 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 16 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
15 import org.springframework.stereotype.Component; 17 import org.springframework.stereotype.Component;
16 18
  19 +import java.util.List;
17 import java.util.concurrent.ConcurrentLinkedQueue; 20 import java.util.concurrent.ConcurrentLinkedQueue;
18 21
19 /** 22 /**
@@ -30,6 +33,9 @@ public class RedisGpsMsgListener implements MessageListener { @@ -30,6 +33,9 @@ public class RedisGpsMsgListener implements MessageListener {
30 @Autowired 33 @Autowired
31 private IRedisCatchStorage redisCatchStorage; 34 private IRedisCatchStorage redisCatchStorage;
32 35
  36 + @Autowired
  37 + private IVideoManagerStorage storager;
  38 +
33 private final ConcurrentLinkedQueue<Message> taskQueue = new ConcurrentLinkedQueue<>(); 39 private final ConcurrentLinkedQueue<Message> taskQueue = new ConcurrentLinkedQueue<>();
34 40
35 @Qualifier("taskExecutor") 41 @Qualifier("taskExecutor")
@@ -46,10 +52,26 @@ public class RedisGpsMsgListener implements MessageListener { @@ -46,10 +52,26 @@ public class RedisGpsMsgListener implements MessageListener {
46 while (!taskQueue.isEmpty()) { 52 while (!taskQueue.isEmpty()) {
47 Message msg = taskQueue.poll(); 53 Message msg = taskQueue.poll();
48 GPSMsgInfo gpsMsgInfo = JSON.parseObject(msg.getBody(), GPSMsgInfo.class); 54 GPSMsgInfo gpsMsgInfo = JSON.parseObject(msg.getBody(), GPSMsgInfo.class);
  55 + // 只是放入redis缓存起来
49 redisCatchStorage.updateGpsMsgInfo(gpsMsgInfo); 56 redisCatchStorage.updateGpsMsgInfo(gpsMsgInfo);
50 } 57 }
51 taskQueueHandlerRun = false; 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 }