单网卡总流量、ipv4流量、ipv6流量合并到一个图
pppoe状态上报增加
This commit is contained in:
@@ -5,6 +5,8 @@ import com.tongran.common.core.web.domain.BaseEntity;
|
||||
import com.tongran.rocketmq.domain.vo.RmPppoeConfigSubVo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* PPPoE配置子表对象 rm_pppoe_config_sub
|
||||
*
|
||||
@@ -19,10 +21,6 @@ public class RmPppoeConfigSub extends BaseEntity
|
||||
/** 主键ID */
|
||||
private Long id;
|
||||
|
||||
/** 主表ID */
|
||||
@Excel(name = "主表ID")
|
||||
private Long mainId;
|
||||
|
||||
/** 序号 */
|
||||
@Excel(name = "序号")
|
||||
private Long serialNumber;
|
||||
@@ -42,6 +40,14 @@ public class RmPppoeConfigSub extends BaseEntity
|
||||
/** IPv4网关 */
|
||||
@Excel(name = "IPv4网关")
|
||||
private String ipv4Gateway;
|
||||
/** 状态(0未连通,1连通) */
|
||||
private String status;
|
||||
/** 上报带宽 */
|
||||
private BigDecimal bandwidthResult;
|
||||
/** MAC地址 */
|
||||
private String macAddress;
|
||||
/** 客户端id */
|
||||
private String clientId;
|
||||
|
||||
public RmPppoeConfigSubVo toVo() {
|
||||
RmPppoeConfigSubVo vo = new RmPppoeConfigSubVo();
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.tongran.rocketmq.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MacVlanRspVo {
|
||||
@JsonProperty("clientId")
|
||||
private String clientId;
|
||||
|
||||
@JsonProperty("macVlans")
|
||||
private List<MacVlanVo> macVlans;
|
||||
|
||||
@JsonProperty("timestamp")
|
||||
private long timestamp;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class MacVlanVo {
|
||||
/** 虚拟网卡id */
|
||||
private String vlanId;
|
||||
|
||||
/** 编号 */
|
||||
private String mid;
|
||||
|
||||
/** 状态 */
|
||||
private String status;
|
||||
}
|
||||
}
|
||||
@@ -101,6 +101,8 @@ public class MessageHandler {
|
||||
private IRmAlarmPushConfigService rmAlarmPushConfigService;
|
||||
@Autowired
|
||||
private IRmFrpcConfigManageService rmFrpcConfigManageService;
|
||||
@Autowired
|
||||
private IRmPppoeConfigSubService rmPppoeConfigSubService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -124,6 +126,28 @@ public class MessageHandler {
|
||||
registerHandler(MsgEnum.心跳上报.getValue(), this::handleHeartbeatMessage);
|
||||
registerHandler(MsgEnum.多公网IP探测.getValue(), this::handleNetWorkDelectMessage);
|
||||
registerHandler(MsgEnum.修改frp配置文件应答.getValue(), this::handleUpdateFrpMessage);
|
||||
registerHandler(MsgEnum.macvlan状态上报.getValue(), this::handleMacvlanMessage);
|
||||
}
|
||||
|
||||
private void handleMacvlanMessage(DeviceMessage message) {
|
||||
List<MacVlanRspVo> macVlanRspVoList = JsonDataParser.parseJsonData(message.getData(), MacVlanRspVo.class);
|
||||
if(!macVlanRspVoList.isEmpty()){
|
||||
MacVlanRspVo macVlanRspVo = macVlanRspVoList.get(0);
|
||||
// 时间戳转换
|
||||
long timestamp = macVlanRspVo.getTimestamp();
|
||||
long millis = timestamp * 1000;
|
||||
Date createTime = new Date(millis / 1000 * 1000); // 去除毫秒
|
||||
List<MacVlanRspVo.MacVlanVo> list = macVlanRspVo.getMacVlans();
|
||||
for (MacVlanRspVo.MacVlanVo macVlanVo : list) {
|
||||
RmPppoeConfigSub rmPppoeConfigSub = new RmPppoeConfigSub();
|
||||
rmPppoeConfigSub.setVlanId(Long.valueOf(macVlanVo.getVlanId()));
|
||||
rmPppoeConfigSub.setSerialNumber(Long.valueOf(macVlanVo.getMid()));
|
||||
rmPppoeConfigSub.setClientId(message.getClientId());
|
||||
rmPppoeConfigSub.setStatus(macVlanVo.getStatus());
|
||||
rmPppoeConfigSub.setUpdateTime(createTime);
|
||||
rmPppoeConfigSubService.updateRmPppoeConfigSubByVlan(rmPppoeConfigSub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleUpdateFrpMessage(DeviceMessage message) {
|
||||
@@ -1143,6 +1167,7 @@ public class MessageHandler {
|
||||
}
|
||||
rmNetworkInterfaceService.insertRmNetworkInterface(insertData);
|
||||
if(childList != null && !childList.isEmpty()){
|
||||
rmNetworkInterfaceChildService.deleteRmNetworkInterfaceChildByClientId(clientId);
|
||||
for (NetworkInfo info : childList) {
|
||||
RmNetworkInterfaceChild insertChild = new RmNetworkInterfaceChild();
|
||||
setNetworkInterfaceChildData(insertChild, info, clientId, networkInfo.getName());
|
||||
@@ -1168,6 +1193,7 @@ public class MessageHandler {
|
||||
boolean needCreateNew = (!StringUtils.equals(networkInfo.getName(), oldInterfaceMsg.getInterfaceName())
|
||||
|| !StringUtils.equals(networkInfo.getGateway(), oldInterfaceMsg.getGateway())) && StringUtils.equals(networkInfo.getMac(), oldInterfaceMsg.getMacAddress());
|
||||
if(childList != null && !childList.isEmpty()){
|
||||
rmNetworkInterfaceChildService.deleteRmNetworkInterfaceChildByClientId(clientId);
|
||||
for (NetworkInfo info : childList) {
|
||||
RmNetworkInterfaceChild insertChild = new RmNetworkInterfaceChild();
|
||||
setNetworkInterfaceChildData(insertChild, info, clientId, networkInfo.getName());
|
||||
|
||||
+4
-1
@@ -1,8 +1,9 @@
|
||||
package com.tongran.rocketmq.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客户端网络接口子接口信息Mapper接口
|
||||
*
|
||||
@@ -58,4 +59,6 @@ public interface RmNetworkInterfaceChildMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmNetworkInterfaceChildByIds(Long[] ids);
|
||||
|
||||
void deleteRmNetworkInterfaceChildByClientId(String clientId);
|
||||
}
|
||||
|
||||
+5
-3
@@ -68,9 +68,11 @@ public interface RmPppoeConfigSubMapper
|
||||
int batchInsertRmPppoeConfigSub(List<RmPppoeConfigSub> subList);
|
||||
|
||||
/**
|
||||
* 根据主表id删除子表信息
|
||||
* @param mainId
|
||||
* 根据clientId删除子表信息
|
||||
* @param clientId
|
||||
* @return
|
||||
*/
|
||||
int deleteRmPppoeConfigSubByMainId(Long mainId);
|
||||
int deleteRmPppoeConfigSubByClientId(String clientId);
|
||||
|
||||
int updateRmPppoeConfigSubByVlan(RmPppoeConfigSub rmPppoeConfigSub);
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,8 +1,9 @@
|
||||
package com.tongran.rocketmq.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客户端网络接口子接口信息Service接口
|
||||
*
|
||||
@@ -58,4 +59,6 @@ public interface IRmNetworkInterfaceChildService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmNetworkInterfaceChildById(Long id);
|
||||
|
||||
void deleteRmNetworkInterfaceChildByClientId(String clientId);
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,8 +1,9 @@
|
||||
package com.tongran.rocketmq.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.tongran.rocketmq.domain.RmPppoeConfigSub;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PPPoE配置子表Service接口
|
||||
*
|
||||
@@ -58,4 +59,6 @@ public interface IRmPppoeConfigSubService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmPppoeConfigSubById(Long id);
|
||||
|
||||
int updateRmPppoeConfigSubByVlan(RmPppoeConfigSub rmPppoeConfigSub);
|
||||
}
|
||||
|
||||
+79
-1
@@ -251,6 +251,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
showRealation.put(name+"netInTraffic", name+"入站流量");
|
||||
showRealation.put(name+"netOutTraffic", name+"出站流量");
|
||||
boolean hasSubInterface = false;
|
||||
boolean needAddIpv4Ipv6 = false; // 标记是否需要添加IPv4和IPv6数据
|
||||
|
||||
// 如果是Ethernet类型,查询子网卡
|
||||
if(isEthernetInterface(name)){
|
||||
RmNetworkInterfaceChild query = new RmNetworkInterfaceChild();
|
||||
@@ -271,6 +273,13 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
showRealation.put(child.getInterfaceName()+"netOutTraffic", child.getInterfaceName()+"出站流量");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 将ipv4和ipv6的线也集合过来 - 只有在没有子网卡时才添加
|
||||
needAddIpv4Ipv6 = true;
|
||||
showRealation.put(name+"netInTrafficIPv4", name+"IPv4入站流量");
|
||||
showRealation.put(name+"netOutTrafficIPv4", name+"IPv4出站流量");
|
||||
showRealation.put(name+"netInTrafficIPv6", name+"IPv6入站流量");
|
||||
showRealation.put(name+"netOutTrafficIPv6", name+"IPv6出站流量");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,7 +291,7 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
}
|
||||
BigDecimal divisor = SpeedUtils.getDivisor(unit);
|
||||
|
||||
// 使用工具类构建多网卡图表数据
|
||||
// 获取总流量图表数据
|
||||
Map<String, Object> resultMap = EchartsMoreDataUtils.buildMultiInterfaceEchartsDataWithTotal(
|
||||
interfaceDataMap,
|
||||
InitialBandwidthTraffic::getCreateTime,
|
||||
@@ -294,10 +303,79 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
);
|
||||
|
||||
resultMap.put("unit", unit);
|
||||
|
||||
// 如果没有子网卡,添加IPv4和IPv6的数据
|
||||
if (needAddIpv4Ipv6) {
|
||||
// 获取总流量yData
|
||||
Map<String, Object> yData = (Map<String, Object>) resultMap.get("yData");
|
||||
List<String> xAxisData = (List<String>) resultMap.get("xData");
|
||||
|
||||
// 获取IPv4流量图表数据
|
||||
Map<String, Object> ipv4Result = 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
|
||||
);
|
||||
|
||||
// 获取IPv6流量图表数据
|
||||
Map<String, Object> ipv6Result = 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
|
||||
);
|
||||
|
||||
// 合并IPv4的yData
|
||||
Map<String, Object> ipv4YData = (Map<String, Object>) ipv4Result.get("yData");
|
||||
for (Map.Entry<String, Object> entry : ipv4YData.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
|
||||
// 重命名key,添加IPv4后缀
|
||||
String newKey = key;
|
||||
if (key.endsWith("netInTraffic")) {
|
||||
newKey = key.replace("netInTraffic", "netInTrafficIPv4");
|
||||
} else if (key.endsWith("netOutTraffic")) {
|
||||
newKey = key.replace("netOutTraffic", "netOutTrafficIPv4");
|
||||
}
|
||||
yData.put(newKey, value);
|
||||
}
|
||||
|
||||
// 合并IPv6的yData
|
||||
Map<String, Object> ipv6YData = (Map<String, Object>) ipv6Result.get("yData");
|
||||
for (Map.Entry<String, Object> entry : ipv6YData.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
|
||||
// 重命名key,添加IPv6后缀
|
||||
String newKey = key;
|
||||
if (key.endsWith("netInTraffic")) {
|
||||
newKey = key.replace("netInTraffic", "netInTrafficIPv6");
|
||||
} else if (key.endsWith("netOutTraffic")) {
|
||||
newKey = key.replace("netOutTraffic", "netOutTrafficIPv6");
|
||||
}
|
||||
yData.put(newKey, value);
|
||||
}
|
||||
|
||||
resultMap.put("yData", yData);
|
||||
}
|
||||
|
||||
if(!showRealation.isEmpty() && hasSubInterface){
|
||||
showRealation.put("totalNetInTraffic", name+"总入站流量");
|
||||
showRealation.put("totalNetOutTraffic", name+"总出站流量");
|
||||
}
|
||||
|
||||
Map<String, String> sortedShowRealation = EchartsMoreDataUtils.sortInterfaceMap(showRealation, name, hasSubInterface);
|
||||
resultMap.put("showRealation", sortedShowRealation);
|
||||
return resultMap;
|
||||
|
||||
+10
-4
@@ -1,12 +1,13 @@
|
||||
package com.tongran.rocketmq.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.tongran.common.core.utils.DateUtils;
|
||||
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
|
||||
import com.tongran.rocketmq.mapper.RmNetworkInterfaceChildMapper;
|
||||
import com.tongran.rocketmq.service.IRmNetworkInterfaceChildService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.tongran.rocketmq.mapper.RmNetworkInterfaceChildMapper;
|
||||
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
|
||||
import com.tongran.rocketmq.service.IRmNetworkInterfaceChildService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客户端网络接口子接口信息Service业务层处理
|
||||
@@ -93,4 +94,9 @@ public class RmNetworkInterfaceChildServiceImpl implements IRmNetworkInterfaceCh
|
||||
{
|
||||
return rmNetworkInterfaceChildMapper.deleteRmNetworkInterfaceChildById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRmNetworkInterfaceChildByClientId(String clientId) {
|
||||
rmNetworkInterfaceChildMapper.deleteRmNetworkInterfaceChildByClientId(clientId);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -49,7 +49,7 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
|
||||
RmPppoeConfigMain rmPppoeConfigMain = rmPppoeConfigMainMapper.selectRmPppoeConfigMainById(id);
|
||||
// 查询子表信息
|
||||
RmPppoeConfigSub rmPppoeConfigSub = new RmPppoeConfigSub();
|
||||
rmPppoeConfigSub.setMainId(id);
|
||||
rmPppoeConfigSub.setClientId(rmPppoeConfigMain.getClientId());
|
||||
List<RmPppoeConfigSub> subList = rmPppoeConfigSubMapper.selectRmPppoeConfigSubList(rmPppoeConfigSub);
|
||||
rmPppoeConfigMain.setSubList(subList);
|
||||
return rmPppoeConfigMain;
|
||||
@@ -81,12 +81,12 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
|
||||
List<RmPppoeConfigSub> subList = rmPppoeConfigMain.getSubList();
|
||||
if(subList != null && !subList.isEmpty()){
|
||||
for (RmPppoeConfigSub rmPppoeConfigSub : subList) {
|
||||
rmPppoeConfigSub.setMainId(rmPppoeConfigMain.getId());
|
||||
rmPppoeConfigSub.setClientId(rmPppoeConfigMain.getClientId());
|
||||
rmPppoeConfigSub.setCreateTime(DateUtils.getNowDate());
|
||||
rmPppoeConfigSub.setUpdateTime(DateUtils.getNowDate());
|
||||
}
|
||||
// 删除子表信息
|
||||
rmPppoeConfigSubMapper.deleteRmPppoeConfigSubByMainId(rmPppoeConfigMain.getId());
|
||||
rmPppoeConfigSubMapper.deleteRmPppoeConfigSubByClientId(rmPppoeConfigMain.getClientId());
|
||||
// 批量新增
|
||||
rmPppoeConfigSubMapper.batchInsertRmPppoeConfigSub(subList);
|
||||
}
|
||||
|
||||
+10
-4
@@ -1,12 +1,13 @@
|
||||
package com.tongran.rocketmq.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.tongran.common.core.utils.DateUtils;
|
||||
import com.tongran.rocketmq.domain.RmPppoeConfigSub;
|
||||
import com.tongran.rocketmq.mapper.RmPppoeConfigSubMapper;
|
||||
import com.tongran.rocketmq.service.IRmPppoeConfigSubService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.tongran.rocketmq.mapper.RmPppoeConfigSubMapper;
|
||||
import com.tongran.rocketmq.domain.RmPppoeConfigSub;
|
||||
import com.tongran.rocketmq.service.IRmPppoeConfigSubService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PPPoE配置子表Service业务层处理
|
||||
@@ -93,4 +94,9 @@ public class RmPppoeConfigSubServiceImpl implements IRmPppoeConfigSubService
|
||||
{
|
||||
return rmPppoeConfigSubMapper.deleteRmPppoeConfigSubById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateRmPppoeConfigSubByVlan(RmPppoeConfigSub rmPppoeConfigSub) {
|
||||
return rmPppoeConfigSubMapper.updateRmPppoeConfigSubByVlan(rmPppoeConfigSub);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user