修复图形x轴时间跨界问题、交换机月收益不展示95值问题。
ipv4 ipv6增加子网卡统计
This commit is contained in:
@@ -674,7 +674,6 @@ public class MessageHandler {
|
||||
|
||||
// 交换机在线状态改为在线(只在第3次心跳时执行)
|
||||
if(newHeartbeatCount == 3){
|
||||
log.info("客户端ID: {} 第3次心跳,更新交换机状态为在线", clientId);
|
||||
RmSwitchManagementRemote rmSwitchManagementRemote = new RmSwitchManagementRemote();
|
||||
rmSwitchManagementRemote.setClientId(clientId);
|
||||
R<List<RmSwitchManagementRemote>> rmSwitchManagementRemoteListR = remoteRevenueConfigService.getSwitchNameByClientId(rmSwitchManagementRemote, SecurityConstants.INNER);
|
||||
|
||||
+202
-60
@@ -18,7 +18,6 @@ import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
@@ -251,7 +250,7 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
interfaceDataMap.put(name, mainList);
|
||||
showRealation.put(name+"netInTraffic", name+"入站流量");
|
||||
showRealation.put(name+"netOutTraffic", name+"出站流量");
|
||||
|
||||
boolean hasSubInterface = false;
|
||||
// 如果是Ethernet类型,查询子网卡
|
||||
if(isEthernetInterface(name)){
|
||||
RmNetworkInterfaceChild query = new RmNetworkInterfaceChild();
|
||||
@@ -259,6 +258,7 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
query.setParentInterface(name);
|
||||
List<RmNetworkInterfaceChild> children = rmNetworkInterfaceChildMapper.selectRmNetworkInterfaceChildList(query);
|
||||
if(children != null && !children.isEmpty()){
|
||||
hasSubInterface = true;
|
||||
for (RmNetworkInterfaceChild child : children) {
|
||||
InitialBandwidthTraffic childTraffic = new InitialBandwidthTraffic();
|
||||
BeanUtils.copyProperties(initialBandwidthTraffic, childTraffic);
|
||||
@@ -294,7 +294,7 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
);
|
||||
|
||||
resultMap.put("unit", unit);
|
||||
if(!showRealation.isEmpty()){
|
||||
if(!showRealation.isEmpty() && hasSubInterface){
|
||||
showRealation.put("totalNetInTraffic", name+"总入站流量");
|
||||
showRealation.put("totalNetOutTraffic", name+"总出站流量");
|
||||
}
|
||||
@@ -335,66 +335,160 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
|
||||
@Override
|
||||
public Map<String, Object> netInterfaceIpv4TrafficEcharts(InitialBandwidthTraffic initialBandwidthTraffic) {
|
||||
// 流量信息
|
||||
List<InitialBandwidthTraffic> list = getListByTableName(initialBandwidthTraffic);
|
||||
// 主网卡IPv4流量信息
|
||||
List<InitialBandwidthTraffic> mainList = getListByTableName(initialBandwidthTraffic);
|
||||
String originalName = initialBandwidthTraffic.getName();
|
||||
String name = originalName;
|
||||
|
||||
if (originalName != null && originalName.contains("(")) {
|
||||
int index = originalName.indexOf("(");
|
||||
name = originalName.substring(0, index);
|
||||
}
|
||||
|
||||
// 存储所有网卡的数据
|
||||
Map<String, List<InitialBandwidthTraffic>> interfaceDataMap = new LinkedHashMap<>();
|
||||
// 展示关系
|
||||
Map<String, String> showRealation = new HashMap<>();
|
||||
interfaceDataMap.put(name, mainList);
|
||||
showRealation.put(name + "netInSpeedData", name + "IPv4入站流量");
|
||||
showRealation.put(name + "netOutSpeedData", name + "IPv4出站流量");
|
||||
boolean hasSubInterface = false;
|
||||
|
||||
// 如果是Ethernet类型,查询子网卡
|
||||
if (isEthernetInterface(name)) {
|
||||
RmNetworkInterfaceChild query = new RmNetworkInterfaceChild();
|
||||
query.setClientId(initialBandwidthTraffic.getClientId());
|
||||
query.setParentInterface(name);
|
||||
List<RmNetworkInterfaceChild> children = rmNetworkInterfaceChildMapper.selectRmNetworkInterfaceChildList(query);
|
||||
if (children != null && !children.isEmpty()) {
|
||||
hasSubInterface = true;
|
||||
for (RmNetworkInterfaceChild child : children) {
|
||||
InitialBandwidthTraffic childTraffic = new InitialBandwidthTraffic();
|
||||
BeanUtils.copyProperties(initialBandwidthTraffic, childTraffic);
|
||||
childTraffic.setName(child.getInterfaceName());
|
||||
List<InitialBandwidthTraffic> childTrafficList = getListByTableName(childTraffic);
|
||||
|
||||
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出站流量");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
String unit = SpeedUtils.calculateUnitWithStringTraffic(list, "ipv4InSpeed", "ipv4OutSpeed");
|
||||
if(initialBandwidthTraffic.getUnit() != null){
|
||||
// 计算单位
|
||||
String unit = SpeedUtils.calculateUnitWithStringTraffic(mainList, "ipv4InSpeed", "ipv4OutSpeed");
|
||||
if (initialBandwidthTraffic.getUnit() != null) {
|
||||
unit = initialBandwidthTraffic.getUnit();
|
||||
}
|
||||
BigDecimal divisor = SpeedUtils.getDivisor(unit);
|
||||
Map<String, Function<InitialBandwidthTraffic, ?>> extractors = new LinkedHashMap<>();
|
||||
extractors.put("netInSpeedData", info ->
|
||||
info != null && info.getIpv4InSpeed() != null ?
|
||||
new BigDecimal(info.getIpv4InSpeed()).divide(divisor, 2, RoundingMode.HALF_UP) :
|
||||
null);
|
||||
|
||||
extractors.put("netOutSpeedData", info ->
|
||||
info != null && info.getIpv4OutSpeed() != null ?
|
||||
new BigDecimal(info.getIpv4OutSpeed()).divide(divisor, 2, RoundingMode.HALF_UP) :
|
||||
null);
|
||||
Map<String, Object> resultMap = EchartsDataUtils.buildEchartsDataAutoPadding(
|
||||
list, InitialBandwidthTraffic::getCreateTime, extractors,
|
||||
initialBandwidthTraffic.getStartTime(), initialBandwidthTraffic.getEndTime()
|
||||
// 使用工具类构建多网卡图表数据
|
||||
Map<String, Object> resultMap = EchartsMoreDataUtils.buildMultiInterfaceEchartsDataWithTotal(
|
||||
interfaceDataMap,
|
||||
InitialBandwidthTraffic::getCreateTime,
|
||||
info -> info != null && info.getIpv4InSpeed() != null ?
|
||||
new BigDecimal(info.getIpv4InSpeed()) : null,
|
||||
info -> info != null && info.getIpv4OutSpeed() != null ?
|
||||
new BigDecimal(info.getIpv4OutSpeed()) : null,
|
||||
initialBandwidthTraffic.getStartTime(),
|
||||
initialBandwidthTraffic.getEndTime(),
|
||||
divisor
|
||||
);
|
||||
|
||||
resultMap.put("unit", unit);
|
||||
if (!showRealation.isEmpty() && hasSubInterface) {
|
||||
showRealation.put("totalNetInSpeedData", name + "IPv4总入站流量");
|
||||
showRealation.put("totalNetOutSpeedData", name + "IPv4总出站流量");
|
||||
}
|
||||
resultMap.put("showRealation", showRealation);
|
||||
return resultMap;
|
||||
} catch (Exception e){
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new HashMap<>();
|
||||
}
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> netInterfaceIpv6TrafficEcharts(InitialBandwidthTraffic initialBandwidthTraffic) {
|
||||
// 流量信息
|
||||
List<InitialBandwidthTraffic> list = getListByTableName(initialBandwidthTraffic);
|
||||
// 主网卡IPv6流量信息
|
||||
List<InitialBandwidthTraffic> mainList = getListByTableName(initialBandwidthTraffic);
|
||||
String originalName = initialBandwidthTraffic.getName();
|
||||
String name = originalName;
|
||||
|
||||
if (originalName != null && originalName.contains("(")) {
|
||||
int index = originalName.indexOf("(");
|
||||
name = originalName.substring(0, index);
|
||||
}
|
||||
|
||||
// 存储所有网卡的数据
|
||||
Map<String, List<InitialBandwidthTraffic>> interfaceDataMap = new LinkedHashMap<>();
|
||||
// 展示关系
|
||||
Map<String, String> showRealation = new HashMap<>();
|
||||
interfaceDataMap.put(name, mainList);
|
||||
showRealation.put(name + "netInSpeedData", name + "IPv6入站流量");
|
||||
showRealation.put(name + "netOutSpeedData", name + "IPv6出站流量");
|
||||
boolean hasSubInterface = false;
|
||||
|
||||
// 如果是Ethernet类型,查询子网卡
|
||||
if (isEthernetInterface(name)) {
|
||||
RmNetworkInterfaceChild query = new RmNetworkInterfaceChild();
|
||||
query.setClientId(initialBandwidthTraffic.getClientId());
|
||||
query.setParentInterface(name);
|
||||
List<RmNetworkInterfaceChild> children = rmNetworkInterfaceChildMapper.selectRmNetworkInterfaceChildList(query);
|
||||
if (children != null && !children.isEmpty()) {
|
||||
hasSubInterface = true;
|
||||
for (RmNetworkInterfaceChild child : children) {
|
||||
InitialBandwidthTraffic childTraffic = new InitialBandwidthTraffic();
|
||||
BeanUtils.copyProperties(initialBandwidthTraffic, childTraffic);
|
||||
childTraffic.setName(child.getInterfaceName());
|
||||
List<InitialBandwidthTraffic> childTrafficList = getListByTableName(childTraffic);
|
||||
|
||||
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出站流量");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
String unit = SpeedUtils.calculateUnitWithStringTraffic(list, "ipv6InSpeed", "ipv6OutSpeed");
|
||||
if(initialBandwidthTraffic.getUnit() != null){
|
||||
// 计算单位
|
||||
String unit = SpeedUtils.calculateUnitWithStringTraffic(mainList, "ipv6InSpeed", "ipv6OutSpeed");
|
||||
if (initialBandwidthTraffic.getUnit() != null) {
|
||||
unit = initialBandwidthTraffic.getUnit();
|
||||
}
|
||||
BigDecimal divisor = SpeedUtils.getDivisor(unit);
|
||||
Map<String, Function<InitialBandwidthTraffic, ?>> extractors = new LinkedHashMap<>();
|
||||
extractors.put("netInSpeedData", info ->
|
||||
info != null && info.getIpv6InSpeed() != null ?
|
||||
new BigDecimal(info.getIpv6InSpeed()).divide(divisor, 2, RoundingMode.HALF_UP) :
|
||||
null);
|
||||
|
||||
extractors.put("netOutSpeedData", info ->
|
||||
info != null && info.getIpv6OutSpeed() != null ?
|
||||
new BigDecimal(info.getIpv6OutSpeed()).divide(divisor, 2, RoundingMode.HALF_UP) :
|
||||
null);
|
||||
Map<String, Object> resultMap = EchartsDataUtils.buildEchartsDataAutoPadding(
|
||||
list, InitialBandwidthTraffic::getCreateTime, extractors,
|
||||
initialBandwidthTraffic.getStartTime(), initialBandwidthTraffic.getEndTime()
|
||||
// 使用工具类构建多网卡图表数据
|
||||
Map<String, Object> resultMap = EchartsMoreDataUtils.buildMultiInterfaceEchartsDataWithTotal(
|
||||
interfaceDataMap,
|
||||
InitialBandwidthTraffic::getCreateTime,
|
||||
info -> info != null && info.getIpv6InSpeed() != null ?
|
||||
new BigDecimal(info.getIpv6InSpeed()) : null,
|
||||
info -> info != null && info.getIpv6OutSpeed() != null ?
|
||||
new BigDecimal(info.getIpv6OutSpeed()) : null,
|
||||
initialBandwidthTraffic.getStartTime(),
|
||||
initialBandwidthTraffic.getEndTime(),
|
||||
divisor
|
||||
);
|
||||
|
||||
resultMap.put("unit", unit);
|
||||
if (!showRealation.isEmpty() && hasSubInterface) {
|
||||
showRealation.put("totalNetInSpeedData", name + "IPv6总入站流量");
|
||||
showRealation.put("totalNetOutSpeedData", name + "IPv6总出站流量");
|
||||
}
|
||||
resultMap.put("showRealation", showRealation);
|
||||
return resultMap;
|
||||
} catch (Exception e){
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new HashMap<>();
|
||||
}
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -413,7 +507,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
trafficData.setName(interfaceName);
|
||||
trafficData.setStartTime(initialBandwidthTraffic.getStartTime());
|
||||
trafficData.setEndTime(initialBandwidthTraffic.getEndTime());
|
||||
Map<String, Object> resultMap = getEchartsData(trafficData);
|
||||
// 修改为新的支持子网卡的方法
|
||||
Map<String, Object> resultMap = getBatchEchartsData(trafficData);
|
||||
resultMap.put("interfaceName", interfaceName);
|
||||
resultMap.put("clientId", clientId);
|
||||
resultList.add(resultMap);
|
||||
@@ -423,39 +518,86 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建echarts图表
|
||||
* 构建支持子网卡的批量echarts图表数据
|
||||
* @param initialBandwidthTraffic
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getEchartsData(InitialBandwidthTraffic initialBandwidthTraffic){
|
||||
// 流量信息
|
||||
List<InitialBandwidthTraffic> list = getListByTableName(initialBandwidthTraffic);
|
||||
public Map<String, Object> getBatchEchartsData(InitialBandwidthTraffic initialBandwidthTraffic) {
|
||||
// 主网卡流量信息
|
||||
List<InitialBandwidthTraffic> mainList = getListByTableName(initialBandwidthTraffic);
|
||||
String originalName = initialBandwidthTraffic.getName();
|
||||
String name = originalName;
|
||||
|
||||
if (originalName != null && originalName.contains("(")) {
|
||||
int index = originalName.indexOf("(");
|
||||
name = originalName.substring(0, index);
|
||||
}
|
||||
|
||||
// 存储所有网卡的数据
|
||||
Map<String, List<InitialBandwidthTraffic>> interfaceDataMap = new LinkedHashMap<>();
|
||||
// 展示关系
|
||||
Map<String, String> showRealation = new HashMap<>();
|
||||
interfaceDataMap.put(name, mainList);
|
||||
showRealation.put(name + "netInSpeedData", name + "入站流量");
|
||||
showRealation.put(name + "netOutSpeedData", name + "出站流量");
|
||||
boolean hasSubInterface = false;
|
||||
|
||||
// 如果是Ethernet类型,查询子网卡
|
||||
if (isEthernetInterface(name)) {
|
||||
RmNetworkInterfaceChild query = new RmNetworkInterfaceChild();
|
||||
query.setClientId(initialBandwidthTraffic.getClientId());
|
||||
query.setParentInterface(name);
|
||||
List<RmNetworkInterfaceChild> children = rmNetworkInterfaceChildMapper.selectRmNetworkInterfaceChildList(query);
|
||||
if (children != null && !children.isEmpty()) {
|
||||
hasSubInterface = true;
|
||||
for (RmNetworkInterfaceChild child : children) {
|
||||
InitialBandwidthTraffic childTraffic = new InitialBandwidthTraffic();
|
||||
BeanUtils.copyProperties(initialBandwidthTraffic, childTraffic);
|
||||
childTraffic.setName(child.getInterfaceName());
|
||||
List<InitialBandwidthTraffic> childTrafficList = getListByTableName(childTraffic);
|
||||
|
||||
if (childTrafficList != null && !childTrafficList.isEmpty()) {
|
||||
interfaceDataMap.put(child.getInterfaceName(), childTrafficList);
|
||||
showRealation.put(child.getInterfaceName() + "netInSpeedData", child.getInterfaceName() + "入站流量");
|
||||
showRealation.put(child.getInterfaceName() + "netOutSpeedData", child.getInterfaceName() + "出站流量");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
String unit = SpeedUtils.calculateUnitWithStringTraffic(list, "inSpeed", "outSpeed");
|
||||
if(initialBandwidthTraffic.getUnit() != null){
|
||||
// 计算单位
|
||||
String unit = SpeedUtils.calculateUnitWithStringTraffic(mainList, "inSpeed", "outSpeed");
|
||||
if (initialBandwidthTraffic.getUnit() != null) {
|
||||
unit = initialBandwidthTraffic.getUnit();
|
||||
}
|
||||
BigDecimal divisor = SpeedUtils.getDivisor(unit);
|
||||
Map<String, Function<InitialBandwidthTraffic, ?>> extractors = new LinkedHashMap<>();
|
||||
extractors.put("netInSpeedData", info ->
|
||||
info != null && info.getInSpeed() != null ?
|
||||
new BigDecimal(info.getInSpeed()).divide(divisor, 2, RoundingMode.HALF_UP) :
|
||||
null);
|
||||
|
||||
extractors.put("netOutSpeedData", info ->
|
||||
info != null && info.getOutSpeed() != null ?
|
||||
new BigDecimal(info.getOutSpeed()).divide(divisor, 2, RoundingMode.HALF_UP) :
|
||||
null);
|
||||
Map<String, Object> resultMap = EchartsDataUtils.buildEchartsDataAutoPadding(
|
||||
list, InitialBandwidthTraffic::getCreateTime, extractors,
|
||||
initialBandwidthTraffic.getStartTime(), initialBandwidthTraffic.getEndTime()
|
||||
// 使用工具类构建多网卡图表数据
|
||||
Map<String, Object> resultMap = EchartsMoreDataUtils.buildMultiInterfaceEchartsDataWithTotal(
|
||||
interfaceDataMap,
|
||||
InitialBandwidthTraffic::getCreateTime,
|
||||
info -> info != null && info.getInSpeed() != null ?
|
||||
new BigDecimal(info.getInSpeed()) : null,
|
||||
info -> info != null && info.getOutSpeed() != null ?
|
||||
new BigDecimal(info.getOutSpeed()) : null,
|
||||
initialBandwidthTraffic.getStartTime(),
|
||||
initialBandwidthTraffic.getEndTime(),
|
||||
divisor
|
||||
);
|
||||
|
||||
resultMap.put("unit", unit);
|
||||
if (!showRealation.isEmpty() && hasSubInterface) {
|
||||
showRealation.put("totalNetInSpeedData", name + "总入站流量");
|
||||
showRealation.put("totalNetOutSpeedData", name + "总出站流量");
|
||||
}
|
||||
resultMap.put("showRealation", showRealation);
|
||||
return resultMap;
|
||||
} catch (Exception e){
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new HashMap<>();
|
||||
}
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user