优化网卡名称变更处理

增加非saas平台拨号数据处理
优化详情信息
This commit is contained in:
gaoyutao
2026-01-07 19:20:01 +08:00
parent 86d7385c15
commit ea6caa0211
15 changed files with 126 additions and 33 deletions
@@ -1,11 +1,13 @@
package com.tongran.system.api.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class NetworkInfo {
// 运营商
@JsonProperty("carrier")
@@ -36,6 +38,9 @@ public class NetworkInfo {
private String publicIp;
@JsonProperty("type")
private String type;
/** 与外网的连通性(0否,1是) */
@JsonProperty("status")
private String status;
// 如果是子接口,存储父接口名称
@JsonProperty("parentInterface")
private String parentInterface;
@@ -27,7 +27,8 @@ public class AllInterfaceName extends BaseEntity
/** 接口名称 */
@Excel(name = "接口名称")
private String interfaceName;
/** 接口名称备注 */
private String interfaceNameRemark;
/** 设备序列号 */
@Excel(name = "设备序列号")
private String deviceSn;
@@ -8,7 +8,9 @@ import com.tongran.system.api.RemoteRocketMqService;
import com.tongran.system.api.domain.RmNetworkInterfaceRemote;
import com.tongran.system.domain.AllInterfaceName;
import com.tongran.system.domain.RmEpsTopologyManagement;
import com.tongran.system.domain.RmSwitchInterfaceInfo;
import com.tongran.system.mapper.AllInterfaceNameMapper;
import com.tongran.system.mapper.RmSwitchInterfaceInfoMapper;
import com.tongran.system.service.IAllInterfaceNameService;
import com.tongran.system.service.IRmEpsTopologyManagementService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -35,6 +37,8 @@ public class AllInterfaceNameServiceImpl implements IAllInterfaceNameService
private RemoteRocketMqService remoteRocketMqService;
@Autowired
private IRmEpsTopologyManagementService rmEpsTopologyManagementService;
@Autowired
private RmSwitchInterfaceInfoMapper rmSwitchInterfaceInfoMapper;
/**
* 查询所有接口名称
@@ -88,6 +92,17 @@ public class AllInterfaceNameServiceImpl implements IAllInterfaceNameService
// 使用ID作为键,避免对象相等性问题
Map<Long, Boolean> matchStatusMap = new HashMap<>();
for (AllInterfaceName interfaceName : nonSubInterfaces) {
if ("2".equals(allInterfaceName.getResourceType())) {
// 查询端口备注
// 查询端口备注信息
RmSwitchInterfaceInfo queryParam = new RmSwitchInterfaceInfo();
queryParam.setClientId(allInterfaceName.getClientId());
queryParam.setInterfaceName(allInterfaceName.getInterfaceName());
List<RmSwitchInterfaceInfo> interfaceInfos = rmSwitchInterfaceInfoMapper.selectRmSwitchInterfaceInfoList(queryParam);
if(interfaceInfos != null && !interfaceInfos.isEmpty()){
interfaceName.setInterfaceNameRemark(interfaceInfos.get(0).getInterfaceRemark());
}
}
boolean isMatched = isInterfaceMatched(interfaceName);
matchStatusMap.put(interfaceName.getId(), isMatched);
@@ -138,11 +153,16 @@ public class AllInterfaceNameServiceImpl implements IAllInterfaceNameService
}
List<RmNetworkInterfaceRemote> interfaceRemoteList = netWorkListR.getData();
boolean isBusiness = interfaceRemoteList.stream()
boolean isBusiness = interfaceRemoteList.stream()
.filter(info -> "1".equals(info.getBindIp()) || "3".equals(info.getBindIp()))
.anyMatch(internet ->
interfaceName.getServerIp() != null && internet.getMacAddress() != null &&
interfaceName.getServerIp().equalsIgnoreCase(internet.getMacAddress())
interfaceName.getServerIp().equalsIgnoreCase(internet.getMacAddress()) &&
// 新增:比较网卡名称
interfaceName.getInterfaceName() != null && internet.getInterfaceName() != null &&
getBaseInterfaceName(interfaceName.getInterfaceName()).equalsIgnoreCase(
getBaseInterfaceName(internet.getInterfaceName())
)
);
return isBusiness;
@@ -171,6 +191,17 @@ public class AllInterfaceNameServiceImpl implements IAllInterfaceNameService
return false;
}
// 提取基础网卡名称
private String getBaseInterfaceName(String fullName) {
if (fullName == null) return null;
// 尝试按括号分割
String[] parts = fullName.split("[(]");
if (parts.length > 0) {
return parts[0].trim();
}
return fullName;
}
/**
* 新增所有接口名称
*
@@ -231,6 +231,7 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
EpsInitialTrafficData condition = new EpsInitialTrafficData();
condition.setTableName(tableName);
condition.setClientId(queryParam.getClientId());
condition.setMac(queryParam.getMac());
condition.setServiceSn(queryParam.getServiceSn());
condition.setStartTime(queryParam.getStartTime());
condition.setEndTime(queryParam.getEndTime());
@@ -775,8 +776,30 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
calculateSegment95(queryParam, dailyStartTime, dailyEndTime, calculationMode);
}
}else{
queryParam.setBusinessId(null);
calculateNormalDeviceBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
// 获取所有不同的网卡
Set<String> names = records.stream()
.map(EpsMethodChangeRecord::getTrafficPort)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
if(names != null && !names.isEmpty()){
// 对每个网卡计算全天的95带宽
for (String name : names) {
// 查询mac
AllInterfaceName allInterfaceName = new AllInterfaceName();
allInterfaceName.setClientId(queryParam.getClientId());
allInterfaceName.setInterfaceName(name);
allInterfaceName.setResourceType("1");
List<AllInterfaceName> allInterfaceNameList = allInterfaceNameMapper.selectByNames(allInterfaceName);
if(allInterfaceNameList != null && !allInterfaceNameList.isEmpty()){
AllInterfaceName interfaceName = allInterfaceNameList.get(0);
queryParam.setMac(interfaceName.getServerIp());
calculateSegment95(queryParam, dailyStartTime, dailyEndTime, calculationMode);
}
}
}else{
queryParam.setBusinessId(null);
calculateNormalDeviceBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
}
}
}else{
queryParam.setBusinessId(null);
@@ -48,6 +48,7 @@
<if test="serverIp != null and serverIp != ''"> and server_ip = #{serverIp}</if>
<if test="portStatus != null and portStatus != ''"> and port_status = #{portStatus}</if>
</where>
order by create_time desc
</select>
<select id="selectAllInterfaceNameById" parameterType="Long" resultMap="AllInterfaceNameResult">
@@ -156,7 +157,7 @@
all_interface_name
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="interfaceName != null and interfaceName != ''"> and interface_name = #{interfaceName}</if>
<if test="interfaceName != null and interfaceName != ''"> and interface_name like concat(#{interfaceName},'%')</if>
<if test="deviceSn != null and deviceSn != ''"> and device_sn = #{deviceSn}</if>
<if test="nodeName != null and nodeName != ''"> and node_name = #{nodeName}</if>
<if test="businessCode != null and businessCode != ''"> and business_code = #{businessCode}</if>
@@ -387,9 +387,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.client_id AS clientId,
a.ipV6 AS ipV6
FROM ${tableName} a
INNER JOIN rm_network_interface b ON a.client_id = b.client_id and a.mac=b.mac_address
AND (b.bind_ip = 1 OR b.bind_ip = 3)
AND b.new_flag = 1
<!-- 动态关联表 -->
<if test="mac == null or mac == ''">
INNER JOIN rm_network_interface b ON a.client_id = b.client_id and a.mac = b.mac_address
AND (b.bind_ip = 1 OR b.bind_ip = 3)
AND b.new_flag = 1
</if>
<where>
<if test="serviceSn != '' and serviceSn != null">
and a.service_sn = #{serviceSn}
@@ -409,6 +412,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="revenueMethod != null">
and a.revenue_method = #{revenueMethod}
</if>
<if test="mac != null and mac != ''">
and a.mac = #{mac}
</if>
</where>
GROUP BY a.create_time DESC
</select>
@@ -71,4 +71,7 @@ public class RmNetworkInterfaceChild extends BaseEntity
/** 是否为新的(0否 1是) */
@Excel(name = "是否为新的(0否 1是)")
private Integer newFlag;
/** 是否连通外网(0否,1是) */
@Excel(name = "是否连通外网(0否,1是)")
private String status;
}
@@ -42,6 +42,8 @@ public class RmPppoeConfigSub extends BaseEntity
private String ipv4Gateway;
/** 状态(0未连通,1连通) */
private String status;
/** 虚拟网卡连通状态 */
private String virStatus;
/** 上报带宽 */
private BigDecimal bandwidthResult;
/** MAC地址 */
@@ -25,7 +25,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;
@@ -1279,6 +1278,7 @@ public class MessageHandler {
networkInterface.setProvince(networkInfo.getProvince());
networkInterface.setPublicIp(networkInfo.getPublicIp());
networkInterface.setInterfaceType(networkInfo.getType());
networkInterface.setStatus(networkInfo.getStatus());
}
/**
@@ -1,7 +1,6 @@
package com.tongran.rocketmq.mapper;
import com.tongran.rocketmq.domain.InitialSystemOtherCollectData;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@@ -77,8 +76,8 @@ public interface InitialSystemOtherCollectDataMapper
int deleteInitialSystemOtherCollectData(InitialSystemOtherCollectData deleteData);
/**
* 获取总内存
* @param clientId
* @param otherCollectData
* @return
*/
String getMemTotalSize(@Param("clientId") String clientId);
String getMemTotalSize(InitialSystemOtherCollectData otherCollectData);
}
@@ -3,6 +3,7 @@ package com.tongran.rocketmq.service.impl;
import com.tongran.common.core.utils.*;
import com.tongran.rocketmq.domain.InitialBandwidthTraffic;
import com.tongran.rocketmq.domain.InitialCpuInfo;
import com.tongran.rocketmq.domain.InitialSystemOtherCollectData;
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
import com.tongran.rocketmq.mapper.InitialBandwidthTrafficMapper;
import com.tongran.rocketmq.mapper.InitialCpuInfoMapper;
@@ -610,7 +611,10 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
sppedMsg = new InitialBandwidthTraffic();
}
resultMap.put("speed", sppedMsg.getSpeed());
String memTotalSize = initialSystemOtherCollectDataMapper.getMemTotalSize(initialBandwidthTraffic.getClientId());
InitialSystemOtherCollectData memQuery = new InitialSystemOtherCollectData();
memQuery.setClientId(initialBandwidthTraffic.getClientId());
memQuery.setTableName(TableSubUtil.getTableName(DateUtils.getNowDate(), "initial_system_other_collect_data"));
String memTotalSize = initialSystemOtherCollectDataMapper.getMemTotalSize(memQuery);
resultMap.put("memTotalSize", memTotalSize);
// 获取cpu数量
InitialCpuInfo cpuInfo = initialCpuInfoMapper.getCpuInfoByClientId(initialBandwidthTraffic.getClientId());
@@ -48,6 +48,13 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
RmPppoeConfigSub rmPppoeConfigSub = new RmPppoeConfigSub();
rmPppoeConfigSub.setClientId(rmPppoeConfigMain.getClientId());
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);
return pppoeConfigMain;
}
@@ -126,12 +126,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getMemTotalSize" parameterType="String" resultType="String">
select
floor(d.collect_value/(1024 * 1024)) as memTotalSize
FROM initial_system_other_collect_data d
FROM ${tableName} d
INNER JOIN (
SELECT
client_id,
MAX(create_time) as max_time
FROM initial_system_other_collect_data
FROM ${tableName}
WHERE collect_type='memorySizeTotalCollect'
AND client_id = #{clientId}
GROUP BY client_id
@@ -24,10 +24,11 @@
<result property="updateBy" column="update_by" />
<result property="bindIp" column="bind_ip" />
<result property="newFlag" column="new_flag" />
<result property="status" column="status" />
</resultMap>
<sql id="selectRmNetworkInterfaceChildVo">
select id, client_id, parent_interface, isp, province, city, public_ip, interface_name, mac_address, interface_type, ipv4_address, ipv6_address, gateway, create_time, update_time, create_by, update_by, bind_ip, new_flag from rm_network_interface_child
select id, client_id, parent_interface, isp, province, city, public_ip, interface_name, mac_address, interface_type, ipv4_address, ipv6_address, gateway, create_time, update_time, create_by, update_by, bind_ip, new_flag, status from rm_network_interface_child
</sql>
<select id="selectRmNetworkInterfaceChildList" parameterType="RmNetworkInterfaceChild" resultMap="RmNetworkInterfaceChildResult">
@@ -47,6 +48,7 @@
<if test="gateway != null and gateway != ''"> and gateway = #{gateway}</if>
<if test="bindIp != null and bindIp != ''"> and bind_ip = #{bindIp}</if>
<if test="newFlag != null "> and new_flag = #{newFlag}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
</where>
</select>
@@ -76,6 +78,7 @@
<if test="updateBy != null">update_by,</if>
<if test="bindIp != null">bind_ip,</if>
<if test="newFlag != null">new_flag,</if>
<if test="status != null">status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clientId != null">#{clientId},</if>
@@ -96,6 +99,7 @@
<if test="updateBy != null">#{updateBy},</if>
<if test="bindIp != null">#{bindIp},</if>
<if test="newFlag != null">#{newFlag},</if>
<if test="status != null">#{status},</if>
</trim>
</insert>
@@ -120,6 +124,7 @@
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="bindIp != null">bind_ip = #{bindIp},</if>
<if test="newFlag != null">new_flag = #{newFlag},</if>
<if test="status != null">status = #{status},</if>
</trim>
<where>
<choose>
@@ -12,33 +12,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="ipv4Address" column="ipv4_address" />
<result property="ipv4MaskBits" column="ipv4_mask_bits" />
<result property="ipv4Gateway" column="ipv4_gateway" />
<result property="bandwidthResult" column="bandwidth_result" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="status" column="status" />
<result property="macAddress" column="mac_address" />
</resultMap>
<sql id="selectRmPppoeConfigSubVo">
select id, client_id, serial_number, vlan_id, ipv4_address, ipv4_mask_bits, ipv4_gateway, create_time, update_time, create_by, update_by, status from rm_pppoe_config_sub
select id, client_id, serial_number, vlan_id, ipv4_address, ipv4_mask_bits, ipv4_gateway, bandwidth_result, create_time, update_time, create_by, update_by, status from rm_pppoe_config_sub
</sql>
<select id="selectRmPppoeConfigSubList" parameterType="RmPppoeConfigSub" resultMap="RmPppoeConfigSubResult">
<select id="selectRmPppoeConfigSubList" parameterType="RmPppoeConfigSub" resultType="RmPppoeConfigSub">
SELECT
a.id,
a.client_id,
a.serial_number,
a.vlan_id,
a.ipv4_address,
a.ipv4_mask_bits,
a.ipv4_gateway,
a.create_time,
a.update_time,
a.create_by,
a.update_by,
a.status,
b.mac_address
a.client_id clientId,
a.serial_number serialNumber,
a.vlan_id vlanId,
a.ipv4_address ipv4Address,
a.ipv4_mask_bits ipv4MaskBits,
a.ipv4_gateway ipv4Gateway,
a.create_time createTime,
a.update_time updateTime,
a.create_by createBy,
a.update_by updateBy,
a.status status,
b.mac_address macAddress,
b.status virStatus
FROM
rm_pppoe_config_sub a
LEFT JOIN
@@ -70,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ipv4Address != null">ipv4_address,</if>
<if test="ipv4MaskBits != null">ipv4_mask_bits,</if>
<if test="ipv4Gateway != null">ipv4_gateway,</if>
<if test="bandwidthResult != null">bandwidth_result,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
@@ -83,6 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ipv4Address != null">#{ipv4Address},</if>
<if test="ipv4MaskBits != null">#{ipv4MaskBits},</if>
<if test="ipv4Gateway != null">#{ipv4Gateway},</if>
<if test="bandwidthResult != null">#{bandwidthResult},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
@@ -100,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ipv4Address != null">ipv4_address = #{ipv4Address},</if>
<if test="ipv4MaskBits != null">ipv4_mask_bits = #{ipv4MaskBits},</if>
<if test="ipv4Gateway != null">ipv4_gateway = #{ipv4Gateway},</if>
<if test="bandwidthResult != null">bandwidth_result = #{bandwidthResult},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
@@ -121,7 +125,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<insert id="batchInsertRmPppoeConfigSub" parameterType="java.util.List">
insert into rm_pppoe_config_sub
(client_id, serial_number, vlan_id, ipv4_address, ipv4_mask_bits, ipv4_gateway, create_time, update_time, create_by, update_by)
(client_id, serial_number, vlan_id, ipv4_address, ipv4_mask_bits, ipv4_gateway,
bandwidth_result, create_time, update_time, create_by, update_by)
values
<foreach collection="list" item="item" separator=",">
(
@@ -131,6 +136,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.ipv4Address},
#{item.ipv4MaskBits},
#{item.ipv4Gateway},
#{item.bandwidthResult},
#{item.createTime},
#{item.updateTime},
#{item.createBy},