优化网卡名称变更处理

增加非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
@@ -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>