From 29abfb9009e990b493ac64d3f7e4ca7de9b7a3b0 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 31 Jan 2024 14:09:25 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=A2=9E=E5=8A=A0Json=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/operation/monitor/impl/MonitorServiceImpl.java | 2 +- .../operational/config/service/impl/CentralMonitorServiceImpl.java | 7 +++++-- .../operational/station/service/impl/RealMonitorServiceImpl.java | 6 +++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java index 831dade..8f41d10 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java @@ -344,7 +344,7 @@ public class MonitorServiceImpl implements MonitorService { Thread.currentThread().interrupt(); } pool.shutdown(); - redisTemplate.opsForValue().set(moniter_station_cache_final, stationList); + redisTemplate.opsForValue().set(moniter_station_cache_final, JSONObject.toJSONString(stationList)); } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java index 6f92abc..3f8b367 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java @@ -1,5 +1,7 @@ package com.hnac.hzims.operational.config.service.impl; +import cn.hutool.core.lang.TypeReference; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -75,10 +77,11 @@ public class CentralMonitorServiceImpl implements CentralMonitorService { if (CollectionUtil.isEmpty(codeList)) { return null; } - List result = (List) redisTemplate.opsForValue().get(moniter_station_key); - if (StringUtil.isEmpty(result)) { + Object json = redisTemplate.opsForValue().get(moniter_station_key); + if (StringUtil.isEmpty(json)) { return null; } + List result = JSONObject.parseObject(json.toString(), new TypeReference>() {}); return result.stream().filter(o -> codeList.contains(o.getStationCode())).collect(Collectors.toList()); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java index 411588c..352d070 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java @@ -851,8 +851,12 @@ public class RealMonitorServiceImpl implements IRealMonitorService { if(ObjectUtil.isEmpty(message) || CollectionUtil.isEmpty(message.getDeptIds())){ return null; } + Object json = redisTemplate.opsForValue().get(moniter_station_key); + if(ObjectUtil.isEmpty(json)){ + return null; + } // 获取所有监控缓存数据 - List realStationVoList = (List) redisTemplate.opsForValue().get(moniter_station_key); + List realStationVoList = JSONObject.parseObject(json.toString(),new TypeReference>() {}); if(CollectionUtil.isEmpty(realStationVoList)){ return null; }