diff --git a/tongran-common/tongran-common-core/src/main/java/com/tongran/common/core/enums/MsgEnum.java b/tongran-common/tongran-common-core/src/main/java/com/tongran/common/core/enums/MsgEnum.java
index 5a39dc8..4b77c6a 100644
--- a/tongran-common/tongran-common-core/src/main/java/com/tongran/common/core/enums/MsgEnum.java
+++ b/tongran-common/tongran-common-core/src/main/java/com/tongran/common/core/enums/MsgEnum.java
@@ -51,6 +51,8 @@ public enum MsgEnum {
网络上报重试("NET_RECOVER"),
+ 业务网络上报("BUSINESS_NET"),
+
挂载上报("POINT"),
系统其他上报("OTHER_SYSTEM"),
diff --git a/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/RmResourceRegistrationServiceImpl.java b/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/RmResourceRegistrationServiceImpl.java
index 1257701..47e21de 100644
--- a/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/RmResourceRegistrationServiceImpl.java
+++ b/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/RmResourceRegistrationServiceImpl.java
@@ -529,7 +529,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
}
}
- log.info("批量设置资源信息完成,耗时: {}ms", System.currentTimeMillis() - startTime);
+// log.debug("批量设置资源信息完成,耗时: {}ms", System.currentTimeMillis() - startTime);
}
/**
* 使用批量查询的结果设置网络信息
diff --git a/tongran-modules/tongran-system/src/main/resources/mapper/system/EpsInitialTrafficDataMapper.xml b/tongran-modules/tongran-system/src/main/resources/mapper/system/EpsInitialTrafficDataMapper.xml
index f26783d..482a228 100644
--- a/tongran-modules/tongran-system/src/main/resources/mapper/system/EpsInitialTrafficDataMapper.xml
+++ b/tongran-modules/tongran-system/src/main/resources/mapper/system/EpsInitialTrafficDataMapper.xml
@@ -256,7 +256,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT = 'CPU监控信息表';
- CREATE TABLE ${tableName} (
+ CREATE TABLE IF NOT EXISTS ${tableName} (
`id` varchar(64) COMMENT '容器ID',
`name` varchar(255) COMMENT '容器名称',
`status` varchar(20) COMMENT '容器状态(running/stopped/error等)',
@@ -275,7 +275,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT = '容器监控信息表';
- CREATE TABLE ${tableName} (
+ CREATE TABLE IF NOT EXISTS ${tableName} (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增主键ID',
`client_id` varchar(255) NOT NULL COMMENT '客户端ID',
`mount` varchar(255) NOT NULL COMMENT '挂载点路径(如\"/\"、\"/data\"等)',
@@ -292,7 +292,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT = '挂载点监控信息表';
- CREATE TABLE ${tableName} (
+ CREATE TABLE IF NOT EXISTS ${tableName} (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`client_id` varchar(255) comment '客户端唯一标识',
`mac` varchar(255) comment 'mac地址',
@@ -311,7 +311,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`)
+ `total_ipv4_in_speed` varchar(50) DEFAULT NULL COMMENT 'IPv4接收总流量',
+ `total_ipv4_out_speed` varchar(50) DEFAULT NULL COMMENT 'IPv4发送总流量',
+ `total_ipv6_in_speed` varchar(50) DEFAULT NULL COMMENT 'IPv6接收总流量',
+ `total_ipv6_out_speed` varchar(50) DEFAULT NULL COMMENT 'IPv6发送总流量',
+ `total_in_speed` varchar(50) DEFAULT NULL COMMENT '累计接收字总节数',
+ `total_out_speed` varchar(50) DEFAULT NULL COMMENT '累计发送总字节数',
+ PRIMARY KEY (`id`),
+ UNIQUE INDEX `uk_client_mac_name_time`(`client_id`, `mac`, `name`, `create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='网络业务流量监控表';
diff --git a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/domain/InitialNetBusinessTraffic.java b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/domain/InitialNetBusinessTraffic.java
index 5194477..e648b29 100644
--- a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/domain/InitialNetBusinessTraffic.java
+++ b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/domain/InitialNetBusinessTraffic.java
@@ -75,4 +75,21 @@ public class InitialNetBusinessTraffic extends BaseEntity
private String startTime;
private String endTime;
+ /** 单位 */
+ private String unit;
+ /** 总接收带宽 */
+ @Excel(name = "总接收带宽")
+ private String totalInSpeed;
+
+ /** 总发送带宽 */
+ @Excel(name = "总发送带宽")
+ private String totalOutSpeed;
+ /** IPv4接收总流量 */
+ private String totalIpv4InSpeed;
+ /** IPv4发送总流量 */
+ private String totalIpv4OutSpeed;
+ /** IPv6接收总流量 */
+ private String totalIpv6InSpeed;
+ /** IPv6发送总流量 */
+ private String totalIpv6OutSpeed;
}
diff --git a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/domain/InitialNetBusinessTrafficTemp.java b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/domain/InitialNetBusinessTrafficTemp.java
index e87a7d3..3f34536 100644
--- a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/domain/InitialNetBusinessTrafficTemp.java
+++ b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/domain/InitialNetBusinessTrafficTemp.java
@@ -1,9 +1,8 @@
package com.tongran.rocketmq.domain;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
import com.tongran.common.core.annotation.Excel;
import com.tongran.common.core.web.domain.BaseEntity;
+import lombok.Data;
/**
* 网络业务流量监控对象 initial_net_business_traffic_temp
@@ -11,6 +10,7 @@ import com.tongran.common.core.web.domain.BaseEntity;
* @author gyt
* @date 2026-03-06
*/
+@Data
public class InitialNetBusinessTrafficTemp extends BaseEntity
{
private static final long serialVersionUID = 1L;
@@ -65,158 +65,22 @@ public class InitialNetBusinessTrafficTemp extends BaseEntity
/** IPv6发送流量 */
@Excel(name = "IPv6发送流量")
private String ipv6OutSpeed;
+ /** 单位 */
+ private String unit;
+ /** 总接收带宽 */
+ @Excel(name = "总接收带宽")
+ private String totalInSpeed;
- public void setId(Long id)
- {
- this.id = id;
- }
+ /** 总发送带宽 */
+ @Excel(name = "总发送带宽")
+ private String totalOutSpeed;
+ /** IPv4接收总流量 */
+ private String totalIpv4InSpeed;
+ /** IPv4发送总流量 */
+ private String totalIpv4OutSpeed;
+ /** IPv6接收总流量 */
+ private String totalIpv6InSpeed;
+ /** IPv6发送总流量 */
+ private String totalIpv6OutSpeed;
- public Long getId()
- {
- return id;
- }
-
- public void setClientId(String clientId)
- {
- this.clientId = clientId;
- }
-
- public String getClientId()
- {
- return clientId;
- }
-
- public void setMac(String mac)
- {
- this.mac = mac;
- }
-
- public String getMac()
- {
- return mac;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setPid(Long pid)
- {
- this.pid = pid;
- }
-
- public Long getPid()
- {
- return pid;
- }
-
- public void setProcessName(String processName)
- {
- this.processName = processName;
- }
-
- public String getProcessName()
- {
- return processName;
- }
-
- public void setInSpeed(String inSpeed)
- {
- this.inSpeed = inSpeed;
- }
-
- public String getInSpeed()
- {
- return inSpeed;
- }
-
- public void setOutSpeed(String outSpeed)
- {
- this.outSpeed = outSpeed;
- }
-
- public String getOutSpeed()
- {
- return outSpeed;
- }
-
- public void setConnectionCount(Long connectionCount)
- {
- this.connectionCount = connectionCount;
- }
-
- public Long getConnectionCount()
- {
- return connectionCount;
- }
-
- public void setIpv4InSpeed(String ipv4InSpeed)
- {
- this.ipv4InSpeed = ipv4InSpeed;
- }
-
- public String getIpv4InSpeed()
- {
- return ipv4InSpeed;
- }
-
- public void setIpv4OutSpeed(String ipv4OutSpeed)
- {
- this.ipv4OutSpeed = ipv4OutSpeed;
- }
-
- public String getIpv4OutSpeed()
- {
- return ipv4OutSpeed;
- }
-
- public void setIpv6InSpeed(String ipv6InSpeed)
- {
- this.ipv6InSpeed = ipv6InSpeed;
- }
-
- public String getIpv6InSpeed()
- {
- return ipv6InSpeed;
- }
-
- public void setIpv6OutSpeed(String ipv6OutSpeed)
- {
- this.ipv6OutSpeed = ipv6OutSpeed;
- }
-
- public String getIpv6OutSpeed()
- {
- return ipv6OutSpeed;
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
- .append("id", getId())
- .append("clientId", getClientId())
- .append("mac", getMac())
- .append("name", getName())
- .append("pid", getPid())
- .append("processName", getProcessName())
- .append("inSpeed", getInSpeed())
- .append("outSpeed", getOutSpeed())
- .append("connectionCount", getConnectionCount())
- .append("ipv4InSpeed", getIpv4InSpeed())
- .append("ipv4OutSpeed", getIpv4OutSpeed())
- .append("ipv6InSpeed", getIpv6InSpeed())
- .append("ipv6OutSpeed", getIpv6OutSpeed())
- .append("createBy", getCreateBy())
- .append("createTime", getCreateTime())
- .append("updateBy", getUpdateBy())
- .append("updateTime", getUpdateTime())
- .append("remark", getRemark())
- .toString();
- }
}
diff --git a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/handler/MessageHandler.java b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/handler/MessageHandler.java
index 26fdb61..1457888 100644
--- a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/handler/MessageHandler.java
+++ b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/handler/MessageHandler.java
@@ -128,6 +128,10 @@ public class MessageHandler {
@Autowired
private IInitialBandwidthTrafficTempService initialBandwidthTrafficTempService;
@Autowired
+ private IInitialNetBusinessTrafficTempService initialNetBusinessTrafficTempService;
+ @Autowired
+ private IInitialNetBusinessTrafficService iInitialNetBusinessTrafficService;
+ @Autowired
private IRmAlarmLogService rmAlarmLogService;
@Autowired
private IRmFrpcConfigManageService rmFrpcConfigManageService;
@@ -168,6 +172,7 @@ public class MessageHandler {
registerHandler(MsgEnum.内存上报.getValue(), this::handleMemoryMessage);
registerHandler(MsgEnum.网络上报.getValue(), this::handleNetMessage);
registerHandler(MsgEnum.网络上报重试.getValue(), this::handleNetRecoverMessage);
+ registerHandler(MsgEnum.业务网络上报.getValue(), this::handleBusinessNetMessage);
registerHandler(MsgEnum.挂载上报.getValue(), this::handleMountPointMessage);
registerHandler(MsgEnum.系统其他上报.getValue(), this::handleOtherSystemMessage);
registerHandler(MsgEnum.心跳上报.getValue(), this::handleHeartbeatMessage);
@@ -179,6 +184,149 @@ public class MessageHandler {
registerHandler(MsgEnum.内存详情上报.getValue(), this::handleMemoryDetailsMessage);
}
+ private void handleBusinessNetMessage(DeviceMessage message) {
+ List interfaces = JsonDataParser.parseJsonData(message.getData(), InitialNetBusinessTraffic.class);
+ if(!interfaces.isEmpty()){
+ String clientId = message.getClientId();
+ // 时间戳转换
+ long timestamp = interfaces.get(0).getTimestamp();
+ long millis = timestamp * 1000;
+ Date createTime = new Date(millis / 1000 * 1000); // 去除毫秒
+ String timeStr = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",createTime);
+ // 创建比timestamp少5分钟的时间
+ long fiveMinutesEarlier = millis - (5 * 60 * 1000); // 减去5分钟的毫秒数
+ Date fiveMinutesEarlierDate = new Date(fiveMinutesEarlier / 1000 * 1000); // 同样去除毫秒
+ // 查询临时表信息,计算实际流量值
+ InitialNetBusinessTrafficTemp temp = new InitialNetBusinessTrafficTemp();
+ temp.setCreateTime(fiveMinutesEarlierDate);
+ temp.setClientId(clientId);
+ List tempList = initialNetBusinessTrafficTempService.selectInitialNetBusinessTrafficTempList(temp);
+ if(!tempList.isEmpty()){
+ // 1. 构建快速查找的Map,使用MAC地址+网卡名称作为唯一键
+ Map tempMap = tempList.stream()
+ .collect(Collectors.toMap(
+ tempItem -> generateKey(tempItem.getMac(), tempItem.getName()),
+ Function.identity(),
+ (existing, replacement) -> existing
+ ));
+
+ // 2. 预计算除数(避免重复创建对象)
+ BigDecimal divisor = new BigDecimal(300);
+
+ interfaces.forEach(iface -> {
+ iface.setClientId(clientId);
+ iface.setCreateTime(createTime);
+
+ // 设置总流量(转换为比特)
+ iface.setTotalOutSpeed(dataProcessUtil.bytesToBits(iface.getOutSpeed()));
+ iface.setTotalInSpeed(dataProcessUtil.bytesToBits(iface.getInSpeed()));
+ iface.setTotalIpv4OutSpeed(dataProcessUtil.bytesToBits(iface.getIpv4OutSpeed()));
+ iface.setTotalIpv4InSpeed(dataProcessUtil.bytesToBits(iface.getIpv4InSpeed()));
+ iface.setTotalIpv6OutSpeed(dataProcessUtil.bytesToBits(iface.getIpv6OutSpeed()));
+ iface.setTotalIpv6InSpeed(dataProcessUtil.bytesToBits(iface.getIpv6InSpeed()));
+ // 首次采集,速率设为null
+ iface.setInSpeed(null);
+ iface.setOutSpeed(null);
+ iface.setIpv4InSpeed(null);
+ iface.setIpv4OutSpeed(null);
+ iface.setIpv6InSpeed(null);
+ iface.setIpv6OutSpeed(null);
+
+ // 使用MAC地址+网卡名称作为查找键
+ String key = generateKey(iface.getMac(), iface.getName());
+ InitialNetBusinessTrafficTemp tempInfo = tempMap.get(key);
+ if (tempInfo != null) {
+ // 计算总流入速率
+ if (iface.getTotalInSpeed() != null && tempInfo.getTotalInSpeed() != null) {
+ BigDecimal nowInSpeed = new BigDecimal(iface.getTotalInSpeed());
+ BigDecimal tempInSpeed = new BigDecimal(tempInfo.getTotalInSpeed());
+ BigDecimal inDiff = nowInSpeed.subtract(tempInSpeed);
+ if (inDiff.compareTo(BigDecimal.ZERO) >= 0) {
+ iface.setInSpeed(inDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
+ }
+ }
+ // 计算总流出速率
+ if (iface.getTotalOutSpeed() != null && tempInfo.getTotalOutSpeed() != null) {
+ BigDecimal nowOutSpeed = new BigDecimal(iface.getTotalOutSpeed());
+ BigDecimal tempOutSpeed = new BigDecimal(tempInfo.getTotalOutSpeed());
+ BigDecimal outDiff = nowOutSpeed.subtract(tempOutSpeed);
+ if (outDiff.compareTo(BigDecimal.ZERO) >= 0) {
+ iface.setOutSpeed(outDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
+ }
+ }
+ // 计算IPv4流入速率
+ if (iface.getTotalIpv4InSpeed() != null && tempInfo.getTotalIpv4InSpeed() != null) {
+ BigDecimal nowIpv4In = new BigDecimal(iface.getTotalIpv4InSpeed());
+ BigDecimal tempIpv4In = new BigDecimal(tempInfo.getTotalIpv4InSpeed());
+ BigDecimal ipv4InDiff = nowIpv4In.subtract(tempIpv4In);
+ if (ipv4InDiff.compareTo(BigDecimal.ZERO) >= 0) {
+ iface.setIpv4InSpeed(ipv4InDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
+ }
+ }
+ // 计算IPv4流出速率
+ if (iface.getTotalIpv4OutSpeed() != null && tempInfo.getTotalIpv4OutSpeed() != null) {
+ BigDecimal nowIpv4Out = new BigDecimal(iface.getTotalIpv4OutSpeed());
+ BigDecimal tempIpv4Out = new BigDecimal(tempInfo.getTotalIpv4OutSpeed());
+ BigDecimal ipv4OutDiff = nowIpv4Out.subtract(tempIpv4Out);
+ if (ipv4OutDiff.compareTo(BigDecimal.ZERO) >= 0) {
+ iface.setIpv4OutSpeed(ipv4OutDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
+ }
+ }
+ // 计算IPv6流入速率
+ if (iface.getTotalIpv6InSpeed() != null && tempInfo.getTotalIpv6InSpeed() != null) {
+ BigDecimal nowIpv6In = new BigDecimal(iface.getTotalIpv6InSpeed());
+ BigDecimal tempIpv6In = new BigDecimal(tempInfo.getTotalIpv6InSpeed());
+ BigDecimal ipv6InDiff = nowIpv6In.subtract(tempIpv6In);
+ if (ipv6InDiff.compareTo(BigDecimal.ZERO) >= 0) {
+ iface.setIpv6InSpeed(ipv6InDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
+ }
+ }
+ // 计算IPv6流出速率
+ if (iface.getTotalIpv6OutSpeed() != null && tempInfo.getTotalIpv6OutSpeed() != null) {
+ BigDecimal nowIpv6Out = new BigDecimal(iface.getTotalIpv6OutSpeed());
+ BigDecimal tempIpv6Out = new BigDecimal(tempInfo.getTotalIpv6OutSpeed());
+ BigDecimal ipv6OutDiff = nowIpv6Out.subtract(tempIpv6Out);
+ if (ipv6OutDiff.compareTo(BigDecimal.ZERO) >= 0) {
+ iface.setIpv6OutSpeed(ipv6OutDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
+ }
+ }
+ }
+ });
+ // 清空临时表对应server信息
+ initialNetBusinessTrafficTempService.deleteBusinessTempMsgByClientId(clientId);
+ }else{
+ interfaces.forEach(iface -> {
+ iface.setClientId(clientId);
+ iface.setCreateTime(createTime);
+ // 设置总流量(转换为比特)
+ iface.setTotalOutSpeed(dataProcessUtil.bytesToBits(iface.getOutSpeed()));
+ iface.setTotalInSpeed(dataProcessUtil.bytesToBits(iface.getInSpeed()));
+ iface.setTotalIpv4OutSpeed(dataProcessUtil.bytesToBits(iface.getIpv4OutSpeed()));
+ iface.setTotalIpv4InSpeed(dataProcessUtil.bytesToBits(iface.getIpv4InSpeed()));
+ iface.setTotalIpv6OutSpeed(dataProcessUtil.bytesToBits(iface.getIpv6OutSpeed()));
+ iface.setTotalIpv6InSpeed(dataProcessUtil.bytesToBits(iface.getIpv6InSpeed()));
+
+ // 首次采集,速率设为null
+ iface.setInSpeed(null);
+ iface.setOutSpeed(null);
+ iface.setIpv4InSpeed(null);
+ iface.setIpv4OutSpeed(null);
+ iface.setIpv6InSpeed(null);
+ iface.setIpv6OutSpeed(null);
+ });
+ }
+ InitialNetBusinessTraffic data = new InitialNetBusinessTraffic();
+ // 批量入库集合
+ data.setList(interfaces);
+ // 临时表 用来计算流量速率
+ initialNetBusinessTrafficTempService.batchInsertBusinessTemp(interfaces);
+ // 初始流量数据入库
+ iInitialNetBusinessTrafficService.batchInsertBusinessTraffic(data);
+ }else{
+ throw new RuntimeException("业务NET流量data数据为空");
+ }
+ }
+
private void handleMemoryDetailsMessage(DeviceMessage message) {
List memoryVoList = JsonDataParser.parseJsonData(message.getData(), MemoryVo.class);
String clientId = message.getClientId();
@@ -1413,8 +1561,8 @@ public class MessageHandler {
String prevTime = redisTemplate.opsForValue().get(timeKey);
String prevHeartbeatCount = redisTemplate.opsForValue().get(heartbeatCountKey);
Boolean prevAlertStatus = redisTemplate.hasKey(alertKey);
- log.debug("客户端ID: {} 处理前状态 - status: {}, time: {}, heartbeatCount: {}, hasAlert: {}",
- clientId, prevStatus, prevTime, prevHeartbeatCount, prevAlertStatus);
+// log.debug("客户端ID: {} 处理前状态 - status: {}, time: {}, heartbeatCount: {}, hasAlert: {}",
+// clientId, prevStatus, prevTime, prevHeartbeatCount, prevAlertStatus);
// 原子递增心跳计数(线程安全)
Long newHeartbeatCount = redisTemplate.opsForValue().increment(heartbeatCountKey);
@@ -1431,7 +1579,7 @@ public class MessageHandler {
}
});
- log.debug("客户端ID: {} 心跳处理完成,当前心跳次数: {}", clientId, newHeartbeatCount);
+// log.debug("客户端ID: {} 心跳处理完成,当前心跳次数: {}", clientId, newHeartbeatCount);
// 检查是否之前有告警状态(心跳恢复检测)
if (Boolean.TRUE.equals(redisTemplate.hasKey(alertKey))) {
@@ -1463,7 +1611,7 @@ public class MessageHandler {
// 只有达到3次心跳才执行数据库操作
if (newHeartbeatCount >= 3) {
- log.debug("客户端ID: {} 达到{}次心跳,开始执行数据库操作", clientId, newHeartbeatCount);
+// log.debug("客户端ID: {} 达到{}次心跳,开始执行数据库操作", clientId, newHeartbeatCount);
// 添加逻辑节点标识
RmResourceRegistrationRemote updateData = new RmResourceRegistrationRemote();
@@ -1518,8 +1666,8 @@ public class MessageHandler {
String currentTime = redisTemplate.opsForValue().get(timeKey);
String currentHeartbeatCount = redisTemplate.opsForValue().get(heartbeatCountKey);
Boolean currentAlertStatus = redisTemplate.hasKey(alertKey);
- log.debug("客户端ID: {} 处理后状态 - status: {}, time: {}, heartbeatCount: {}, hasAlert: {}",
- clientId, currentStatus, currentTime, currentHeartbeatCount, currentAlertStatus);
+// log.debug("客户端ID: {} 处理后状态 - status: {}, time: {}, heartbeatCount: {}, hasAlert: {}",
+// clientId, currentStatus, currentTime, currentHeartbeatCount, currentAlertStatus);
} catch (Exception e) {
log.error("处理心跳消息异常, clientId: {}", clientId, e);
@@ -2079,7 +2227,7 @@ public class MessageHandler {
boolean needUpdate = false;
// 逐个字段比较是否需要更新
- if (!StringUtils.equals(networkInfo.getCity(), oldInterfaceMsg.getCity())) {
+ if (networkInfo.getCity() != null && !StringUtils.equals(networkInfo.getCity(), oldInterfaceMsg.getCity())) {
updateData.setCity(networkInfo.getCity());
needUpdate = true;
}
@@ -2091,15 +2239,15 @@ public class MessageHandler {
updateData.setIpv6Address(networkInfo.getIpv6());
needUpdate = true;
}
- if (!StringUtils.equals(networkInfo.getProvince(), oldInterfaceMsg.getProvince())) {
+ if (networkInfo.getProvince() != null && !StringUtils.equals(networkInfo.getProvince(), oldInterfaceMsg.getProvince())) {
updateData.setProvince(networkInfo.getProvince());
needUpdate = true;
}
- if (!StringUtils.equals(networkInfo.getPublicIp(), oldInterfaceMsg.getPublicIp())) {
+ if (networkInfo.getPublicIp() != null && !StringUtils.equals(networkInfo.getPublicIp(), oldInterfaceMsg.getPublicIp())) {
updateData.setPublicIp(networkInfo.getPublicIp());
needUpdate = true;
}
- if (!StringUtils.equals(networkInfo.getCarrier(), oldInterfaceMsg.getIsp())) {
+ if (networkInfo.getCarrier() != null && !StringUtils.equals(networkInfo.getCarrier(), oldInterfaceMsg.getIsp())) {
updateData.setIsp(networkInfo.getCarrier());
needUpdate = true;
}
diff --git a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/mapper/InitialNetBusinessTrafficTempMapper.java b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/mapper/InitialNetBusinessTrafficTempMapper.java
index feaeadd..94d4dd5 100644
--- a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/mapper/InitialNetBusinessTrafficTempMapper.java
+++ b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/mapper/InitialNetBusinessTrafficTempMapper.java
@@ -1,5 +1,6 @@
package com.tongran.rocketmq.mapper;
+import com.tongran.rocketmq.domain.InitialNetBusinessTraffic;
import com.tongran.rocketmq.domain.InitialNetBusinessTrafficTemp;
import java.util.List;
@@ -64,7 +65,7 @@ public interface InitialNetBusinessTrafficTempMapper
int deleteBusinessTempMsgByClientIdAndTime(InitialNetBusinessTrafficTemp initialNetBusinessTrafficTemp);
- int batchInsertBusinessTemp(List interfaces);
+ int batchInsertBusinessTemp(List interfaces);
- int batchInsertBusinessRecoverTemp(List interfaces);
+ int batchInsertBusinessRecoverTemp(List interfaces);
}
diff --git a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/IInitialNetBusinessTrafficTempService.java b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/IInitialNetBusinessTrafficTempService.java
index 24f898f..e8841ef 100644
--- a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/IInitialNetBusinessTrafficTempService.java
+++ b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/IInitialNetBusinessTrafficTempService.java
@@ -1,5 +1,6 @@
package com.tongran.rocketmq.service;
+import com.tongran.rocketmq.domain.InitialNetBusinessTraffic;
import com.tongran.rocketmq.domain.InitialNetBusinessTrafficTemp;
import java.util.List;
@@ -63,6 +64,6 @@ public interface IInitialNetBusinessTrafficTempService
int deleteBusinessTempMsgByClientId(String clientId);
public int deleteBusinessTempMsgByClientIdAndTime(InitialNetBusinessTrafficTemp initialNetBusinessTrafficTemp);
- public int batchInsertBusinessTemp(List interfaces);
- public int batchInsertBusinessRecoverTemp(List interfaces);
+ public int batchInsertBusinessTemp(List interfaces);
+ public int batchInsertBusinessRecoverTemp(List interfaces);
}
diff --git a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/impl/InitialNetBusinessTrafficTempServiceImpl.java b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/impl/InitialNetBusinessTrafficTempServiceImpl.java
index 218fc2c..414eb3d 100644
--- a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/impl/InitialNetBusinessTrafficTempServiceImpl.java
+++ b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/impl/InitialNetBusinessTrafficTempServiceImpl.java
@@ -1,6 +1,7 @@
package com.tongran.rocketmq.service.impl;
import com.tongran.common.core.utils.DateUtils;
+import com.tongran.rocketmq.domain.InitialNetBusinessTraffic;
import com.tongran.rocketmq.domain.InitialNetBusinessTrafficTemp;
import com.tongran.rocketmq.mapper.InitialNetBusinessTrafficTempMapper;
import com.tongran.rocketmq.service.IInitialNetBusinessTrafficTempService;
@@ -104,11 +105,11 @@ public class InitialNetBusinessTrafficTempServiceImpl implements IInitialNetBusi
}
@Override
- public int batchInsertBusinessTemp(List interfaces) {
+ public int batchInsertBusinessTemp(List interfaces) {
return initialNetBusinessTrafficTempMapper.batchInsertBusinessTemp(interfaces);
}
@Override
- public int batchInsertBusinessRecoverTemp(List interfaces) {
+ public int batchInsertBusinessRecoverTemp(List interfaces) {
return initialNetBusinessTrafficTempMapper.batchInsertBusinessRecoverTemp(interfaces);
}
}
diff --git a/tongran-rocketmq/src/main/resources/mapper/rocketmq/InitialNetBusinessTrafficMapper.xml b/tongran-rocketmq/src/main/resources/mapper/rocketmq/InitialNetBusinessTrafficMapper.xml
index 27e52e1..2f59a1c 100644
--- a/tongran-rocketmq/src/main/resources/mapper/rocketmq/InitialNetBusinessTrafficMapper.xml
+++ b/tongran-rocketmq/src/main/resources/mapper/rocketmq/InitialNetBusinessTrafficMapper.xml
@@ -1,9 +1,9 @@
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
+
@@ -18,6 +18,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+
+
+
+
+
+
@@ -26,12 +32,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- select id, client_id, mac, name, pid, process_name, in_speed, out_speed, connection_count, ipv4_in_speed, ipv4_out_speed, ipv6_in_speed, ipv6_out_speed, create_by, create_time, update_by, update_time, remark from initial_net_business_traffic
+ select id, client_id, mac, name, pid, process_name, in_speed, out_speed, connection_count, ipv4_in_speed, ipv4_out_speed, ipv6_in_speed, ipv6_out_speed, total_in_speed, total_out_speed, total_ipv4_in_speed, total_ipv4_out_speed, total_ipv6_in_speed, total_ipv6_out_speed, create_by, create_time, update_by, update_time, remark from initial_net_business_traffic
-
+
\ No newline at end of file
diff --git a/tongran-rocketmq/src/main/resources/mapper/rocketmq/InitialNetBusinessTrafficTempMapper.xml b/tongran-rocketmq/src/main/resources/mapper/rocketmq/InitialNetBusinessTrafficTempMapper.xml
index 9fbcf33..3a88c6d 100644
--- a/tongran-rocketmq/src/main/resources/mapper/rocketmq/InitialNetBusinessTrafficTempMapper.xml
+++ b/tongran-rocketmq/src/main/resources/mapper/rocketmq/InitialNetBusinessTrafficTempMapper.xml
@@ -1,9 +1,9 @@
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
+
@@ -18,6 +18,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+
+
+
+
+
+
@@ -26,12 +32,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- select id, client_id, mac, name, pid, process_name, in_speed, out_speed, connection_count, ipv4_in_speed, ipv4_out_speed, ipv6_in_speed, ipv6_out_speed, create_by, create_time, update_by, update_time, remark from initial_net_business_traffic_temp
+ select id, client_id, mac, name, pid, process_name, in_speed, out_speed, connection_count, ipv4_in_speed, ipv4_out_speed, ipv6_in_speed, ipv6_out_speed, total_in_speed, total_out_speed, total_ipv4_in_speed, total_ipv4_out_speed, total_ipv6_in_speed, total_ipv6_out_speed, create_by, create_time, update_by, update_time, remark from initial_net_business_traffic_temp
-
+
and client_id = #{clientId}
and mac = #{mac}
and name like concat('%', #{name}, '%')
@@ -44,9 +50,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and ipv4_out_speed = #{ipv4OutSpeed}
and ipv6_in_speed = #{ipv6InSpeed}
and ipv6_out_speed = #{ipv6OutSpeed}
+ and total_in_speed = #{totalInSpeed}
+ and total_out_speed = #{totalOutSpeed}
+ and total_ipv4_in_speed = #{totalIpv4InSpeed}
+ and total_ipv4_out_speed = #{totalIpv4OutSpeed}
+ and total_ipv6_in_speed = #{totalIpv6InSpeed}
+ and total_ipv6_out_speed = #{totalIpv6OutSpeed}
-
+
where id = #{id}
@@ -67,12 +79,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ipv4_out_speed,
ipv6_in_speed,
ipv6_out_speed,
+ total_in_speed,
+ total_out_speed,
+ total_ipv4_in_speed,
+ total_ipv4_out_speed,
+ total_ipv6_in_speed,
+ total_ipv6_out_speed,
create_by,
create_time,
update_by,
update_time,
remark,
-
+
#{clientId},
#{mac},
@@ -86,12 +104,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{ipv4OutSpeed},
#{ipv6InSpeed},
#{ipv6OutSpeed},
+ #{totalInSpeed},
+ #{totalOutSpeed},
+ #{totalIpv4InSpeed},
+ #{totalIpv4OutSpeed},
+ #{totalIpv6InSpeed},
+ #{totalIpv6OutSpeed},
#{createBy},
#{createTime},
#{updateBy},
#{updateTime},
#{remark},
-
+
@@ -109,6 +133,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ipv4_out_speed = #{ipv4OutSpeed},
ipv6_in_speed = #{ipv6InSpeed},
ipv6_out_speed = #{ipv6OutSpeed},
+ total_in_speed = #{totalInSpeed},
+ total_out_speed = #{totalOutSpeed},
+ total_ipv4_in_speed = #{totalIpv4InSpeed},
+ total_ipv4_out_speed = #{totalIpv4OutSpeed},
+ total_ipv6_in_speed = #{totalIpv6InSpeed},
+ total_ipv6_out_speed = #{totalIpv6OutSpeed},
create_by = #{createBy},
create_time = #{createTime},
update_by = #{updateBy},
@@ -123,7 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- delete from initial_net_business_traffic_temp where id in
+ delete from initial_net_business_traffic_temp where id in
#{id}
@@ -138,13 +168,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into initial_net_business_traffic_temp
(client_id, mac, name, pid, process_name, in_speed, out_speed,
connection_count, ipv4_in_speed, ipv4_out_speed, ipv6_in_speed,
- ipv6_out_speed, create_by, create_time, update_by, update_time, remark)
+ ipv6_out_speed, total_in_speed, total_out_speed, total_ipv4_in_speed, total_ipv4_out_speed, total_ipv6_in_speed, total_ipv6_out_speed, create_by, create_time, update_by, update_time, remark)
values
(#{item.clientId}, #{item.mac}, #{item.name}, #{item.pid},
#{item.processName}, #{item.inSpeed}, #{item.outSpeed},
#{item.connectionCount}, #{item.ipv4InSpeed}, #{item.ipv4OutSpeed},
- #{item.ipv6InSpeed}, #{item.ipv6OutSpeed}, #{item.createBy},
+ #{item.ipv6InSpeed}, #{item.ipv6OutSpeed}, #{item.totalInSpeed}, #{item.totalOutSpeed}, #{item.totalIpv4InSpeed}, #{item.totalIpv4OutSpeed}, #{item.totalIpv6InSpeed}, #{item.totalIpv6OutSpeed}, #{item.createBy},
#{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark})
@@ -152,13 +182,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into initial_net_business_traffic_temp
(client_id, mac, name, pid, process_name, in_speed, out_speed,
connection_count, ipv4_in_speed, ipv4_out_speed, ipv6_in_speed,
- ipv6_out_speed, create_by, create_time, update_by, update_time, remark)
+ ipv6_out_speed, total_in_speed, total_out_speed, total_ipv4_in_speed, total_ipv4_out_speed, total_ipv6_in_speed, total_ipv6_out_speed, create_by, create_time, update_by, update_time, remark)
values
(#{item.clientId}, #{item.mac}, #{item.name}, #{item.pid},
#{item.processName}, #{item.inSpeed}, #{item.outSpeed},
#{item.connectionCount}, #{item.ipv4InSpeed}, #{item.ipv4OutSpeed},
- #{item.ipv6InSpeed}, #{item.ipv6OutSpeed}, #{item.createBy},
+ #{item.ipv6InSpeed}, #{item.ipv6OutSpeed}, #{item.totalInSpeed}, #{item.totalOutSpeed}, #{item.totalIpv4InSpeed}, #{item.totalIpv4OutSpeed}, #{item.totalIpv6InSpeed}, #{item.totalIpv6OutSpeed}, #{item.createBy},
#{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark})