From 14a750a736f480a4163f39e7c13f632c859e914b Mon Sep 17 00:00:00 2001 From: gaoyutao Date: Mon, 19 Jan 2026 18:17:23 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=89=80=E6=9C=89=E6=B5=81=E9=87=8F?= =?UTF-8?q?=E8=A1=A8=E6=96=B0=E5=A2=9E=E5=AD=97=E6=AE=B5ping=E4=B8=A2?= =?UTF-8?q?=E5=8C=85=E7=8E=87=E3=80=82=202=E3=80=81=E5=BC=80=E5=8F=91ping?= =?UTF-8?q?=E4=B8=A2=E5=8C=85=E7=8E=87=E5=9B=BE=E5=BD=A2=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/domain/EpsInitialTrafficData.java | 2 ++ .../system/EpsInitialTrafficDataMapper.xml | 19 ++++++++++++++----- .../InitialBandwidthTrafficController.java | 9 +++++++++ .../domain/InitialBandwidthTraffic.java | 4 ++++ .../IInitialBandwidthTrafficService.java | 2 ++ .../InitialBandwidthTrafficServiceImpl.java | 13 +++++++++++++ .../mapper/rocketmq/AllDiskNameMapper.xml | 8 ++++---- .../InitialBandwidthTrafficMapper.xml | 14 ++++++++------ 8 files changed, 56 insertions(+), 15 deletions(-) diff --git a/tongran-modules/tongran-system/src/main/java/com/tongran/system/domain/EpsInitialTrafficData.java b/tongran-modules/tongran-system/src/main/java/com/tongran/system/domain/EpsInitialTrafficData.java index 79f9cd0..36fd7ff 100644 --- a/tongran-modules/tongran-system/src/main/java/com/tongran/system/domain/EpsInitialTrafficData.java +++ b/tongran-modules/tongran-system/src/main/java/com/tongran/system/domain/EpsInitialTrafficData.java @@ -149,5 +149,7 @@ public class EpsInitialTrafficData extends BaseEntity { private String totalIpv6OutSpeed; /** IPv6 */ private String ipV6; + /** ping丢包率 */ + private Double pingDropped; } \ No newline at end of file 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 d777025..1cffb3c 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 @@ -41,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" total_ipv6_in_speed VARCHAR(50) COMMENT 'IPv6接收总流量', total_ipv6_out_speed VARCHAR(50) COMMENT 'IPv6发送总流量', ipV6 VARCHAR(50) COMMENT 'IPv6地址', + ping_dropped double COMMENT 'ping丢包率', PRIMARY KEY (id), UNIQUE KEY uk_client_mac_name_time (client_id, mac, name, create_time), INDEX idx_name_time (`name`,create_time) @@ -77,6 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" total_ipv6_in_speed VARCHAR(50) COMMENT 'IPv6接收总流量', total_ipv6_out_speed VARCHAR(50) COMMENT 'IPv6发送总流量', ipV6 VARCHAR(50) COMMENT 'IPv6地址', + ping_dropped double COMMENT 'ping丢包率', PRIMARY KEY (id), UNIQUE KEY uk_client_mac_name_time (client_id, mac, name, create_time), INDEX idx_name_time (`name`,create_time) @@ -258,7 +260,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" total_ipv4_out_speed, total_ipv6_in_speed, total_ipv6_out_speed, - ipV6 + ipV6, + ping_dropped ) VALUES ( #{name}, #{mac}, @@ -290,7 +293,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{totalIpv4OutSpeed}, #{totalIpv6InSpeed}, #{totalIpv6OutSpeed}, - #{ipV6} + #{ipV6}, + #{pingDropped} ) @@ -330,7 +334,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" total_ipv4_out_speed, total_ipv6_in_speed, total_ipv6_out_speed, - ipV6 + ipV6, + ping_dropped ) VALUES ( @@ -367,7 +372,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{data.totalIpv4OutSpeed,jdbcType=VARCHAR}, #{data.totalIpv6InSpeed,jdbcType=VARCHAR}, #{data.totalIpv6OutSpeed,jdbcType=VARCHAR}, - #{data.ipV6,jdbcType=VARCHAR} + #{data.ipV6,jdbcType=VARCHAR}, + #{data.pingDropped,jdbcType=DECIMAL} ) @@ -398,6 +404,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" a.`machine_flow` AS machineFlow, a.`speed` AS speed, a.`duplex` AS duplex, + a.`ping_dropped` AS pingDropped, a.business_id AS businessId, a.business_name AS businessName, a.service_sn AS serviceSn, @@ -473,7 +480,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" total_ipv4_out_speed AS totalIpv4OutSpeed, total_ipv6_in_speed AS totalIpv6InSpeed, total_ipv6_out_speed AS totalIpv6OutSpeed, - ipV6 AS ipV6 + ipV6 AS ipV6, + `ping_dropped` AS pingDropped FROM ${tableName} @@ -485,6 +493,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ORDER BY create_time desc + update ${tableName} set machine_flow=#{machineFlow} where client_id=#{clientId} and create_time=#{createTime} diff --git a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/controller/InitialBandwidthTrafficController.java b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/controller/InitialBandwidthTrafficController.java index 5205bb2..0f49a6c 100644 --- a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/controller/InitialBandwidthTrafficController.java +++ b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/controller/InitialBandwidthTrafficController.java @@ -158,4 +158,13 @@ public class InitialBandwidthTrafficController extends BaseController return success(echartsData); } + /** + * 查询eth0 Ping丢包率信息并封装为多折线ECharts图表数据 + */ + @PostMapping("/pingDroppedEcharts") + public AjaxResult pingDroppedEcharts(@RequestBody InitialBandwidthTraffic initialBandwidthTraffic) { + Map echartsData = initialBandwidthTrafficService.pingDroppedEcharts(initialBandwidthTraffic); + return success(echartsData); + } + } diff --git a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/domain/InitialBandwidthTraffic.java b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/domain/InitialBandwidthTraffic.java index 1fca984..5e84399 100644 --- a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/domain/InitialBandwidthTraffic.java +++ b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/domain/InitialBandwidthTraffic.java @@ -1,5 +1,6 @@ package com.tongran.rocketmq.domain; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.tongran.common.core.annotation.Excel; import com.tongran.common.core.web.domain.BaseEntity; import lombok.Data; @@ -15,6 +16,7 @@ import java.util.Map; * @date 2025-08-20 */ @Data +@JsonIgnoreProperties(ignoreUnknown = true) public class InitialBandwidthTraffic extends BaseEntity { private static final long serialVersionUID = 1L; @@ -103,6 +105,8 @@ public class InitialBandwidthTraffic extends BaseEntity private String totalIpv6InSpeed; /** IPv6发送总流量 */ private String totalIpv6OutSpeed; + /** ping丢包率 */ + private Double pingDropped; /** 多个clientId */ private Map> clientInterfaces; } diff --git a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/IInitialBandwidthTrafficService.java b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/IInitialBandwidthTrafficService.java index 1eb2551..dfa68b5 100644 --- a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/IInitialBandwidthTrafficService.java +++ b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/IInitialBandwidthTrafficService.java @@ -119,4 +119,6 @@ public interface IInitialBandwidthTrafficService * @return */ Map serverDetails(InitialBandwidthTraffic initialBandwidthTraffic); + + Map pingDroppedEcharts(InitialBandwidthTraffic initialBandwidthTraffic); } diff --git a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/impl/InitialBandwidthTrafficServiceImpl.java b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/impl/InitialBandwidthTrafficServiceImpl.java index 248c8e2..07c1ca7 100644 --- a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/impl/InitialBandwidthTrafficServiceImpl.java +++ b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/impl/InitialBandwidthTrafficServiceImpl.java @@ -636,6 +636,19 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf return resultMap; } + @Override + public Map pingDroppedEcharts(InitialBandwidthTraffic initialBandwidthTraffic) { + // 流量信息 + List list = getListByTableName(initialBandwidthTraffic); + Map> extractors = new LinkedHashMap<>(); + extractors.put("pingDropped", info -> info.getPingDropped()); + + return EchartsDataUtils.buildEchartsDataAutoPadding( + list, InitialBandwidthTraffic::getCreateTime, extractors, + initialBandwidthTraffic.getStartTime(), initialBandwidthTraffic.getEndTime() + ); + } + /** * 构建支持子网卡的批量echarts图表数据 * @param initialBandwidthTraffic diff --git a/tongran-rocketmq/src/main/resources/mapper/rocketmq/AllDiskNameMapper.xml b/tongran-rocketmq/src/main/resources/mapper/rocketmq/AllDiskNameMapper.xml index d0f53b1..a88b9c2 100644 --- a/tongran-rocketmq/src/main/resources/mapper/rocketmq/AllDiskNameMapper.xml +++ b/tongran-rocketmq/src/main/resources/mapper/rocketmq/AllDiskNameMapper.xml @@ -146,11 +146,11 @@ a.create_time as createTime, a.update_time as updateTime, b.serial, - b.total, - b.write_speed as writeSpeed, - b.read_speed as readSpeed, + TRUNCATE(IFNULL(b.total,0)/(1024 * 1024 * 1024), 0) as total, + TRUNCATE(IFNULL(b.write_speed,0)/1024, 0) as writeSpeed, + TRUNCATE(IFNULL(b.read_speed,0)/1024, 0) as readSpeed, b.type, - b.used_space as usedSpace + TRUNCATE(IFNULL(b.used_space,0)/(1024 * 1024 * 1024), 0) as usedSpace FROM all_disk_name a LEFT JOIN ( SELECT client_id, name, MAX(create_time) as max_create_time diff --git a/tongran-rocketmq/src/main/resources/mapper/rocketmq/InitialBandwidthTrafficMapper.xml b/tongran-rocketmq/src/main/resources/mapper/rocketmq/InitialBandwidthTrafficMapper.xml index e6004e8..c786a40 100644 --- a/tongran-rocketmq/src/main/resources/mapper/rocketmq/InitialBandwidthTrafficMapper.xml +++ b/tongran-rocketmq/src/main/resources/mapper/rocketmq/InitialBandwidthTrafficMapper.xml @@ -112,14 +112,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" create_by, update_by, client_id, create_time, ipv4_in_speed, ipv4_out_speed, ipv6_in_speed, ipv6_out_speed, total_ipv4_in_speed, total_ipv4_out_speed, total_ipv6_in_speed, total_ipv6_out_speed, - ipV6 + ipV6, ping_dropped ) VALUES ( #{name}, #{mac}, #{status}, #{type}, #{ipV4}, #{inDropped}, #{outDropped}, #{inSpeed}, #{outSpeed}, #{totalInSpeed}, #{totalOutSpeed}, #{duplex}, #{speed}, #{createBy}, #{updateBy}, #{clientId}, #{createTime}, #{ipv4InSpeed}, #{ipv4OutSpeed}, #{ipv6InSpeed}, #{ipv6OutSpeed}, #{totalIpv4InSpeed}, #{totalIpv4OutSpeed}, #{totalIpv6InSpeed}, #{totalIpv6OutSpeed}, - #{ipV6} + #{ipV6}, #{pingDropped} ) @@ -130,7 +130,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" create_by, update_by, client_id, create_time, ipv4_in_speed, ipv4_out_speed, ipv6_in_speed, ipv6_out_speed, total_ipv4_in_speed, total_ipv4_out_speed, total_ipv6_in_speed, total_ipv6_out_speed, - ipV6 + ipV6, ping_dropped ) VALUES ( @@ -139,7 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{item.createBy}, #{item.updateBy}, #{item.clientId}, #{item.createTime}, #{item.ipv4InSpeed}, #{item.ipv4OutSpeed}, #{item.ipv6InSpeed}, #{item.ipv6OutSpeed}, #{item.totalIpv4InSpeed}, #{item.totalIpv4OutSpeed}, #{item.totalIpv6InSpeed}, #{item.totalIpv6OutSpeed}, - #{item.ipV6} + #{item.ipV6}, #{item.pingDropped} ) @@ -173,7 +173,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" total_ipv4_out_speed as totalIpv4OutSpeed, total_ipv6_in_speed as totalIpv6InSpeed, total_ipv6_out_speed as totalIpv6OutSpeed, - ipV6 + ipV6, + ping_dropped as pingDropped from ${tableName} and client_id = #{clientId} @@ -212,7 +213,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" total_ipv4_out_speed as totalIpv4OutSpeed, total_ipv6_in_speed as totalIpv6InSpeed, total_ipv6_out_speed as totalIpv6OutSpeed, - ipV6 + ipV6, + ping_dropped as pingDropped from ${tableName} and client_id = #{clientId}