From 79e77827006df8887aabf9c059e174dca0908369 Mon Sep 17 00:00:00 2001 From: lin <648540858@qq.com> Date: Sat, 13 Dec 2025 15:54:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E7=9B=AE=E5=BD=95=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A6=96=E4=B8=AA=E6=B6=88=E6=81=AF=E7=AD=89?= =?UTF-8?q?=E5=BE=85=E6=97=B6=E9=95=BF=EF=BC=8C=E9=BB=98=E8=AE=A4=E4=B8=A4?= =?UTF-8?q?=E5=88=86=E9=92=9F=EF=BC=8C=E5=85=BC=E5=AE=B9=E4=B8=8B=E7=BA=A7?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=87=8F=E5=A4=A7=EF=BC=8C=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E9=95=BF=E6=97=B6=E9=97=B4=E5=90=8E=E6=89=8D=E8=83=BD=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/RegionServiceImpl.java | 4 +- .../gb28181/session/CatalogDataManager.java | 54 ++++++++++--------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/RegionServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/RegionServiceImpl.java index 903753fcc..f250a7edf 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/RegionServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/RegionServiceImpl.java @@ -15,6 +15,7 @@ import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -30,10 +31,9 @@ import java.util.*; * 区域管理类 */ @Service +@Slf4j public class RegionServiceImpl implements IRegionService { - - private static final Logger log = LoggerFactory.getLogger(RegionServiceImpl.class); @Autowired private RegionMapper regionMapper; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataManager.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataManager.java index c524d72c6..409ea5040 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataManager.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataManager.java @@ -221,13 +221,22 @@ public class CatalogDataManager implements CommandLineRunner { return; } Set keys = dataMap.keySet(); - + // 消息间等待间隔最大五秒 Instant instantBefore5S = Instant.now().minusMillis(TimeUnit.SECONDS.toMillis(5)); + // 消息接收完毕,等待30秒后移除数据 Instant instantBefore30S = Instant.now().minusMillis(TimeUnit.SECONDS.toMillis(30)); + // 初次等待的时间长度,兼容部分下级平台发送初次数据很慢的情况 + Instant instantBefore2M = Instant.now().minusMillis(TimeUnit.MINUTES.toMillis(2)); for (String dataKey : keys) { CatalogData catalogData = dataMap.get(dataKey); - if ( catalogData.getTime().isBefore(instantBefore5S)) { - if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.runIng)) { + if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.ready)) { + if ( catalogData.getTime().isBefore(instantBefore2M)) { + String errorMsg = "同步失败,等待回复超时"; + catalogData.setErrorMsg(errorMsg); + catalogData.setStatus(CatalogData.CatalogDataStatus.end); + } + }else if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.runIng)) { + if ( catalogData.getTime().isBefore(instantBefore5S)) { String deviceId = catalogData.getDevice().getDeviceId(); int sn = catalogData.getSn(); List deviceChannelList = getDeviceChannelList(deviceId, sn); @@ -251,30 +260,27 @@ public class CatalogDataManager implements CommandLineRunner { String errorMsg = "更新成功,共" + catalogData.getTotal() + "条,已更新" + deviceChannelList.size() + "条"; catalogData.setErrorMsg(errorMsg); catalogData.setStatus(CatalogData.CatalogDataStatus.end); - }else if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.ready)) { - String errorMsg = "同步失败,等待回复超时"; - catalogData.setErrorMsg(errorMsg); } - } - if ((catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end) || catalogData.getStatus().equals(CatalogData.CatalogDataStatus.ready)) - && catalogData.getTime().isBefore(instantBefore30S)) { // 超过三十秒,如果标记为end则删除 - dataMap.remove(dataKey); - Set redisKeysForChannel = catalogData.getRedisKeysForChannel(); - if (redisKeysForChannel != null && !redisKeysForChannel.isEmpty()) { - for (String deleteKey : redisKeysForChannel) { - redisTemplate.opsForHash().delete(key, deleteKey); + }else { + if (catalogData.getTime().isBefore(instantBefore30S)) { + dataMap.remove(dataKey); + Set redisKeysForChannel = catalogData.getRedisKeysForChannel(); + if (redisKeysForChannel != null && !redisKeysForChannel.isEmpty()) { + for (String deleteKey : redisKeysForChannel) { + redisTemplate.opsForHash().delete(key, deleteKey); + } } - } - Set redisKeysForRegion = catalogData.getRedisKeysForRegion(); - if (redisKeysForRegion != null && !redisKeysForRegion.isEmpty()) { - for (String deleteKey : redisKeysForRegion) { - redisTemplate.opsForHash().delete(key, deleteKey); + Set redisKeysForRegion = catalogData.getRedisKeysForRegion(); + if (redisKeysForRegion != null && !redisKeysForRegion.isEmpty()) { + for (String deleteKey : redisKeysForRegion) { + redisTemplate.opsForHash().delete(key, deleteKey); + } } - } - Set redisKeysForGroup = catalogData.getRedisKeysForGroup(); - if (redisKeysForGroup != null && !redisKeysForGroup.isEmpty()) { - for (String deleteKey : redisKeysForGroup) { - redisTemplate.opsForHash().delete(key, deleteKey); + Set redisKeysForGroup = catalogData.getRedisKeysForGroup(); + if (redisKeysForGroup != null && !redisKeysForGroup.isEmpty()) { + for (String deleteKey : redisKeysForGroup) { + redisTemplate.opsForHash().delete(key, deleteKey); + } } } }