diff --git a/tongran-common/tongran-common-core/src/main/java/com/tongran/common/core/utils/EchartsMoreDataUtils.java b/tongran-common/tongran-common-core/src/main/java/com/tongran/common/core/utils/EchartsMoreDataUtils.java index 7dd3bcd..d96d417 100644 --- a/tongran-common/tongran-common-core/src/main/java/com/tongran/common/core/utils/EchartsMoreDataUtils.java +++ b/tongran-common/tongran-common-core/src/main/java/com/tongran/common/core/utils/EchartsMoreDataUtils.java @@ -416,4 +416,56 @@ public class EchartsMoreDataUtils { long timeMillis = time.getTime(); return (timeMillis / interval) * interval; } + public static Map sortInterfaceMap(Map interfaceMap, String mainName, boolean hasSub) { + List> list = new ArrayList<>(interfaceMap.entrySet()); + + list.sort((a, b) -> { + String ka = a.getKey(), kb = b.getKey(); + + // 总流量优先 + if (hasSub) { + if (ka.startsWith("total")) return -1; + if (kb.startsWith("total")) return 1; + } + + // 提取接口名 + String na = ka.replace("netInTraffic", "").replace("netOutTraffic", ""); + String nb = kb.replace("netInTraffic", "").replace("netOutTraffic", ""); + + // 主接口优先 + if (na.equals(mainName) && !nb.equals(mainName)) return -1; + if (!na.equals(mainName) && nb.equals(mainName)) return 1; + + // 点号数量排序 + int da = na.length() - na.replace(".", "").length(); + int db = nb.length() - nb.replace(".", "").length(); + if (da != db) return da - db; + + // 数字排序 + String[] sa = na.split("\\."); + String[] sb = nb.split("\\."); + for (int i = 0; i < Math.min(sa.length, sb.length); i++) { + try { + int numa = Integer.parseInt(sa[i]); + int numb = Integer.parseInt(sb[i]); + if (numa != numb) return Integer.compare(numa, numb); + } catch (Exception e) { + int cmp = sa[i].compareTo(sb[i]); + if (cmp != 0) return cmp; + } + } + + // 接口名相同,出站优先 + if (na.equals(nb)) { + if (ka.contains("Out") && kb.contains("In")) return -1; // 出站在前 + if (ka.contains("In") && kb.contains("Out")) return 1; // 入站在后 + } + + return 0; + }); + + Map result = new LinkedHashMap<>(); + list.forEach(e -> result.put(e.getKey(), e.getValue())); + return result; + } } \ No newline at end of file diff --git a/tongran-modules/tongran-system/src/main/java/com/tongran/system/controller/RmResourceRegistrationController.java b/tongran-modules/tongran-system/src/main/java/com/tongran/system/controller/RmResourceRegistrationController.java index f35f93a..dadf007 100644 --- a/tongran-modules/tongran-system/src/main/java/com/tongran/system/controller/RmResourceRegistrationController.java +++ b/tongran-modules/tongran-system/src/main/java/com/tongran/system/controller/RmResourceRegistrationController.java @@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -153,6 +154,20 @@ public class RmResourceRegistrationController extends BaseController List list = rmResourceRegistrationService.selectRmResourceRegistrationList(rmResourceRegistration); return success(list); } + @GetMapping("/getAlarmFlag") + public AjaxResult getAlarmFlag() + { + List list = rmResourceRegistrationService.selectRmResourceRegistrationList(new RmResourceRegistration()); + for (RmResourceRegistration item : list) { + boolean isAlarm = (item.getCpuUtil() != null && item.getCpuUtil().compareTo(BigDecimal.valueOf(80)) >= 0) || + (item.getMemUtil() != null && item.getMemUtil().compareTo(BigDecimal.valueOf(60)) >= 0); + + if (isAlarm) { + return success(true); // 只要有一个告警就返回 + } + } + return success(false); + } /** * 自动注册服务器 diff --git a/tongran-modules/tongran-system/src/main/java/com/tongran/system/domain/AllInterfaceName.java b/tongran-modules/tongran-system/src/main/java/com/tongran/system/domain/AllInterfaceName.java index c3a8cf1..20e6b89 100644 --- a/tongran-modules/tongran-system/src/main/java/com/tongran/system/domain/AllInterfaceName.java +++ b/tongran-modules/tongran-system/src/main/java/com/tongran/system/domain/AllInterfaceName.java @@ -81,5 +81,7 @@ public class AllInterfaceName extends BaseEntity private String label; /** 是否需要展开 */ private boolean expand; + /** 是否业务网卡 */ + private boolean businessFlag; } diff --git a/tongran-modules/tongran-system/src/main/java/com/tongran/system/domain/RmResourceRegistration.java b/tongran-modules/tongran-system/src/main/java/com/tongran/system/domain/RmResourceRegistration.java index e8d0580..58446fa 100644 --- a/tongran-modules/tongran-system/src/main/java/com/tongran/system/domain/RmResourceRegistration.java +++ b/tongran-modules/tongran-system/src/main/java/com/tongran/system/domain/RmResourceRegistration.java @@ -257,4 +257,10 @@ public class RmResourceRegistration extends BaseEntity private String bandwidthRate; /** 昨日95值排序 1正序 2倒叙 3不排序 */ private Integer bandwidthResultSort; + /** cpu利用率 */ + private BigDecimal cpuUtil; + /** 内存使用率 */ + private BigDecimal memUtil; + /** 是否告警 */ + private boolean alarmFlag; } \ No newline at end of file diff --git a/tongran-modules/tongran-system/src/main/java/com/tongran/system/mapper/RmResourceRegistrationMapper.java b/tongran-modules/tongran-system/src/main/java/com/tongran/system/mapper/RmResourceRegistrationMapper.java index 0aac6e0..734174c 100644 --- a/tongran-modules/tongran-system/src/main/java/com/tongran/system/mapper/RmResourceRegistrationMapper.java +++ b/tongran-modules/tongran-system/src/main/java/com/tongran/system/mapper/RmResourceRegistrationMapper.java @@ -122,4 +122,8 @@ public interface RmResourceRegistrationMapper */ int countChildNetwork(@Param("clientId") String clientId, @Param("interfaceName") String interfaceName); + + List getCpuUtil(@Param("clientIdsStr") String clientIdsStr); + + List getMemUtil(@Param("clientIdsStr") String clientIdsStr); } diff --git a/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/AllInterfaceNameServiceImpl.java b/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/AllInterfaceNameServiceImpl.java index 9abfb32..0b9f9ae 100644 --- a/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/AllInterfaceNameServiceImpl.java +++ b/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/AllInterfaceNameServiceImpl.java @@ -15,7 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -58,6 +60,7 @@ public class AllInterfaceNameServiceImpl implements IAllInterfaceNameService if (allInterfaceNameList == null || allInterfaceNameList.isEmpty()) { return allInterfaceNameList; } + // 用于存储非子网卡的接口 List nonSubInterfaces = new ArrayList<>(); for (AllInterfaceName interfaceName : allInterfaceNameList) { @@ -77,21 +80,31 @@ public class AllInterfaceNameServiceImpl implements IAllInterfaceNameService if (nonSubInterfaces.isEmpty()) { return nonSubInterfaces; } + + // 缓存匹配结果,避免重复计算 + Map matchStatusMap = new HashMap<>(); + for (AllInterfaceName interfaceName : nonSubInterfaces) { + boolean isMatched = isInterfaceMatched(interfaceName); + matchStatusMap.put(interfaceName, isMatched); + + // 只设置服务器类型的businessFlag + if ("1".equals(interfaceName.getResourceType())) { + interfaceName.setBusinessFlag(isMatched); + } + } + // 使用自定义排序 return nonSubInterfaces.stream() .sorted((a, b) -> { - // 根据实际业务逻辑判断是否匹配 - // 这里用接口名不为null且包含特定字符作为示例 - boolean aMatched = a.getInterfaceName() != null && a.getInterfaceName().contains("eth"); - boolean bMatched = b.getInterfaceName() != null && b.getInterfaceName().contains("eth"); + boolean aMatched = matchStatusMap.get(a); + boolean bMatched = matchStatusMap.get(b); - // 匹配的排在前面(返回-1),不匹配的排在后面(返回1) if (aMatched && !bMatched) { return -1; } else if (!aMatched && bMatched) { return 1; } else { - return 0; // 都匹配或都不匹配,保持原有顺序 + return 0; } }) .collect(Collectors.toList()); diff --git a/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/EpsInitialTrafficDataServiceImpl.java b/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/EpsInitialTrafficDataServiceImpl.java index 76e8b85..6628239 100644 --- a/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/EpsInitialTrafficDataServiceImpl.java +++ b/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/EpsInitialTrafficDataServiceImpl.java @@ -647,6 +647,9 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe } deoloyDevice = clientIds.toString(); } + if(deoloyDevice == null){ + return null; + } String clientIds = deoloyDevice.replace("\n",","); EpsInitialTrafficData queryParam = new EpsInitialTrafficData(); queryParam.setStartTime(startTime); diff --git a/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/EpsServerRevenueConfigServiceImpl.java b/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/EpsServerRevenueConfigServiceImpl.java index 6079415..b2b732f 100644 --- a/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/EpsServerRevenueConfigServiceImpl.java +++ b/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/EpsServerRevenueConfigServiceImpl.java @@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.Map; @@ -256,34 +257,17 @@ public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfi } if (!records.isEmpty()) { - try { - allInterfaceNameMapper.batchInsert(records); - log.info("批量处理接口名称完成,记录数: {}", records.size()); - }catch (Exception e){ - // 处理死锁异常 - if (isDeadlockException(e)) { - // 找到第一个非null的clientId - String deadlockClientId = records.stream() - .map(AllInterfaceName::getClientId) - .filter(StringUtils::isNotBlank) - .findFirst() - .orElse("unknown"); - log.error("检测到死锁,涉及的clientId: {}", deadlockClientId); - } else { - // 非死锁异常,重新抛出 - log.error("批量处理接口名称失败:{}", e.getMessage()); - } - } + // 排序防止死锁 + records.sort(Comparator + .comparing(AllInterfaceName::getInterfaceName) + .thenComparing(AllInterfaceName::getClientId) + .thenComparing(AllInterfaceName::getSwitchIp) + .thenComparing(AllInterfaceName::getResourceType)); + + allInterfaceNameMapper.batchInsert(records); + log.info("批量处理完成,记录数: {}", records.size()); } } - private boolean isDeadlockException(Exception e) { - String message = e.getMessage(); - return message != null && ( - message.contains("deadlock") || - message.contains("Deadlock") || - message.contains("1213") // MySQL死锁错误码 - ); - } private boolean isValidData(EpsInitialTrafficData data) { return StringUtils.isNotBlank(data.getName()) && StringUtils.isNotBlank(data.getMac()) diff --git a/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/InitialSwitchInfoDetailsServiceImpl.java b/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/InitialSwitchInfoDetailsServiceImpl.java index 7570fbc..88715a4 100644 --- a/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/InitialSwitchInfoDetailsServiceImpl.java +++ b/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/InitialSwitchInfoDetailsServiceImpl.java @@ -368,24 +368,15 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe } if (!records.isEmpty()) { - try { - allInterfaceNameMapper.batchInsert(records); - log.info("批量处理交换机接口名称完成,记录数: {}", records.size()); - }catch (Exception e){ - // 处理死锁异常 - if (isDeadlockException(e)) { - // 找到第一个非null的clientId - String deadlockClientId = records.stream() - .map(AllInterfaceName::getClientId) - .filter(StringUtils::isNotBlank) - .findFirst() - .orElse("unknown"); - log.error("检测到死锁,涉及的clientId: {}", deadlockClientId); - } else { - // 非死锁异常,重新抛出 - log.error("批量处理交换机接口名称失败:{}", e.getMessage()); - } - } + // 排序防止死锁 + records.sort(Comparator + .comparing(AllInterfaceName::getInterfaceName) + .thenComparing(AllInterfaceName::getClientId) + .thenComparing(AllInterfaceName::getSwitchIp) + .thenComparing(AllInterfaceName::getResourceType)); + + allInterfaceNameMapper.batchInsert(records); + log.info("批量处理完成,记录数: {}", records.size()); } } private boolean isDeadlockException(Exception e) { diff --git a/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/RmResourceRegistrationServiceImpl.java b/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/RmResourceRegistrationServiceImpl.java index 639398c..e605612 100644 --- a/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/RmResourceRegistrationServiceImpl.java +++ b/tongran-modules/tongran-system/src/main/java/com/tongran/system/service/impl/RmResourceRegistrationServiceImpl.java @@ -25,6 +25,7 @@ import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; +import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; import static com.tongran.common.core.utils.PageUtils.startPage; @@ -128,7 +129,6 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio // 3. 内存分页 int total = filteredList.size(); - // 注意:这里要用copy,因为后续要修改数据 List pageList = applyPagination(filteredList, pageNum, pageSize); List currentPageData = new ArrayList<>(pageList); @@ -255,12 +255,51 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio RmResourceRegistration::getBandwidthResult, Comparator.nullsLast(Comparator.reverseOrder()) ); + } else if (sortType == 4) { // 告警优先排序 + comparator = (a, b) -> { + // 设置告警标志 + boolean aAlarm = isAlarm(a); + boolean bAlarm = isAlarm(b); + a.setAlarmFlag(aAlarm); + b.setAlarmFlag(bAlarm); + + // 告警优先级最高 + if (aAlarm && !bAlarm) return -1; + if (!aAlarm && bAlarm) return 1; + + if (aAlarm && bAlarm) { + // 告警内按最大资源使用率倒序 + BigDecimal aMax = getMaxUtilization(a); + BigDecimal bMax = getMaxUtilization(b); + if (aMax == null && bMax == null) return 0; + if (aMax == null) return 1; + if (bMax == null) return -1; + return bMax.compareTo(aMax); + } + + return 0; + }; } if (comparator != null) { list.sort(comparator); } } + private boolean isAlarm(RmResourceRegistration item) { + return (item.getCpuUtil() != null && item.getCpuUtil().compareTo(BigDecimal.valueOf(80)) >= 0) || + (item.getMemUtil() != null && item.getMemUtil().compareTo(BigDecimal.valueOf(60)) >= 0); + } + + private BigDecimal getMaxUtilization(RmResourceRegistration item) { + BigDecimal max = BigDecimal.ZERO; + if (item.getCpuUtil() != null && item.getCpuUtil().compareTo(max) > 0) { + max = item.getCpuUtil(); + } + if (item.getMemUtil() != null && item.getMemUtil().compareTo(max) > 0) { + max = item.getMemUtil(); + } + return max.equals(BigDecimal.ZERO) ? null : max; + } /** * 内存分页 */ @@ -286,64 +325,92 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio } long startTime = System.currentTimeMillis(); - - // 设置每批大小 int batchSize = 200; int totalBatches = (int) Math.ceil((double) pageList.size() / batchSize); - for (int batchNum = 0; batchNum < totalBatches; batchNum++) { int fromIndex = batchNum * batchSize; int toIndex = Math.min(fromIndex + batchSize, pageList.size()); List batchList = pageList.subList(fromIndex, toIndex); - - // 收集当前批次需要查询的clientId - String clientIdsStr = batchList.stream() + String clientIdsStr = batchList.parallelStream() .map(RmResourceRegistration::getClientId) .filter(Objects::nonNull) .distinct() .collect(Collectors.joining(",")); + if (StringUtils.isBlank(clientIdsStr)) { continue; } - try { - // 使用批量查询接口 - RmNetworkInterfaceRemote queryParam = new RmNetworkInterfaceRemote(); - queryParam.setClientIds(clientIdsStr); - queryParam.setNewFlag(1); + // 并行查询 + CompletableFuture> cpuFuture = CompletableFuture + .supplyAsync(() -> rmResourceRegistrationMapper.getCpuUtil(clientIdsStr)); - R> result = remoteRocketMqService.getNetworkInterfaceList(queryParam, SecurityConstants.INNER); + CompletableFuture> memFuture = CompletableFuture + .supplyAsync(() -> rmResourceRegistrationMapper.getMemUtil(clientIdsStr)); - if (result == null || result.getData() == null || result.getData().isEmpty()) { - continue; - } + CompletableFuture> networkFuture = CompletableFuture + .supplyAsync(() -> { + RmNetworkInterfaceRemote queryParam = new RmNetworkInterfaceRemote(); + queryParam.setClientIds(clientIdsStr); + queryParam.setNewFlag(1); + R> result = remoteRocketMqService.getNetworkInterfaceList(queryParam, SecurityConstants.INNER); + return result != null ? result.getData() : Collections.emptyList(); + }); - List networkList = result.getData(); + CompletableFuture.allOf(cpuFuture, memFuture, networkFuture).join(); + + List cpuUtilList = cpuFuture.get(); + List memUtilList = memFuture.get(); + List networkList = networkFuture.get(); + + // 构建查找Map + Map cpuUtilMap = cpuUtilList.stream() + .filter(item -> item.getClientId() != null && item.getCpuUtil() != null) + .collect(Collectors.toMap( + RmResourceRegistration::getClientId, + RmResourceRegistration::getCpuUtil + )); + + Map memUtilMap = memUtilList.stream() + .filter(item -> item.getClientId() != null && item.getMemUtil() != null) + .collect(Collectors.toMap( + RmResourceRegistration::getClientId, + RmResourceRegistration::getMemUtil + )); - // 按clientId分组 Map> networkMap = networkList.stream() .filter(Objects::nonNull) .filter(item -> item.getClientId() != null) .collect(Collectors.groupingBy(RmNetworkInterfaceRemote::getClientId)); - // 批量设置当前批次 - for (RmResourceRegistration registration : batchList) { + // 并行处理 + batchList.parallelStream().forEach(registration -> { String clientId = registration.getClientId(); if (clientId != null) { + BigDecimal cpuUtil = cpuUtilMap.get(clientId); + if (cpuUtil != null) { + registration.setCpuUtil(cpuUtil); + } + + BigDecimal memUtil = memUtilMap.get(clientId); + if (memUtil != null) { + registration.setMemUtil(memUtil); + } + List clientNetworks = networkMap.get(clientId); if (clientNetworks != null && !clientNetworks.isEmpty()) { setNetWorkMsgWithNetworkList(registration, clientNetworks); } } - } + }); + } catch (Exception e) { - log.error("第{}批查询网络信息异常", batchNum + 1, e); + log.error("第{}批查询资源信息异常", batchNum + 1, e); } - // 添加小延迟,避免对下游服务造成压力 if (batchNum < totalBatches - 1) { try { Thread.sleep(10); @@ -352,6 +419,8 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio } } } + + log.info("批量设置资源信息完成,耗时: {}ms", System.currentTimeMillis() - startTime); } /** * 使用批量查询的结果设置网络信息 @@ -446,6 +515,16 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio */ public void setNetWorkMsg(RmResourceRegistration registration) { String clientId = registration.getClientId(); + // 根据clientId查询cpu利用率 + List cpuUtilList = rmResourceRegistrationMapper.getCpuUtil(clientId); + // 根据clientId查询mem利用率 + List memUtilList = rmResourceRegistrationMapper.getMemUtil(clientId); + if(cpuUtilList != null && !cpuUtilList.isEmpty()){ + registration.setCpuUtil(cpuUtilList.get(0).getCpuUtil()); + } + if(memUtilList != null && !memUtilList.isEmpty()){ + registration.setMemUtil(memUtilList.get(0).getMemUtil()); + } // 根据clientId查询网卡信息 RmNetworkInterfaceRemote queryParam = new RmNetworkInterfaceRemote(); queryParam.setClientId(clientId); diff --git a/tongran-modules/tongran-system/src/main/resources/mapper/system/RmResourceRegistrationMapper.xml b/tongran-modules/tongran-system/src/main/resources/mapper/system/RmResourceRegistrationMapper.xml index ebd7927..eb077ce 100644 --- a/tongran-modules/tongran-system/src/main/resources/mapper/system/RmResourceRegistrationMapper.xml +++ b/tongran-modules/tongran-system/src/main/resources/mapper/system/RmResourceRegistrationMapper.xml @@ -279,4 +279,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select count(1) from rm_network_interface_child where client_id = #{clientId} and parent_interface = #{interfaceName} + + \ No newline at end of file diff --git a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/impl/InitialBandwidthTrafficServiceImpl.java b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/impl/InitialBandwidthTrafficServiceImpl.java index 924d352..700981f 100644 --- a/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/impl/InitialBandwidthTrafficServiceImpl.java +++ b/tongran-rocketmq/src/main/java/com/tongran/rocketmq/service/impl/InitialBandwidthTrafficServiceImpl.java @@ -298,7 +298,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf showRealation.put("totalNetInTraffic", name+"总入站流量"); showRealation.put("totalNetOutTraffic", name+"总出站流量"); } - resultMap.put("showRealation", showRealation); + Map sortedShowRealation = EchartsMoreDataUtils.sortInterfaceMap(showRealation, name, hasSubInterface); + resultMap.put("showRealation", sortedShowRealation); return resultMap; } catch (Exception e){ @@ -350,8 +351,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf // 展示关系 Map showRealation = new HashMap<>(); interfaceDataMap.put(name, mainList); - showRealation.put(name + "netInSpeedData", name + "IPv4入站流量"); - showRealation.put(name + "netOutSpeedData", name + "IPv4出站流量"); + showRealation.put(name + "netInTraffic", name + "IPv4入站流量"); + showRealation.put(name + "netOutTraffic", name + "IPv4出站流量"); boolean hasSubInterface = false; // 如果是Ethernet类型,查询子网卡 @@ -370,8 +371,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf if (childTrafficList != null && !childTrafficList.isEmpty()) { interfaceDataMap.put(child.getInterfaceName(), childTrafficList); - showRealation.put(child.getInterfaceName() + "netInSpeedData", child.getInterfaceName() + "IPv4入站流量"); - showRealation.put(child.getInterfaceName() + "netOutSpeedData", child.getInterfaceName() + "IPv4出站流量"); + showRealation.put(child.getInterfaceName() + "netInTraffic", child.getInterfaceName() + "IPv4入站流量"); + showRealation.put(child.getInterfaceName() + "netOutTraffic", child.getInterfaceName() + "IPv4出站流量"); } } } @@ -400,10 +401,11 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf resultMap.put("unit", unit); if (!showRealation.isEmpty() && hasSubInterface) { - showRealation.put("totalNetInSpeedData", name + "IPv4总入站流量"); - showRealation.put("totalNetOutSpeedData", name + "IPv4总出站流量"); + showRealation.put("totalNetInTraffic", name + "IPv4总入站流量"); + showRealation.put("totalNetOutTraffic", name + "IPv4总出站流量"); } - resultMap.put("showRealation", showRealation); + Map sortedShowRealation = EchartsMoreDataUtils.sortInterfaceMap(showRealation, name, hasSubInterface); + resultMap.put("showRealation", sortedShowRealation); return resultMap; } catch (Exception e) { @@ -429,8 +431,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf // 展示关系 Map showRealation = new HashMap<>(); interfaceDataMap.put(name, mainList); - showRealation.put(name + "netInSpeedData", name + "IPv6入站流量"); - showRealation.put(name + "netOutSpeedData", name + "IPv6出站流量"); + showRealation.put(name + "netInTraffic", name + "IPv6入站流量"); + showRealation.put(name + "netOutTraffic", name + "IPv6出站流量"); boolean hasSubInterface = false; // 如果是Ethernet类型,查询子网卡 @@ -449,8 +451,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf if (childTrafficList != null && !childTrafficList.isEmpty()) { interfaceDataMap.put(child.getInterfaceName(), childTrafficList); - showRealation.put(child.getInterfaceName() + "netInSpeedData", child.getInterfaceName() + "IPv6入站流量"); - showRealation.put(child.getInterfaceName() + "netOutSpeedData", child.getInterfaceName() + "IPv6出站流量"); + showRealation.put(child.getInterfaceName() + "netInTraffic", child.getInterfaceName() + "IPv6入站流量"); + showRealation.put(child.getInterfaceName() + "netOutTraffic", child.getInterfaceName() + "IPv6出站流量"); } } } @@ -479,10 +481,11 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf resultMap.put("unit", unit); if (!showRealation.isEmpty() && hasSubInterface) { - showRealation.put("totalNetInSpeedData", name + "IPv6总入站流量"); - showRealation.put("totalNetOutSpeedData", name + "IPv6总出站流量"); + showRealation.put("totalNetInTraffic", name + "IPv6总入站流量"); + showRealation.put("totalNetOutTraffic", name + "IPv6总出站流量"); } - resultMap.put("showRealation", showRealation); + Map sortedShowRealation = EchartsMoreDataUtils.sortInterfaceMap(showRealation, name, hasSubInterface); + resultMap.put("showRealation", sortedShowRealation); return resultMap; } catch (Exception e) { @@ -538,8 +541,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf // 展示关系 Map showRealation = new HashMap<>(); interfaceDataMap.put(name, mainList); - showRealation.put(name + "netInSpeedData", name + "入站流量"); - showRealation.put(name + "netOutSpeedData", name + "出站流量"); + showRealation.put(name + "netInTraffic", name + "入站流量"); + showRealation.put(name + "netOutTraffic", name + "出站流量"); boolean hasSubInterface = false; // 如果是Ethernet类型,查询子网卡 @@ -558,8 +561,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf if (childTrafficList != null && !childTrafficList.isEmpty()) { interfaceDataMap.put(child.getInterfaceName(), childTrafficList); - showRealation.put(child.getInterfaceName() + "netInSpeedData", child.getInterfaceName() + "入站流量"); - showRealation.put(child.getInterfaceName() + "netOutSpeedData", child.getInterfaceName() + "出站流量"); + showRealation.put(child.getInterfaceName() + "netInTraffic", child.getInterfaceName() + "入站流量"); + showRealation.put(child.getInterfaceName() + "netOutTraffic", child.getInterfaceName() + "出站流量"); } } } @@ -588,10 +591,11 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf resultMap.put("unit", unit); if (!showRealation.isEmpty() && hasSubInterface) { - showRealation.put("totalNetInSpeedData", name + "总入站流量"); - showRealation.put("totalNetOutSpeedData", name + "总出站流量"); + showRealation.put("totalNetInTraffic", name + "总入站流量"); + showRealation.put("totalNetOutTraffic", name + "总出站流量"); } - resultMap.put("showRealation", showRealation); + Map sortedShowRealation = EchartsMoreDataUtils.sortInterfaceMap(showRealation, name, hasSubInterface); + resultMap.put("showRealation", sortedShowRealation); return resultMap; } catch (Exception e) {