From 6fa30134e843d268f65134c231cee86bd10afff6 Mon Sep 17 00:00:00 2001 From: gaoyutao Date: Mon, 8 Sep 2025 11:45:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=9F=A5=E8=AF=A2=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E9=BB=98=E8=AE=A4=E7=94=9F=E6=95=88=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E6=97=A595=E8=AE=A1=E7=AE=97=E5=80=BC=E8=A6=86?= =?UTF-8?q?=E7=9B=96=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/mapper/EpsNodeBandwidthMapper.java | 2 + .../mapper/RmEpsTopologyManagementMapper.java | 2 + .../EpsInitialTrafficDataServiceImpl.java | 70 +++++++++++++------ .../InitialSwitchInfoDetailsServiceImpl.java | 66 ++++++++++------- .../RmResourceRegistrationServiceImpl.java | 51 ++++++++++---- .../mapper/system/AllInterfaceNameMapper.xml | 2 +- .../mapper/system/EpsNodeBandwidthMapper.xml | 10 ++- .../system/RmEpsTopologyManagementMapper.xml | 7 ++ .../mapper/rocketmq/InitialCpuInfoMapper.xml | 12 ---- .../mapper/rocketmq/InitialDiskInfoMapper.xml | 9 --- .../rocketmq/InitialDockerInfoMapper.xml | 6 -- .../rocketmq/InitialMemoryInfoMapper.xml | 6 -- .../rocketmq/InitialMountPointInfoMapper.xml | 5 -- .../rocketmq/InitialSystemInfoMapper.xml | 13 ---- 14 files changed, 147 insertions(+), 114 deletions(-) diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsNodeBandwidthMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsNodeBandwidthMapper.java index c8604d4..b2d4cdf 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsNodeBandwidthMapper.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsNodeBandwidthMapper.java @@ -83,4 +83,6 @@ public interface EpsNodeBandwidthMapper public int countByAvgMsg(EpsNodeBandwidth epsNodeBandwidth); int updateEpsNodeBandwidthByServerSn(EpsNodeBandwidth epsNodeBandwidth); + + int updateEpsNodeBandwidthBySwitchSn(EpsNodeBandwidth epsNodeBandwidth); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RmEpsTopologyManagementMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RmEpsTopologyManagementMapper.java index 6789044..07a3878 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RmEpsTopologyManagementMapper.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RmEpsTopologyManagementMapper.java @@ -61,4 +61,6 @@ public interface RmEpsTopologyManagementMapper public int deleteRmEpsTopologyManagementByIds(Long[] ids); int updateRmEpsTopologyManagementByServerSn(RmEpsTopologyManagement rmEpsTopologyManagement); + + int updateRmEpsTopologyManagementBySwitchSn(RmEpsTopologyManagement rmEpsTopologyManagement); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsInitialTrafficDataServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsInitialTrafficDataServiceImpl.java index b6afbb4..a10026e 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsInitialTrafficDataServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsInitialTrafficDataServiceImpl.java @@ -324,30 +324,44 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe * 计算并保存95带宽值 */ private void calculateAndSave95Bandwidth(List dataList, String dateTime, String dayOrMonth) { - // 1. 提取并转换带宽值 - List speedsInMbps = dataList.stream() - .map(data -> CalculateUtil.parseSpeedToMbps(data.getOutSpeed())) - .sorted() - .collect(Collectors.toList()); - - // 2. 计算95百分位 - BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95); - - // 3. 保存结果 - EpsInitialTrafficData epsInitialTrafficData = dataList.get(0); - epsInitialTrafficData.setResourceType("1"); - if("2".equals(epsInitialTrafficData.getRevenueMethod())){ - percentile95 = epsInitialTrafficData.getPackageBandwidth(); - epsInitialTrafficData.setBandwidthType("3"); - }else { - if("1".equals(dayOrMonth)){ - epsInitialTrafficData.setBandwidthType("1"); + boolean eff = false; + if(!dataList.isEmpty()){ + if(dataList.size()<288){ + eff = true; } - if("2".equals(dayOrMonth)){ - epsInitialTrafficData.setBandwidthType("2"); + // 1. 提取并转换带宽值 + List speedsInMbps = dataList.stream() + .map(data -> CalculateUtil.parseSpeedToMbps(data.getOutSpeed())) + .sorted() + .collect(Collectors.toList()); + + // 2. 计算95百分位 + BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95); + + // 3. 保存结果 + EpsInitialTrafficData epsInitialTrafficData = dataList.get(0); + epsInitialTrafficData.setResourceType("1"); + if("2".equals(epsInitialTrafficData.getRevenueMethod())){ + percentile95 = epsInitialTrafficData.getPackageBandwidth(); + epsInitialTrafficData.setBandwidthType("3"); + }else { + if("1".equals(dayOrMonth)){ + if(eff){ + epsInitialTrafficData.setBandwidthType("5"); + }else { + epsInitialTrafficData.setBandwidthType("1"); + } + } + if("2".equals(dayOrMonth)){ + if(eff){ + epsInitialTrafficData.setBandwidthType("6"); + }else { + epsInitialTrafficData.setBandwidthType("2"); + } + } } + saveBandwidthResult(epsInitialTrafficData, percentile95, dateTime); } - saveBandwidthResult(epsInitialTrafficData, percentile95, dateTime); } /** @@ -476,4 +490,18 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe epsNodeBandwidthMapper.insertEpsNodeBandwidth(bandwidth); } } + + /** + * 判断是否为有效 + * @param list + * @return + */ + private Boolean isEff(List list){ + if(!list.isEmpty()){ + if(list.size()<288){ + return true; + } + } + return false; + } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/InitialSwitchInfoDetailsServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/InitialSwitchInfoDetailsServiceImpl.java index dc4cfff..25bc86a 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/InitialSwitchInfoDetailsServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/InitialSwitchInfoDetailsServiceImpl.java @@ -312,6 +312,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe // 遍历处理每个交换机 switchSnList.forEach(interfaceName -> { queryParam.setSwitchSn(interfaceName.getSwitchSn()); + queryParam.setSwitchIp(interfaceName.getSwitchIp()); processSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime); }); } @@ -474,34 +475,49 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe * 计算并保存交换机95带宽值 */ private void calculateAndSaveSwitch95Bandwidth(List dataList, String dateTime, String dayOrMonth) { - // 1. 提取并转换带宽值 - List speedsInMbps = dataList.stream() - .map(data -> { - // 根据 interfaceDeviceType 选择 inSpeed 或 outSpeed - String speed = ("1".equals(data.getInterfaceDeviceType())) ? - data.getInSpeed() + "" : data.getOutSpeed() + ""; - // 如果 speed 是纯数字,补充单位 "B/S"(Bytes/s) - if (speed.matches("^\\d+(\\.\\d+)?$")) { - speed += " B/S"; - } - return CalculateUtil.parseSpeedToMbps(speed); - }) - .sorted() - .collect(Collectors.toList()); + boolean eff = false; + if(!dataList.isEmpty()){ + if(dataList.size()<288){ + eff = true; + } + // 1. 提取并转换带宽值 + List speedsInMbps = dataList.stream() + .map(data -> { + // 根据 interfaceDeviceType 选择 inSpeed 或 outSpeed + String speed = "1".equals(data.getInterfaceDeviceType()) + ? (data.getInSpeed() != null ? data.getInSpeed().toString() : BigDecimal.ZERO.toString()) + : (data.getOutSpeed() != null ? data.getOutSpeed().toString() : BigDecimal.ZERO.toString()); + // 如果 speed 是纯数字,补充单位 "B/S"(Bytes/s) + if (speed.matches("^\\d+(\\.\\d+)?$")) { + speed += " B/S"; + } + return CalculateUtil.parseSpeedToMbps(speed); + }) + .sorted() + .collect(Collectors.toList()); - // 2. 计算95百分位 - BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95); + // 2. 计算95百分位 + BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95); - // 3. 保存结果 - InitialSwitchInfoDetails switchInfo = dataList.get(0); - switchInfo.setResourceType("2"); - if("1".equals(dayOrMonth)){ - switchInfo.setBandwidthType("1"); + // 3. 保存结果 + InitialSwitchInfoDetails switchInfo = dataList.get(0); + switchInfo.setResourceType("2"); + if("1".equals(dayOrMonth)){ + if(eff){ + switchInfo.setBandwidthType("5"); + }else{ + switchInfo.setBandwidthType("1"); + } + } + if("2".equals(dayOrMonth)){ + if(eff){ + switchInfo.setBandwidthType("6"); + }else{ + switchInfo.setBandwidthType("2"); + } + } + saveSwitchBandwidthResult(switchInfo, percentile95, dateTime); } - if("2".equals(dayOrMonth)){ - switchInfo.setBandwidthType("2"); - } - saveSwitchBandwidthResult(switchInfo, percentile95, dateTime); } /** diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RmResourceRegistrationServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RmResourceRegistrationServiceImpl.java index faeeddf..03c1e81 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RmResourceRegistrationServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RmResourceRegistrationServiceImpl.java @@ -96,25 +96,46 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio Long id = rmResourceRegistration.getId(); // 根据id查询sn信息 RmResourceRegistration resourceRegistration = rmResourceRegistrationMapper.selectRmResourceRegistrationById(id); - // sn String hardwareSn = resourceRegistration.getHardwareSn(); + String newResourceName = rmResourceRegistration.getResourceName(); + // 如果资源名称有修改,同步修改其他表的资源名称 - if (!resourceRegistration.getResourceName().equals(rmResourceRegistration.getResourceName())){ - // 拓扑管理配置 + if (!resourceRegistration.getResourceName().equals(newResourceName)) { + // 公共的更新对象创建 RmEpsTopologyManagement rmEpsTopologyManagement = new RmEpsTopologyManagement(); - rmEpsTopologyManagement.setServerSn(hardwareSn); - rmEpsTopologyManagement.setServerName(rmResourceRegistration.getResourceName()); - rmEpsTopologyManagementMapper.updateRmEpsTopologyManagementByServerSn(rmEpsTopologyManagement); - // 服务器收益配置表 - EpsServerRevenueConfig epsServerRevenueConfig = new EpsServerRevenueConfig(); - epsServerRevenueConfig.setHardwareSn(hardwareSn); - epsServerRevenueConfig.setNodeName(rmResourceRegistration.getResourceName()); - epsServerRevenueConfigMapper.updateEpsServerRevenueConfigByServerSn(epsServerRevenueConfig); - // 95收益信息表 EpsNodeBandwidth epsNodeBandwidth = new EpsNodeBandwidth(); - epsNodeBandwidth.setHardwareSn(hardwareSn); - epsNodeBandwidth.setNodeName(rmResourceRegistration.getResourceName()); - epsNodeBandwidthMapper.updateEpsNodeBandwidthByServerSn(epsNodeBandwidth); + + switch (resourceRegistration.getResourceType()) { + case "1": // 服务器类型 + // 更新拓扑管理配置 + rmEpsTopologyManagement.setServerSn(hardwareSn); + rmEpsTopologyManagement.setServerName(newResourceName); + rmEpsTopologyManagementMapper.updateRmEpsTopologyManagementByServerSn(rmEpsTopologyManagement); + + // 更新服务器收益配置表 + EpsServerRevenueConfig epsServerRevenueConfig = new EpsServerRevenueConfig(); + epsServerRevenueConfig.setHardwareSn(hardwareSn); + epsServerRevenueConfig.setNodeName(newResourceName); + epsServerRevenueConfigMapper.updateEpsServerRevenueConfigByServerSn(epsServerRevenueConfig); + + // 更新95收益信息表 + epsNodeBandwidth.setHardwareSn(hardwareSn); + epsNodeBandwidth.setNodeName(newResourceName); + epsNodeBandwidthMapper.updateEpsNodeBandwidthByServerSn(epsNodeBandwidth); + break; + + case "2": // 交换机类型 + // 更新拓扑管理配置 + rmEpsTopologyManagement.setSwitchSn(hardwareSn); + rmEpsTopologyManagement.setSwitchName(newResourceName); + rmEpsTopologyManagementMapper.updateRmEpsTopologyManagementBySwitchSn(rmEpsTopologyManagement); + + // 更新95收益信息表 + epsNodeBandwidth.setSwitchSn(hardwareSn); + epsNodeBandwidth.setUplinkSwitch(newResourceName); + epsNodeBandwidthMapper.updateEpsNodeBandwidthBySwitchSn(epsNodeBandwidth); + break; + } } // 禁止修改sn序列号 rmResourceRegistration.setHardwareSn(null); diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/AllInterfaceNameMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/AllInterfaceNameMapper.xml index c2b4dec..5ef0e0f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/AllInterfaceNameMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/AllInterfaceNameMapper.xml @@ -210,7 +210,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialDiskInfoMapper.xml b/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialDiskInfoMapper.xml index 72b26d1..2d0dfaf 100644 --- a/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialDiskInfoMapper.xml +++ b/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialDiskInfoMapper.xml @@ -30,15 +30,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and client_id = #{clientId} - and name like concat('%', #{name}, '%') - and serial = #{serial} - and total = #{total} - and write_speed = #{writeSpeed} - and read_speed = #{readSpeed} - and write_times = #{writeTimes} - and read_times = #{readTimes} - and write_bytes = #{writeBytes} - and read_bytes = #{readBytes} order by create_time desc diff --git a/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialDockerInfoMapper.xml b/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialDockerInfoMapper.xml index dcd8e8f..3fae61e 100644 --- a/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialDockerInfoMapper.xml +++ b/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialDockerInfoMapper.xml @@ -27,12 +27,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialMountPointInfoMapper.xml b/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialMountPointInfoMapper.xml index 5745b0a..eb7970f 100644 --- a/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialMountPointInfoMapper.xml +++ b/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialMountPointInfoMapper.xml @@ -26,11 +26,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and client_id = #{clientId} - and mount = #{mount} - and vfs_type = #{vfsType} - and vfs_free = #{vfsFree} - and vfs_total = #{vfsTotal} - and vfs_util = #{vfsUtil} order by create_time desc diff --git a/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialSystemInfoMapper.xml b/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialSystemInfoMapper.xml index 9238328..8c6ea2b 100644 --- a/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialSystemInfoMapper.xml +++ b/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialSystemInfoMapper.xml @@ -34,19 +34,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and client_id = #{clientId} - and os = #{os} - and arch = #{arch} - and max_proc = #{maxProc} - and run_proc_num = #{runProcNum} - and users_num = #{usersNum} - and disk_size_total = #{diskSizeTotal} - and boot_time = #{bootTime} - and uname like concat('%', #{uname}, '%') - and local_time = #{localTime} - and up_time = #{upTime} - and proc_num = #{procNum} - and time_stamp = #{timeStamp} - and uuid = #{uuid} order by create_time desc