优化pppoe数据处理

流量图改为只保留有ipv4的流量网卡流量。
流量图增加显示对应的ipv4。
This commit is contained in:
gaoyutao
2026-01-08 18:24:05 +08:00
parent d7432bc53f
commit f5f5a97744
6 changed files with 57 additions and 44 deletions
@@ -23,7 +23,7 @@ import static com.tongran.common.core.web.domain.AjaxResult.success;
@RestController @RestController
@RequestMapping("/epsTrafficData") @RequestMapping("/epsTrafficData")
@RequiredArgsConstructor @RequiredArgsConstructor
@RequiresPermissions("rocketmq:traffic") @RequiresPermissions("rocketmq:trafficAnalysis")
public class EpsInitialTrafficDataController { public class EpsInitialTrafficDataController {
private final EpsInitialTrafficDataService epsInitialTrafficDataService; private final EpsInitialTrafficDataService epsInitialTrafficDataService;
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
/** /**
@@ -45,7 +46,8 @@ public class RocketMsgListener implements MessageListenerConcurrently {
//获取topic //获取topic
for (MessageExt messageExt : list) { for (MessageExt messageExt : list) {
// 解析消息内容 // 解析消息内容
String body = new String(messageExt.getBody()); // 明确指定UTF-8编码
String body = new String(messageExt.getBody(), StandardCharsets.UTF_8);
log.info("接受到的消息为:{}", body); log.info("接受到的消息为:{}", body);
String tags = messageExt.getTags(); String tags = messageExt.getTags();
String topic = messageExt.getTopic(); String topic = messageExt.getTopic();
@@ -253,8 +253,12 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
// 展示关系 // 展示关系
Map<String, String> showRealation = new HashMap<>(); Map<String, String> showRealation = new HashMap<>();
interfaceDataMap.put(name, mainList); interfaceDataMap.put(name, mainList);
showRealation.put(name+"netInTraffic", name+"入站流量"); String ipv4 = "";
showRealation.put(name+"netOutTraffic", name+"出站流量"); if(mainList != null && !mainList.isEmpty()){
ipv4 = mainList.get(0).getIpV4();
}
showRealation.put(name+"netInTraffic", name+"入站流量" + " IPv4: "+ipv4);
showRealation.put(name+"netOutTraffic", name+"出站流量" + " IPv4: "+ipv4);
boolean hasSubInterface = false; boolean hasSubInterface = false;
boolean needAddIpv4Ipv6 = false; // 标记是否需要添加IPv4和IPv6数据 boolean needAddIpv4Ipv6 = false; // 标记是否需要添加IPv4和IPv6数据
@@ -274,17 +278,17 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
if(childTrafficList != null && !childTrafficList.isEmpty()){ if(childTrafficList != null && !childTrafficList.isEmpty()){
interfaceDataMap.put(child.getInterfaceName(), childTrafficList); interfaceDataMap.put(child.getInterfaceName(), childTrafficList);
showRealation.put(child.getInterfaceName()+"netInTraffic", child.getInterfaceName()+"入站流量"); showRealation.put(child.getInterfaceName()+"netInTraffic", child.getInterfaceName() + "入站流量" + " IPv4: "+child.getIpv4Address());
showRealation.put(child.getInterfaceName()+"netOutTraffic", child.getInterfaceName()+"出站流量"); showRealation.put(child.getInterfaceName()+"netOutTraffic", child.getInterfaceName() + "出站流量" + " IPv4: "+child.getIpv4Address());
} }
} }
} else { } else {
// 将ipv4和ipv6的线也集合过来 - 只有在没有子网卡时才添加 // 将ipv4和ipv6的线也集合过来 - 只有在没有子网卡时才添加
needAddIpv4Ipv6 = true; needAddIpv4Ipv6 = true;
showRealation.put(name+"netInTrafficIPv4", name+"IPv4入站流量"); showRealation.put(name+"netInTrafficIPv4", name+"IPv4入站流量" + " IPv4: "+ipv4);
showRealation.put(name+"netOutTrafficIPv4", name+"IPv4出站流量"); showRealation.put(name+"netOutTrafficIPv4", name+"IPv4出站流量" + " IPv4: "+ipv4);
showRealation.put(name+"netInTrafficIPv6", name+"IPv6入站流量"); showRealation.put(name+"netInTrafficIPv6", name+"IPv6入站流量" + " IPv4: "+ipv4);
showRealation.put(name+"netOutTrafficIPv6", name+"IPv6出站流量"); showRealation.put(name+"netOutTrafficIPv6", name+"IPv6出站流量" + " IPv4: "+ipv4);
} }
} }
@@ -377,8 +381,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
} }
if(!showRealation.isEmpty() && hasSubInterface){ if(!showRealation.isEmpty() && hasSubInterface){
showRealation.put("totalNetInTraffic", name+"总入站流量"); showRealation.put("totalNetInTraffic", name+"总入站流量" + " IPv4: "+ipv4);
showRealation.put("totalNetOutTraffic", name+"总出站流量"); showRealation.put("totalNetOutTraffic", name+"总出站流量" + " IPv4: "+ipv4);
} }
Map<String, String> sortedShowRealation = EchartsMoreDataUtils.sortInterfaceMap(showRealation, name, hasSubInterface); Map<String, String> sortedShowRealation = EchartsMoreDataUtils.sortInterfaceMap(showRealation, name, hasSubInterface);
@@ -434,8 +438,12 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
// 展示关系 // 展示关系
Map<String, String> showRealation = new HashMap<>(); Map<String, String> showRealation = new HashMap<>();
interfaceDataMap.put(name, mainList); interfaceDataMap.put(name, mainList);
showRealation.put(name + "netInTraffic", name + "IPv4入站流量"); String ipv4 = "";
showRealation.put(name + "netOutTraffic", name + "IPv4出站流量"); if(mainList != null && !mainList.isEmpty()){
ipv4 = mainList.get(0).getIpV4();
}
showRealation.put(name + "netInTraffic", name + "IPv4入站流量" + " IPv4: "+ipv4);
showRealation.put(name + "netOutTraffic", name + "IPv4出站流量" + " IPv4: "+ipv4);
boolean hasSubInterface = false; boolean hasSubInterface = false;
// 如果是Ethernet类型,查询子网卡 // 如果是Ethernet类型,查询子网卡
@@ -454,8 +462,9 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
if (childTrafficList != null && !childTrafficList.isEmpty()) { if (childTrafficList != null && !childTrafficList.isEmpty()) {
interfaceDataMap.put(child.getInterfaceName(), childTrafficList); interfaceDataMap.put(child.getInterfaceName(), childTrafficList);
showRealation.put(child.getInterfaceName() + "netInTraffic", child.getInterfaceName() + "IPv4入站流量"); showRealation.put(child.getInterfaceName() + "netInTraffic", child.getInterfaceName() + "IPv4入站流量" + " IPv4: "+child.getIpv4Address());
showRealation.put(child.getInterfaceName() + "netOutTraffic", child.getInterfaceName() + "IPv4出站流量"); showRealation.put(child.getInterfaceName() + "netOutTraffic", child.getInterfaceName() + "IPv4出站流量" + " IPv4: "+child.getIpv4Address());
} }
} }
} }
@@ -484,8 +493,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
resultMap.put("unit", unit); resultMap.put("unit", unit);
if (!showRealation.isEmpty() && hasSubInterface) { if (!showRealation.isEmpty() && hasSubInterface) {
showRealation.put("totalNetInTraffic", name + "IPv4总入站流量"); showRealation.put("totalNetInTraffic", name + "IPv4总入站流量" + " IPv4: "+ipv4);
showRealation.put("totalNetOutTraffic", name + "IPv4总出站流量"); showRealation.put("totalNetOutTraffic", name + "IPv4总出站流量" + " IPv4: "+ipv4);
} }
Map<String, String> sortedShowRealation = EchartsMoreDataUtils.sortInterfaceMap(showRealation, name, hasSubInterface); Map<String, String> sortedShowRealation = EchartsMoreDataUtils.sortInterfaceMap(showRealation, name, hasSubInterface);
resultMap.put("showRealation", sortedShowRealation); resultMap.put("showRealation", sortedShowRealation);
@@ -514,8 +523,12 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
// 展示关系 // 展示关系
Map<String, String> showRealation = new HashMap<>(); Map<String, String> showRealation = new HashMap<>();
interfaceDataMap.put(name, mainList); interfaceDataMap.put(name, mainList);
showRealation.put(name + "netInTraffic", name + "IPv6入站流量"); String ipv4 = "";
showRealation.put(name + "netOutTraffic", name + "IPv6出站流量"); if(mainList != null && !mainList.isEmpty()){
ipv4 = mainList.get(0).getIpV4();
}
showRealation.put(name + "netInTraffic", name + "IPv6入站流量" + " IPv4: "+ipv4);
showRealation.put(name + "netOutTraffic", name + "IPv6出站流量" + " IPv4: "+ipv4);
boolean hasSubInterface = false; boolean hasSubInterface = false;
// 如果是Ethernet类型,查询子网卡 // 如果是Ethernet类型,查询子网卡
@@ -534,8 +547,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
if (childTrafficList != null && !childTrafficList.isEmpty()) { if (childTrafficList != null && !childTrafficList.isEmpty()) {
interfaceDataMap.put(child.getInterfaceName(), childTrafficList); interfaceDataMap.put(child.getInterfaceName(), childTrafficList);
showRealation.put(child.getInterfaceName() + "netInTraffic", child.getInterfaceName() + "IPv6入站流量"); showRealation.put(child.getInterfaceName() + "netInTraffic", child.getInterfaceName() + "IPv6入站流量" + " IPv4: "+child.getIpv4Address());
showRealation.put(child.getInterfaceName() + "netOutTraffic", child.getInterfaceName() + "IPv6出站流量"); showRealation.put(child.getInterfaceName() + "netOutTraffic", child.getInterfaceName() + "IPv6出站流量" + " IPv4: "+child.getIpv4Address());
} }
} }
} }
@@ -564,8 +577,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
resultMap.put("unit", unit); resultMap.put("unit", unit);
if (!showRealation.isEmpty() && hasSubInterface) { if (!showRealation.isEmpty() && hasSubInterface) {
showRealation.put("totalNetInTraffic", name + "IPv6总入站流量"); showRealation.put("totalNetInTraffic", name + "IPv6总入站流量" + " IPv4: "+ipv4);
showRealation.put("totalNetOutTraffic", name + "IPv6总出站流量"); showRealation.put("totalNetOutTraffic", name + "IPv6总出站流量" + " IPv4: "+ipv4);
} }
Map<String, String> sortedShowRealation = EchartsMoreDataUtils.sortInterfaceMap(showRealation, name, hasSubInterface); Map<String, String> sortedShowRealation = EchartsMoreDataUtils.sortInterfaceMap(showRealation, name, hasSubInterface);
resultMap.put("showRealation", sortedShowRealation); resultMap.put("showRealation", sortedShowRealation);
@@ -647,8 +660,12 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
// 展示关系 // 展示关系
Map<String, String> showRealation = new HashMap<>(); Map<String, String> showRealation = new HashMap<>();
interfaceDataMap.put(name, mainList); interfaceDataMap.put(name, mainList);
showRealation.put(name + "netInTraffic", name + "入站流量"); String ipv4 = "";
showRealation.put(name + "netOutTraffic", name + "出站流量"); if(mainList != null && !mainList.isEmpty()){
ipv4 = mainList.get(0).getIpV4();
}
showRealation.put(name + "netInTraffic", name + "入站流量" + " IPv4: "+ipv4);
showRealation.put(name + "netOutTraffic", name + "出站流量" + " IPv4: "+ipv4);
boolean hasSubInterface = false; boolean hasSubInterface = false;
// 如果是Ethernet类型,查询子网卡 // 如果是Ethernet类型,查询子网卡
@@ -667,8 +684,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
if (childTrafficList != null && !childTrafficList.isEmpty()) { if (childTrafficList != null && !childTrafficList.isEmpty()) {
interfaceDataMap.put(child.getInterfaceName(), childTrafficList); interfaceDataMap.put(child.getInterfaceName(), childTrafficList);
showRealation.put(child.getInterfaceName() + "netInTraffic", child.getInterfaceName() + "入站流量"); showRealation.put(child.getInterfaceName() + "netInTraffic", child.getInterfaceName() + "入站流量" + " IPv4: "+child.getIpv4Address());
showRealation.put(child.getInterfaceName() + "netOutTraffic", child.getInterfaceName() + "出站流量"); showRealation.put(child.getInterfaceName() + "netOutTraffic", child.getInterfaceName() + "出站流量" + " IPv4: "+child.getIpv4Address());
} }
} }
} }
@@ -697,8 +714,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
resultMap.put("unit", unit); resultMap.put("unit", unit);
if (!showRealation.isEmpty() && hasSubInterface) { if (!showRealation.isEmpty() && hasSubInterface) {
showRealation.put("totalNetInTraffic", name + "总入站流量"); showRealation.put("totalNetInTraffic", name + "总入站流量" + " IPv4: "+ipv4);
showRealation.put("totalNetOutTraffic", name + "总出站流量"); showRealation.put("totalNetOutTraffic", name + "总出站流量" + " IPv4: "+ipv4);
} }
Map<String, String> sortedShowRealation = EchartsMoreDataUtils.sortInterfaceMap(showRealation, name, hasSubInterface); Map<String, String> sortedShowRealation = EchartsMoreDataUtils.sortInterfaceMap(showRealation, name, hasSubInterface);
resultMap.put("showRealation", sortedShowRealation); resultMap.put("showRealation", sortedShowRealation);
@@ -18,6 +18,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -48,13 +49,6 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
RmPppoeConfigSub rmPppoeConfigSub = new RmPppoeConfigSub(); RmPppoeConfigSub rmPppoeConfigSub = new RmPppoeConfigSub();
rmPppoeConfigSub.setClientId(rmPppoeConfigMain.getClientId()); rmPppoeConfigSub.setClientId(rmPppoeConfigMain.getClientId());
List<RmPppoeConfigSub> subList = rmPppoeConfigSubMapper.selectRmPppoeConfigSubList(rmPppoeConfigSub); List<RmPppoeConfigSub> subList = rmPppoeConfigSubMapper.selectRmPppoeConfigSubList(rmPppoeConfigSub);
if(subList != null && !subList.isEmpty()){
for (RmPppoeConfigSub pppoeConfigSub : subList) {
if(pppoeConfigSub.getStatus() == null){
pppoeConfigSub.setStatus(pppoeConfigSub.getVirStatus());
}
}
}
pppoeConfigMain.setSubList(subList); pppoeConfigMain.setSubList(subList);
return pppoeConfigMain; return pppoeConfigMain;
} }
@@ -83,6 +77,7 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
rmPppoeConfigMain.setCreateTime(DateUtils.getNowDate()); rmPppoeConfigMain.setCreateTime(DateUtils.getNowDate());
int rows = rmPppoeConfigMainMapper.insertRmPppoeConfigMain(rmPppoeConfigMain); int rows = rmPppoeConfigMainMapper.insertRmPppoeConfigMain(rmPppoeConfigMain);
List<RmPppoeConfigSub> subList = rmPppoeConfigMain.getSubList(); List<RmPppoeConfigSub> subList = rmPppoeConfigMain.getSubList();
List<RmPppoeConfigSubVo> voList = new ArrayList<>();
if(subList != null && !subList.isEmpty()){ if(subList != null && !subList.isEmpty()){
for (RmPppoeConfigSub rmPppoeConfigSub : subList) { for (RmPppoeConfigSub rmPppoeConfigSub : subList) {
rmPppoeConfigSub.setClientId(rmPppoeConfigMain.getClientId()); rmPppoeConfigSub.setClientId(rmPppoeConfigMain.getClientId());
@@ -93,13 +88,13 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
rmPppoeConfigSubMapper.deleteRmPppoeConfigSubByClientId(rmPppoeConfigMain.getClientId()); rmPppoeConfigSubMapper.deleteRmPppoeConfigSubByClientId(rmPppoeConfigMain.getClientId());
// 批量新增 // 批量新增
rmPppoeConfigSubMapper.batchInsertRmPppoeConfigSub(subList); rmPppoeConfigSubMapper.batchInsertRmPppoeConfigSub(subList);
voList = subList.stream()
.map(RmPppoeConfigSub::toVo)
.collect(Collectors.toList());
} }
// 构建pppoe策略 // 构建pppoe策略
PppoeVo pppoeVo = new PppoeVo(); PppoeVo pppoeVo = new PppoeVo();
BeanUtils.copyProperties(rmPppoeConfigMain, pppoeVo); BeanUtils.copyProperties(rmPppoeConfigMain, pppoeVo);
List<RmPppoeConfigSubVo> voList = subList.stream()
.map(RmPppoeConfigSub::toVo)
.collect(Collectors.toList());
pppoeVo.setSubList(voList); pppoeVo.setSubList(voList);
String pppoeStr = JSONObject.toJSONString(pppoeVo); String pppoeStr = JSONObject.toJSONString(pppoeVo);
PolicyTypeVo policyTypeVo = new PolicyTypeVo(); PolicyTypeVo policyTypeVo = new PolicyTypeVo();
@@ -35,7 +35,7 @@
<include refid="selectRmNetworkInterfaceChildVo"/> <include refid="selectRmNetworkInterfaceChildVo"/>
<where> <where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if> <if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="parentInterface != null and parentInterface != ''"> and parent_interface = #{parentInterface}</if> <if test="parentInterface != null and parentInterface != ''"> and parent_interface = #{parentInterface} and ipv4_address != '' and ipv4_address != 'N/A'</if>
<if test="isp != null and isp != ''"> and isp = #{isp}</if> <if test="isp != null and isp != ''"> and isp = #{isp}</if>
<if test="province != null and province != ''"> and province = #{province}</if> <if test="province != null and province != ''"> and province = #{province}</if>
<if test="city != null and city != ''"> and city = #{city}</if> <if test="city != null and city != ''"> and city = #{city}</if>
@@ -37,9 +37,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.update_time updateTime, a.update_time updateTime,
a.create_by createBy, a.create_by createBy,
a.update_by updateBy, a.update_by updateBy,
a.status status, b.status status,
b.mac_address macAddress, b.mac_address macAddress
b.status virStatus
FROM FROM
rm_pppoe_config_sub a rm_pppoe_config_sub a
LEFT JOIN LEFT JOIN