Browse Source

#增加Json转换

zhongwei
yang_shj 10 months ago
parent
commit
29abfb9009
  1. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java
  2. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java
  3. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java

2
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));
}
/**

7
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<RealStationVo> result = (List<RealStationVo>) 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<RealStationVo> result = JSONObject.parseObject(json.toString(), new TypeReference<List<RealStationVo>>() {});
return result.stream().filter(o -> codeList.contains(o.getStationCode())).collect(Collectors.toList());
}

6
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<RealStationVo> realStationVoList = (List<RealStationVo>) redisTemplate.opsForValue().get(moniter_station_key);
List<RealStationVo> realStationVoList = JSONObject.parseObject(json.toString(),new TypeReference<List<RealStationVo>>() {});
if(CollectionUtil.isEmpty(realStationVoList)){
return null;
}

Loading…
Cancel
Save