月均日95值计算方式新增1024,资源监控模块接口新增

This commit is contained in:
gaoyutao
2025-09-17 09:34:00 +08:00
parent f9d4835d4c
commit f922fb752f
34 changed files with 827 additions and 59 deletions

View File

@@ -89,8 +89,10 @@ public class TableScheduleConfig {
.thenRun(() -> calculateServerMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1024"))
.thenRun(() -> calculateSwitchMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1000"))
.thenRun(() -> calculateSwitchMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1024"))
.thenRun(() -> calculateServerAvgMonthlyBandwidth(monthlyStartTime, monthlyEndTime))
.thenRun(() -> calculateSwitchAvgMonthlyBandwidth(monthlyStartTime, monthlyEndTime))
.thenRun(() -> calculateServerAvgMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1000"))
.thenRun(() -> calculateServerAvgMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1024"))
.thenRun(() -> calculateSwitchAvgMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1000"))
.thenRun(() -> calculateSwitchAvgMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1024"))
.exceptionally(e -> {
log.error("月度带宽计算链执行异常", e); // 仅保留最终异常捕获
return null;
@@ -145,7 +147,7 @@ public class TableScheduleConfig {
/**
* 计算服务器月平均95带宽值
*/
private void calculateServerAvgMonthlyBandwidth(String monthlyStartTime, String monthlyEndTime) {
private void calculateServerAvgMonthlyBandwidth(String monthlyStartTime, String monthlyEndTime, String calculationMode) {
log.info("开始计算服务器月平均95带宽值...");
try {
EpsNodeBandwidth epsNodeBandwidth = new EpsNodeBandwidth();
@@ -154,7 +156,7 @@ public class TableScheduleConfig {
List<AllInterfaceName> snList = allInterfaceNameService.getAllDeviceSn(new AllInterfaceName());
for (AllInterfaceName allInterfaceName : snList) {
processServerAvgBandwidth(epsNodeBandwidth, allInterfaceName);
processServerAvgBandwidth(epsNodeBandwidth, allInterfaceName, calculationMode);
}
log.info("服务器月平均95带宽值计算完成");
} catch (Exception e) {
@@ -165,7 +167,7 @@ public class TableScheduleConfig {
/**
* 处理单个服务器的平均带宽计算
*/
private void processServerAvgBandwidth(EpsNodeBandwidth epsNodeBandwidth, AllInterfaceName allInterfaceName) {
private void processServerAvgBandwidth(EpsNodeBandwidth epsNodeBandwidth, AllInterfaceName allInterfaceName, String calculationMode) {
final String deviceSn = allInterfaceName.getDeviceSn();
try {
@@ -216,6 +218,7 @@ public class TableScheduleConfig {
// 创建业务带宽对象
EpsNodeBandwidth bandwidthWithBiz = new EpsNodeBandwidth();
bandwidthWithBiz.setHardwareSn(deviceSn);
bandwidthWithBiz.setCalculationMode(calculationMode);
bandwidthWithBiz.setNodeName(serverConfig.getNodeName());
bandwidthWithBiz.setStartTime(epsNodeBandwidth.getStartTime());
bandwidthWithBiz.setEndTime(epsNodeBandwidth.getEndTime());
@@ -244,6 +247,7 @@ public class TableScheduleConfig {
// 5. 处理正常情况(无业务变更或无需处理变更)
EpsNodeBandwidth normalBandwidth = new EpsNodeBandwidth();
normalBandwidth.setHardwareSn(deviceSn);
normalBandwidth.setCalculationMode(calculationMode);
normalBandwidth.setNodeName(serverConfig.getNodeName());
normalBandwidth.setStartTime(epsNodeBandwidth.getStartTime());
normalBandwidth.setEndTime(epsNodeBandwidth.getEndTime());
@@ -260,7 +264,7 @@ public class TableScheduleConfig {
/**
* 计算交换机月平均95带宽值
*/
private void calculateSwitchAvgMonthlyBandwidth(String monthlyStartTime, String monthlyEndTime) {
private void calculateSwitchAvgMonthlyBandwidth(String monthlyStartTime, String monthlyEndTime, String calculationMode) {
log.info("开始计算交换机月平均95带宽值...");
try {
EpsNodeBandwidth epsNodeBandwidth = new EpsNodeBandwidth();
@@ -269,7 +273,7 @@ public class TableScheduleConfig {
List<AllInterfaceName> switchSnList = allInterfaceNameService.getAllSwitchSn(new AllInterfaceName());
for (AllInterfaceName switchSnMsg : switchSnList) {
processSwitchAvgBandwidth(epsNodeBandwidth, switchSnMsg);
processSwitchAvgBandwidth(epsNodeBandwidth, switchSnMsg, calculationMode);
}
log.info("交换机月平均95带宽值计算完成");
} catch (Exception e) {
@@ -280,7 +284,7 @@ public class TableScheduleConfig {
/**
* 处理单个交换机的平均带宽计算
*/
private void processSwitchAvgBandwidth(EpsNodeBandwidth epsNodeBandwidth, AllInterfaceName switchSnMsg) {
private void processSwitchAvgBandwidth(EpsNodeBandwidth epsNodeBandwidth, AllInterfaceName switchSnMsg, String calculationMode) {
final String switchSn = switchSnMsg.getSwitchSn();
try {
@@ -346,6 +350,7 @@ public class TableScheduleConfig {
// 创建业务带宽对象
EpsNodeBandwidth bandwidthWithBiz = new EpsNodeBandwidth();
bandwidthWithBiz.setSwitchSn(switchSn);
bandwidthWithBiz.setCalculationMode(calculationMode);
bandwidthWithBiz.setInterfaceName(topology.getInterfaceName());
bandwidthWithBiz.setHardwareSn(serverSn);
bandwidthWithBiz.setNodeName(topology.getServerName());
@@ -377,6 +382,7 @@ public class TableScheduleConfig {
// 5. 处理普通情况(无变更记录)
EpsNodeBandwidth normalBandwidth = new EpsNodeBandwidth();
normalBandwidth.setSwitchSn(switchSn);
normalBandwidth.setCalculationMode(calculationMode);
normalBandwidth.setInterfaceName(topology.getInterfaceName());
normalBandwidth.setHardwareSn(topology.getServerSn());
normalBandwidth.setNodeName(topology.getServerName());
@@ -394,6 +400,7 @@ public class TableScheduleConfig {
// 5. 处理机房出口情况
EpsNodeBandwidth normalBandwidth = new EpsNodeBandwidth();
normalBandwidth.setSwitchSn(switchSn);
normalBandwidth.setCalculationMode(calculationMode);
normalBandwidth.setInterfaceName(topology.getInterfaceName());
normalBandwidth.setInterfaceLinkDeviceType(topology.getConnectedDeviceType());
normalBandwidth.setStartTime(epsNodeBandwidth.getStartTime());

View File

@@ -0,0 +1,67 @@
package com.ruoyi.system.controller;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageDomain;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.system.domain.RmResourceGroup;
import com.ruoyi.system.domain.RmResourceRegistration;
import com.ruoyi.system.service.EpsInitialTrafficDataService;
import com.ruoyi.system.service.IRmResourceGroupService;
import com.ruoyi.system.service.IRmResourceRegistrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 资源监控API
*
* @author gyt
* @date 2025-08-25
*/
@RestController
@RequestMapping("/resourceMonitor")
public class ResourceMonitorController extends BaseController
{
@Autowired
private EpsInitialTrafficDataService epsInitialTrafficDataService;
@Autowired
private IRmResourceGroupService rmResourceGroupService;
@Autowired
private IRmResourceRegistrationService rmResourceRegistrationService;
/**
* 获取资源分组列表
* @return
*/
@GetMapping("resourceGroupList")
public AjaxResult resourceGroupList(){
RmResourceGroup rmResourceGroup = new RmResourceGroup();
return success(rmResourceGroupService.selectRmResourceGroupList(rmResourceGroup));
}
/**
* 服务器整体发送带宽利用率
* @return
*/
@GetMapping("trafficRateByServer")
public AjaxResult trafficRateByServer(){
return success(epsInitialTrafficDataService.trafficRateByServer());
}
/**
* 获取资源列表
* @return
*/
@PostMapping("getRegisterListByGroupId")
public TableDataInfo getRegisterListByGroupId(@RequestBody RmResourceGroup rmResourceGroup){
// 拿到注册信息
PageDomain pageDomain = new PageDomain();
pageDomain.setPageNum(rmResourceGroup.getPageNum());
pageDomain.setPageSize(rmResourceGroup.getPageSize());
startPage(pageDomain);
List<RmResourceRegistration> list = rmResourceGroupService.getRegisterList(rmResourceGroup);
return getDataTable(list);
}
}

View File

@@ -329,6 +329,24 @@ public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService
));
mapList.add(nodeData);
});
if("2".equals(epsNodeBandwidth.getResourceType())){
// 按interfaceName 升序(处理 null 值)
mapList.sort((map1, map2) -> {
// 按 interfaceName 升序(处理 null 值)
String interfaceName1 = (String) map1.get("interfaceName");
String interfaceName2 = (String) map2.get("interfaceName");
if (interfaceName1 == null && interfaceName2 == null) {
return 0; // 两者都为 null视为相等
} else if (interfaceName1 == null) {
return -1; // null 排在前面(升序)
} else if (interfaceName2 == null) {
return 1; // null 排在前面(升序)
} else {
return interfaceName1.compareTo(interfaceName2); // 正常比较
}
});
}
return mapList;
}

View File

@@ -457,6 +457,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
}
}
if("2".equals(rmEpsTopologyManagement.getConnectedDeviceType())){
queryParam.setServerSn(null);
calculateNormalSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
}
}

View File

@@ -248,6 +248,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="businessId != '' and businessId != null">
and business_id = #{businessId}
</if>
<if test="calculationMode != '' and calculationMode != null">
and calculation_mode = #{calculationMode}
</if>
</where>
</select>