saas平台联调agent存储业务流量。
优化ip存储,未探测到,保留上次结果。
This commit is contained in:
+2
@@ -51,6 +51,8 @@ public enum MsgEnum {
|
||||
|
||||
网络上报重试("NET_RECOVER"),
|
||||
|
||||
业务网络上报("BUSINESS_NET"),
|
||||
|
||||
挂载上报("POINT"),
|
||||
|
||||
系统其他上报("OTHER_SYSTEM"),
|
||||
|
||||
+1
-1
@@ -529,7 +529,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
}
|
||||
}
|
||||
|
||||
log.info("批量设置资源信息完成,耗时: {}ms", System.currentTimeMillis() - startTime);
|
||||
// log.debug("批量设置资源信息完成,耗时: {}ms", System.currentTimeMillis() - startTime);
|
||||
}
|
||||
/**
|
||||
* 使用批量查询的结果设置网络信息
|
||||
|
||||
+11
-4
@@ -256,7 +256,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT = 'CPU监控信息表';
|
||||
</update>
|
||||
<update id="createDockerInfo">
|
||||
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 = '容器监控信息表';
|
||||
</update>
|
||||
<update id="createMountPointInfo">
|
||||
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 = '挂载点监控信息表';
|
||||
</update>
|
||||
<update id="createNetBusinessInfo">
|
||||
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='网络业务流量监控表';
|
||||
</update>
|
||||
<!-- 单条插入语句 -->
|
||||
|
||||
+17
@@ -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;
|
||||
}
|
||||
|
||||
+18
-154
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<InitialNetBusinessTraffic> 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<InitialNetBusinessTrafficTemp> tempList = initialNetBusinessTrafficTempService.selectInitialNetBusinessTrafficTempList(temp);
|
||||
if(!tempList.isEmpty()){
|
||||
// 1. 构建快速查找的Map,使用MAC地址+网卡名称作为唯一键
|
||||
Map<String, InitialNetBusinessTrafficTemp> 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<MemoryVo> 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;
|
||||
}
|
||||
|
||||
+3
-2
@@ -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<InitialNetBusinessTrafficTemp> interfaces);
|
||||
int batchInsertBusinessTemp(List<InitialNetBusinessTraffic> interfaces);
|
||||
|
||||
int batchInsertBusinessRecoverTemp(List<InitialNetBusinessTrafficTemp> interfaces);
|
||||
int batchInsertBusinessRecoverTemp(List<InitialNetBusinessTraffic> interfaces);
|
||||
}
|
||||
|
||||
+3
-2
@@ -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<InitialNetBusinessTrafficTemp> interfaces);
|
||||
public int batchInsertBusinessRecoverTemp(List<InitialNetBusinessTrafficTemp> interfaces);
|
||||
public int batchInsertBusinessTemp(List<InitialNetBusinessTraffic> interfaces);
|
||||
public int batchInsertBusinessRecoverTemp(List<InitialNetBusinessTraffic> interfaces);
|
||||
}
|
||||
|
||||
+3
-2
@@ -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<InitialNetBusinessTrafficTemp> interfaces) {
|
||||
public int batchInsertBusinessTemp(List<InitialNetBusinessTraffic> interfaces) {
|
||||
return initialNetBusinessTrafficTempMapper.batchInsertBusinessTemp(interfaces);
|
||||
}
|
||||
@Override
|
||||
public int batchInsertBusinessRecoverTemp(List<InitialNetBusinessTrafficTemp> interfaces) {
|
||||
public int batchInsertBusinessRecoverTemp(List<InitialNetBusinessTraffic> interfaces) {
|
||||
return initialNetBusinessTrafficTempMapper.batchInsertBusinessRecoverTemp(interfaces);
|
||||
}
|
||||
}
|
||||
|
||||
+59
-16
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.tongran.rocketmq.mapper.InitialNetBusinessTrafficMapper">
|
||||
|
||||
|
||||
<resultMap type="InitialNetBusinessTraffic" id="InitialNetBusinessTrafficResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="clientId" column="client_id" />
|
||||
@@ -18,6 +18,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="ipv4OutSpeed" column="ipv4_out_speed" />
|
||||
<result property="ipv6InSpeed" column="ipv6_in_speed" />
|
||||
<result property="ipv6OutSpeed" column="ipv6_out_speed" />
|
||||
<result property="totalInSpeed" column="total_in_speed" />
|
||||
<result property="totalOutSpeed" column="total_out_speed" />
|
||||
<result property="totalIpv4InSpeed" column="total_ipv4_in_speed" />
|
||||
<result property="totalIpv4OutSpeed" column="total_ipv4_out_speed" />
|
||||
<result property="totalIpv6InSpeed" column="total_ipv6_in_speed" />
|
||||
<result property="totalIpv6OutSpeed" column="total_ipv6_out_speed" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
@@ -26,12 +32,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectInitialNetBusinessTrafficVo">
|
||||
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
|
||||
</sql>
|
||||
|
||||
<select id="selectInitialNetBusinessTrafficList" parameterType="InitialNetBusinessTraffic" resultMap="InitialNetBusinessTrafficResult">
|
||||
<include refid="selectInitialNetBusinessTrafficVo"/>
|
||||
<where>
|
||||
<where>
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
<if test="mac != null and mac != ''"> and mac = #{mac}</if>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
@@ -44,9 +50,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="ipv4OutSpeed != null and ipv4OutSpeed != ''"> and ipv4_out_speed = #{ipv4OutSpeed}</if>
|
||||
<if test="ipv6InSpeed != null and ipv6InSpeed != ''"> and ipv6_in_speed = #{ipv6InSpeed}</if>
|
||||
<if test="ipv6OutSpeed != null and ipv6OutSpeed != ''"> and ipv6_out_speed = #{ipv6OutSpeed}</if>
|
||||
<if test="totalInSpeed != null and totalInSpeed != ''"> and total_in_speed = #{totalInSpeed}</if>
|
||||
<if test="totalOutSpeed != null and totalOutSpeed != ''"> and total_out_speed = #{totalOutSpeed}</if>
|
||||
<if test="totalIpv4InSpeed != null and totalIpv4InSpeed != ''"> and total_ipv4_in_speed = #{totalIpv4InSpeed}</if>
|
||||
<if test="totalIpv4OutSpeed != null and totalIpv4OutSpeed != ''"> and total_ipv4_out_speed = #{totalIpv4OutSpeed}</if>
|
||||
<if test="totalIpv6InSpeed != null and totalIpv6InSpeed != ''"> and total_ipv6_in_speed = #{totalIpv6InSpeed}</if>
|
||||
<if test="totalIpv6OutSpeed != null and totalIpv6OutSpeed != ''"> and total_ipv6_out_speed = #{totalIpv6OutSpeed}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectInitialNetBusinessTrafficById" parameterType="Long" resultMap="InitialNetBusinessTrafficResult">
|
||||
<include refid="selectInitialNetBusinessTrafficVo"/>
|
||||
where id = #{id}
|
||||
@@ -67,12 +79,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="ipv4OutSpeed != null">ipv4_out_speed,</if>
|
||||
<if test="ipv6InSpeed != null">ipv6_in_speed,</if>
|
||||
<if test="ipv6OutSpeed != null">ipv6_out_speed,</if>
|
||||
<if test="totalInSpeed != null">total_in_speed,</if>
|
||||
<if test="totalOutSpeed != null">total_out_speed,</if>
|
||||
<if test="totalIpv4InSpeed != null">total_ipv4_in_speed,</if>
|
||||
<if test="totalIpv4OutSpeed != null">total_ipv4_out_speed,</if>
|
||||
<if test="totalIpv6InSpeed != null">total_ipv6_in_speed,</if>
|
||||
<if test="totalIpv6OutSpeed != null">total_ipv6_out_speed,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="clientId != null">#{clientId},</if>
|
||||
<if test="mac != null">#{mac},</if>
|
||||
@@ -86,12 +104,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="ipv4OutSpeed != null">#{ipv4OutSpeed},</if>
|
||||
<if test="ipv6InSpeed != null">#{ipv6InSpeed},</if>
|
||||
<if test="ipv6OutSpeed != null">#{ipv6OutSpeed},</if>
|
||||
<if test="totalInSpeed != null">#{totalInSpeed},</if>
|
||||
<if test="totalOutSpeed != null">#{totalOutSpeed},</if>
|
||||
<if test="totalIpv4InSpeed != null">#{totalIpv4InSpeed},</if>
|
||||
<if test="totalIpv4OutSpeed != null">#{totalIpv4OutSpeed},</if>
|
||||
<if test="totalIpv6InSpeed != null">#{totalIpv6InSpeed},</if>
|
||||
<if test="totalIpv6OutSpeed != null">#{totalIpv6OutSpeed},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateInitialNetBusinessTraffic" parameterType="InitialNetBusinessTraffic">
|
||||
@@ -109,6 +133,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="ipv4OutSpeed != null">ipv4_out_speed = #{ipv4OutSpeed},</if>
|
||||
<if test="ipv6InSpeed != null">ipv6_in_speed = #{ipv6InSpeed},</if>
|
||||
<if test="ipv6OutSpeed != null">ipv6_out_speed = #{ipv6OutSpeed},</if>
|
||||
<if test="totalInSpeed != null">total_in_speed = #{totalInSpeed},</if>
|
||||
<if test="totalOutSpeed != null">total_out_speed = #{totalOutSpeed},</if>
|
||||
<if test="totalIpv4InSpeed != null">total_ipv4_in_speed = #{totalIpv4InSpeed},</if>
|
||||
<if test="totalIpv4OutSpeed != null">total_ipv4_out_speed = #{totalIpv4OutSpeed},</if>
|
||||
<if test="totalIpv6InSpeed != null">total_ipv6_in_speed = #{totalIpv6InSpeed},</if>
|
||||
<if test="totalIpv6OutSpeed != null">total_ipv6_out_speed = #{totalIpv6OutSpeed},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
@@ -123,41 +153,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</delete>
|
||||
|
||||
<delete id="deleteInitialNetBusinessTrafficByIds" parameterType="String">
|
||||
delete from initial_net_business_traffic where id in
|
||||
delete from initial_net_business_traffic where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
<insert id="batchInsertBusinessTraffic" parameterType="list">
|
||||
insert into initial_net_business_traffic
|
||||
insert into ${tableName}
|
||||
(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
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{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})
|
||||
</foreach>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`in_speed` = IF(VALUES(`in_speed`) IS NOT NULL, VALUES(`in_speed`), `in_speed`),
|
||||
`out_speed` = IF(VALUES(`out_speed`) IS NOT NULL, VALUES(`out_speed`), `out_speed`),
|
||||
`ipv4_in_speed` = IF(VALUES(`ipv4_in_speed`) IS NOT NULL, VALUES(`ipv4_in_speed`), `ipv4_in_speed`),
|
||||
`ipv4_out_speed` = IF(VALUES(`ipv4_out_speed`) IS NOT NULL, VALUES(`ipv4_out_speed`), `ipv4_out_speed`),
|
||||
`ipv6_in_speed` = IF(VALUES(`ipv6_in_speed`) IS NOT NULL, VALUES(`ipv6_in_speed`), `ipv6_in_speed`),
|
||||
`ipv6_out_speed` = IF(VALUES(`ipv6_out_speed`) IS NOT NULL, VALUES(`ipv6_out_speed`), `ipv6_out_speed`)
|
||||
</insert>
|
||||
<insert id="batchInsertBusinessRecoverTraffic" parameterType="list">
|
||||
insert into initial_net_business_traffic
|
||||
insert into ${tableName}
|
||||
(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
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{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})
|
||||
</foreach>
|
||||
</insert>
|
||||
<select id="getNetBusinessTrafficList" parameterType="InitialNetBusinessTraffic" resultMap="InitialNetBusinessTrafficResult">
|
||||
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
|
||||
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 ${tableName}
|
||||
<where>
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
@@ -172,6 +209,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="ipv4OutSpeed != null and ipv4OutSpeed != ''"> and ipv4_out_speed = #{ipv4OutSpeed}</if>
|
||||
<if test="ipv6InSpeed != null and ipv6InSpeed != ''"> and ipv6_in_speed = #{ipv6InSpeed}</if>
|
||||
<if test="ipv6OutSpeed != null and ipv6OutSpeed != ''"> and ipv6_out_speed = #{ipv6OutSpeed}</if>
|
||||
<if test="totalInSpeed != null and totalInSpeed != ''"> and total_in_speed = #{totalInSpeed}</if>
|
||||
<if test="totalOutSpeed != null and totalOutSpeed != ''"> and total_out_speed = #{totalOutSpeed}</if>
|
||||
<if test="totalIpv4InSpeed != null and totalIpv4InSpeed != ''"> and total_ipv4_in_speed = #{totalIpv4InSpeed}</if>
|
||||
<if test="totalIpv4OutSpeed != null and totalIpv4OutSpeed != ''"> and total_ipv4_out_speed = #{totalIpv4OutSpeed}</if>
|
||||
<if test="totalIpv6InSpeed != null and totalIpv6InSpeed != ''"> and total_ipv6_in_speed = #{totalIpv6InSpeed}</if>
|
||||
<if test="totalIpv6OutSpeed != null and totalIpv6OutSpeed != ''"> and total_ipv6_out_speed = #{totalIpv6OutSpeed}</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
+43
-13
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.tongran.rocketmq.mapper.InitialNetBusinessTrafficTempMapper">
|
||||
|
||||
|
||||
<resultMap type="InitialNetBusinessTrafficTemp" id="InitialNetBusinessTrafficTempResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="clientId" column="client_id" />
|
||||
@@ -18,6 +18,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="ipv4OutSpeed" column="ipv4_out_speed" />
|
||||
<result property="ipv6InSpeed" column="ipv6_in_speed" />
|
||||
<result property="ipv6OutSpeed" column="ipv6_out_speed" />
|
||||
<result property="totalInSpeed" column="total_in_speed" />
|
||||
<result property="totalOutSpeed" column="total_out_speed" />
|
||||
<result property="totalIpv4InSpeed" column="total_ipv4_in_speed" />
|
||||
<result property="totalIpv4OutSpeed" column="total_ipv4_out_speed" />
|
||||
<result property="totalIpv6InSpeed" column="total_ipv6_in_speed" />
|
||||
<result property="totalIpv6OutSpeed" column="total_ipv6_out_speed" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
@@ -26,12 +32,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectInitialNetBusinessTrafficTempVo">
|
||||
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
|
||||
</sql>
|
||||
|
||||
<select id="selectInitialNetBusinessTrafficTempList" parameterType="InitialNetBusinessTrafficTemp" resultMap="InitialNetBusinessTrafficTempResult">
|
||||
<include refid="selectInitialNetBusinessTrafficTempVo"/>
|
||||
<where>
|
||||
<where>
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
<if test="mac != null and mac != ''"> and mac = #{mac}</if>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
@@ -44,9 +50,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="ipv4OutSpeed != null and ipv4OutSpeed != ''"> and ipv4_out_speed = #{ipv4OutSpeed}</if>
|
||||
<if test="ipv6InSpeed != null and ipv6InSpeed != ''"> and ipv6_in_speed = #{ipv6InSpeed}</if>
|
||||
<if test="ipv6OutSpeed != null and ipv6OutSpeed != ''"> and ipv6_out_speed = #{ipv6OutSpeed}</if>
|
||||
<if test="totalInSpeed != null and totalInSpeed != ''"> and total_in_speed = #{totalInSpeed}</if>
|
||||
<if test="totalOutSpeed != null and totalOutSpeed != ''"> and total_out_speed = #{totalOutSpeed}</if>
|
||||
<if test="totalIpv4InSpeed != null and totalIpv4InSpeed != ''"> and total_ipv4_in_speed = #{totalIpv4InSpeed}</if>
|
||||
<if test="totalIpv4OutSpeed != null and totalIpv4OutSpeed != ''"> and total_ipv4_out_speed = #{totalIpv4OutSpeed}</if>
|
||||
<if test="totalIpv6InSpeed != null and totalIpv6InSpeed != ''"> and total_ipv6_in_speed = #{totalIpv6InSpeed}</if>
|
||||
<if test="totalIpv6OutSpeed != null and totalIpv6OutSpeed != ''"> and total_ipv6_out_speed = #{totalIpv6OutSpeed}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectInitialNetBusinessTrafficTempById" parameterType="Long" resultMap="InitialNetBusinessTrafficTempResult">
|
||||
<include refid="selectInitialNetBusinessTrafficTempVo"/>
|
||||
where id = #{id}
|
||||
@@ -67,12 +79,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="ipv4OutSpeed != null">ipv4_out_speed,</if>
|
||||
<if test="ipv6InSpeed != null">ipv6_in_speed,</if>
|
||||
<if test="ipv6OutSpeed != null">ipv6_out_speed,</if>
|
||||
<if test="totalInSpeed != null">total_in_speed,</if>
|
||||
<if test="totalOutSpeed != null">total_out_speed,</if>
|
||||
<if test="totalIpv4InSpeed != null">total_ipv4_in_speed,</if>
|
||||
<if test="totalIpv4OutSpeed != null">total_ipv4_out_speed,</if>
|
||||
<if test="totalIpv6InSpeed != null">total_ipv6_in_speed,</if>
|
||||
<if test="totalIpv6OutSpeed != null">total_ipv6_out_speed,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="clientId != null">#{clientId},</if>
|
||||
<if test="mac != null">#{mac},</if>
|
||||
@@ -86,12 +104,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="ipv4OutSpeed != null">#{ipv4OutSpeed},</if>
|
||||
<if test="ipv6InSpeed != null">#{ipv6InSpeed},</if>
|
||||
<if test="ipv6OutSpeed != null">#{ipv6OutSpeed},</if>
|
||||
<if test="totalInSpeed != null">#{totalInSpeed},</if>
|
||||
<if test="totalOutSpeed != null">#{totalOutSpeed},</if>
|
||||
<if test="totalIpv4InSpeed != null">#{totalIpv4InSpeed},</if>
|
||||
<if test="totalIpv4OutSpeed != null">#{totalIpv4OutSpeed},</if>
|
||||
<if test="totalIpv6InSpeed != null">#{totalIpv6InSpeed},</if>
|
||||
<if test="totalIpv6OutSpeed != null">#{totalIpv6OutSpeed},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateInitialNetBusinessTrafficTemp" parameterType="InitialNetBusinessTrafficTemp">
|
||||
@@ -109,6 +133,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="ipv4OutSpeed != null">ipv4_out_speed = #{ipv4OutSpeed},</if>
|
||||
<if test="ipv6InSpeed != null">ipv6_in_speed = #{ipv6InSpeed},</if>
|
||||
<if test="ipv6OutSpeed != null">ipv6_out_speed = #{ipv6OutSpeed},</if>
|
||||
<if test="totalInSpeed != null">total_in_speed = #{totalInSpeed},</if>
|
||||
<if test="totalOutSpeed != null">total_out_speed = #{totalOutSpeed},</if>
|
||||
<if test="totalIpv4InSpeed != null">total_ipv4_in_speed = #{totalIpv4InSpeed},</if>
|
||||
<if test="totalIpv4OutSpeed != null">total_ipv4_out_speed = #{totalIpv4OutSpeed},</if>
|
||||
<if test="totalIpv6InSpeed != null">total_ipv6_in_speed = #{totalIpv6InSpeed},</if>
|
||||
<if test="totalIpv6OutSpeed != null">total_ipv6_out_speed = #{totalIpv6OutSpeed},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
@@ -123,7 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</delete>
|
||||
|
||||
<delete id="deleteInitialNetBusinessTrafficTempByIds" parameterType="String">
|
||||
delete from initial_net_business_traffic_temp where id in
|
||||
delete from initial_net_business_traffic_temp where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
@@ -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
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{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})
|
||||
</foreach>
|
||||
</insert>
|
||||
@@ -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
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{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})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
Reference in New Issue
Block a user