优化实时95值计算功能、服务器收益功能、用户自定义列展示、交换机基础数据采集
This commit is contained in:
@@ -0,0 +1,240 @@
|
||||
package com.ruoyi.common.core.utils;
|
||||
|
||||
public class ConvertOtherTypeUtil {
|
||||
/**
|
||||
* 根据接口类型代码获取对应的类型名称
|
||||
* @param typeCode 接口类型代码 (1, 2, 3...)
|
||||
* @return 接口类型名称,如果未找到返回 "unknown"
|
||||
*/
|
||||
public static String getInterfaceTypeName(int typeCode) {
|
||||
switch (typeCode) {
|
||||
case 1: return "other";
|
||||
case 2: return "regular1822";
|
||||
case 3: return "hdh1822";
|
||||
case 4: return "ddnX25";
|
||||
case 5: return "rfc877x25";
|
||||
case 6: return "ethernetCsmacd";
|
||||
case 7: return "iso88023Csmacd";
|
||||
case 8: return "iso88024TokenBus";
|
||||
case 9: return "iso88025TokenRing";
|
||||
case 10: return "iso88026Man";
|
||||
case 11: return "starLan";
|
||||
case 12: return "proteon10Mbit";
|
||||
case 13: return "proteon80Mbit";
|
||||
case 14: return "hyperchannel";
|
||||
case 15: return "fddi";
|
||||
case 16: return "lapb";
|
||||
case 17: return "sdlc";
|
||||
case 18: return "ds1";
|
||||
case 19: return "e1";
|
||||
case 20: return "basicISDN";
|
||||
case 21: return "primaryISDN";
|
||||
case 22: return "propPointToPointSerial";
|
||||
case 23: return "ppp";
|
||||
case 24: return "softwareLoopback";
|
||||
case 25: return "eon";
|
||||
case 26: return "ethernet3Mbit";
|
||||
case 27: return "nsip";
|
||||
case 28: return "slip";
|
||||
case 29: return "ultra";
|
||||
case 30: return "ds3";
|
||||
case 31: return "sip";
|
||||
case 32: return "frameRelay";
|
||||
case 33: return "rs232";
|
||||
case 34: return "para";
|
||||
case 35: return "arcnet";
|
||||
case 36: return "arcnetPlus";
|
||||
case 37: return "atm";
|
||||
case 38: return "miox25";
|
||||
case 39: return "sonet";
|
||||
case 40: return "x25ple";
|
||||
case 41: return "iso88022llc";
|
||||
case 42: return "localTalk";
|
||||
case 43: return "smdsDxi";
|
||||
case 44: return "frameRelayService";
|
||||
case 45: return "v35";
|
||||
case 46: return "hssi";
|
||||
case 47: return "hippi";
|
||||
case 48: return "modem";
|
||||
case 49: return "aal5";
|
||||
case 50: return "sonetPath";
|
||||
case 51: return "sonetVT";
|
||||
case 52: return "smdsIcip";
|
||||
case 53: return "propVirtual";
|
||||
case 54: return "propMultiplexor";
|
||||
case 55: return "ieee80212";
|
||||
case 56: return "fibreChannel";
|
||||
case 57: return "hippiInterface";
|
||||
case 58: return "frameRelayInterconnect";
|
||||
case 59: return "aflane8023";
|
||||
case 60: return "aflane8025";
|
||||
case 61: return "cctEmul";
|
||||
case 62: return "fastEther";
|
||||
case 63: return "isdn";
|
||||
case 64: return "v11";
|
||||
case 65: return "v36";
|
||||
case 66: return "g703at64k";
|
||||
case 67: return "g703at2mb";
|
||||
case 68: return "qllc";
|
||||
case 69: return "fastEtherFX";
|
||||
case 70: return "channel";
|
||||
case 71: return "ieee80211";
|
||||
case 72: return "ibm370parChan";
|
||||
case 73: return "escon";
|
||||
case 74: return "dlsw";
|
||||
case 75: return "isdns";
|
||||
case 76: return "isdnu";
|
||||
case 77: return "lapd";
|
||||
case 78: return "ipSwitch";
|
||||
case 79: return "rsrb";
|
||||
case 80: return "atmLogical";
|
||||
case 81: return "ds0";
|
||||
case 82: return "ds0Bundle";
|
||||
case 83: return "bsc";
|
||||
case 84: return "async";
|
||||
case 85: return "cnr";
|
||||
case 86: return "iso88025Dtr";
|
||||
case 87: return "eplrs";
|
||||
case 88: return "arap";
|
||||
case 89: return "propCnls";
|
||||
case 90: return "hostPad";
|
||||
case 91: return "termPad";
|
||||
case 92: return "frameRelayMPI";
|
||||
case 93: return "x213";
|
||||
case 94: return "adsl";
|
||||
case 95: return "radsl";
|
||||
case 96: return "sdsl";
|
||||
case 97: return "vdsl";
|
||||
case 98: return "iso88025CRFPInt";
|
||||
case 99: return "myrinet";
|
||||
case 100: return "voiceEM";
|
||||
case 101: return "voiceFXO";
|
||||
case 102: return "voiceFXS";
|
||||
case 103: return "voiceEncap";
|
||||
case 104: return "voiceOverIp";
|
||||
case 105: return "atmDxi";
|
||||
case 106: return "atmFuni";
|
||||
case 107: return "atmIma";
|
||||
case 108: return "pppMultilinkBundle";
|
||||
case 109: return "ipOverCdlc";
|
||||
case 110: return "ipOverClaw";
|
||||
case 111: return "stackToStack";
|
||||
case 112: return "virtualIpAddress";
|
||||
case 113: return "mpc";
|
||||
case 114: return "ipOverAtm";
|
||||
case 115: return "iso88025Fiber";
|
||||
case 116: return "tdlc";
|
||||
case 117: return "gigabitEthernet";
|
||||
case 118: return "hdlc";
|
||||
case 119: return "lapf";
|
||||
case 120: return "v37";
|
||||
case 121: return "x25mlp";
|
||||
case 122: return "x25huntGroup";
|
||||
case 123: return "trasnpHdlc";
|
||||
case 124: return "interleave";
|
||||
case 125: return "fast";
|
||||
case 126: return "ip";
|
||||
case 127: return "docsCableMaclayer";
|
||||
case 128: return "docsCableDownstream";
|
||||
case 129: return "docsCableUpstream";
|
||||
case 130: return "a12MppSwitch";
|
||||
case 131: return "tunnel";
|
||||
case 132: return "coffee";
|
||||
case 133: return "ces";
|
||||
case 134: return "atmSubInterface";
|
||||
case 135: return "l2vlan";
|
||||
case 136: return "l3ipvlan";
|
||||
case 137: return "l3ipxvlan";
|
||||
case 138: return "digitalPowerline";
|
||||
case 139: return "mediaMailOverIp";
|
||||
case 140: return "dtm";
|
||||
case 141: return "dcn";
|
||||
case 142: return "ipForward";
|
||||
case 143: return "msdsl";
|
||||
case 144: return "ieee1394";
|
||||
case 145: return "if-gsn";
|
||||
case 146: return "dvbRccMacLayer";
|
||||
case 147: return "dvbRccDownstream";
|
||||
case 148: return "dvbRccUpstream";
|
||||
case 149: return "atmVirtual";
|
||||
case 150: return "mplsTunnel";
|
||||
case 151: return "srp";
|
||||
case 152: return "voiceOverAtm";
|
||||
case 153: return "voiceOverFrameRelay";
|
||||
case 154: return "idsl";
|
||||
case 155: return "compositeLink";
|
||||
case 156: return "ss7SigLink";
|
||||
case 157: return "propWirelessP2P";
|
||||
case 158: return "frForward";
|
||||
case 159: return "rfc1483";
|
||||
case 160: return "usb";
|
||||
case 161: return "ieee8023adLag";
|
||||
case 162: return "bgppolicyaccounting";
|
||||
case 163: return "frf16MfrBundle";
|
||||
case 164: return "h323Gatekeeper";
|
||||
case 165: return "h323Proxy";
|
||||
case 166: return "mpls";
|
||||
case 167: return "mfSigLink";
|
||||
case 168: return "hdsl2";
|
||||
case 169: return "shdsl";
|
||||
case 170: return "ds1FDL";
|
||||
case 171: return "pos";
|
||||
case 172: return "dvbAsiIn";
|
||||
case 173: return "dvbAsiOut";
|
||||
case 174: return "plc";
|
||||
case 175: return "nfas";
|
||||
case 176: return "tr008";
|
||||
case 177: return "gr303RDT";
|
||||
case 178: return "gr303IDT";
|
||||
case 179: return "isup";
|
||||
case 180: return "propDocsWirelessMaclayer";
|
||||
case 181: return "propDocsWirelessDownstream";
|
||||
case 182: return "propDocsWirelessUpstream";
|
||||
case 183: return "hiperlan2";
|
||||
case 184: return "propBWAp2Mp";
|
||||
case 185: return "sonetOverheadChannel";
|
||||
case 186: return "digitalWrapperOverheadChannel";
|
||||
case 187: return "aal2";
|
||||
case 188: return "radioMAC";
|
||||
case 189: return "atmRadio";
|
||||
case 190: return "imt";
|
||||
case 191: return "mvl";
|
||||
case 192: return "reachDSL";
|
||||
case 193: return "frDlciEndPt";
|
||||
case 194: return "atmVciEndPt";
|
||||
case 195: return "opticalChannel";
|
||||
case 196: return "opticalTransport";
|
||||
case 197: return "propAtm";
|
||||
case 198: return "voiceOverCable";
|
||||
case 199: return "infiniband";
|
||||
case 200: return "teLink";
|
||||
case 201: return "q2931";
|
||||
case 202: return "virtualTg";
|
||||
case 203: return "sipTg";
|
||||
case 204: return "sipSig";
|
||||
case 205: return "docsCableUpstreamChannel";
|
||||
case 206: return "econet";
|
||||
case 207: return "pon155";
|
||||
case 208: return "pon622";
|
||||
case 209: return "bridge";
|
||||
case 210: return "linegroup";
|
||||
case 211: return "voiceEMFGD";
|
||||
case 212: return "voiceFGDEANA";
|
||||
case 213: return "voiceDID";
|
||||
case 214: return "mpegTransport";
|
||||
case 215: return "sixToFour";
|
||||
case 216: return "gtp";
|
||||
case 217: return "pdnEtherLoop1";
|
||||
case 218: return "pdnEtherLoop2";
|
||||
case 219: return "opticalChannelGroup";
|
||||
case 220: return "homepna";
|
||||
case 221: return "gfp";
|
||||
case 222: return "ciscoISLvlan";
|
||||
case 223: return "actelisMetaLOOP";
|
||||
case 224: return "fcipLink";
|
||||
case 225: return "rpr";
|
||||
case 226: return "qam";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -374,4 +374,10 @@ public class SpeedUtils {
|
||||
|
||||
return recommendedUnit;
|
||||
}
|
||||
|
||||
// Mbit 转 Bit 换算:1 Mbit = 1,000,000 Bit
|
||||
public static BigDecimal mbitToBit(BigDecimal mbitValue) {
|
||||
if (mbitValue == null) return BigDecimal.ZERO;
|
||||
return mbitValue.multiply(new BigDecimal("1000000"));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.system.config;
|
||||
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.system.domain.*;
|
||||
import com.ruoyi.system.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -73,7 +72,7 @@ public class TableScheduleConfig {
|
||||
() -> initialSwitchInfoDetailsService.calculateSwitch95BandwidthDaily(initialSwitchInfoDetails, dailyStartTime, dailyEndTime, "1024")));
|
||||
}
|
||||
// 每天5点04执行 计算金山95带宽值/日
|
||||
@Scheduled(cron = "0 4 5 * * ?", zone = "Asia/Shanghai")
|
||||
// @Scheduled(cron = "0 4 5 * * ?", zone = "Asia/Shanghai")
|
||||
public void calculateJinShan95() {
|
||||
// 获取昨天的日期范围(北京时间)
|
||||
LocalDate yesterday = LocalDate.now(ZoneId.of("Asia/Shanghai")).minusDays(1);
|
||||
@@ -188,96 +187,87 @@ public class TableScheduleConfig {
|
||||
* 处理单个服务器的平均带宽计算
|
||||
*/
|
||||
private void processServerAvgBandwidth(EpsNodeBandwidth epsNodeBandwidth, AllInterfaceName allInterfaceName, String calculationMode) {
|
||||
final String deviceSn = allInterfaceName.getDeviceSn();
|
||||
final String clientId = allInterfaceName.getClientId();
|
||||
|
||||
try {
|
||||
// 1. 设置基础设备信息
|
||||
epsNodeBandwidth.setHardwareSn(deviceSn);
|
||||
epsNodeBandwidth.setClientId(clientId);
|
||||
// 查询业务变更记录
|
||||
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
|
||||
changeQuery.setClientId(clientId);
|
||||
changeQuery.setStartTime(epsNodeBandwidth.getStartTime());
|
||||
changeQuery.setEndTime(epsNodeBandwidth.getEndTime());
|
||||
|
||||
// 2. 查询服务器配置
|
||||
EpsServerRevenueConfig queryConfig = new EpsServerRevenueConfig();
|
||||
queryConfig.setHardwareSn(deviceSn);
|
||||
List<EpsServerRevenueConfig> configList = epsServerRevenueConfigService.selectEpsServerRevenueConfigList(queryConfig);
|
||||
EpsServerRevenueConfig serverConfig = configList.isEmpty() ? new EpsServerRevenueConfig() : configList.get(0);
|
||||
epsNodeBandwidth.setNodeName(serverConfig.getNodeName());
|
||||
List<EpsMethodChangeRecord> records = epsMethodChangeRecordService.selectEpsMethodChangeRecordList(changeQuery);
|
||||
|
||||
// 3. 检查是否需要处理业务变更
|
||||
boolean shouldProcessChange = serverConfig.getUpdateTime() != null
|
||||
&& epsNodeBandwidth.getStartTime() != null
|
||||
&& epsNodeBandwidth.getStartTime().length() >= 10
|
||||
&& "1".equals(serverConfig.getChanged())
|
||||
&& DateUtils.parseDateToStr("yyyy-MM", serverConfig.getUpdateTime())
|
||||
.equals(epsNodeBandwidth.getStartTime().substring(0, 7));
|
||||
// 按businessCode分组处理(修复null key问题)
|
||||
if (!records.isEmpty()) {
|
||||
Map<String, List<EpsMethodChangeRecord>> groupedRecords = records.stream()
|
||||
.filter(record -> record.getBusinessCode() != null) // 过滤掉businessCode为null的记录
|
||||
.collect(Collectors.groupingBy(EpsMethodChangeRecord::getBusinessCode));
|
||||
|
||||
// 4. 处理业务变更情况
|
||||
if (shouldProcessChange) {
|
||||
// 查询业务变更记录
|
||||
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
|
||||
changeQuery.setHardwareSn(deviceSn);
|
||||
changeQuery.setStartTime(epsNodeBandwidth.getStartTime());
|
||||
changeQuery.setEndTime(epsNodeBandwidth.getEndTime());
|
||||
// 处理每个业务分组
|
||||
for (Map.Entry<String, List<EpsMethodChangeRecord>> entry : groupedRecords.entrySet()) {
|
||||
String businessCode = entry.getKey();
|
||||
// 取第一个有效业务名称(同businessCode的业务名称应该相同)
|
||||
String businessName = entry.getValue().stream()
|
||||
.filter(r -> r.getBusinessName() != null)
|
||||
.findFirst()
|
||||
.map(EpsMethodChangeRecord::getBusinessName)
|
||||
.orElse("未知业务");
|
||||
|
||||
List<EpsMethodChangeRecord> records = epsMethodChangeRecordService.selectEpsMethodChangeRecordList(changeQuery);
|
||||
// 创建业务带宽对象
|
||||
EpsNodeBandwidth bandwidthWithBiz = new EpsNodeBandwidth();
|
||||
bandwidthWithBiz.setClientId(clientId);
|
||||
bandwidthWithBiz.setCalculationMode(calculationMode);
|
||||
bandwidthWithBiz.setStartTime(epsNodeBandwidth.getStartTime());
|
||||
bandwidthWithBiz.setEndTime(epsNodeBandwidth.getEndTime());
|
||||
bandwidthWithBiz.setBusinessId(businessCode);
|
||||
bandwidthWithBiz.setBusinessName(businessName);
|
||||
bandwidthWithBiz.setResourceType("1");
|
||||
|
||||
// 按businessCode分组处理(修复null key问题)
|
||||
if (!records.isEmpty()) {
|
||||
Map<String, List<EpsMethodChangeRecord>> groupedRecords = records.stream()
|
||||
.filter(record -> record.getBusinessCode() != null) // 过滤掉businessCode为null的记录
|
||||
.collect(Collectors.groupingBy(EpsMethodChangeRecord::getBusinessCode));
|
||||
|
||||
// 处理每个业务分组
|
||||
for (Map.Entry<String, List<EpsMethodChangeRecord>> entry : groupedRecords.entrySet()) {
|
||||
String businessCode = entry.getKey();
|
||||
// 取第一个有效业务名称(同businessCode的业务名称应该相同)
|
||||
String businessName = entry.getValue().stream()
|
||||
.filter(r -> r.getBusinessName() != null)
|
||||
.findFirst()
|
||||
.map(EpsMethodChangeRecord::getBusinessName)
|
||||
.orElse("未知业务");
|
||||
|
||||
// 创建业务带宽对象
|
||||
EpsNodeBandwidth bandwidthWithBiz = new EpsNodeBandwidth();
|
||||
bandwidthWithBiz.setHardwareSn(deviceSn);
|
||||
bandwidthWithBiz.setCalculationMode(calculationMode);
|
||||
bandwidthWithBiz.setNodeName(serverConfig.getNodeName());
|
||||
bandwidthWithBiz.setStartTime(epsNodeBandwidth.getStartTime());
|
||||
bandwidthWithBiz.setEndTime(epsNodeBandwidth.getEndTime());
|
||||
bandwidthWithBiz.setBusinessId(businessCode);
|
||||
bandwidthWithBiz.setBusinessName(businessName);
|
||||
bandwidthWithBiz.setResourceType("1");
|
||||
|
||||
// 执行计算
|
||||
epsNodeBandwidthService.calculateAvg(bandwidthWithBiz);
|
||||
}
|
||||
|
||||
// 处理businessCode为null的记录(如果有)
|
||||
List<EpsMethodChangeRecord> nullBusinessRecords = records.stream()
|
||||
.filter(record -> record.getBusinessCode() == null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!nullBusinessRecords.isEmpty()) {
|
||||
log.warn("服务器 {} 有 {} 条记录的businessCode为null", deviceSn, nullBusinessRecords.size());
|
||||
// 可以选择记录日志或进行其他处理
|
||||
}
|
||||
|
||||
return; // 业务变更处理完成后直接返回
|
||||
// 执行计算
|
||||
epsNodeBandwidthService.calculateAvg(bandwidthWithBiz);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理businessCode为null的记录(如果有)
|
||||
List<EpsMethodChangeRecord> nullBusinessRecords = records.stream()
|
||||
.filter(record -> record.getBusinessCode() == null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!nullBusinessRecords.isEmpty()) {
|
||||
log.warn("服务器 {} 有 {} 条记录的businessCode为null", clientId, nullBusinessRecords.size());
|
||||
// 可以选择记录日志或进行其他处理
|
||||
}
|
||||
|
||||
return; // 业务变更处理完成后直接返回
|
||||
}
|
||||
String businessCode = null;
|
||||
String businessName = null;
|
||||
// 查询绑定的业务
|
||||
EpsMethodChangeRecord queryParam = new EpsMethodChangeRecord();
|
||||
queryParam.setClientId(clientId);
|
||||
List<EpsMethodChangeRecord> recordList = epsMethodChangeRecordService.selectEpsMethodChangeRecordList(queryParam);
|
||||
if(!recordList.isEmpty()){
|
||||
EpsMethodChangeRecord record = recordList.stream()
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
businessCode = record.getBusinessCode();
|
||||
businessName = record.getBusinessName();
|
||||
}
|
||||
// 5. 处理正常情况(无业务变更或无需处理变更)
|
||||
EpsNodeBandwidth normalBandwidth = new EpsNodeBandwidth();
|
||||
normalBandwidth.setHardwareSn(deviceSn);
|
||||
normalBandwidth.setClientId(clientId);
|
||||
normalBandwidth.setCalculationMode(calculationMode);
|
||||
normalBandwidth.setNodeName(serverConfig.getNodeName());
|
||||
normalBandwidth.setStartTime(epsNodeBandwidth.getStartTime());
|
||||
normalBandwidth.setEndTime(epsNodeBandwidth.getEndTime());
|
||||
normalBandwidth.setBusinessId(serverConfig.getBusinessCode());
|
||||
normalBandwidth.setBusinessName(serverConfig.getBusinessName());
|
||||
normalBandwidth.setBusinessId(businessCode);
|
||||
normalBandwidth.setBusinessName(businessName);
|
||||
normalBandwidth.setResourceType("1");
|
||||
epsNodeBandwidthService.calculateAvg(normalBandwidth);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("处理服务器 {} 平均带宽失败", deviceSn, e);
|
||||
log.error("处理服务器 {} 平均带宽失败", clientId, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,131 +295,128 @@ public class TableScheduleConfig {
|
||||
* 处理单个交换机的平均带宽计算
|
||||
*/
|
||||
private void processSwitchAvgBandwidth(EpsNodeBandwidth epsNodeBandwidth, AllInterfaceName switchSnMsg, String calculationMode) {
|
||||
final String switchSn = switchSnMsg.getSwitchSn();
|
||||
final String clientId = switchSnMsg.getClientId();
|
||||
|
||||
try {
|
||||
// 1. 查询交换机拓扑信息
|
||||
RmEpsTopologyManagement managementQuery = new RmEpsTopologyManagement();
|
||||
managementQuery.setSwitchSn(switchSn);
|
||||
managementQuery.setClientId(clientId);
|
||||
List<RmEpsTopologyManagement> topologyList = rmEpsTopologyManagementService.selectRmEpsTopologyManagementList(managementQuery);
|
||||
if(!topologyList.isEmpty()){
|
||||
for (RmEpsTopologyManagement topology : topologyList) {
|
||||
epsNodeBandwidth.setClientId(clientId);
|
||||
epsNodeBandwidth.setInterfaceName(topology.getInterfaceName());
|
||||
|
||||
// 2. 设置基础信息
|
||||
RmEpsTopologyManagement topology = topologyList.isEmpty() ? new RmEpsTopologyManagement() : topologyList.get(0);
|
||||
epsNodeBandwidth.setSwitchSn(switchSn);
|
||||
epsNodeBandwidth.setInterfaceName(topology.getInterfaceName());
|
||||
// 3. 判断连接设备类型
|
||||
boolean isServerConnected = "1".equals(topology.getConnectedDeviceType());
|
||||
|
||||
// 3. 判断连接设备类型
|
||||
boolean isServerConnected = "1".equals(topology.getConnectedDeviceType());
|
||||
// 4. 处理服务器连接的情况
|
||||
if (isServerConnected && topology.getServerClientId() != null) {
|
||||
String serverClientId = topology.getServerClientId();
|
||||
String serverSn = topology.getServerSn();
|
||||
// 查询业务变更记录
|
||||
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
|
||||
changeQuery.setClientId(serverClientId);
|
||||
changeQuery.setStartTime(epsNodeBandwidth.getStartTime());
|
||||
changeQuery.setEndTime(epsNodeBandwidth.getEndTime());
|
||||
List<EpsMethodChangeRecord> records = epsMethodChangeRecordService.selectEpsMethodChangeRecordList(changeQuery);
|
||||
|
||||
// 4. 处理服务器连接的情况
|
||||
if (isServerConnected && topology.getServerSn() != null) {
|
||||
String serverSn = topology.getServerSn();
|
||||
epsNodeBandwidth.setHardwareSn(serverSn);
|
||||
// 查询服务器配置
|
||||
EpsServerRevenueConfig queryConfig = new EpsServerRevenueConfig();
|
||||
queryConfig.setHardwareSn(serverSn);
|
||||
List<EpsServerRevenueConfig> configList = epsServerRevenueConfigService.selectEpsServerRevenueConfigList(queryConfig);
|
||||
EpsServerRevenueConfig serverConfig = configList.isEmpty() ? new EpsServerRevenueConfig() : configList.get(0);
|
||||
epsNodeBandwidth.setNodeName(serverConfig.getNodeName());
|
||||
// 按businessCode分组处理
|
||||
if (!records.isEmpty()) {
|
||||
Map<String, List<EpsMethodChangeRecord>> groupedRecords = records.stream()
|
||||
.filter(record -> record.getBusinessCode() != null) // 过滤掉businessCode为null的记录
|
||||
.collect(Collectors.groupingBy(EpsMethodChangeRecord::getBusinessCode));
|
||||
|
||||
// 检查是否需要处理业务变更
|
||||
boolean shouldProcessChange = serverConfig.getUpdateTime() != null
|
||||
&& epsNodeBandwidth.getStartTime() != null
|
||||
&& epsNodeBandwidth.getStartTime().length() >= 10
|
||||
&& "1".equals(serverConfig.getChanged())
|
||||
&& DateUtils.parseDateToStr("yyyy-MM", serverConfig.getUpdateTime())
|
||||
.equals(epsNodeBandwidth.getStartTime().substring(0, 7));
|
||||
// 处理每个业务分组
|
||||
for (Map.Entry<String, List<EpsMethodChangeRecord>> entry : groupedRecords.entrySet()) {
|
||||
String businessCode = entry.getKey();
|
||||
List<EpsMethodChangeRecord> businessRecords = entry.getValue();
|
||||
|
||||
if(shouldProcessChange){
|
||||
// 查询业务变更记录
|
||||
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
|
||||
changeQuery.setHardwareSn(serverSn);
|
||||
changeQuery.setStartTime(epsNodeBandwidth.getStartTime());
|
||||
changeQuery.setEndTime(epsNodeBandwidth.getEndTime());
|
||||
// 取第一个有效业务名称
|
||||
String businessName = businessRecords.stream()
|
||||
.filter(r -> r.getBusinessName() != null)
|
||||
.findFirst()
|
||||
.map(EpsMethodChangeRecord::getBusinessName)
|
||||
.orElse("未知业务");
|
||||
|
||||
List<EpsMethodChangeRecord> records = epsMethodChangeRecordService.selectEpsMethodChangeRecordList(changeQuery);
|
||||
// 创建业务带宽对象
|
||||
EpsNodeBandwidth bandwidthWithBiz = new EpsNodeBandwidth();
|
||||
bandwidthWithBiz.setClientId(clientId);
|
||||
bandwidthWithBiz.setCalculationMode(calculationMode);
|
||||
bandwidthWithBiz.setInterfaceName(topology.getInterfaceName());
|
||||
bandwidthWithBiz.setHardwareSn(serverSn);
|
||||
bandwidthWithBiz.setUplinkSwitch(topology.getSwitchName());
|
||||
bandwidthWithBiz.setInterfaceLinkDeviceType(topology.getConnectedDeviceType());
|
||||
bandwidthWithBiz.setStartTime(epsNodeBandwidth.getStartTime());
|
||||
bandwidthWithBiz.setEndTime(epsNodeBandwidth.getEndTime());
|
||||
bandwidthWithBiz.setBusinessId(businessCode);
|
||||
bandwidthWithBiz.setBusinessName(businessName);
|
||||
bandwidthWithBiz.setResourceType("2");
|
||||
bandwidthWithBiz.setServerClientId(serverClientId);
|
||||
// 执行计算
|
||||
epsNodeBandwidthService.calculateAvg(bandwidthWithBiz);
|
||||
}
|
||||
|
||||
// 按businessCode分组处理
|
||||
if (!records.isEmpty()) {
|
||||
Map<String, List<EpsMethodChangeRecord>> groupedRecords = records.stream()
|
||||
.filter(record -> record.getBusinessCode() != null) // 过滤掉businessCode为null的记录
|
||||
.collect(Collectors.groupingBy(EpsMethodChangeRecord::getBusinessCode));
|
||||
// 处理businessCode为null的记录(如果有)
|
||||
List<EpsMethodChangeRecord> nullBusinessRecords = records.stream()
|
||||
.filter(record -> record.getBusinessCode() == null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 处理每个业务分组
|
||||
for (Map.Entry<String, List<EpsMethodChangeRecord>> entry : groupedRecords.entrySet()) {
|
||||
String businessCode = entry.getKey();
|
||||
List<EpsMethodChangeRecord> businessRecords = entry.getValue();
|
||||
if (!nullBusinessRecords.isEmpty()) {
|
||||
log.warn("交换机 {} 有 {} 条记录的businessCode为null", clientId, nullBusinessRecords.size());
|
||||
// 可以选择记录日志或进行其他处理
|
||||
}
|
||||
|
||||
// 取第一个有效业务名称
|
||||
String businessName = businessRecords.stream()
|
||||
.filter(r -> r.getBusinessName() != null)
|
||||
.findFirst()
|
||||
.map(EpsMethodChangeRecord::getBusinessName)
|
||||
.orElse("未知业务");
|
||||
|
||||
// 创建业务带宽对象
|
||||
EpsNodeBandwidth bandwidthWithBiz = new EpsNodeBandwidth();
|
||||
bandwidthWithBiz.setSwitchSn(switchSn);
|
||||
bandwidthWithBiz.setCalculationMode(calculationMode);
|
||||
bandwidthWithBiz.setInterfaceName(topology.getInterfaceName());
|
||||
bandwidthWithBiz.setHardwareSn(serverSn);
|
||||
bandwidthWithBiz.setNodeName(topology.getServerName());
|
||||
bandwidthWithBiz.setUplinkSwitch(topology.getSwitchName());
|
||||
bandwidthWithBiz.setInterfaceLinkDeviceType(topology.getConnectedDeviceType());
|
||||
bandwidthWithBiz.setStartTime(epsNodeBandwidth.getStartTime());
|
||||
bandwidthWithBiz.setEndTime(epsNodeBandwidth.getEndTime());
|
||||
bandwidthWithBiz.setBusinessId(businessCode);
|
||||
bandwidthWithBiz.setBusinessName(businessName);
|
||||
bandwidthWithBiz.setResourceType("2");
|
||||
|
||||
// 执行计算
|
||||
epsNodeBandwidthService.calculateAvg(bandwidthWithBiz);
|
||||
return; // 业务变更处理完成后直接返回
|
||||
}else{
|
||||
String businessCode = null;
|
||||
String businessName = null;
|
||||
// 查询绑定的业务
|
||||
EpsMethodChangeRecord queryParam = new EpsMethodChangeRecord();
|
||||
queryParam.setClientId(clientId);
|
||||
queryParam.setTrafficPort(topology.getServerPort());
|
||||
List<EpsMethodChangeRecord> recordList = epsMethodChangeRecordService.selectEpsMethodChangeRecordList(queryParam);
|
||||
if(!recordList.isEmpty()){
|
||||
EpsMethodChangeRecord record = recordList.stream()
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
businessCode = record.getBusinessCode();
|
||||
businessName = record.getBusinessName();
|
||||
}
|
||||
// 5. 处理普通情况(无变更记录)
|
||||
EpsNodeBandwidth normalBandwidth = new EpsNodeBandwidth();
|
||||
normalBandwidth.setClientId(clientId);
|
||||
normalBandwidth.setBusinessId(businessCode);
|
||||
normalBandwidth.setBusinessName(businessName);
|
||||
normalBandwidth.setCalculationMode(calculationMode);
|
||||
normalBandwidth.setInterfaceName(topology.getInterfaceName());
|
||||
normalBandwidth.setHardwareSn(topology.getServerSn());
|
||||
normalBandwidth.setUplinkSwitch(topology.getSwitchName());
|
||||
normalBandwidth.setInterfaceLinkDeviceType(topology.getConnectedDeviceType());
|
||||
normalBandwidth.setStartTime(epsNodeBandwidth.getStartTime());
|
||||
normalBandwidth.setEndTime(epsNodeBandwidth.getEndTime());
|
||||
normalBandwidth.setResourceType("2");
|
||||
normalBandwidth.setServerClientId(serverClientId);
|
||||
epsNodeBandwidthService.calculateAvg(normalBandwidth);
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理businessCode为null的记录(如果有)
|
||||
List<EpsMethodChangeRecord> nullBusinessRecords = records.stream()
|
||||
.filter(record -> record.getBusinessCode() == null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!nullBusinessRecords.isEmpty()) {
|
||||
log.warn("交换机 {} 有 {} 条记录的businessCode为null", switchSn, nullBusinessRecords.size());
|
||||
// 可以选择记录日志或进行其他处理
|
||||
}
|
||||
|
||||
return; // 业务变更处理完成后直接返回
|
||||
}
|
||||
}else{
|
||||
// 5. 处理普通情况(无变更记录)
|
||||
// 5. 处理机房出口情况
|
||||
EpsNodeBandwidth normalBandwidth = new EpsNodeBandwidth();
|
||||
normalBandwidth.setSwitchSn(switchSn);
|
||||
normalBandwidth.setClientId(clientId);
|
||||
normalBandwidth.setCalculationMode(calculationMode);
|
||||
normalBandwidth.setInterfaceName(topology.getInterfaceName());
|
||||
normalBandwidth.setHardwareSn(topology.getServerSn());
|
||||
normalBandwidth.setNodeName(topology.getServerName());
|
||||
normalBandwidth.setUplinkSwitch(topology.getSwitchName());
|
||||
normalBandwidth.setInterfaceLinkDeviceType(topology.getConnectedDeviceType());
|
||||
normalBandwidth.setStartTime(epsNodeBandwidth.getStartTime());
|
||||
normalBandwidth.setEndTime(epsNodeBandwidth.getEndTime());
|
||||
normalBandwidth.setBusinessId(serverConfig.getBusinessCode());
|
||||
normalBandwidth.setBusinessName(serverConfig.getBusinessName());
|
||||
normalBandwidth.setResourceType("2");
|
||||
epsNodeBandwidthService.calculateAvg(normalBandwidth);
|
||||
}
|
||||
}else{
|
||||
log.warn("未检测到拓扑配置,交换机clientId:{}", clientId);
|
||||
}
|
||||
|
||||
// 5. 处理机房出口情况
|
||||
EpsNodeBandwidth normalBandwidth = new EpsNodeBandwidth();
|
||||
normalBandwidth.setSwitchSn(switchSn);
|
||||
normalBandwidth.setCalculationMode(calculationMode);
|
||||
normalBandwidth.setInterfaceName(topology.getInterfaceName());
|
||||
normalBandwidth.setInterfaceLinkDeviceType(topology.getConnectedDeviceType());
|
||||
normalBandwidth.setStartTime(epsNodeBandwidth.getStartTime());
|
||||
normalBandwidth.setEndTime(epsNodeBandwidth.getEndTime());
|
||||
normalBandwidth.setResourceType("2");
|
||||
epsNodeBandwidthService.calculateAvg(normalBandwidth);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("处理交换机 {} 平均带宽失败", switchSn, e);
|
||||
log.error("处理交换机 {} 平均带宽失败", clientId, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.util.Map;
|
||||
* 提供流量数据的REST接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/eps-traffic-data")
|
||||
@RequestMapping("/epsTrafficData")
|
||||
@RequiredArgsConstructor
|
||||
public class EpsInitialTrafficDataController {
|
||||
|
||||
|
||||
@@ -144,4 +144,17 @@ public class EpsTaskStatisticsController extends BaseController
|
||||
Map echartsMap = epsTaskStatisticsService.getRraphicalMsg(epsTaskStatistics);
|
||||
return success(echartsMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取月均日95值的日列表
|
||||
* @param epsTaskStatistics
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("system:taskStatistics:list")
|
||||
@PostMapping("/getAvgTimeList")
|
||||
public AjaxResult getAvgTimeList(@RequestBody EpsTaskStatistics epsTaskStatistics)
|
||||
{
|
||||
List<String> avgTimeList = epsTaskStatisticsService.getAvgTimeList(epsTaskStatistics);
|
||||
return success(avgTimeList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,13 +25,14 @@ public class UserTableColumnConfigController extends BaseController
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户自定义列配置详细信息
|
||||
* 根据获取用户id获取自定义列配置详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:columnConfig:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
@PostMapping(value = "/getColumnConfigByUserId")
|
||||
public AjaxResult getColumnConfigByUserId(@RequestBody UserTableColumnConfig userTableColumnConfig)
|
||||
{
|
||||
return success(userTableColumnConfigService.selectUserTableColumnConfigById(id));
|
||||
UserTableColumnConfig columnConfig = userTableColumnConfigService.getColumnConfigByUserId(userTableColumnConfig);
|
||||
return success(columnConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,31 +40,11 @@ public class UserTableColumnConfigController extends BaseController
|
||||
*/
|
||||
@RequiresPermissions("system:columnConfig:add")
|
||||
@Log(title = "用户自定义列配置", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@PostMapping("addColumnConfig")
|
||||
public AjaxResult add(@RequestBody UserTableColumnConfig userTableColumnConfig)
|
||||
{
|
||||
return toAjax(userTableColumnConfigService.insertUserTableColumnConfig(userTableColumnConfig));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户自定义列配置
|
||||
*/
|
||||
@RequiresPermissions("system:columnConfig:edit")
|
||||
@Log(title = "用户自定义列配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody UserTableColumnConfig userTableColumnConfig)
|
||||
{
|
||||
return toAjax(userTableColumnConfigService.updateUserTableColumnConfig(userTableColumnConfig));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户自定义列配置
|
||||
*/
|
||||
@RequiresPermissions("system:columnConfig:remove")
|
||||
@Log(title = "用户自定义列配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(userTableColumnConfigService.deleteUserTableColumnConfigByIds(ids));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ public class AllInterfaceName extends BaseEntity
|
||||
private String serverIp;
|
||||
/** 交换机接口别名 */
|
||||
private String otherName;
|
||||
/** 前端需要 id 别名 */
|
||||
private Long value;
|
||||
/** 业务需要 拼接id 交换机clientId,交换机接口名称值 别名 */
|
||||
private String value;
|
||||
/** 前端需要 name 别名 */
|
||||
private String label;
|
||||
|
||||
|
||||
@@ -118,6 +118,8 @@ public class EpsInitialTrafficData extends BaseEntity {
|
||||
private boolean flag95 = false;
|
||||
/** 计算方式 */
|
||||
private String calculationMode;
|
||||
/** 95值 */
|
||||
private BigDecimal percentile95;
|
||||
|
||||
|
||||
}
|
||||
@@ -74,29 +74,10 @@ public class EpsNodeBandwidth extends BaseEntity
|
||||
/** 金山流量Mbps/日 */
|
||||
private BigDecimal machineFlow;
|
||||
|
||||
/** 设备业务客户id */
|
||||
@Excel(name = "设备业务客户id")
|
||||
private String customerId;
|
||||
|
||||
/** 设备业务客户名称 */
|
||||
@Excel(name = "设备业务客户名称")
|
||||
private String customerName;
|
||||
|
||||
/** 业务号 */
|
||||
@Excel(name = "业务号")
|
||||
private String serviceNumber;
|
||||
|
||||
/** 上联交换机 */
|
||||
@Excel(name = "上联交换机")
|
||||
private String uplinkSwitch;
|
||||
|
||||
/** 创建人id */
|
||||
@Excel(name = "创建人id")
|
||||
private Long creatorId;
|
||||
|
||||
/** 创建人名称 */
|
||||
@Excel(name = "创建人名称")
|
||||
private String creatorName;
|
||||
|
||||
/** 交换机sn */
|
||||
@Excel(name = "交换机sn")
|
||||
@@ -129,19 +110,22 @@ public class EpsNodeBandwidth extends BaseEntity
|
||||
private String endTime;
|
||||
/** 月份 */
|
||||
private String monthTime;
|
||||
/** 备注 */
|
||||
/** 交换机接口名称别名 */
|
||||
private String remark1;
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createDatetime;
|
||||
|
||||
/** 节点名称集合 */
|
||||
private List<String> nodeNames;
|
||||
|
||||
/** 交换机名称集合 */
|
||||
private List<String> switchNames;
|
||||
/** 计算方式 */
|
||||
private String calculationMode;
|
||||
/** 客户端id */
|
||||
private String clientId;
|
||||
/** 交换机连接的服务器客户端id */
|
||||
private String serverClientId;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -118,4 +118,10 @@ public class InitialSwitchInfoDetails extends BaseEntity
|
||||
public String interfaceNames;
|
||||
/** 是否95值 */
|
||||
private boolean flag95 = false;
|
||||
/** 服务器客户端id */
|
||||
private String serverClientId;
|
||||
/** 交换机接口别名 */
|
||||
private String interfaceNameRemark;
|
||||
/** 95值 */
|
||||
private BigDecimal percentile95;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,8 @@ public class UserTableColumnConfig extends BaseEntity
|
||||
private Long userId;
|
||||
|
||||
/** 页面路由标识(例如:system:user:list, business:order:manage) */
|
||||
@Excel(name = "页面路由标识", readConverterExp = "例=如:system:user:list,,b=usiness:order:manage")
|
||||
private String pageRoute;
|
||||
|
||||
/** 列配置(JSON数组格式) */
|
||||
@Excel(name = "列配置", readConverterExp = "J=SON数组格式")
|
||||
private String columnConfig;
|
||||
}
|
||||
|
||||
@@ -62,11 +62,38 @@ public interface IEpsTaskStatisticsService
|
||||
*/
|
||||
public int deleteEpsTaskStatisticsById(Long id);
|
||||
|
||||
/**
|
||||
* 获取相关数据
|
||||
* @param epsTaskStatistics
|
||||
* @return
|
||||
*/
|
||||
PageInfo<?> getRelateData(EpsTaskStatistics epsTaskStatistics);
|
||||
|
||||
/**
|
||||
* 修改相关数据
|
||||
* @param epsTaskStatistics
|
||||
* @return
|
||||
*/
|
||||
int updateRelateData(EpsTaskStatistics epsTaskStatistics);
|
||||
|
||||
/**
|
||||
* 重新计算
|
||||
* @param epsTaskStatistics
|
||||
* @return
|
||||
*/
|
||||
int recaculate(EpsTaskStatistics epsTaskStatistics);
|
||||
|
||||
/**
|
||||
* 图形分析
|
||||
* @param epsTaskStatistics
|
||||
* @return
|
||||
*/
|
||||
Map getRraphicalMsg(EpsTaskStatistics epsTaskStatistics);
|
||||
|
||||
/**
|
||||
* 获取月均日95值的日期
|
||||
* @param epsTaskStatistics
|
||||
* @return
|
||||
*/
|
||||
List<String> getAvgTimeList(EpsTaskStatistics epsTaskStatistics);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ public interface IRmSwitchManagementService
|
||||
|
||||
/**
|
||||
* 交换机信息树形结构
|
||||
* @param rmSwitchManagement
|
||||
* @return
|
||||
*/
|
||||
List<RmSwitchManagement> getAllSwitchNameTree();
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.domain.UserTableColumnConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户自定义列配置Service接口
|
||||
*
|
||||
@@ -58,4 +59,10 @@ public interface IUserTableColumnConfigService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserTableColumnConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 根据用户id获取自定义列详情
|
||||
* @return
|
||||
*/
|
||||
UserTableColumnConfig getColumnConfigByUserId(UserTableColumnConfig userTableColumnConfig);
|
||||
}
|
||||
|
||||
@@ -199,7 +199,9 @@ public class EpsBusinessDeployServiceImpl implements IEpsBusinessDeployService
|
||||
changeRecord.setBusinessCode(businessCode);
|
||||
changeRecord.setBusinessName(businessName);
|
||||
changeRecord.setCreateTime(DateUtils.getNowDate());
|
||||
changeRecord.setUpdateTime(DateUtils.getNowDate());
|
||||
changeRecord.setCreatBy(SecurityUtils.getUsername());
|
||||
changeRecord.setUpdateBy(SecurityUtils.getUsername());
|
||||
// 修改内容
|
||||
String content = "流量网口设置为" + interfaceName + ",业务为" + businessName;
|
||||
changeRecord.setChangeContent(content);
|
||||
|
||||
@@ -34,6 +34,7 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataService {
|
||||
|
||||
private static final String DATE_TIME_FORMATTER = "yyyy-MM-dd HH:mm:ss";
|
||||
@Autowired
|
||||
private EpsInitialTrafficDataMapper epsInitialTrafficDataMapper;
|
||||
@Autowired
|
||||
@@ -46,6 +47,8 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
private EpsMethodChangeRecordMapper epsMethodChangeRecordMapper;
|
||||
@Autowired
|
||||
private EpsBusinessDeployMapper epsBusinessDeployMapper;
|
||||
@Autowired
|
||||
private RmEpsTopologyManagementMapper rmEpsTopologyManagementMapper;
|
||||
@Override
|
||||
public void createNextMonthTables() {
|
||||
LocalDate nextMonth = LocalDate.now().plusMonths(1);
|
||||
@@ -258,7 +261,6 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
// 遍历处理每个设备
|
||||
snList.forEach(interfaceName -> {
|
||||
queryParam.setClientId(interfaceName.getClientId());
|
||||
queryParam.setName(interfaceName.getInterfaceName());
|
||||
calculateChangedDeviceBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
|
||||
});
|
||||
}
|
||||
@@ -447,6 +449,8 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
BeanUtils.copyProperties(queryParam, dailyQuery); // 复制原有属性
|
||||
dailyQuery.setStartTime(dayStart);
|
||||
dailyQuery.setEndTime(dayEnd);
|
||||
// 时间范围
|
||||
String timeRange = "从" + dayStart + "到" + dayEnd;
|
||||
|
||||
// 根据clientId查询已经配置的接口
|
||||
String clientIds = queryParam.getClientIds();
|
||||
@@ -454,9 +458,8 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
if(clientIdArr != null){
|
||||
for (String clientId : clientIdArr) {
|
||||
try {
|
||||
dailyQuery.setClientIds(clientId);
|
||||
Map<String, Object> resultMap = serverNetSpeedEcharts(dailyQuery);
|
||||
// 查询95值
|
||||
BigDecimal percentile95 = BigDecimal.ZERO;
|
||||
EpsNodeBandwidth bandwidthQuery = new EpsNodeBandwidth();
|
||||
bandwidthQuery.setBandwidthType("1");
|
||||
bandwidthQuery.setCreateTime(DateUtils.parseDate(date));
|
||||
@@ -466,8 +469,10 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
|
||||
if(!epsNodeBandwidthList.isEmpty()){
|
||||
EpsNodeBandwidth nodeBandwidth = epsNodeBandwidthList.get(0);
|
||||
resultMap.put("95value", nodeBandwidth.getBandwidthResult());
|
||||
percentile95 = nodeBandwidth.getBandwidthResult();
|
||||
}
|
||||
dailyQuery.setClientIds(clientId);
|
||||
Map<String, Object> resultMap = serverNetSpeedEcharts(dailyQuery, percentile95);
|
||||
// 查询业务信息
|
||||
String businessName = null;
|
||||
EpsBusinessDeploy businessQuery = new EpsBusinessDeploy();
|
||||
@@ -488,6 +493,7 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
}
|
||||
String name = joiner.toString();
|
||||
resultMap.put("name", name);
|
||||
resultMap.put("timeRange", timeRange);
|
||||
resultList.add(resultMap);
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
@@ -523,15 +529,15 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
BeanUtils.copyProperties(queryParam, dailyQuery); // 复制原有属性
|
||||
dailyQuery.setStartTime(monthStart);
|
||||
dailyQuery.setEndTime(monthEnd);
|
||||
String timeRange = "从" + monthStart + "到" + monthEnd;
|
||||
// 根据clientId查询已经配置的接口
|
||||
String clientIds = queryParam.getClientIds();
|
||||
String[] clientIdArr = clientIds.split(",");
|
||||
if(clientIdArr != null){
|
||||
for (String clientId : clientIdArr) {
|
||||
try {
|
||||
dailyQuery.setClientIds(clientId);
|
||||
Map<String, Object> resultMap = serverNetSpeedEcharts(dailyQuery);
|
||||
// 查询95值
|
||||
BigDecimal percentile95 = BigDecimal.ZERO;
|
||||
EpsNodeBandwidth bandwidthQuery = new EpsNodeBandwidth();
|
||||
bandwidthQuery.setBandwidthType("1");
|
||||
bandwidthQuery.setCreateTime(DateUtils.parseDate(monthStart));
|
||||
@@ -541,8 +547,10 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
|
||||
if(!epsNodeBandwidthList.isEmpty()){
|
||||
EpsNodeBandwidth nodeBandwidth = epsNodeBandwidthList.get(0);
|
||||
resultMap.put("95value", nodeBandwidth.getBandwidthResult());
|
||||
percentile95 = nodeBandwidth.getBandwidthResult();
|
||||
}
|
||||
dailyQuery.setClientIds(clientId);
|
||||
Map<String, Object> resultMap = serverNetSpeedEcharts(dailyQuery, percentile95);
|
||||
// 查询业务信息
|
||||
String businessName = null;
|
||||
EpsBusinessDeploy businessQuery = new EpsBusinessDeploy();
|
||||
@@ -563,6 +571,7 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
}
|
||||
String name = joiner.toString();
|
||||
resultMap.put("name", name);
|
||||
resultMap.put("timeRange", timeRange);
|
||||
resultList.add(resultMap);
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
@@ -577,22 +586,34 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
* @param epsInitialTrafficData
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> serverNetSpeedEcharts(EpsInitialTrafficData epsInitialTrafficData) {
|
||||
public Map<String, Object> serverNetSpeedEcharts(EpsInitialTrafficData epsInitialTrafficData, BigDecimal percentile95) {
|
||||
List<EpsInitialTrafficData> list = getTrafficListByClientIds(epsInitialTrafficData);
|
||||
try {
|
||||
SpeedUtils.SpeedResult result = SpeedUtils.calculateWithStringTraffic(list, "inSpeed", "outSpeed");
|
||||
BigDecimal divisor = SpeedUtils.getDivisor(result.getRecommendedUnit());
|
||||
Map<String, Function<EpsInitialTrafficData, ?>> extractors = new LinkedHashMap<>();
|
||||
if(!list.isEmpty()){
|
||||
try {
|
||||
list.forEach(data -> data.setPercentile95(SpeedUtils.mbitToBit(percentile95)));
|
||||
SpeedUtils.SpeedResult result = SpeedUtils.calculateWithStringTraffic(list, "inSpeed", "outSpeed");
|
||||
BigDecimal divisor = SpeedUtils.getDivisor(result.getRecommendedUnit());
|
||||
Map<String, Function<EpsInitialTrafficData, ?>> extractors = new LinkedHashMap<>();
|
||||
|
||||
extractors.put("netOutSpeedData", info ->
|
||||
info != null && info.getOutSpeed() != null ?
|
||||
new BigDecimal(info.getOutSpeed()).divide(divisor, 0, RoundingMode.HALF_UP) :
|
||||
0);
|
||||
Map<String, Object> resultMap = EchartsDataUtils.buildEchartsData(list, EpsInitialTrafficData::getCreateTime, extractors);
|
||||
resultMap.put("other", result);
|
||||
return resultMap;
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
extractors.put("netOutSpeedData", info ->
|
||||
info != null && info.getOutSpeed() != null ?
|
||||
new BigDecimal(info.getOutSpeed()).divide(divisor, 0, RoundingMode.HALF_UP) :
|
||||
0);
|
||||
extractors.put("netMachineFlowData", info ->
|
||||
info != null && info.getMachineFlow() != null ?
|
||||
new BigDecimal(info.getMachineFlow()).divide(divisor, 0, RoundingMode.HALF_UP) :
|
||||
0);
|
||||
extractors.put("percentile95", info ->
|
||||
info != null && info.getPercentile95() != null ?
|
||||
info.getPercentile95().divide(divisor, 2, RoundingMode.HALF_UP) :
|
||||
0);
|
||||
Map<String, Object> resultMap = EchartsDataUtils.buildEchartsData(list, EpsInitialTrafficData::getCreateTime, extractors);
|
||||
resultMap.put("other", result);
|
||||
resultMap.put("95value", percentile95);
|
||||
return resultMap;
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return new HashMap<>();
|
||||
}
|
||||
@@ -628,7 +649,6 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
// 1. 获取业务变更记录(按时间降序)
|
||||
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
|
||||
changeQuery.setClientId(queryParam.getClientId());
|
||||
changeQuery.setTrafficPort(queryParam.getName());
|
||||
changeQuery.setStartTime(dailyStartTime);
|
||||
changeQuery.setEndTime(dailyEndTime);
|
||||
List<EpsMethodChangeRecord> records = epsMethodChangeRecordMapper
|
||||
@@ -693,15 +713,15 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
String dailyStartTime,
|
||||
String dailyEndTime, String calculationMode) {
|
||||
// 1. 处理变更时间段(从最新到最早)
|
||||
String endTime = records.get(0).getCreateTime() + "";
|
||||
String endTime = DateUtils.parseDateToStr(DATE_TIME_FORMATTER, records.get(0).getCreateTime());
|
||||
for (int i = 1; i < records.size(); i++) {
|
||||
String startTime = records.get(i).getCreateTime() + "";
|
||||
String startTime = DateUtils.parseDateToStr(DATE_TIME_FORMATTER, records.get(i).getCreateTime());
|
||||
calculateSegment95(queryParam, startTime, endTime, calculationMode);
|
||||
endTime = startTime; // 移动时间窗口
|
||||
}
|
||||
|
||||
// 2. 处理最早变更前的时间段(昨天00:00:00 ~ 最早变更时间)
|
||||
String earliestChangeTime = records.get(records.size()-1).getCreateTime() + "";
|
||||
String earliestChangeTime = DateUtils.parseDateToStr(DATE_TIME_FORMATTER, records.get(records.size()-1).getCreateTime());
|
||||
calculateSegment95(queryParam, dailyStartTime, earliestChangeTime, calculationMode);
|
||||
|
||||
// 3. 处理最后变更后的时间段(最新变更时间 ~ 昨天23:59:59)
|
||||
@@ -764,9 +784,7 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
EpsNodeBandwidth bandwidth = new EpsNodeBandwidth();
|
||||
bandwidth.setClientId(data.getClientId());
|
||||
bandwidth.setHardwareSn(data.getServiceSn());
|
||||
bandwidth.setInterfaceName(data.getName());
|
||||
bandwidth.setCalculationMode(calculationMode);
|
||||
bandwidth.setNodeName(data.getNodeName());
|
||||
bandwidth.setBusinessId(data.getBusinessId());
|
||||
bandwidth.setBusinessName(data.getBusinessName());
|
||||
bandwidth.setResourceType(data.getResourceType());
|
||||
@@ -803,6 +821,15 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown bandwidthType: " + data.getBandwidthType());
|
||||
}
|
||||
// 根据clientId查询交换机上联
|
||||
RmEpsTopologyManagement topologQuery = new RmEpsTopologyManagement();
|
||||
topologQuery.setServerClientId(data.getClientId());
|
||||
List<RmEpsTopologyManagement> topologyList = rmEpsTopologyManagementMapper.selectRmEpsTopologyManagementList(topologQuery);
|
||||
if(!topologyList.isEmpty()){
|
||||
RmEpsTopologyManagement rmEpsTopologyManagement = topologyList.get(0);
|
||||
bandwidth.setUplinkSwitch(rmEpsTopologyManagement.getSwitchName());
|
||||
bandwidth.setInterfaceName(rmEpsTopologyManagement.getInterfaceName());
|
||||
}
|
||||
if(!exitsList.isEmpty()){
|
||||
bandwidth.setUpdateTime(DateUtils.getNowDate());
|
||||
bandwidth.setId(exitsList.get(0).getId());
|
||||
|
||||
@@ -5,9 +5,11 @@ import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.common.core.web.page.PageDomain;
|
||||
import com.ruoyi.system.domain.EpsInitialTrafficData;
|
||||
import com.ruoyi.system.domain.EpsNodeBandwidth;
|
||||
import com.ruoyi.system.domain.RmSwitchManagement;
|
||||
import com.ruoyi.system.mapper.EpsMethodChangeRecordMapper;
|
||||
import com.ruoyi.system.mapper.EpsNodeBandwidthMapper;
|
||||
import com.ruoyi.system.mapper.EpsServerRevenueConfigMapper;
|
||||
import com.ruoyi.system.mapper.RmSwitchManagementMapper;
|
||||
import com.ruoyi.system.service.EpsInitialTrafficDataService;
|
||||
import com.ruoyi.system.service.IEpsNodeBandwidthService;
|
||||
import com.ruoyi.system.util.EchartsDataConverter;
|
||||
@@ -45,6 +47,8 @@ public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService
|
||||
private EpsServerRevenueConfigMapper epsServerRevenueConfigMapper;
|
||||
@Autowired
|
||||
private EpsMethodChangeRecordMapper epsMethodChangeRecordMapper;
|
||||
@Autowired
|
||||
private RmSwitchManagementMapper rmSwitchManagementMapper;
|
||||
|
||||
/**
|
||||
* 查询节点带宽信息
|
||||
@@ -183,7 +187,7 @@ public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService
|
||||
// 3. 获取计算数据(防止空指针)
|
||||
EpsNodeBandwidth calculatedData = epsNodeBandwidthMapper.calculateAvg(epsNodeBandwidth);
|
||||
if (calculatedData == null) {
|
||||
log.warn("未找到计算数据,硬件SN: {}", epsNodeBandwidth.getHardwareSn());
|
||||
log.warn("未找到计算数据,clientId: {}", epsNodeBandwidth.getClientId());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -221,16 +225,20 @@ public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService
|
||||
epsNodeBandwidth.setId(existingRecords.get(0).getId());
|
||||
epsNodeBandwidth.setUpdateTime(DateUtils.getNowDate());
|
||||
}else{
|
||||
if(epsNodeBandwidth.getStartTime() == null){
|
||||
epsNodeBandwidth.setCreateTime(DateUtils.parseDate(monthTime));
|
||||
}else{
|
||||
epsNodeBandwidth.setCreateTime(DateUtils.parseDate(epsNodeBandwidth.getStartTime()));
|
||||
}
|
||||
epsNodeBandwidth.setCreateTime(DateUtils.parseDate(monthTime));
|
||||
}
|
||||
// 月均日95值
|
||||
BigDecimal avgMonthly = sum95Daily.divide(BigDecimal.valueOf(daysInMonth), 2, RoundingMode.HALF_UP);
|
||||
epsNodeBandwidth.setAvgMonthlyBandwidth95(avgMonthly);
|
||||
epsNodeBandwidth.setBandwidthResult(avgMonthly);
|
||||
// 根据clientId查询交换机名称
|
||||
RmSwitchManagement query = new RmSwitchManagement();
|
||||
query.setClientId(epsNodeBandwidth.getClientId());
|
||||
List<RmSwitchManagement> switchMsgList = rmSwitchManagementMapper.selectRmSwitchManagementList(query);
|
||||
if(!switchMsgList.isEmpty()){
|
||||
RmSwitchManagement switchManagement = switchMsgList.get(0);
|
||||
epsNodeBandwidth.setUplinkSwitch(switchManagement.getSwitchName());
|
||||
}
|
||||
// 8. 执行插入或更新操作
|
||||
return existingRecords.isEmpty() ?
|
||||
epsNodeBandwidthMapper.insertEpsNodeBandwidth(epsNodeBandwidth) :
|
||||
|
||||
@@ -137,13 +137,24 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
|
||||
processAvg95Data(epsTaskStatistics);
|
||||
}
|
||||
}else{
|
||||
String resources = epsTaskStatistics.getIncludedResources();
|
||||
String clientIds = Arrays.stream(resources.split(","))
|
||||
.map(msg -> msg.split(";"))
|
||||
.filter(resource -> resource.length >= 3)
|
||||
.map(resource -> resource[1])
|
||||
.collect(Collectors.joining(","));
|
||||
String interfaceNames = Arrays.stream(resources.split(","))
|
||||
.map(msg -> msg.split(";"))
|
||||
.filter(resource -> resource.length >= 3)
|
||||
.map(resource -> resource[2])
|
||||
.collect(Collectors.joining(","));
|
||||
if(StringUtils.equals(epsTaskStatistics.getCalculationType(), "1")){
|
||||
InitialSwitchInfoDetails queryParam = new InitialSwitchInfoDetails();
|
||||
queryParam.setStartTime(epsTaskStatistics.getStartTime());
|
||||
queryParam.setEndTime(epsTaskStatistics.getEndTime());
|
||||
queryParam.setBusinessCode(epsTaskStatistics.getBusinessCode());
|
||||
queryParam.setClientIds(epsTaskStatistics.getIncludedResources());
|
||||
queryParam.setInterfaceNames(epsTaskStatistics.getInterfaceNames());
|
||||
queryParam.setClientIds(clientIds);
|
||||
queryParam.setInterfaceNames(interfaceNames);
|
||||
List<InitialSwitchInfoDetails> dataList = initialSwitchInfoDetailsMapper
|
||||
.sumSwitchTrafficByclientIds(queryParam);
|
||||
if(!dataList.isEmpty()){
|
||||
@@ -166,8 +177,8 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
|
||||
queryParam.setStartTime(timeRange.getStart());
|
||||
queryParam.setEndTime(timeRange.getEnd());
|
||||
queryParam.setBusinessCode(epsTaskStatistics.getBusinessCode());
|
||||
queryParam.setClientIds(epsTaskStatistics.getIncludedResources());
|
||||
queryParam.setInterfaceNames(epsTaskStatistics.getInterfaceNames());
|
||||
queryParam.setClientIds(clientIds);
|
||||
queryParam.setInterfaceNames(interfaceNames);
|
||||
List<InitialSwitchInfoDetails> dataList = initialSwitchInfoDetailsMapper
|
||||
.sumSwitchTrafficByclientIds(queryParam);
|
||||
if(!dataList.isEmpty()){
|
||||
@@ -350,6 +361,12 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
|
||||
}
|
||||
}
|
||||
}else{
|
||||
String resources = taskMsg.getIncludedResources();
|
||||
String result = Arrays.stream(resources.split(","))
|
||||
.map(msg -> msg.split(";"))
|
||||
.filter(resource -> resource.length >= 4)
|
||||
.map(resource -> "[" + resource[3] + "].[" + resource[2] + "]")
|
||||
.collect(Collectors.joining(";"));
|
||||
List<InitialSwitchInfoDetails> list = trafficRedisHashUtil.getListFromHash(taskId.toString(), InitialSwitchInfoDetails.class);
|
||||
if(!list.isEmpty()){
|
||||
if(StringUtils.equals("1", taskMsg.getCalculationType())){
|
||||
@@ -361,7 +378,7 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
|
||||
.limit(pageSize)
|
||||
.collect(Collectors.toList());
|
||||
for (InitialSwitchInfoDetails initialSwitchInfoDetails : pageList) {
|
||||
initialSwitchInfoDetails.setName(taskMsg.getIncludedResources());
|
||||
initialSwitchInfoDetails.setName(result);
|
||||
}
|
||||
PageInfo<InitialSwitchInfoDetails> pageInfo = new PageInfo<>();
|
||||
pageInfo.setPageNum(pageNum);
|
||||
@@ -389,6 +406,31 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
|
||||
return new PageInfo<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取月均日数据的日期
|
||||
* @param epsTaskStatistics
|
||||
* @return
|
||||
*/
|
||||
public List<String> getAvgTimeList(EpsTaskStatistics epsTaskStatistics){
|
||||
List<String> resultList = new ArrayList<>();
|
||||
Long taskId = epsTaskStatistics.getId();
|
||||
EpsTaskStatistics taskMsg = epsTaskStatisticsMapper.selectEpsTaskStatisticsById(taskId);
|
||||
|
||||
if(StringUtils.equals(taskMsg.getCalculationType(), "2")){
|
||||
List<EpsInitialTrafficData> list = trafficRedisHashUtil.getListFromHash(taskId.toString(), EpsInitialTrafficData.class);
|
||||
if(!list.isEmpty()){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
resultList = list.stream()
|
||||
.map(data -> sdf.format(data.getCreateTime()))
|
||||
.distinct()
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateRelateData(EpsTaskStatistics epsTaskStatistics) {
|
||||
// 查询任务详情
|
||||
@@ -442,10 +484,22 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
|
||||
// 查询任务详情
|
||||
Long taskId = epsTaskStatistics.getId();
|
||||
EpsTaskStatistics taskMsg = epsTaskStatisticsMapper.selectEpsTaskStatisticsById(taskId);
|
||||
String startTime = taskMsg.getStartTime();
|
||||
String endTime = taskMsg.getEndTime();
|
||||
String timeRange = "";
|
||||
if(endTime == null){
|
||||
timeRange = startTime;
|
||||
}else{
|
||||
timeRange = startTime + "~" + endTime;
|
||||
}
|
||||
if(StringUtils.equals("1", taskMsg.getResourceType())){
|
||||
List<EpsInitialTrafficData> list = trafficRedisHashUtil.getListFromHash(taskId.toString(), EpsInitialTrafficData.class);
|
||||
if(!list.isEmpty()){
|
||||
try{
|
||||
BigDecimal percentile95 = "1".equals(taskMsg.getCalculationType())
|
||||
? taskMsg.getPercentile95()
|
||||
: taskMsg.getMonthlyAvgPercentile95();
|
||||
list.forEach(data -> data.setPercentile95(SpeedUtils.mbitToBit(percentile95)));
|
||||
SpeedUtils.SpeedResult result = SpeedUtils.calculateWithStringTraffic(list, "inSpeed", "outSpeed");
|
||||
BigDecimal divisor = SpeedUtils.getDivisor(result.getRecommendedUnit());
|
||||
Map<String, Function<EpsInitialTrafficData, ?>> extractors = new LinkedHashMap<>();
|
||||
@@ -454,13 +508,14 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
|
||||
info != null && info.getOutSpeed() != null ?
|
||||
new BigDecimal(info.getOutSpeed()).divide(divisor, 0, RoundingMode.HALF_UP) :
|
||||
0);
|
||||
extractors.put("percentile95", info ->
|
||||
info != null && info.getPercentile95() != null ?
|
||||
info.getPercentile95().divide(divisor, 2, RoundingMode.HALF_UP) :
|
||||
0);
|
||||
Map<String, Object> resultMap = EchartsDataUtils.buildEchartsData(list, EpsInitialTrafficData::getCreateTime, extractors);
|
||||
resultMap.put("other", result);
|
||||
if(StringUtils.equals("1", taskMsg.getCalculationType())){
|
||||
resultMap.put("percentile95", taskMsg.getPercentile95());
|
||||
}else{
|
||||
resultMap.put("percentile95", taskMsg.getMonthlyAvgPercentile95());
|
||||
}
|
||||
resultMap.put("percentile95", percentile95);
|
||||
resultMap.put("timeRange", timeRange);
|
||||
return resultMap;
|
||||
}catch (Exception e){
|
||||
System.err.println(e.getMessage());
|
||||
@@ -470,6 +525,10 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
|
||||
List<InitialSwitchInfoDetails> list = trafficRedisHashUtil.getListFromHash(taskId.toString(), InitialSwitchInfoDetails.class);
|
||||
if(!list.isEmpty()){
|
||||
try{
|
||||
BigDecimal percentile95 = "1".equals(taskMsg.getCalculationType())
|
||||
? taskMsg.getPercentile95()
|
||||
: taskMsg.getMonthlyAvgPercentile95();
|
||||
list.forEach(data -> data.setPercentile95(SpeedUtils.mbitToBit(percentile95)));
|
||||
SpeedUtils.SpeedResult result = SpeedUtils.calculateWithAverageBasedUnit(list, "inSpeed", "outSpeed");
|
||||
BigDecimal divisor = SpeedUtils.getDivisor(result.getRecommendedUnit());
|
||||
Map<String, Function<InitialSwitchInfoDetails, ?>> extractors = new LinkedHashMap<>();
|
||||
@@ -482,6 +541,10 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
|
||||
info != null && info.getOutSpeed() != null ?
|
||||
info.getOutSpeed().divide(divisor, 0, RoundingMode.HALF_UP) :
|
||||
0);
|
||||
extractors.put("percentile95", info ->
|
||||
info != null && info.getPercentile95() != null ?
|
||||
info.getPercentile95().divide(divisor, 2, RoundingMode.HALF_UP) :
|
||||
0);
|
||||
Map<String, Object> resultMap = EchartsDataUtils.buildEchartsData(list, InitialSwitchInfoDetails::getCreateTime, extractors);
|
||||
resultMap.put("other", result);
|
||||
if(StringUtils.equals("1", taskMsg.getCalculationType())){
|
||||
@@ -489,6 +552,7 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
|
||||
}else{
|
||||
resultMap.put("percentile95", taskMsg.getMonthlyAvgPercentile95());
|
||||
}
|
||||
resultMap.put("timeRange", timeRange);
|
||||
return resultMap;
|
||||
}catch (Exception e){
|
||||
System.err.println(e.getMessage());
|
||||
|
||||
@@ -43,6 +43,8 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
@Autowired
|
||||
private RmEpsTopologyManagementMapper rmEpsTopologyManagementMapper;
|
||||
@Autowired
|
||||
private RmSwitchManagementMapper rmSwitchManagementMapper;
|
||||
@Autowired
|
||||
private AllInterfaceNameMapper allInterfaceNameMapper;
|
||||
@Autowired
|
||||
private EpsServerRevenueConfigMapper epsServerRevenueConfigMapper;
|
||||
@@ -55,6 +57,8 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
@Autowired
|
||||
private EpsBusinessDeployMapper epsBusinessDeployMapper;
|
||||
|
||||
private static final String DATE_TIME_FORMATTER = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
/**
|
||||
* 查询交换机监控信息
|
||||
*
|
||||
@@ -147,31 +151,37 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
String interfaceName = details.getName();
|
||||
RmEpsTopologyManagement rmEpsTopologyManagement = new RmEpsTopologyManagement();
|
||||
rmEpsTopologyManagement.setInterfaceName(interfaceName);
|
||||
rmEpsTopologyManagement.setSwitchIpAddress(details.getSwitchIp());
|
||||
rmEpsTopologyManagement.setClientId(details.getClientId());
|
||||
List<RmEpsTopologyManagement> managements = rmEpsTopologyManagementMapper.selectRmEpsTopologyManagementList(rmEpsTopologyManagement);
|
||||
// 赋值
|
||||
if(!managements.isEmpty()){
|
||||
for (RmEpsTopologyManagement management : managements) {
|
||||
if("1".equals(management.getConnectedDeviceType())){
|
||||
details.setOutSpeed(null);
|
||||
}else{
|
||||
details.setInSpeed(null);
|
||||
}
|
||||
details.setSwitchSn(management.getSwitchSn());
|
||||
details.setSwitchName(management.getSwitchName());
|
||||
details.setInterfaceDeviceType(management.getConnectedDeviceType());
|
||||
details.setServerName(management.getServerName());
|
||||
details.setServerPort(management.getServerPort());
|
||||
details.setServerSn(management.getServerSn());
|
||||
details.setServerClientId(management.getServerClientId());
|
||||
// 查询端口备注信息
|
||||
RmSwitchInterfaceInfo queryOtheName = new RmSwitchInterfaceInfo();
|
||||
queryOtheName.setClientId(details.getClientId());
|
||||
queryOtheName.setInterfaceName(management.getInterfaceName());
|
||||
List<RmSwitchInterfaceInfo> interfaceInfos = rmSwitchInterfaceInfoMapper.selectRmSwitchInterfaceInfoList(queryOtheName);
|
||||
if(!interfaceInfos.isEmpty()){
|
||||
// 接口别名
|
||||
details.setInterfaceNameRemark(interfaceInfos.get(0).getInterfaceRemark());
|
||||
}
|
||||
// 根据服务器sn查询业务
|
||||
if(management.getServerSn() != null){
|
||||
EpsServerRevenueConfig epsServerRevenueConfig = new EpsServerRevenueConfig();
|
||||
epsServerRevenueConfig.setHardwareSn(management.getServerSn());
|
||||
List<EpsServerRevenueConfig> businessList = epsServerRevenueConfigMapper.selectEpsServerRevenueConfigList(epsServerRevenueConfig);
|
||||
if(!businessList.isEmpty()){
|
||||
EpsServerRevenueConfig revenueConfig = businessList.get(0);
|
||||
details.setBusinessName(revenueConfig.getBusinessName());
|
||||
details.setBusinessCode(revenueConfig.getBusinessCode());
|
||||
if(management.getServerClientId() != null){
|
||||
String serverClientId = management.getServerClientId();
|
||||
// 查询业务信息
|
||||
EpsBusinessDeploy queryBD = new EpsBusinessDeploy();
|
||||
queryBD.setClientId(serverClientId);
|
||||
queryBD.setReviewStatus(ReviewEnum.通过.getCode());
|
||||
List<EpsBusinessDeploy> businessDeploys = epsBusinessDeployMapper.selectEpsBusinessDeployList(queryBD);
|
||||
if(!businessDeploys.isEmpty()){
|
||||
details.setBusinessCode(businessDeploys.get(0).getBusinessCode());
|
||||
details.setBusinessName(businessDeploys.get(0).getBusinessName());
|
||||
}
|
||||
}else {
|
||||
details.setBusinessCode(null);
|
||||
@@ -353,7 +363,6 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
// 遍历处理每个交换机
|
||||
switchSnList.forEach(interfaceName -> {
|
||||
queryParam.setClientId(interfaceName.getClientId());
|
||||
queryParam.setSwitchIp(interfaceName.getSwitchIp());
|
||||
processSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
|
||||
});
|
||||
}
|
||||
@@ -474,17 +483,16 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
// 根据交换机sn查询连接的服务器sn
|
||||
RmEpsTopologyManagement management = new RmEpsTopologyManagement();
|
||||
management.setClientId(queryParam.getClientId());
|
||||
management.setSwitchIpAddress(queryParam.getSwitchIp());
|
||||
List<RmEpsTopologyManagement> serverSnList = rmEpsTopologyManagementMapper.selectRmEpsTopologyManagementList(management);
|
||||
if(!serverSnList.isEmpty()){
|
||||
for (RmEpsTopologyManagement rmEpsTopologyManagement : serverSnList) {
|
||||
queryParam.setName(rmEpsTopologyManagement.getInterfaceName());
|
||||
if("1".equals(rmEpsTopologyManagement.getConnectedDeviceType())){
|
||||
queryParam.setServerSn(rmEpsTopologyManagement.getServerSn());
|
||||
queryParam.setServerClientId(rmEpsTopologyManagement.getServerClientId());
|
||||
// 根据业务变更情况选择计算方式
|
||||
calculateChangedSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
|
||||
}else{
|
||||
queryParam.setServerSn(null);
|
||||
queryParam.setServerClientId(null);
|
||||
calculateNormalSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
|
||||
}
|
||||
}
|
||||
@@ -507,7 +515,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
String dailyEndTime, String calculationMode) {
|
||||
// 获取业务变更记录(按时间降序)
|
||||
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
|
||||
changeQuery.setClientId(queryParam.getClientId());
|
||||
changeQuery.setClientId(queryParam.getServerClientId());
|
||||
changeQuery.setStartTime(dailyStartTime);
|
||||
changeQuery.setEndTime(dailyEndTime);
|
||||
List<EpsMethodChangeRecord> records = epsMethodChangeRecordMapper
|
||||
@@ -584,15 +592,15 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
String dailyStartTime,
|
||||
String dailyEndTime, String calculationMode) {
|
||||
// 1. 处理变更时间段(从最新到最早)
|
||||
String endTime = records.get(0).getCreateTime() + "";
|
||||
String endTime = DateUtils.parseDateToStr(DATE_TIME_FORMATTER, records.get(0).getCreateTime());
|
||||
for (int i = 1; i < records.size(); i++) {
|
||||
String startTime = records.get(i).getCreateTime() + "";
|
||||
String startTime = DateUtils.parseDateToStr(DATE_TIME_FORMATTER, records.get(i).getCreateTime());
|
||||
calculateSwitchSegment95(queryParam, startTime, endTime, calculationMode);
|
||||
endTime = startTime; // 移动时间窗口
|
||||
}
|
||||
|
||||
// 2. 处理最早变更前的时间段(昨天00:00:00 ~ 最早变更时间)
|
||||
String earliestChangeTime = records.get(records.size()-1).getCreateTime() + "";
|
||||
String earliestChangeTime = DateUtils.parseDateToStr(DATE_TIME_FORMATTER, records.get(records.size()-1).getCreateTime());
|
||||
calculateSwitchSegment95(queryParam, dailyStartTime, earliestChangeTime, calculationMode);
|
||||
|
||||
// 3. 处理最后变更后的时间段(最新变更时间 ~ 昨天23:59:59)
|
||||
@@ -653,15 +661,23 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
BigDecimal result,
|
||||
String dateTime, String calculationMode) {
|
||||
EpsNodeBandwidth bandwidth = new EpsNodeBandwidth();
|
||||
// 根据clientId查询交换机名称
|
||||
RmSwitchManagement query = new RmSwitchManagement();
|
||||
query.setClientId(data.getClientId());
|
||||
List<RmSwitchManagement> switchMsgList = rmSwitchManagementMapper.selectRmSwitchManagementList(query);
|
||||
if(!switchMsgList.isEmpty()){
|
||||
RmSwitchManagement switchManagement = switchMsgList.get(0);
|
||||
bandwidth.setUplinkSwitch(switchManagement.getSwitchName());
|
||||
}
|
||||
bandwidth.setBusinessName(data.getBusinessName());
|
||||
bandwidth.setBusinessId(data.getBusinessCode());
|
||||
bandwidth.setClientId(data.getClientId());
|
||||
bandwidth.setHardwareSn(data.getServerSn());
|
||||
bandwidth.setCalculationMode(calculationMode);
|
||||
bandwidth.setSwitchSn(data.getSwitchSn());
|
||||
bandwidth.setNodeName(data.getServerName());
|
||||
bandwidth.setUplinkSwitch(data.getSwitchName());
|
||||
bandwidth.setInterfaceName(data.getName());
|
||||
bandwidth.setRemark1(data.getInterfaceNameRemark());
|
||||
bandwidth.setServerClientId(data.getServerClientId());
|
||||
bandwidth.setResourceType(data.getResourceType());
|
||||
bandwidth.setBandwidthType(data.getBandwidthType());
|
||||
bandwidth.setInterfaceLinkDeviceType(data.getInterfaceDeviceType());
|
||||
@@ -722,7 +738,8 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
// 构造当天的开始和结束时间(精确到秒)
|
||||
String dayStart = date.atStartOfDay().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
String dayEnd = date.atTime(23, 59, 59).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
// 时间范围
|
||||
String timeRange = "从" + dayStart + "到" + dayEnd;
|
||||
// 创建当天的查询条件
|
||||
InitialSwitchInfoDetails dailyQuery = new InitialSwitchInfoDetails();
|
||||
BeanUtils.copyProperties(initialSwitchInfoDetails, dailyQuery); // 复制原有属性
|
||||
@@ -739,9 +756,8 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
if(!rmEpsTopologyManagements.isEmpty()){
|
||||
for (RmEpsTopologyManagement rmEpsTopologyManagement : rmEpsTopologyManagements) {
|
||||
try {
|
||||
dailyQuery.setName(rmEpsTopologyManagement.getInterfaceName());
|
||||
Map<String, Object> resultMap = switchNetSpeedEcharts(dailyQuery);
|
||||
// 查询95值
|
||||
BigDecimal percentile95 = BigDecimal.ZERO;
|
||||
EpsNodeBandwidth query = new EpsNodeBandwidth();
|
||||
query.setBandwidthType("1");
|
||||
query.setCreateTime(DateUtils.parseDate(date));
|
||||
@@ -751,8 +767,10 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
List<EpsNodeBandwidth> epsNodeBandwidthList = epsNodeBandwidthMapper.selectEpsNodeBandwidthList(query);
|
||||
if(!epsNodeBandwidthList.isEmpty()){
|
||||
EpsNodeBandwidth nodeBandwidth = epsNodeBandwidthList.get(0);
|
||||
resultMap.put("95value", nodeBandwidth.getBandwidthResult());
|
||||
percentile95 = nodeBandwidth.getBandwidthResult();
|
||||
}
|
||||
dailyQuery.setName(rmEpsTopologyManagement.getInterfaceName());
|
||||
Map<String, Object> resultMap = switchNetSpeedEcharts(dailyQuery, percentile95);
|
||||
// 查询端口备注信息
|
||||
RmSwitchInterfaceInfo queryOtheName = new RmSwitchInterfaceInfo();
|
||||
queryOtheName.setClientId(clientId);
|
||||
@@ -786,6 +804,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
}
|
||||
String name = joiner.toString();
|
||||
resultMap.put("name", name);
|
||||
resultMap.put("timeRange", timeRange);
|
||||
resultList.add(resultMap);
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
@@ -822,6 +841,8 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
BeanUtils.copyProperties(initialSwitchInfoDetails, dailyQuery); // 复制原有属性
|
||||
dailyQuery.setStartTime(monthStart);
|
||||
dailyQuery.setEndTime(monthEnd);
|
||||
// 时间范围
|
||||
String timeRange = "从" + monthStart + "到" + monthEnd;
|
||||
// 根据交换机名称查询clientId
|
||||
String clientIds = initialSwitchInfoDetails.getClientIds();
|
||||
String[] clientIdArr = clientIds.split(",");
|
||||
@@ -833,9 +854,8 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
if(!rmEpsTopologyManagements.isEmpty()){
|
||||
for (RmEpsTopologyManagement rmEpsTopologyManagement : rmEpsTopologyManagements) {
|
||||
try {
|
||||
dailyQuery.setName(rmEpsTopologyManagement.getInterfaceName());
|
||||
Map<String, Object> resultMap = switchNetSpeedEcharts(dailyQuery);
|
||||
// 查询95值
|
||||
BigDecimal percentile95 = BigDecimal.ZERO;
|
||||
EpsNodeBandwidth query = new EpsNodeBandwidth();
|
||||
query.setBandwidthType("1");
|
||||
query.setCreateTime(DateUtils.parseDate(monthStart));
|
||||
@@ -844,8 +864,10 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
List<EpsNodeBandwidth> epsNodeBandwidthList = epsNodeBandwidthMapper.selectEpsNodeBandwidthList(query);
|
||||
if(!epsNodeBandwidthList.isEmpty()){
|
||||
EpsNodeBandwidth nodeBandwidth = epsNodeBandwidthList.get(0);
|
||||
resultMap.put("95value", nodeBandwidth.getBandwidthResult());
|
||||
percentile95 = nodeBandwidth.getBandwidthResult();
|
||||
}
|
||||
dailyQuery.setName(rmEpsTopologyManagement.getInterfaceName());
|
||||
Map<String, Object> resultMap = switchNetSpeedEcharts(dailyQuery, percentile95);
|
||||
// 查询端口备注信息
|
||||
RmSwitchInterfaceInfo queryOtheName = new RmSwitchInterfaceInfo();
|
||||
queryOtheName.setClientId(clientId);
|
||||
@@ -879,6 +901,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
}
|
||||
String name = joiner.toString();
|
||||
resultMap.put("name", name);
|
||||
resultMap.put("timeRange", timeRange);
|
||||
resultList.add(resultMap);
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
@@ -894,9 +917,10 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
* @param initialSwitchInfoDetails
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> switchNetSpeedEcharts(InitialSwitchInfoDetails initialSwitchInfoDetails) {
|
||||
public Map<String, Object> switchNetSpeedEcharts(InitialSwitchInfoDetails initialSwitchInfoDetails, BigDecimal percentile95) {
|
||||
List<InitialSwitchInfoDetails> list = initialSwitchInfoDetailsMapper.getswitchDetailList(initialSwitchInfoDetails);
|
||||
try {
|
||||
list.forEach(data -> data.setPercentile95(SpeedUtils.mbitToBit(percentile95)));
|
||||
SpeedUtils.SpeedResult result = SpeedUtils.calculateWithAverageBasedUnit(list, "inSpeed", "outSpeed");
|
||||
BigDecimal divisor = SpeedUtils.getDivisor(result.getRecommendedUnit());
|
||||
Map<String, Function<InitialSwitchInfoDetails, ?>> extractors = new LinkedHashMap<>();
|
||||
@@ -909,8 +933,13 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
info != null && info.getOutSpeed() != null ?
|
||||
info.getOutSpeed().divide(divisor, 0, RoundingMode.HALF_UP) :
|
||||
0);
|
||||
extractors.put("percentile95", info ->
|
||||
info != null && info.getPercentile95() != null ?
|
||||
info.getPercentile95().divide(divisor, 2, RoundingMode.HALF_UP) :
|
||||
0);
|
||||
Map<String, Object> resultMap = EchartsDataUtils.buildEchartsData(list, InitialSwitchInfoDetails::getCreateTime, extractors);
|
||||
resultMap.put("other", result);
|
||||
resultMap.put("95value", percentile95);
|
||||
return resultMap;
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -527,6 +527,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
recordAddData.setClientId(registerMsg.getClientId());
|
||||
recordAddData.setTrafficPort(networkInfo.getName());
|
||||
recordAddData.setUpdateTime(DateUtils.getNowDate());
|
||||
recordAddData.setCreateTime(DateUtils.getNowDate());
|
||||
recordAddData.setUpdateBy(SecurityUtils.getUsername());
|
||||
recordAddData.setCreatBy(SecurityUtils.getUsername());
|
||||
StringBuilder content = new StringBuilder();
|
||||
@@ -636,6 +637,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
EpsMethodChangeRecord record = new EpsMethodChangeRecord();
|
||||
record.setClientId(clientId);
|
||||
record.setTrafficPort(map.get("interfaceName").toString());
|
||||
record.setCreateTime(now);
|
||||
record.setUpdateTime(now);
|
||||
record.setUpdateBy(username);
|
||||
record.setCreatBy(username);
|
||||
@@ -720,7 +722,9 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
changeRecord.setBusinessCode(rmResourceRegistration.getBusinessCode());
|
||||
changeRecord.setBusinessName(rmResourceRegistration.getBusinessName());
|
||||
changeRecord.setCreateTime(DateUtils.getNowDate());
|
||||
changeRecord.setUpdateTime(DateUtils.getNowDate());
|
||||
changeRecord.setCreatBy(SecurityUtils.getUsername());
|
||||
changeRecord.setUpdateBy(SecurityUtils.getUsername());
|
||||
// 修改内容
|
||||
String content = "业务为" + rmResourceRegistration.getBusinessName();
|
||||
changeRecord.setChangeContent(content);
|
||||
|
||||
@@ -167,20 +167,31 @@ public class RmSwitchManagementServiceImpl implements IRmSwitchManagementService
|
||||
switchManagement.setLabel(switchManagement.getSwitchName());
|
||||
// 该交换机的所有接口信息
|
||||
String clientId = switchManagement.getClientId();
|
||||
String switchName = switchManagement.getSwitchName();
|
||||
AllInterfaceName allInterfaceName = new AllInterfaceName();
|
||||
allInterfaceName.setClientId(clientId);
|
||||
List<AllInterfaceName> interfaceNameList = allInterfaceNameMapper.selectAllInterfaceNameList(allInterfaceName);
|
||||
for (AllInterfaceName interfaceName : interfaceNameList) {
|
||||
interfaceName.setValue(interfaceName.getId());
|
||||
String valueStr = String.join(";",
|
||||
interfaceName.getId().toString(),
|
||||
clientId,
|
||||
interfaceName.getInterfaceName(),
|
||||
switchName
|
||||
);
|
||||
interfaceName.setValue(valueStr);
|
||||
interfaceName.setLabel(interfaceName.getInterfaceName());
|
||||
// 查询别名
|
||||
RmSwitchInterfaceInfo query = new RmSwitchInterfaceInfo();
|
||||
query.setInterfaceName(interfaceName.getInterfaceName());
|
||||
query.setClientId(clientId);
|
||||
List<RmSwitchInterfaceInfo> interfaceInfos = rmSwitchInterfaceInfoMapper.selectRmSwitchInterfaceInfoList(query);
|
||||
String otherName = "";
|
||||
if(!interfaceInfos.isEmpty()){
|
||||
interfaceName.setOtherName(interfaceInfos.get(0).getInterfaceRemark());
|
||||
otherName = interfaceInfos.get(0).getInterfaceRemark();
|
||||
interfaceName.setOtherName(otherName);
|
||||
}
|
||||
String labelStr = String.join(" ",interfaceName.getInterfaceName(), otherName);
|
||||
interfaceName.setLabel(labelStr);
|
||||
}
|
||||
switchManagement.setChildren(interfaceNameList);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.system.domain.UserTableColumnConfig;
|
||||
import com.ruoyi.system.mapper.UserTableColumnConfigMapper;
|
||||
import com.ruoyi.system.service.IUserTableColumnConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.mapper.UserTableColumnConfigMapper;
|
||||
import com.ruoyi.system.domain.UserTableColumnConfig;
|
||||
import com.ruoyi.system.service.IUserTableColumnConfigService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户自定义列配置Service业务层处理
|
||||
@@ -53,8 +55,28 @@ public class UserTableColumnConfigServiceImpl implements IUserTableColumnConfigS
|
||||
@Override
|
||||
public int insertUserTableColumnConfig(UserTableColumnConfig userTableColumnConfig)
|
||||
{
|
||||
Long userId = userTableColumnConfig.getUserId();
|
||||
if(userId == null){
|
||||
System.err.println("用户不存在");
|
||||
return 0;
|
||||
}
|
||||
if(userTableColumnConfig.getPageRoute() == null){
|
||||
System.err.println("路由不存在");
|
||||
return 0;
|
||||
}
|
||||
userTableColumnConfig.setCreateTime(DateUtils.getNowDate());
|
||||
return userTableColumnConfigMapper.insertUserTableColumnConfig(userTableColumnConfig);
|
||||
userTableColumnConfig.setUserId(userId);
|
||||
// 查询该用户是否已存在配置
|
||||
UserTableColumnConfig configQuery = new UserTableColumnConfig();
|
||||
configQuery.setUserId(userId);
|
||||
configQuery.setPageRoute(userTableColumnConfig.getPageRoute());
|
||||
List<UserTableColumnConfig> exits = userTableColumnConfigMapper.selectUserTableColumnConfigList(configQuery);
|
||||
if(exits.isEmpty()){
|
||||
userTableColumnConfigMapper.insertUserTableColumnConfig(userTableColumnConfig);
|
||||
}else{
|
||||
userTableColumnConfigMapper.updateUserTableColumnConfig(userTableColumnConfig);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,4 +115,16 @@ public class UserTableColumnConfigServiceImpl implements IUserTableColumnConfigS
|
||||
{
|
||||
return userTableColumnConfigMapper.deleteUserTableColumnConfigById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserTableColumnConfig getColumnConfigByUserId(UserTableColumnConfig userTableColumnConfig) {
|
||||
UserTableColumnConfig configQuery = new UserTableColumnConfig();
|
||||
configQuery.setUserId(SecurityUtils.getUserId());
|
||||
configQuery.setPageRoute(userTableColumnConfig.getPageRoute());
|
||||
List<UserTableColumnConfig> userTableColumnConfigList = userTableColumnConfigMapper.selectUserTableColumnConfigList(configQuery);
|
||||
if(!userTableColumnConfigList.isEmpty()){
|
||||
return userTableColumnConfigList.get(0);
|
||||
}
|
||||
return new UserTableColumnConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,13 +198,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="getAllDeviceSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
|
||||
SELECT
|
||||
client_id AS clientId, interface_name interfaceName
|
||||
client_id AS clientId
|
||||
FROM
|
||||
all_interface_name
|
||||
<where>
|
||||
and resource_type = '1' and interface_name != ''
|
||||
and resource_type = '1' and client_id != ''
|
||||
</where>
|
||||
group by interface_name
|
||||
group by client_id
|
||||
</select>
|
||||
<select id="getAllSwitchSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
|
||||
SELECT
|
||||
|
||||
@@ -175,8 +175,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
`ipV4` AS ipV4,
|
||||
`in_dropped` AS inDropped,
|
||||
`out_dropped` AS outDropped,
|
||||
`in_speed` AS inSpeed,
|
||||
`out_speed` AS outSpeed,
|
||||
sum(ifnull(`in_speed`,0)) AS inSpeed,
|
||||
sum(ifnull(`out_speed`,0)) AS outSpeed,
|
||||
`machine_flow` AS machineFlow,
|
||||
`speed` AS speed,
|
||||
`duplex` AS duplex,
|
||||
@@ -213,7 +213,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</if>
|
||||
|
||||
</where>
|
||||
ORDER BY create_time desc
|
||||
group BY create_time desc
|
||||
</select>
|
||||
|
||||
<!-- 条件查询 -->
|
||||
|
||||
@@ -16,14 +16,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="avgMonthlyBandwidth95" column="avg_monthly_bandwidth_95" />
|
||||
<result property="packageBandwidthDaily" column="package_bandwidth_daily" />
|
||||
<result property="machineFlow" column="machine_flow" />
|
||||
<result property="customerId" column="customer_id" />
|
||||
<result property="customerName" column="customer_name" />
|
||||
<result property="serviceNumber" column="service_number" />
|
||||
<result property="uplinkSwitch" column="uplink_switch" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="creatorId" column="creator_id" />
|
||||
<result property="creatorName" column="creator_name" />
|
||||
<result property="switchSn" column="switch_sn" />
|
||||
<result property="interfaceName" column="interface_name" />
|
||||
<result property="resourceType" column="resource_type" />
|
||||
@@ -36,22 +31,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="remark1" column="remark1" />
|
||||
<result property="createDatetime" column="create_datetime" />
|
||||
<result property="clientId" column="client_id" />
|
||||
<result property="serverClientId" column="server_client_id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEpsNodeBandwidthVo">
|
||||
select id, node_name, hardware_sn, calculation_mode, bandwidth_type, bandwidth_result, bandwidth_95_daily,
|
||||
bandwidth_95_monthly, avg_monthly_bandwidth_95, package_bandwidth_daily, machine_flow, customer_id,
|
||||
customer_name, service_number, uplink_switch, create_time, update_time, creator_id, creator_name,
|
||||
switch_sn, interface_name, resource_type, interface_link_device_type, effective_bandwidth_95_daily,
|
||||
effective_bandwidth_95_monthly, effective_avg_monthly_bandwidth_95, business_name, business_id,
|
||||
remark1, create_datetime, client_id from eps_node_bandwidth
|
||||
select id, node_name, hardware_sn, calculation_mode, bandwidth_type, bandwidth_result, bandwidth_95_daily, bandwidth_95_monthly, avg_monthly_bandwidth_95, package_bandwidth_daily, machine_flow, uplink_switch, create_time, update_time, switch_sn, interface_name, resource_type, interface_link_device_type, effective_bandwidth_95_daily, effective_bandwidth_95_monthly, effective_avg_monthly_bandwidth_95, business_name, business_id, remark1, create_datetime, client_id, server_client_id, create_by, update_by from eps_node_bandwidth
|
||||
</sql>
|
||||
|
||||
<select id="selectEpsNodeBandwidthList" parameterType="EpsNodeBandwidth" resultMap="EpsNodeBandwidthResult">
|
||||
<include refid="selectEpsNodeBandwidthVo"/>
|
||||
<where>
|
||||
<if test="nodeName != null and nodeName != ''"> and node_name like concat('%', #{nodeName}, '%')</if>
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
<if test="hardwareSn != null and hardwareSn != ''"> and hardware_sn = #{hardwareSn}</if>
|
||||
<if test="calculationMode != null and calculationMode != ''"> and calculation_mode = #{calculationMode}</if>
|
||||
<if test="bandwidthType != null and bandwidthType != ''"> and bandwidth_type = #{bandwidthType}</if>
|
||||
@@ -60,12 +52,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="bandwidth95Monthly != null "> and bandwidth_95_monthly = #{bandwidth95Monthly}</if>
|
||||
<if test="avgMonthlyBandwidth95 != null "> and avg_monthly_bandwidth_95 = #{avgMonthlyBandwidth95}</if>
|
||||
<if test="packageBandwidthDaily != null "> and package_bandwidth_daily = #{packageBandwidthDaily}</if>
|
||||
<if test="customerId != null and customerId != ''"> and customer_id = #{customerId}</if>
|
||||
<if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
|
||||
<if test="serviceNumber != null and serviceNumber != ''"> and service_number = #{serviceNumber}</if>
|
||||
<if test="machineFlow != null "> and machine_flow = #{machineFlow}</if>
|
||||
<if test="uplinkSwitch != null and uplinkSwitch != ''"> and uplink_switch like concat('%', #{uplinkSwitch}, '%')</if>
|
||||
<if test="creatorId != null "> and creator_id = #{creatorId}</if>
|
||||
<if test="creatorName != null and creatorName != ''"> and creator_name like concat('%', #{creatorName}, '%')</if>
|
||||
<if test="switchSn != null and switchSn != ''"> and switch_sn = #{switchSn}</if>
|
||||
<if test="interfaceName != null and interfaceName != ''"> and interface_name like concat('%', #{interfaceName}, '%')</if>
|
||||
<if test="resourceType != null and resourceType != ''"> and resource_type = #{resourceType}</if>
|
||||
@@ -76,6 +64,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="businessName != null and businessName != ''"> and business_name like concat('%', #{businessName}, '%')</if>
|
||||
<if test="businessId != null and businessId != ''"> and business_id = #{businessId}</if>
|
||||
<if test="remark1 != null and remark1 != ''"> and remark1 = #{remark1}</if>
|
||||
<if test="createDatetime != null "> and create_datetime = #{createDatetime}</if>
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
<if test="serverClientId != null and serverClientId != ''"> and server_client_id = #{serverClientId}</if>
|
||||
<if test="startTime != null and startTime != ''"> and create_time >= #{startTime}</if>
|
||||
<if test="endTime != null and endTime != ''"> and create_time <= #{endTime}</if>
|
||||
<if test="createTime != null"> and create_time = #{createTime}</if>
|
||||
@@ -112,14 +103,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="bandwidth95Monthly != null">bandwidth_95_monthly,</if>
|
||||
<if test="avgMonthlyBandwidth95 != null">avg_monthly_bandwidth_95,</if>
|
||||
<if test="packageBandwidthDaily != null">package_bandwidth_daily,</if>
|
||||
<if test="customerId != null">customer_id,</if>
|
||||
<if test="customerName != null">customer_name,</if>
|
||||
<if test="serviceNumber != null">service_number,</if>
|
||||
<if test="machineFlow != null">machine_flow,</if>
|
||||
<if test="uplinkSwitch != null">uplink_switch,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="creatorId != null">creator_id,</if>
|
||||
<if test="creatorName != null">creator_name,</if>
|
||||
<if test="switchSn != null">switch_sn,</if>
|
||||
<if test="interfaceName != null">interface_name,</if>
|
||||
<if test="resourceType != null">resource_type,</if>
|
||||
@@ -130,8 +115,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="businessName != null">business_name,</if>
|
||||
<if test="businessId != null">business_id,</if>
|
||||
<if test="remark1 != null">remark1,</if>
|
||||
<if test="createDatetime != null">create_datetime,</if>
|
||||
<if test="clientId != null">client_id,</if>
|
||||
create_datetime,
|
||||
<if test="serverClientId != null">server_client_id,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
create_time,
|
||||
update_time,
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="nodeName != null">#{nodeName},</if>
|
||||
@@ -143,14 +133,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="bandwidth95Monthly != null">#{bandwidth95Monthly},</if>
|
||||
<if test="avgMonthlyBandwidth95 != null">#{avgMonthlyBandwidth95},</if>
|
||||
<if test="packageBandwidthDaily != null">#{packageBandwidthDaily},</if>
|
||||
<if test="customerId != null">#{customerId},</if>
|
||||
<if test="customerName != null">#{customerName},</if>
|
||||
<if test="serviceNumber != null">#{serviceNumber},</if>
|
||||
<if test="machineFlow != null">#{machineFlow},</if>
|
||||
<if test="uplinkSwitch != null">#{uplinkSwitch},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="creatorId != null">#{creatorId},</if>
|
||||
<if test="creatorName != null">#{creatorName},</if>
|
||||
<if test="switchSn != null">#{switchSn},</if>
|
||||
<if test="interfaceName != null">#{interfaceName},</if>
|
||||
<if test="resourceType != null">#{resourceType},</if>
|
||||
@@ -161,8 +145,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="businessName != null">#{businessName},</if>
|
||||
<if test="businessId != null">#{businessId},</if>
|
||||
<if test="remark1 != null">#{remark1},</if>
|
||||
<if test="createDatetime != null">#{createDatetime},</if>
|
||||
<if test="clientId != null">#{clientId},</if>
|
||||
NOW(),
|
||||
<if test="serverClientId != null">#{serverClientId},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<choose>
|
||||
<when test="createTime != null">
|
||||
#{createTime},
|
||||
</when>
|
||||
<otherwise>
|
||||
NOW(),
|
||||
</otherwise>
|
||||
</choose>
|
||||
<choose>
|
||||
<when test="updateTime != null">
|
||||
#{updateTime},
|
||||
</when>
|
||||
<otherwise>
|
||||
NOW(),
|
||||
</otherwise>
|
||||
</choose>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -178,14 +181,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="bandwidth95Monthly != null">bandwidth_95_monthly = #{bandwidth95Monthly},</if>
|
||||
<if test="avgMonthlyBandwidth95 != null">avg_monthly_bandwidth_95 = #{avgMonthlyBandwidth95},</if>
|
||||
<if test="packageBandwidthDaily != null">package_bandwidth_daily = #{packageBandwidthDaily},</if>
|
||||
<if test="customerId != null">customer_id = #{customerId},</if>
|
||||
<if test="customerName != null">customer_name = #{customerName},</if>
|
||||
<if test="serviceNumber != null">service_number = #{serviceNumber},</if>
|
||||
<if test="machineFlow != null">machine_flow = #{machineFlow},</if>
|
||||
<if test="uplinkSwitch != null">uplink_switch = #{uplinkSwitch},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="creatorId != null">creator_id = #{creatorId},</if>
|
||||
<if test="creatorName != null">creator_name = #{creatorName},</if>
|
||||
<if test="switchSn != null">switch_sn = #{switchSn},</if>
|
||||
<if test="interfaceName != null">interface_name = #{interfaceName},</if>
|
||||
<if test="resourceType != null">resource_type = #{resourceType},</if>
|
||||
@@ -198,6 +197,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="remark1 != null">remark1 = #{remark1},</if>
|
||||
<if test="createDatetime != null">create_datetime = #{createDatetime},</if>
|
||||
<if test="clientId != null">client_id = #{clientId},</if>
|
||||
<if test="serverClientId != null">server_client_id = #{serverClientId},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
@@ -14,7 +14,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="type" column="type" />
|
||||
<result property="inSpeed" column="in_speed" />
|
||||
<result property="outSpeed" column="out_speed" />
|
||||
<result property="maxSpeed" column="max_speed" />
|
||||
<result property="switchIp" column="switch_ip" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
@@ -34,10 +33,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="ifInErrors" column="if_in_errors" />
|
||||
<result property="ifOutErrors" column="if_out_errors" />
|
||||
<result property="ifIndex" column="if_index" />
|
||||
<result property="maxSpeed" column="max_speed" />
|
||||
<result property="interfaceNameRemark" column="interface_name_remark" />
|
||||
<result property="serverClientId" column="server_client_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectInitialSwitchInfoDetailsVo">
|
||||
select id, client_id, name, in_bytes, out_bytes, status, type, in_speed, out_speed, max_speed, switch_ip, create_by, update_by, create_time, update_time, switch_name, interface_device_type, server_name, server_port, server_sn, switch_sn, business_code, business_name, if_speed, if_in_discards, if_out_discards, if_in_errors, if_out_errors, if_index from initial_switch_info_details
|
||||
select id, client_id, name, in_bytes, out_bytes, status, type, in_speed, out_speed, switch_ip, create_by, update_by, create_time, update_time, switch_name, interface_device_type, server_name, server_port, server_sn, switch_sn, business_code, business_name, if_speed, if_in_discards, if_out_discards, if_in_errors, if_out_errors, if_index, max_speed, interface_name_remark, server_client_id from initial_switch_info_details
|
||||
</sql>
|
||||
|
||||
<select id="selectInitialSwitchInfoDetailsList" parameterType="InitialSwitchInfoDetails" resultMap="InitialSwitchInfoDetailsResult">
|
||||
@@ -60,6 +62,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="switchSn != null and switchSn != ''"> and switch_sn = #{switchSn}</if>
|
||||
<if test="businessCode != null and businessCode != ''"> and business_code = #{businessCode}</if>
|
||||
<if test="businessName != null and businessName != ''"> and business_name like concat('%', #{businessName}, '%')</if>
|
||||
<if test="interfaceNameRemark != null and interfaceNameRemark != ''"> and interface_name_remark = #{interfaceNameRemark}</if>
|
||||
<if test="serverClientId != null and serverClientId != ''"> and server_client_id = #{serverClientId}</if>
|
||||
<if test="startTime != null">
|
||||
and create_time >= #{startTime}
|
||||
</if>
|
||||
@@ -86,7 +90,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="type != null">type,</if>
|
||||
<if test="inSpeed != null">in_speed,</if>
|
||||
<if test="outSpeed != null">out_speed,</if>
|
||||
<if test="maxSpeed != null">max_speed,</if>
|
||||
<if test="switchIp != null">switch_ip,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
@@ -105,7 +108,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="ifOutDiscards != null">if_out_discards,</if>
|
||||
<if test="ifInErrors != null">if_in_errors,</if>
|
||||
<if test="ifOutErrors != null">if_out_errors,</if>
|
||||
<if test="ifIndex != null and ifIndex != ''">if_index,</if>
|
||||
<if test="ifIndex != null">if_index,</if>
|
||||
<if test="maxSpeed != null">max_speed,</if>
|
||||
<if test="interfaceNameRemark != null">interface_name_remark,</if>
|
||||
<if test="serverClientId != null">server_client_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="clientId != null and clientId != ''">#{clientId},</if>
|
||||
@@ -116,7 +122,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="inSpeed != null">#{inSpeed},</if>
|
||||
<if test="outSpeed != null">#{outSpeed},</if>
|
||||
<if test="maxSpeed != null">#{maxSpeed},</if>
|
||||
<if test="switchIp != null">#{switchIp},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
@@ -135,7 +140,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="ifOutDiscards != null">#{ifOutDiscards},</if>
|
||||
<if test="ifInErrors != null">#{ifInErrors},</if>
|
||||
<if test="ifOutErrors != null">#{ifOutErrors},</if>
|
||||
<if test="ifIndex != null and ifIndex != ''">#{ifIndex},</if>
|
||||
<if test="ifIndex != null">#{ifIndex},</if>
|
||||
<if test="maxSpeed != null">#{maxSpeed},</if>
|
||||
<if test="interfaceNameRemark != null">#{interfaceNameRemark},</if>
|
||||
<if test="serverClientId != null">#{serverClientId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -150,7 +158,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="inSpeed != null">in_speed = #{inSpeed},</if>
|
||||
<if test="outSpeed != null">out_speed = #{outSpeed},</if>
|
||||
<if test="maxSpeed != null">max_speed = #{maxSpeed},</if>
|
||||
<if test="switchIp != null">switch_ip = #{switchIp},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
@@ -169,7 +176,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="ifOutDiscards != null">if_out_discards = #{ifOutDiscards},</if>
|
||||
<if test="ifInErrors != null">if_in_errors = #{ifInErrors},</if>
|
||||
<if test="ifOutErrors != null">if_out_errors = #{ifOutErrors},</if>
|
||||
<if test="ifIndex != null and ifIndex != ''">if_index = #{ifIndex},</if>
|
||||
<if test="ifIndex != null">if_index = #{ifIndex},</if>
|
||||
<if test="maxSpeed != null">max_speed = #{maxSpeed},</if>
|
||||
<if test="interfaceNameRemark != null">interface_name_remark = #{interfaceNameRemark},</if>
|
||||
<if test="serverClientId != null">server_client_id = #{serverClientId},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
@@ -196,7 +206,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
`type`,
|
||||
in_speed AS inSpeed,
|
||||
out_speed AS outSpeed,
|
||||
max_speed AS maxSpeed,
|
||||
switch_ip AS switchIp,
|
||||
if_index AS ifIndex,
|
||||
if_speed AS ifSpeed,
|
||||
@@ -248,7 +257,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
create_by,
|
||||
update_by,
|
||||
create_time,
|
||||
update_time
|
||||
update_time,
|
||||
interface_name_remark,
|
||||
server_client_id
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="dataList" item="item" separator=",">
|
||||
@@ -294,7 +305,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<otherwise>
|
||||
NOW()
|
||||
</otherwise>
|
||||
</choose>
|
||||
</choose>,
|
||||
#{item.interfaceNameRemark},
|
||||
#{item.serverClientId}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
@@ -359,7 +359,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and client_id = #{clientId}
|
||||
</when>
|
||||
<otherwise>
|
||||
1=0 <!-- 如果两个条件都不满足,则不更新任何记录 -->
|
||||
and 1=0 <!-- 如果两个条件都不满足,则不更新任何记录 -->
|
||||
</otherwise>
|
||||
</choose>
|
||||
</where>
|
||||
|
||||
@@ -61,7 +61,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="updateUserTableColumnConfig" parameterType="UserTableColumnConfig">
|
||||
update user_table_column_config
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="pageRoute != null and pageRoute != ''">page_route = #{pageRoute},</if>
|
||||
<if test="columnConfig != null and columnConfig != ''">column_config = #{columnConfig},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
@@ -70,7 +69,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
<where>
|
||||
<choose>
|
||||
<when test="id != null">
|
||||
and id = #{id}
|
||||
</when>
|
||||
<when test="userId != null">
|
||||
and user_id = #{userId}
|
||||
</when>
|
||||
<otherwise>
|
||||
and 1=0 <!-- 如果两个条件都不满足,则不更新任何记录 -->
|
||||
</otherwise>
|
||||
</choose>
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<delete id="deleteUserTableColumnConfigById" parameterType="Long">
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.springframework.data.redis.core.RedisOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.SessionCallback;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@@ -651,7 +650,7 @@ public class DeviceMessageHandler {
|
||||
}
|
||||
|
||||
// 添加一个定时任务方法,定期检查心跳状态
|
||||
@Scheduled(fixedRate = 60000) // 每60s检查一次
|
||||
// @Scheduled(fixedRate = 60000) // 每60s检查一次
|
||||
public void checkHeartbeatStatus() {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
log.debug("开始心跳状态检查,当前时间: {}", currentTime);
|
||||
|
||||
@@ -115,6 +115,7 @@ public class MessageHandler {
|
||||
private void handleNetWorkDelectMessage(DeviceMessage message) {
|
||||
List<RegisterMsgVo> interfaces = JsonDataParser.parseJsonData(message.getData(), RegisterMsgVo.class);
|
||||
if(!interfaces.isEmpty()) {
|
||||
String clientId = message.getClientId();
|
||||
RegisterMsgVo registerMsg = interfaces.get(0);
|
||||
// 时间戳转换
|
||||
long timestamp = registerMsg.getTimestamp();
|
||||
@@ -126,6 +127,7 @@ public class MessageHandler {
|
||||
NetworkInfo networkInfo = networkInfoList.get(0);
|
||||
// 查询该网卡信息是否存在
|
||||
RmNetworkInterface queryParam = new RmNetworkInterface();
|
||||
queryParam.setClientId(clientId);
|
||||
queryParam.setMacAddress(networkInfo.getMac());
|
||||
queryParam.setNewFlag(1);
|
||||
List<RmNetworkInterface> exits = rmNetworkInterfaceService.selectRmNetworkInterfaceList(queryParam);
|
||||
@@ -134,7 +136,7 @@ public class MessageHandler {
|
||||
RmNetworkInterface insertData = new RmNetworkInterface();
|
||||
// 业务ip和管理网ip
|
||||
insertData.setBindIp("3");
|
||||
insertData.setClientId(registerMsg.getClientId());
|
||||
insertData.setClientId(clientId);
|
||||
insertData.setIsp(networkInfo.getCarrier());
|
||||
insertData.setCity(networkInfo.getCity());
|
||||
insertData.setGateway(networkInfo.getGateway());
|
||||
@@ -152,9 +154,10 @@ public class MessageHandler {
|
||||
|| !StringUtils.equals(networkInfo.getGateway(),oldInterfaceMsg.getGateway())){
|
||||
// 查询该网卡信息是否旧数据
|
||||
RmNetworkInterface query = new RmNetworkInterface();
|
||||
query.setMacAddress(networkInfo.getMac());
|
||||
query.setMacAddress(oldInterfaceMsg.getMacAddress());
|
||||
query.setClientId(clientId);
|
||||
query.setNewFlag(999);
|
||||
List<RmNetworkInterface> oldExits = rmNetworkInterfaceService.selectRmNetworkInterfaceList(queryParam);
|
||||
List<RmNetworkInterface> oldExits = rmNetworkInterfaceService.selectRmNetworkInterfaceList(query);
|
||||
if(!oldExits.isEmpty()){
|
||||
// 先删除旧数据
|
||||
oldExits.forEach(oldMsg ->{
|
||||
@@ -164,10 +167,11 @@ public class MessageHandler {
|
||||
// 先将已存在的改为旧数据
|
||||
RmNetworkInterface oldData = new RmNetworkInterface();
|
||||
oldData.setNewFlag(0);
|
||||
oldData.setMacAddress(networkInfo.getMac());
|
||||
oldData.setClientId(clientId);
|
||||
oldData.setMacAddress(oldInterfaceMsg.getMacAddress());
|
||||
rmNetworkInterfaceService.updateRmNetworkInterfaceByMac(oldData);
|
||||
RmNetworkInterface insertData = new RmNetworkInterface();
|
||||
insertData.setMacAddress(networkInfo.getMac());
|
||||
insertData.setClientId(clientId);
|
||||
insertData.setIsp(networkInfo.getCarrier());
|
||||
insertData.setCity(networkInfo.getCity());
|
||||
insertData.setGateway(networkInfo.getGateway());
|
||||
@@ -209,6 +213,8 @@ public class MessageHandler {
|
||||
}
|
||||
// 只有有字段变化时才执行更新
|
||||
if (needUpdate) {
|
||||
updateData.setClientId(clientId);
|
||||
updateData.setMacAddress(oldInterfaceMsg.getMacAddress());
|
||||
rmNetworkInterfaceService.updateRmNetworkInterfaceByMac(updateData);
|
||||
}
|
||||
}
|
||||
@@ -217,13 +223,14 @@ public class MessageHandler {
|
||||
for (NetworkInfo networkInfo : networkInfoList) {
|
||||
// 查询该网卡信息是否存在
|
||||
RmNetworkInterface queryParam = new RmNetworkInterface();
|
||||
queryParam.setClientId(clientId);
|
||||
queryParam.setMacAddress(networkInfo.getMac());
|
||||
List<RmNetworkInterface> exits = rmNetworkInterfaceService.selectRmNetworkInterfaceList(queryParam);
|
||||
if(exits.isEmpty()){
|
||||
// 保存网卡信息
|
||||
RmNetworkInterface insertData = new RmNetworkInterface();
|
||||
// 业务ip和管理网ip
|
||||
insertData.setClientId(registerMsg.getClientId());
|
||||
insertData.setClientId(clientId);
|
||||
insertData.setIsp(networkInfo.getCarrier());
|
||||
insertData.setCity(networkInfo.getCity());
|
||||
insertData.setGateway(networkInfo.getGateway());
|
||||
@@ -241,9 +248,10 @@ public class MessageHandler {
|
||||
|| !StringUtils.equals(networkInfo.getGateway(),oldInterfaceMsg.getGateway())){
|
||||
// 查询该网卡信息是否旧数据
|
||||
RmNetworkInterface query = new RmNetworkInterface();
|
||||
query.setClientId(clientId);
|
||||
query.setMacAddress(networkInfo.getMac());
|
||||
query.setNewFlag(999);
|
||||
List<RmNetworkInterface> oldExits = rmNetworkInterfaceService.selectRmNetworkInterfaceList(queryParam);
|
||||
List<RmNetworkInterface> oldExits = rmNetworkInterfaceService.selectRmNetworkInterfaceList(query);
|
||||
if(!oldExits.isEmpty()){
|
||||
// 先删除旧数据
|
||||
oldExits.forEach(oldMsg ->{
|
||||
@@ -253,10 +261,11 @@ public class MessageHandler {
|
||||
// 先将已存在的改为旧数据
|
||||
RmNetworkInterface oldData = new RmNetworkInterface();
|
||||
oldData.setNewFlag(0);
|
||||
oldData.setMacAddress(networkInfo.getMac());
|
||||
oldData.setClientId(clientId);
|
||||
oldData.setMacAddress(oldInterfaceMsg.getMacAddress());
|
||||
rmNetworkInterfaceService.updateRmNetworkInterfaceByMac(oldData);
|
||||
RmNetworkInterface insertData = new RmNetworkInterface();
|
||||
insertData.setMacAddress(networkInfo.getMac());
|
||||
insertData.setClientId(clientId);
|
||||
insertData.setIsp(networkInfo.getCarrier());
|
||||
insertData.setCity(networkInfo.getCity());
|
||||
insertData.setGateway(networkInfo.getGateway());
|
||||
@@ -290,7 +299,7 @@ public class MessageHandler {
|
||||
updateData.setBindIp("0");
|
||||
// 修改绑定公网ip状态
|
||||
RmResourceRegistrationRemote updateParam = new RmResourceRegistrationRemote();
|
||||
updateParam.setClientId(registerMsg.getClientId());
|
||||
updateParam.setClientId(clientId);
|
||||
updateParam.setMultiPublicIpStatus("0");
|
||||
remoteRevenueConfigService.updateStatusByResource(updateParam, SecurityConstants.INNER);
|
||||
}
|
||||
@@ -304,6 +313,8 @@ public class MessageHandler {
|
||||
}
|
||||
// 只有有字段变化时才执行更新
|
||||
if (needUpdate) {
|
||||
updateData.setClientId(clientId);
|
||||
updateData.setMacAddress(oldInterfaceMsg.getMacAddress());
|
||||
rmNetworkInterfaceService.updateRmNetworkInterfaceByMac(updateData);
|
||||
}
|
||||
}
|
||||
@@ -339,6 +350,7 @@ public class MessageHandler {
|
||||
private void handleRegisterMessage(DeviceMessage message) {
|
||||
List<RegisterMsgVo> interfaces = JsonDataParser.parseJsonData(message.getData(), RegisterMsgVo.class);
|
||||
if(!interfaces.isEmpty()) {
|
||||
String clientId = message.getClientId();
|
||||
RegisterMsgVo registerMsg = interfaces.get(0);
|
||||
// 自动注册服务器信息
|
||||
RmRegisterMsgRemote rmRegisterMsgRemote = new RmRegisterMsgRemote();
|
||||
@@ -359,6 +371,7 @@ public class MessageHandler {
|
||||
NetworkInfo networkInfo = networkInfoList.get(0);
|
||||
// 查询该网卡信息是否存在
|
||||
RmNetworkInterface queryParam = new RmNetworkInterface();
|
||||
queryParam.setClientId(clientId);
|
||||
queryParam.setMacAddress(networkInfo.getMac());
|
||||
queryParam.setNewFlag(1);
|
||||
List<RmNetworkInterface> exits = rmNetworkInterfaceService.selectRmNetworkInterfaceList(queryParam);
|
||||
@@ -367,7 +380,7 @@ public class MessageHandler {
|
||||
RmNetworkInterface insertData = new RmNetworkInterface();
|
||||
// 业务ip和管理网ip
|
||||
insertData.setBindIp("3");
|
||||
insertData.setClientId(registerMsg.getClientId());
|
||||
insertData.setClientId(clientId);
|
||||
insertData.setIsp(networkInfo.getCarrier());
|
||||
insertData.setCity(networkInfo.getCity());
|
||||
insertData.setGateway(networkInfo.getGateway());
|
||||
@@ -385,9 +398,10 @@ public class MessageHandler {
|
||||
|| !StringUtils.equals(networkInfo.getGateway(),oldInterfaceMsg.getGateway())){
|
||||
// 查询该网卡信息是否旧数据
|
||||
RmNetworkInterface query = new RmNetworkInterface();
|
||||
query.setMacAddress(networkInfo.getMac());
|
||||
query.setClientId(clientId);
|
||||
query.setMacAddress(oldInterfaceMsg.getMacAddress());
|
||||
query.setNewFlag(999);
|
||||
List<RmNetworkInterface> oldExits = rmNetworkInterfaceService.selectRmNetworkInterfaceList(queryParam);
|
||||
List<RmNetworkInterface> oldExits = rmNetworkInterfaceService.selectRmNetworkInterfaceList(query);
|
||||
if(!oldExits.isEmpty()){
|
||||
// 先删除旧数据
|
||||
oldExits.forEach(oldMsg ->{
|
||||
@@ -397,10 +411,11 @@ public class MessageHandler {
|
||||
// 先将已存在的改为旧数据
|
||||
RmNetworkInterface oldData = new RmNetworkInterface();
|
||||
oldData.setNewFlag(0);
|
||||
oldData.setMacAddress(networkInfo.getMac());
|
||||
oldData.setMacAddress(oldInterfaceMsg.getMacAddress());
|
||||
oldData.setClientId(clientId);
|
||||
rmNetworkInterfaceService.updateRmNetworkInterfaceByMac(oldData);
|
||||
RmNetworkInterface insertData = new RmNetworkInterface();
|
||||
insertData.setMacAddress(networkInfo.getMac());
|
||||
insertData.setClientId(clientId);
|
||||
insertData.setIsp(networkInfo.getCarrier());
|
||||
insertData.setCity(networkInfo.getCity());
|
||||
insertData.setGateway(networkInfo.getGateway());
|
||||
@@ -442,6 +457,8 @@ public class MessageHandler {
|
||||
}
|
||||
// 只有有字段变化时才执行更新
|
||||
if (needUpdate) {
|
||||
updateData.setClientId(clientId);
|
||||
updateData.setMacAddress(oldInterfaceMsg.getMacAddress());
|
||||
rmNetworkInterfaceService.updateRmNetworkInterfaceByMac(updateData);
|
||||
}
|
||||
}
|
||||
@@ -451,12 +468,13 @@ public class MessageHandler {
|
||||
// 查询该网卡信息是否存在
|
||||
RmNetworkInterface queryParam = new RmNetworkInterface();
|
||||
queryParam.setMacAddress(networkInfo.getMac());
|
||||
queryParam.setClientId(clientId);
|
||||
List<RmNetworkInterface> exits = rmNetworkInterfaceService.selectRmNetworkInterfaceList(queryParam);
|
||||
if(exits.isEmpty()){
|
||||
// 保存网卡信息
|
||||
RmNetworkInterface insertData = new RmNetworkInterface();
|
||||
// 业务ip和管理网ip
|
||||
insertData.setClientId(registerMsg.getClientId());
|
||||
insertData.setClientId(clientId);
|
||||
insertData.setIsp(networkInfo.getCarrier());
|
||||
insertData.setCity(networkInfo.getCity());
|
||||
insertData.setGateway(networkInfo.getGateway());
|
||||
@@ -474,9 +492,10 @@ public class MessageHandler {
|
||||
|| !StringUtils.equals(networkInfo.getGateway(),oldInterfaceMsg.getGateway())){
|
||||
// 查询该网卡信息是否旧数据
|
||||
RmNetworkInterface query = new RmNetworkInterface();
|
||||
query.setMacAddress(networkInfo.getMac());
|
||||
query.setClientId(clientId);
|
||||
query.setMacAddress(oldInterfaceMsg.getMacAddress());
|
||||
query.setNewFlag(999);
|
||||
List<RmNetworkInterface> oldExits = rmNetworkInterfaceService.selectRmNetworkInterfaceList(queryParam);
|
||||
List<RmNetworkInterface> oldExits = rmNetworkInterfaceService.selectRmNetworkInterfaceList(query);
|
||||
if(!oldExits.isEmpty()){
|
||||
// 先删除旧数据
|
||||
oldExits.forEach(oldMsg ->{
|
||||
@@ -486,10 +505,11 @@ public class MessageHandler {
|
||||
// 先将已存在的改为旧数据
|
||||
RmNetworkInterface oldData = new RmNetworkInterface();
|
||||
oldData.setNewFlag(0);
|
||||
oldData.setMacAddress(networkInfo.getMac());
|
||||
oldData.setClientId(clientId);
|
||||
oldData.setMacAddress(oldInterfaceMsg.getMacAddress());
|
||||
rmNetworkInterfaceService.updateRmNetworkInterfaceByMac(oldData);
|
||||
RmNetworkInterface insertData = new RmNetworkInterface();
|
||||
insertData.setMacAddress(networkInfo.getMac());
|
||||
insertData.setClientId(clientId);
|
||||
insertData.setIsp(networkInfo.getCarrier());
|
||||
insertData.setCity(networkInfo.getCity());
|
||||
insertData.setGateway(networkInfo.getGateway());
|
||||
@@ -523,7 +543,7 @@ public class MessageHandler {
|
||||
updateData.setBindIp("0");
|
||||
// 修改绑定公网ip状态
|
||||
RmResourceRegistrationRemote updateParam = new RmResourceRegistrationRemote();
|
||||
updateParam.setClientId(registerMsg.getClientId());
|
||||
updateParam.setClientId(clientId);
|
||||
updateParam.setMultiPublicIpStatus("0");
|
||||
remoteRevenueConfigService.updateStatusByResource(updateParam, SecurityConstants.INNER);
|
||||
}
|
||||
@@ -537,6 +557,8 @@ public class MessageHandler {
|
||||
}
|
||||
// 只有有字段变化时才执行更新
|
||||
if (needUpdate) {
|
||||
updateData.setClientId(clientId);
|
||||
updateData.setMacAddress(oldInterfaceMsg.getMacAddress());
|
||||
rmNetworkInterfaceService.updateRmNetworkInterfaceByMac(updateData);
|
||||
}
|
||||
}
|
||||
@@ -942,7 +964,7 @@ public class MessageHandler {
|
||||
RmResourceRegistrationRemote rmResourceRegistrationRemote = new RmResourceRegistrationRemote();
|
||||
rmResourceRegistrationRemote.setOnlineStatus(status);
|
||||
rmResourceRegistrationRemote.setRegistrationStatus(status);
|
||||
rmResourceRegistrationRemote.setHardwareSn(clientId);
|
||||
rmResourceRegistrationRemote.setClientId(clientId);
|
||||
remoteRevenueConfigService.updateStatusByResource(rmResourceRegistrationRemote, SecurityConstants.INNER);
|
||||
}
|
||||
// 插入心跳日志到数据库
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.rocketmq.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.utils.ConvertOtherTypeUtil;
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.common.core.utils.EchartsDataUtils;
|
||||
import com.ruoyi.common.core.utils.SpeedUtils;
|
||||
@@ -134,8 +135,11 @@ public class InitialSwitchInfoServiceImpl implements IInitialSwitchInfoService
|
||||
*/
|
||||
@Override
|
||||
public InitialSwitchInfo getSwitchNetDetailsMsg(InitialSwitchInfo initialSwitchInfo) {
|
||||
|
||||
return initialSwitchInfoMapper.getSwitchNetDetailsMsg(initialSwitchInfo);
|
||||
InitialSwitchInfo info = initialSwitchInfoMapper.getSwitchNetDetailsMsg(initialSwitchInfo);
|
||||
if(info.getType()!=null){
|
||||
info.setType(ConvertOtherTypeUtil.getInterfaceTypeName(Integer.parseInt(info.getType())));
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -434,10 +434,11 @@ public class RmMonitorPolicyServiceImpl implements IRmMonitorPolicyService
|
||||
startCollectSwitchMsgToDevices(policy.getDeployDevice(), uniqueList, switchOidVo);
|
||||
}
|
||||
// 更新策略状态为已下发
|
||||
if("1".equals(policy.getPriority())){
|
||||
if("1".equals(policy.getPriority()) && "0".equals(policy.getStatus())){
|
||||
RmMonitorPolicy policyUpdate = new RmMonitorPolicy();
|
||||
policyUpdate.setId(id);
|
||||
policyUpdate.setStatus("1");
|
||||
policyUpdate.setDeployTime(DateUtils.getNowDate());
|
||||
rmMonitorPolicyMapper.updateRmMonitorPolicy(policyUpdate);
|
||||
}
|
||||
return 1;
|
||||
@@ -875,6 +876,9 @@ public class RmMonitorPolicyServiceImpl implements IRmMonitorPolicyService
|
||||
try {
|
||||
// 根据clientId 查询 交换机信息
|
||||
RmSwitchManagementRemote switchMsg = dataProcessUtil.getSwitchMsg(clientId);
|
||||
if(switchMsg == null){
|
||||
continue;
|
||||
}
|
||||
String switchIp = switchMsg.getSnmpAddress();
|
||||
String community = switchMsg.getCommunityName();
|
||||
int port = Math.toIntExact(switchMsg.getSnmpPort());
|
||||
|
||||
@@ -123,7 +123,7 @@ public class DynamicOidCollector {
|
||||
for (Integer index : indexes) {
|
||||
Map<String, String> deviceInfo = getDeviceInfo(target, index, oidParams);
|
||||
if (!deviceInfo.isEmpty()) {
|
||||
deviceInfo.put("index", String.valueOf(index));
|
||||
// deviceInfo.put("index", String.valueOf(index));
|
||||
results.add(deviceInfo);
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public class DynamicOidCollector {
|
||||
return new CollectionResult(switchVo.getIp(), deviceType, results, true);
|
||||
} catch (Exception e) {
|
||||
String errorMsg = String.format("采集失败: {}", e.getMessage());
|
||||
System.err.printf("采集交换机 {} 的 {} 信息失败: {}",
|
||||
log.error("采集交换机 {} 的 {} 信息失败: {}",
|
||||
switchVo.getIp(), deviceType, errorMsg);
|
||||
return new CollectionResult(switchVo.getIp(), deviceType, errorMsg);
|
||||
}
|
||||
@@ -520,51 +520,49 @@ public class DynamicOidCollector {
|
||||
/**
|
||||
* 主程序入口 (支持v2c和v3测试)
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
DynamicOidCollector collector = new DynamicOidCollector();
|
||||
|
||||
try {
|
||||
// 初始化
|
||||
collector.init();
|
||||
|
||||
// 创建动态配置的交换机列表 (支持v2c和v3混合)
|
||||
List<SwitchOidDto> switches = Arrays.asList(
|
||||
createExampleSwitch("123.182.89.17", "chengde_200G"), // v2c
|
||||
createV3ExampleSwitch("1.194.193.81", "v3user", "SHA", "auth123", "AES128", "priv123") // v3
|
||||
);
|
||||
|
||||
// 并发采集所有交换机
|
||||
System.out.println("开始并发采集 " + switches.size() + " 台交换机...");
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
Map<String, Map<String, CollectionResult>> results = collector.collectAllSwitches(switches);
|
||||
|
||||
long endTime = System.currentTimeMillis();
|
||||
|
||||
// 显示统计信息
|
||||
System.out.println("\n=== 采集统计 ===");
|
||||
int totalDevices = 0;
|
||||
for (Map.Entry<String, Map<String, CollectionResult>> entry : results.entrySet()) {
|
||||
String ip = entry.getKey();
|
||||
Map<String, CollectionResult> deviceResults = entry.getValue();
|
||||
|
||||
int switchDevices = deviceResults.values().stream()
|
||||
.filter(CollectionResult::isSuccess)
|
||||
.mapToInt(r -> r.getData().size())
|
||||
.sum();
|
||||
|
||||
totalDevices += switchDevices;
|
||||
log.info("交换机 {}: %d 个设备", ip, switchDevices);
|
||||
}
|
||||
|
||||
log.info("总计: %d 台交换机, %d 个设备", results.size(), totalDevices);
|
||||
log.info("总采集时间: %.2f 秒", (endTime - startTime) / 1000.0);
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("采集程序出错: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
collector.shutdown();
|
||||
}
|
||||
}
|
||||
// public static void main(String[] args) {
|
||||
// DynamicOidCollector collector = new DynamicOidCollector();
|
||||
//
|
||||
// try {
|
||||
// // 初始化
|
||||
// collector.init();
|
||||
//
|
||||
// // 创建动态配置的交换机列表 (支持v2c和v3混合)
|
||||
// List<SwitchOidDto> switches = Arrays.asList(
|
||||
// createExampleSwitch("123.182.89.17", "chengde_200G"), // v2c
|
||||
// createV3ExampleSwitch("1.194.193.81", "v3user", "SHA", "auth123", "AES128", "priv123") // v3
|
||||
// );
|
||||
//
|
||||
// // 并发采集所有交换机
|
||||
// log.info("开始并发采集 {} 台交换机...", switches.size());
|
||||
// long startTime = System.currentTimeMillis();
|
||||
//
|
||||
// Map<String, Map<String, CollectionResult>> results = collector.collectAllSwitches(switches);
|
||||
//
|
||||
// long endTime = System.currentTimeMillis();
|
||||
//
|
||||
// // 显示统计信息
|
||||
// int totalDevices = 0;
|
||||
// for (Map.Entry<String, Map<String, CollectionResult>> entry : results.entrySet()) {
|
||||
// String ip = entry.getKey();
|
||||
// Map<String, CollectionResult> deviceResults = entry.getValue();
|
||||
//
|
||||
// int switchDevices = deviceResults.values().stream()
|
||||
// .filter(CollectionResult::isSuccess)
|
||||
// .mapToInt(r -> r.getData().size())
|
||||
// .sum();
|
||||
//
|
||||
// totalDevices += switchDevices;
|
||||
// }
|
||||
//
|
||||
// log.info("总计: %d 台交换机, %d 个设备", results.size(), totalDevices);
|
||||
// log.info("总采集时间: %.2f 秒", (endTime - startTime) / 1000.0);
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// log.error("采集程序出错: {}", e.getMessage());
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// collector.shutdown();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -7,7 +7,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@@ -22,14 +25,33 @@ public class SwitchStrategyInitializer {
|
||||
public void init() {
|
||||
log.info("开始初始化交换机采集策略...");
|
||||
try {
|
||||
// 下发优先级为0的交换机策略
|
||||
RmMonitorPolicy queryParam = new RmMonitorPolicy();
|
||||
queryParam.setPriority("0");
|
||||
queryParam.setResourceType("switch");
|
||||
List<RmMonitorPolicy> defaultPolicy = rmMonitorPolicyService.selectRmMonitorPolicyList(queryParam);
|
||||
if(!defaultPolicy.isEmpty()){
|
||||
rmMonitorPolicyService.issueSwitchPolicy(defaultPolicy.get(0).getId());
|
||||
}
|
||||
// 下发交换机策略(优先级0和已下发的优先级1)
|
||||
List<RmMonitorPolicy> policiesToIssue = new ArrayList<>();
|
||||
|
||||
// 1. 添加优先级为0的默认策略
|
||||
RmMonitorPolicy defaultQuery = new RmMonitorPolicy();
|
||||
defaultQuery.setPriority("0");
|
||||
defaultQuery.setResourceType("switch");
|
||||
rmMonitorPolicyService.selectRmMonitorPolicyList(defaultQuery)
|
||||
.stream()
|
||||
.findFirst()
|
||||
.ifPresent(policiesToIssue::add);
|
||||
|
||||
// 2. 添加已下发的优先级1策略
|
||||
RmMonitorPolicy issuedQuery = new RmMonitorPolicy();
|
||||
issuedQuery.setPriority("1");
|
||||
issuedQuery.setStatus("1");
|
||||
issuedQuery.setResourceType("switch");
|
||||
List<RmMonitorPolicy> monitorPolicies = rmMonitorPolicyService.selectRmMonitorPolicyList(issuedQuery);
|
||||
List<RmMonitorPolicy> monitorPolicyList = monitorPolicies.stream()
|
||||
.sorted(Comparator.comparing(RmMonitorPolicy::getCreateTime))
|
||||
.collect(Collectors.toList());
|
||||
policiesToIssue.addAll(monitorPolicyList);
|
||||
|
||||
// 3. 统一下发所有符合条件的策略
|
||||
policiesToIssue.forEach(policy ->
|
||||
rmMonitorPolicyService.issueSwitchPolicy(policy.getId())
|
||||
);
|
||||
} catch (Exception e) {
|
||||
log.error("初始化交换机采集策略失败", e);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,15 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectInitialSwitchInfoVo">
|
||||
select id, client_id, name, in_bytes, out_bytes, status, type, in_speed, out_speed, switch_ip, if_index, if_speed, if_in_discards, if_out_discards, if_in_errors, if_out_errors, create_by, update_by, create_time, update_time from initial_switch_info
|
||||
select id, client_id, name, in_bytes, out_bytes,
|
||||
CASE
|
||||
WHEN status = 1 THEN 'up'
|
||||
WHEN status = 2 THEN 'down'
|
||||
ELSE `status`
|
||||
END AS status,
|
||||
type, in_speed, out_speed, switch_ip, if_index,
|
||||
if_speed, if_in_discards, if_out_discards, if_in_errors, if_out_errors, create_by, update_by, create_time,
|
||||
update_time from initial_switch_info
|
||||
</sql>
|
||||
|
||||
<select id="selectInitialSwitchInfoList" parameterType="InitialSwitchInfo" resultMap="InitialSwitchInfoResult">
|
||||
|
||||
@@ -143,6 +143,6 @@
|
||||
<if test="bindIp != null">bind_ip = #{bindIp},</if>
|
||||
<if test="newFlag != null">new_flag = #{newFlag},</if>
|
||||
</trim>
|
||||
where mac_address = #{macAddress}
|
||||
where mac_address = #{macAddress} and clientId = #{clientId}
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user