From 4f52333506b8dd6ebb0b645e95dc18dbe137da71 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: Tue, 24 Sep 2024 16:25:21 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../iot/vmp/gb28181/dao/DeviceChannelMapper.java | 8 ++++++++
.../iot/vmp/service/IMobilePositionService.java | 4 ++++
.../vmp/service/impl/MobilePositionServiceImpl.java | 6 +++++-
.../vmp/service/redisMsg/RedisGpsMsgListener.java | 12 ++++++++----
4 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java
index db872f69..a92cbeea 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java
@@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.gb28181.dao;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelReduce;
+import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
@@ -1047,4 +1048,11 @@ public interface DeviceChannelMapper {
" WHERE id=#{channelId}" +
" "})
void changeAudio(@Param("channelId") int channelId, @Param("audio") boolean audio);
+
+ @Update("")
+ void updateStreamGPS(List gpsMsgInfoList);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/service/IMobilePositionService.java b/src/main/java/com/genersoft/iot/vmp/service/IMobilePositionService.java
index 28ab1d1f..bbfe7a7e 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/IMobilePositionService.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/IMobilePositionService.java
@@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.service;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
+import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import java.util.List;
@@ -17,4 +18,7 @@ public interface IMobilePositionService {
List queryEnablePlatformListWithAsMessageChannel();
MobilePosition queryLatestPosition(String deviceId);
+
+ void updateStreamGPS(List gpsMsgInfoList);
+
}
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MobilePositionServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MobilePositionServiceImpl.java
index 20cf8f8f..623543a6 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/MobilePositionServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MobilePositionServiceImpl.java
@@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.gb28181.dao.PlatformMapper;
import com.genersoft.iot.vmp.service.IMobilePositionService;
import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.DeviceMobilePositionMapper;
+import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
@@ -92,7 +93,10 @@ public class MobilePositionServiceImpl implements IMobilePositionService {
return mobilePositionMapper.queryLatestPositionByDevice(deviceId);
}
-
+ @Override
+ public void updateStreamGPS(List gpsMsgInfoList) {
+ channelMapper.updateStreamGPS(gpsMsgInfoList);
+ }
@Scheduled(fixedRate = 1000)
@Transactional
diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java
index 86a9d537..aa8c6c7a 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java
@@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.service.redisMsg;
import com.alibaba.fastjson2.JSON;
+import com.genersoft.iot.vmp.service.IMobilePositionService;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import lombok.extern.slf4j.Slf4j;
@@ -29,6 +30,9 @@ public class RedisGpsMsgListener implements MessageListener {
@Autowired
private IRedisCatchStorage redisCatchStorage;
+ @Autowired
+ private IMobilePositionService mobilePositionService;
+
private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>();
@Qualifier("taskExecutor")
@@ -63,10 +67,10 @@ public class RedisGpsMsgListener implements MessageListener {
*/
@Scheduled(fixedRate = 2 * 1000) //每2秒执行一次
public void execute(){
- List gpsMsgInfo = redisCatchStorage.getAllGpsMsgInfo();
- if (gpsMsgInfo.size() > 0) {
-// storager.updateStreamGPS(gpsMsgInfo);
- for (GPSMsgInfo msgInfo : gpsMsgInfo) {
+ List gpsMsgInfoList = redisCatchStorage.getAllGpsMsgInfo();
+ if (!gpsMsgInfoList.isEmpty()) {
+ mobilePositionService.updateStreamGPS(gpsMsgInfoList);
+ for (GPSMsgInfo msgInfo : gpsMsgInfoList) {
msgInfo.setStored(true);
redisCatchStorage.updateGpsMsgInfo(msgInfo);
}