Merge branch 'main' of https://git.jsspisoft.com/ry-das
This commit is contained in:
commit
402ccd0eb1
@ -50,13 +50,13 @@ public class HeartbeatCommand implements BaseCommand{
|
||||
if (realNode != null){
|
||||
boolean real = realNode.asBoolean();
|
||||
String key = String.format("link:%s:real", linkId);
|
||||
ops.set(key, real, HEARTBEAT_TTL, TimeUnit.SECONDS);
|
||||
ops.set(key, real?1:0, HEARTBEAT_TTL, TimeUnit.SECONDS);
|
||||
}
|
||||
JsonNode ftpNode = linkNode.get("ftp");
|
||||
if (ftpNode != null){
|
||||
boolean ftp = ftpNode.asBoolean();
|
||||
String key = String.format("link:%s:ftp", linkId);
|
||||
ops.set(key, ftp, HEARTBEAT_TTL, TimeUnit.SECONDS);
|
||||
ops.set(key, ftp?1:0, HEARTBEAT_TTL, TimeUnit.SECONDS);
|
||||
}
|
||||
String key = String.format("link:%s:online", linkId);
|
||||
// 更新链路在线状态到Redis
|
||||
|
@ -38,9 +38,23 @@ public class SysCommunicationLinkVo {
|
||||
private String nodeName;
|
||||
|
||||
/**
|
||||
* 状态 0 - 正常 1 - 通讯中断
|
||||
* 链路状态 0 - 离线, 1 - 正常
|
||||
*/
|
||||
private Integer onlineStatus;
|
||||
|
||||
/**
|
||||
* ftp状态 0 - 异常 1 - 正常
|
||||
*/
|
||||
private Integer ftpStatus;
|
||||
|
||||
/**
|
||||
* 实时数据状态 0 - 异常 1 - 正常
|
||||
*/
|
||||
private Integer realStatus;
|
||||
|
||||
/**
|
||||
* 实时数据状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 所属系统节点id
|
||||
|
@ -39,6 +39,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@ -81,7 +82,7 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
SysIotModelServiceMapper iotModelServiceMapper;
|
||||
|
||||
@Autowired
|
||||
AdminRedisTemplate adminRedisTemplate;
|
||||
RedisTemplate<String,Object> redisTemplate;
|
||||
|
||||
@Override
|
||||
public List<SysNodeVo> querySysNodeList() {
|
||||
@ -144,6 +145,7 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
*/
|
||||
@Override
|
||||
public PageDataInfo<SysCommunicationLinkVo> querySysCommunicationLinkList(SysCommunicationLinkDto sysCommunicationLinkDto) {
|
||||
ValueOperations<String,Object> ops = redisTemplate.opsForValue();
|
||||
// 初始化分页查询对象
|
||||
PageQuery pageQuery = new PageQuery();
|
||||
pageQuery.setPageNum(sysCommunicationLinkDto.getPageNum());
|
||||
@ -158,32 +160,37 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
// 根据条件判断是否需要查询在线状态
|
||||
if (sysCommunicationLinkDto.getWithStatus() != null && sysCommunicationLinkDto.getWithStatus() == 1) {
|
||||
// 初始化用于存储在线状态键的列表
|
||||
List<String> keys = new ArrayList<>(records.size());
|
||||
|
||||
List<String> onlines = new ArrayList<>(records.size());
|
||||
List<String> ftps = new ArrayList<>(records.size());
|
||||
List<String> reals = new ArrayList<>(records.size());
|
||||
// 遍历查询结果,构造每个通信链路的在线状态键
|
||||
for (int i = 0; i < records.size(); i++) {
|
||||
SysCommunicationLinkVo sysCommunicationLinkVo = records.get(i);
|
||||
String onlineKey = String.format("link:%d:online", sysCommunicationLinkVo.getId());
|
||||
keys.add(onlineKey);
|
||||
onlines.add(String.format("link:%d:online", sysCommunicationLinkVo.getId()));
|
||||
ftps.add(String.format("link:%d:ftp", sysCommunicationLinkVo.getId()));
|
||||
reals.add(String.format("link:%d:real", sysCommunicationLinkVo.getId()));
|
||||
}
|
||||
|
||||
// 批量获取在线状态值
|
||||
List<Object> values = adminRedisTemplate.mGet(keys);
|
||||
List<Object> onlinesStatus = ops.multiGet(onlines);
|
||||
List<Object> ftpsStatus = ops.multiGet(ftps);
|
||||
List<Object> realsStatus = ops.multiGet(reals);
|
||||
|
||||
// 遍历在线状态值,更新通信链路的在线状态
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
Object val = values.get(i);
|
||||
if (val == null) {
|
||||
records.get(i).setStatus(1);
|
||||
for (int i = 0; i < records.size(); i++) {
|
||||
SysCommunicationLinkVo sysCommunicationLinkVo = records.get(i);
|
||||
Integer ostatus = (Integer) onlinesStatus.get(i);
|
||||
Integer fstatus = (Integer) ftpsStatus.get(i);
|
||||
Integer rstatus = (Integer) realsStatus.get(i);
|
||||
if (ostatus == null) {
|
||||
ostatus = 0;
|
||||
}
|
||||
else{
|
||||
Integer status = NumberUtil.parseInt(val.toString(), null);
|
||||
if (status == null || status == 0) {
|
||||
records.get(i).setStatus(1);
|
||||
}
|
||||
else{
|
||||
records.get(i).setStatus(0);
|
||||
sysCommunicationLinkVo.setOnlineStatus(ostatus);
|
||||
if (fstatus != null){
|
||||
sysCommunicationLinkVo.setFtpStatus(fstatus);
|
||||
}
|
||||
if (rstatus != null ){
|
||||
sysCommunicationLinkVo.setRealStatus(rstatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user