增加存储子网卡信息、修复子网卡流量递增问题
子网卡流量图合并
This commit is contained in:
+9
-1
@@ -56,7 +56,7 @@ public interface RemoteRocketMqService {
|
||||
public R<List<RmNetworkInterfaceRemote>> getNetworkInterfaceList(@RequestBody RmNetworkInterfaceRemote rmNetworkInterfaceRemote, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 获取网卡接口列表
|
||||
* 绑定业务网卡
|
||||
* @param rmNetworkInterfaceRemote
|
||||
* @param source
|
||||
* @return
|
||||
@@ -98,4 +98,12 @@ public interface RemoteRocketMqService {
|
||||
public R<Integer> issueDefaultPolicyByClientId(@RequestParam("clientId") String clientId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
@PostMapping("policy/addDeployScript")
|
||||
R<Integer> addDeployScript(@RequestBody RmDeployScriptRemote addData, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
/**
|
||||
* 获取子网卡接口列表
|
||||
* @param rmNetworkInterfaceRemote
|
||||
* @param source
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/networkInterfaceChild/innerGetChildList")
|
||||
public R<List<RmNetworkInterfaceRemote>> innerGetChildList(@RequestBody RmNetworkInterfaceRemote rmNetworkInterfaceRemote, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
}
|
||||
|
||||
+9
@@ -3,6 +3,8 @@ package com.tongran.system.api.domain;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class NetworkInfo {
|
||||
// 运营商
|
||||
@@ -34,4 +36,11 @@ public class NetworkInfo {
|
||||
private String publicIp;
|
||||
@JsonProperty("type")
|
||||
private String type;
|
||||
// 如果是子接口,存储父接口名称
|
||||
@JsonProperty("parentInterface")
|
||||
private String parentInterface;
|
||||
|
||||
// 如果是父接口,存储子接口列表
|
||||
@JsonProperty("subInterfaces")
|
||||
private List<NetworkInfo> subInterfaces;
|
||||
}
|
||||
|
||||
+3
@@ -56,4 +56,7 @@ public class RmNetworkInterfaceRemote extends BaseEntity {
|
||||
private Integer newFlag;
|
||||
/** 服务器clientId集合 */
|
||||
private String clientIds;
|
||||
|
||||
// 如果是子接口,存储父接口名称
|
||||
private String parentInterface;
|
||||
}
|
||||
|
||||
+5
@@ -83,6 +83,11 @@ public class RemoteRocketMqFallbackFactory implements FallbackFactory<RemoteRock
|
||||
public R<Integer> addDeployScript(RmDeployScriptRemote addData, String source) {
|
||||
return R.fail(throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<RmNetworkInterfaceRemote>> innerGetChildList(RmNetworkInterfaceRemote rmNetworkInterfaceRemote, String source) {
|
||||
return R.fail(throwable.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+409
@@ -0,0 +1,409 @@
|
||||
package com.tongran.common.core.utils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class EchartsMoreDataUtils {
|
||||
|
||||
|
||||
/**
|
||||
* 构建多网卡ECharts图表数据(带汇总流量)
|
||||
* 每个网卡会生成两个独立的Y轴属性:{interfaceName}netInTraffic 和 {interfaceName}netOutTraffic
|
||||
* 同时生成汇总流量:totalNetInTraffic 和 totalNetOutTraffic
|
||||
*/
|
||||
public static <T> Map<String, Object> buildMultiInterfaceEchartsDataWithTotal(
|
||||
Map<String, List<T>> interfaceDataMap,
|
||||
Function<T, Date> timeExtractor,
|
||||
Function<T, BigDecimal> inSpeedExtractor,
|
||||
Function<T, BigDecimal> outSpeedExtractor,
|
||||
String startTime,
|
||||
String endTime,
|
||||
BigDecimal divisor) {
|
||||
|
||||
try {
|
||||
// 解析时间字符串
|
||||
Date startDate = parseStringToDate(startTime);
|
||||
Date endDate = parseStringToDate(endTime);
|
||||
|
||||
if (startDate == null || endDate == null) {
|
||||
throw new IllegalArgumentException("开始时间或结束时间格式错误");
|
||||
}
|
||||
|
||||
if (startDate.after(endDate)) {
|
||||
throw new IllegalArgumentException("开始时间不能晚于结束时间");
|
||||
}
|
||||
|
||||
// 收集所有网卡的时间点
|
||||
Set<Date> allTimePoints = new TreeSet<>();
|
||||
Map<String, Map<Long, T>> interfaceTimeMap = new LinkedHashMap<>();
|
||||
|
||||
// 为每个网卡处理数据
|
||||
for (Map.Entry<String, List<T>> entry : interfaceDataMap.entrySet()) {
|
||||
String interfaceName = entry.getKey();
|
||||
List<T> interfaceList = entry.getValue();
|
||||
|
||||
if (interfaceList == null || interfaceList.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 按时间排序
|
||||
List<T> sortedList = interfaceList.stream()
|
||||
.sorted(Comparator.comparing(timeExtractor))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 自动检测时间间隔
|
||||
long timeInterval = detectTimeInterval(sortedList, timeExtractor);
|
||||
|
||||
// 创建时间到数据的映射
|
||||
Map<Long, T> timeMap = sortedList.stream()
|
||||
.collect(Collectors.toMap(
|
||||
item -> normalizeTime(timeExtractor.apply(item), timeInterval),
|
||||
Function.identity(),
|
||||
(a, b) -> a
|
||||
));
|
||||
|
||||
interfaceTimeMap.put(interfaceName, timeMap);
|
||||
|
||||
// 添加时间点到总集合
|
||||
for (T item : sortedList) {
|
||||
allTimePoints.add(timeExtractor.apply(item));
|
||||
}
|
||||
}
|
||||
|
||||
// 生成完整的时间序列
|
||||
List<Date> fullTimeSeries = generateFullTimeSeriesForMultiInterface(
|
||||
allTimePoints, startDate, endDate);
|
||||
|
||||
// 准备X轴和Y轴数据
|
||||
List<String> xAxisData = new ArrayList<>();
|
||||
Map<String, Object> yData = new LinkedHashMap<>();
|
||||
|
||||
// 初始化每个网卡的Y轴数据结构
|
||||
interfaceDataMap.keySet().forEach(interfaceName -> {
|
||||
yData.put(interfaceName + "netInTraffic", new ArrayList<BigDecimal>());
|
||||
yData.put(interfaceName + "netOutTraffic", new ArrayList<BigDecimal>());
|
||||
});
|
||||
|
||||
// 初始化汇总流量数据结构
|
||||
List<BigDecimal> totalNetInTraffic = new ArrayList<>();
|
||||
List<BigDecimal> totalNetOutTraffic = new ArrayList<>();
|
||||
yData.put("totalNetInTraffic", totalNetInTraffic);
|
||||
yData.put("totalNetOutTraffic", totalNetOutTraffic);
|
||||
|
||||
// 遍历所有时间点
|
||||
for (Date time : fullTimeSeries) {
|
||||
// X轴数据
|
||||
xAxisData.add(parseDateToStr(time));
|
||||
|
||||
// 标准化当前时间
|
||||
long normalizedTime = normalizeTime(time, 300000L); // 5分钟间隔
|
||||
|
||||
// 当前时间点的总流量
|
||||
BigDecimal timeTotalInSpeed = BigDecimal.ZERO;
|
||||
BigDecimal timeTotalOutSpeed = BigDecimal.ZERO;
|
||||
|
||||
// 处理每个网卡的数据
|
||||
for (Map.Entry<String, Map<Long, T>> entry : interfaceTimeMap.entrySet()) {
|
||||
String interfaceName = entry.getKey();
|
||||
Map<Long, T> timeMap = entry.getValue();
|
||||
|
||||
T item = timeMap.get(normalizedTime);
|
||||
|
||||
// 获取入方向数据列表
|
||||
@SuppressWarnings("unchecked")
|
||||
List<BigDecimal> inSpeedList = (List<BigDecimal>) yData.get(interfaceName + "netInTraffic");
|
||||
// 获取出方向数据列表
|
||||
@SuppressWarnings("unchecked")
|
||||
List<BigDecimal> outSpeedList = (List<BigDecimal>) yData.get(interfaceName + "netOutTraffic");
|
||||
|
||||
if (item != null) {
|
||||
// 有真实数据
|
||||
BigDecimal inSpeed = inSpeedExtractor.apply(item);
|
||||
BigDecimal outSpeed = outSpeedExtractor.apply(item);
|
||||
|
||||
// 单位转换
|
||||
BigDecimal convertedInSpeed = inSpeed != null ?
|
||||
inSpeed.divide(divisor, 2, RoundingMode.HALF_UP) : null;
|
||||
BigDecimal convertedOutSpeed = outSpeed != null ?
|
||||
outSpeed.divide(divisor, 2, RoundingMode.HALF_UP) : null;
|
||||
|
||||
inSpeedList.add(convertedInSpeed);
|
||||
outSpeedList.add(convertedOutSpeed);
|
||||
|
||||
// 累加到总流量
|
||||
if (convertedInSpeed != null) {
|
||||
timeTotalInSpeed = timeTotalInSpeed.add(convertedInSpeed);
|
||||
}
|
||||
if (convertedOutSpeed != null) {
|
||||
timeTotalOutSpeed = timeTotalOutSpeed.add(convertedOutSpeed);
|
||||
}
|
||||
} else {
|
||||
// 无数据的时间点,补null
|
||||
inSpeedList.add(null);
|
||||
outSpeedList.add(null);
|
||||
}
|
||||
}
|
||||
|
||||
// 添加当前时间点的总流量
|
||||
totalNetInTraffic.add(timeTotalInSpeed.compareTo(BigDecimal.ZERO) == 0 ? null : timeTotalInSpeed);
|
||||
totalNetOutTraffic.add(timeTotalOutSpeed.compareTo(BigDecimal.ZERO) == 0 ? null : timeTotalOutSpeed);
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("xData", xAxisData);
|
||||
result.put("yData", yData);
|
||||
return result;
|
||||
|
||||
} catch (Exception e) {
|
||||
// 记录日志
|
||||
System.err.println("构建多网卡图表数据失败: " + e.getMessage());
|
||||
return createEmptyMultiInterfaceResultWithTotal(interfaceDataMap.keySet(), startTime, endTime);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 为多网卡生成完整的时间序列
|
||||
*/
|
||||
private static List<Date> generateFullTimeSeriesForMultiInterface(
|
||||
Set<Date> allInterfaceTimePoints,
|
||||
Date startDate,
|
||||
Date endDate) {
|
||||
|
||||
// 获取实际数据的时间范围
|
||||
Date actualStartTime = allInterfaceTimePoints.isEmpty() ? startDate :
|
||||
Collections.min(allInterfaceTimePoints);
|
||||
Date actualEndTime = allInterfaceTimePoints.isEmpty() ? endDate :
|
||||
Collections.max(allInterfaceTimePoints);
|
||||
|
||||
// 计算稀疏间隔
|
||||
long totalTimeRange = endDate.getTime() - startDate.getTime();
|
||||
long sparseInterval = totalTimeRange > 12L * 30 * 24 * 60 * 60 * 1000 ?
|
||||
30L * 24 * 60 * 60 * 1000 : 2L * 24 * 60 * 60 * 1000;
|
||||
|
||||
// 使用默认的5分钟作为数据期间间隔
|
||||
long dataInterval = 300000L;
|
||||
|
||||
// 生成三段时间序列
|
||||
List<Date> fullTimeSeries = new ArrayList<>();
|
||||
|
||||
// 1. 开始时间到数据开始时间(稀疏间隔)
|
||||
if (startDate.before(actualStartTime)) {
|
||||
List<Date> beforeSeries = generateTimeSeries(startDate, actualStartTime, sparseInterval);
|
||||
fullTimeSeries.addAll(beforeSeries);
|
||||
}
|
||||
|
||||
// 2. 数据开始时间到数据结束时间(正常间隔)
|
||||
List<Date> dataSeries = generateTimeSeries(actualStartTime, actualEndTime, dataInterval);
|
||||
fullTimeSeries.addAll(dataSeries);
|
||||
|
||||
// 3. 数据结束时间到结束时间(稀疏间隔)
|
||||
if (actualEndTime.before(endDate)) {
|
||||
// 调整actualEndTime的下一个点开始,避免重复
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(actualEndTime);
|
||||
cal.setTimeInMillis(cal.getTimeInMillis() + dataInterval);
|
||||
Date nextAfterActualEnd = cal.getTime();
|
||||
|
||||
if (nextAfterActualEnd.before(endDate) || nextAfterActualEnd.equals(endDate)) {
|
||||
List<Date> afterSeries = generateTimeSeries(nextAfterActualEnd, endDate, sparseInterval);
|
||||
fullTimeSeries.addAll(afterSeries);
|
||||
}
|
||||
}
|
||||
|
||||
return fullTimeSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建多网卡空结果(带汇总流量)
|
||||
*/
|
||||
private static Map<String, Object> createEmptyMultiInterfaceResultWithTotal(
|
||||
Set<String> interfaceNames, String startTime, String endTime) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
try {
|
||||
// 解析时间范围
|
||||
Date startDate = parseStringToDate(startTime);
|
||||
Date endDate = parseStringToDate(endTime);
|
||||
|
||||
if (startDate != null && endDate != null && !startDate.after(endDate)) {
|
||||
// 动态计算时间间隔
|
||||
long timeRange = endDate.getTime() - startDate.getTime();
|
||||
long interval;
|
||||
|
||||
if (timeRange > 12L * 30 * 24 * 60 * 60 * 1000) { // 超过12个月
|
||||
interval = 30L * 24 * 60 * 60 * 1000; // 每月1个点
|
||||
} else {
|
||||
interval = 2L * 24 * 60 * 60 * 1000; // 2天1个点
|
||||
}
|
||||
|
||||
List<Date> fullTimeSeries = generateTimeSeries(startDate, endDate, interval);
|
||||
|
||||
// 构建x轴数据
|
||||
List<String> xAxisData = new ArrayList<>();
|
||||
for (Date date : fullTimeSeries) {
|
||||
xAxisData.add(parseDateToStr(date));
|
||||
}
|
||||
result.put("xData", xAxisData);
|
||||
|
||||
// 构建y轴数据(空数据集)
|
||||
Map<String, Object> yData = new LinkedHashMap<>();
|
||||
int dataSize = xAxisData.size();
|
||||
|
||||
// 为每个网卡创建空数据系列
|
||||
for (String interfaceName : interfaceNames) {
|
||||
List<Object> inSpeedSeries = new ArrayList<>();
|
||||
List<Object> outSpeedSeries = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < dataSize; i++) {
|
||||
if (i == 0) {
|
||||
// 第一个点补0
|
||||
inSpeedSeries.add(0);
|
||||
outSpeedSeries.add(0);
|
||||
} else {
|
||||
// 其他点补null
|
||||
inSpeedSeries.add(null);
|
||||
outSpeedSeries.add(null);
|
||||
}
|
||||
}
|
||||
|
||||
yData.put(interfaceName + "netInTraffic", inSpeedSeries);
|
||||
yData.put(interfaceName + "netOutTraffic", outSpeedSeries);
|
||||
}
|
||||
|
||||
// 创建汇总流量的空数据系列
|
||||
List<Object> totalInSpeedSeries = new ArrayList<>();
|
||||
List<Object> totalOutSpeedSeries = new ArrayList<>();
|
||||
for (int i = 0; i < dataSize; i++) {
|
||||
if (i == 0) {
|
||||
totalInSpeedSeries.add(0);
|
||||
totalOutSpeedSeries.add(0);
|
||||
} else {
|
||||
totalInSpeedSeries.add(null);
|
||||
totalOutSpeedSeries.add(null);
|
||||
}
|
||||
}
|
||||
yData.put("totalNetInTraffic", totalInSpeedSeries);
|
||||
yData.put("totalNetOutTraffic", totalOutSpeedSeries);
|
||||
|
||||
result.put("yData", yData);
|
||||
|
||||
} else {
|
||||
// 时间解析失败时返回空数据
|
||||
result.put("xData", new ArrayList<>());
|
||||
Map<String, Object> yData = new LinkedHashMap<>();
|
||||
for (String interfaceName : interfaceNames) {
|
||||
yData.put(interfaceName + "netInTraffic", new ArrayList<>());
|
||||
yData.put(interfaceName + "netOutTraffic", new ArrayList<>());
|
||||
}
|
||||
yData.put("totalNetInTraffic", new ArrayList<>());
|
||||
yData.put("totalNetOutTraffic", new ArrayList<>());
|
||||
result.put("yData", yData);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// 异常时返回空数据
|
||||
result.put("xData", new ArrayList<>());
|
||||
Map<String, Object> yData = new LinkedHashMap<>();
|
||||
for (String interfaceName : interfaceNames) {
|
||||
yData.put(interfaceName + "netInTraffic", new ArrayList<>());
|
||||
yData.put(interfaceName + "netOutTraffic", new ArrayList<>());
|
||||
}
|
||||
yData.put("totalNetInTraffic", new ArrayList<>());
|
||||
yData.put("totalNetOutTraffic", new ArrayList<>());
|
||||
result.put("yData", yData);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 字符串转日期
|
||||
*/
|
||||
private static Date parseStringToDate(String dateStr) {
|
||||
if (dateStr == null || dateStr.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
sdf.setLenient(false); // 严格模式
|
||||
return sdf.parse(dateStr);
|
||||
} catch (ParseException e) {
|
||||
System.err.println("日期解析失败: " + dateStr);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期转字符串
|
||||
*/
|
||||
private static String parseDateToStr(Date date) {
|
||||
if (date == null) {
|
||||
return "";
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return sdf.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成完整的时间序列
|
||||
*/
|
||||
private static List<Date> generateTimeSeries(Date start, Date end, long interval) {
|
||||
List<Date> timeSeries = new ArrayList<>();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(start);
|
||||
|
||||
// 确保开始时间对齐到时间间隔
|
||||
long startMillis = normalizeTime(start, interval);
|
||||
calendar.setTimeInMillis(startMillis);
|
||||
|
||||
while (!calendar.getTime().after(end)) {
|
||||
timeSeries.add(calendar.getTime());
|
||||
calendar.setTimeInMillis(calendar.getTimeInMillis() + interval);
|
||||
}
|
||||
return timeSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动检测时间间隔
|
||||
*/
|
||||
private static <T> long detectTimeInterval(List<T> list, Function<T, Date> timeExtractor) {
|
||||
if (list.size() < 2) {
|
||||
return 300000; // 默认5分钟
|
||||
}
|
||||
|
||||
// 计算时间间隔的众数
|
||||
Map<Long, Integer> intervalCount = new HashMap<>();
|
||||
for (int i = 1; i < list.size(); i++) {
|
||||
long interval = timeExtractor.apply(list.get(i)).getTime() -
|
||||
timeExtractor.apply(list.get(i - 1)).getTime();
|
||||
if (interval > 0) {
|
||||
intervalCount.merge(interval, 1, Integer::sum);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有有效间隔,使用默认值
|
||||
if (intervalCount.isEmpty()) {
|
||||
return 300000L;
|
||||
}
|
||||
|
||||
return intervalCount.entrySet().stream()
|
||||
.max(Map.Entry.comparingByValue())
|
||||
.map(Map.Entry::getKey)
|
||||
.orElse(300000L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间标准化(对齐到时间间隔)
|
||||
*/
|
||||
private static long normalizeTime(Date time, long interval) {
|
||||
long timeMillis = time.getTime();
|
||||
return (timeMillis / interval) * interval;
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.tongran.common.core.utils;
|
||||
|
||||
public class NetworkNameUtil {
|
||||
|
||||
/**
|
||||
* 判断网卡是否为子网卡
|
||||
* @param interfaceName
|
||||
* @return
|
||||
*/
|
||||
public static boolean isSubInterface(String interfaceName) {
|
||||
// 非空检查
|
||||
if (interfaceName == null || interfaceName.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 匹配模式:冒号后跟数字 或 点后跟数字
|
||||
String pattern = ".*[:.]\\d+$";
|
||||
return interfaceName.matches(pattern);
|
||||
}
|
||||
}
|
||||
+8
@@ -122,6 +122,8 @@ public class RmResourceRegistration extends BaseEntity
|
||||
|
||||
@Excel(name = "IP1-网关")
|
||||
private String ip1Gateway; // IP1-网关
|
||||
/** ip1是否存在子网卡 */
|
||||
private boolean ip1IsVirth;
|
||||
|
||||
// IP2 相关字段
|
||||
@Excel(name = "IP2-运营商")
|
||||
@@ -153,6 +155,8 @@ public class RmResourceRegistration extends BaseEntity
|
||||
|
||||
@Excel(name = "IP2-网关")
|
||||
private String ip2Gateway;
|
||||
/** ip2是否存在子网卡 */
|
||||
private boolean ip2IsVirth;
|
||||
|
||||
// IP3 相关字段
|
||||
@Excel(name = "IP3-运营商")
|
||||
@@ -184,6 +188,8 @@ public class RmResourceRegistration extends BaseEntity
|
||||
|
||||
@Excel(name = "IP3-网关")
|
||||
private String ip3Gateway;
|
||||
/** ip3是否存在子网卡 */
|
||||
private boolean ip3IsVirth;
|
||||
|
||||
// 管理网相关字段
|
||||
@Excel(name = "管理网-运营商")
|
||||
@@ -215,6 +221,8 @@ public class RmResourceRegistration extends BaseEntity
|
||||
|
||||
@Excel(name = "管理网-网关")
|
||||
private String mgmtGateway; // 管理网-网关地址
|
||||
/** 管理网-是否存在子网卡 */
|
||||
private boolean mgmIsVirth;
|
||||
|
||||
/** 多条件查询 */
|
||||
private String queryParam;
|
||||
|
||||
+10
@@ -1,6 +1,7 @@
|
||||
package com.tongran.system.mapper;
|
||||
|
||||
import com.tongran.system.domain.RmResourceRegistration;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -112,4 +113,13 @@ public interface RmResourceRegistrationMapper
|
||||
int updateRemark(RmResourceRegistration rmResourceRegistration);
|
||||
|
||||
int addReportedBandwidth(RmResourceRegistration rmResourceRegistration);
|
||||
|
||||
/**
|
||||
* 判断该网卡是否存在子网卡
|
||||
* @param clientId
|
||||
* @param interfaceName
|
||||
* @return
|
||||
*/
|
||||
int countChildNetwork(@Param("clientId") String clientId,
|
||||
@Param("interfaceName") String interfaceName);
|
||||
}
|
||||
|
||||
+25
-5
@@ -3,6 +3,7 @@ package com.tongran.system.service.impl;
|
||||
import com.tongran.common.core.constant.SecurityConstants;
|
||||
import com.tongran.common.core.domain.R;
|
||||
import com.tongran.common.core.utils.DateUtils;
|
||||
import com.tongran.common.core.utils.NetworkNameUtil;
|
||||
import com.tongran.system.api.RemoteRocketMqService;
|
||||
import com.tongran.system.api.domain.RmNetworkInterfaceRemote;
|
||||
import com.tongran.system.domain.AllInterfaceName;
|
||||
@@ -13,6 +14,7 @@ import com.tongran.system.service.IRmEpsTopologyManagementService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -43,7 +45,6 @@ public class AllInterfaceNameServiceImpl implements IAllInterfaceNameService
|
||||
{
|
||||
return allInterfaceNameMapper.selectAllInterfaceNameById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有接口名称列表
|
||||
*
|
||||
@@ -54,16 +55,35 @@ public class AllInterfaceNameServiceImpl implements IAllInterfaceNameService
|
||||
public List<AllInterfaceName> selectAllInterfaceNameList(AllInterfaceName allInterfaceName)
|
||||
{
|
||||
List<AllInterfaceName> allInterfaceNameList = allInterfaceNameMapper.selectAllInterfaceNameList(allInterfaceName);
|
||||
|
||||
if (allInterfaceNameList == null || allInterfaceNameList.isEmpty()) {
|
||||
return allInterfaceNameList;
|
||||
}
|
||||
// 用于存储非子网卡的接口
|
||||
List<AllInterfaceName> nonSubInterfaces = new ArrayList<>();
|
||||
for (AllInterfaceName interfaceName : allInterfaceNameList) {
|
||||
String originalName = interfaceName.getInterfaceName();
|
||||
String name = originalName;
|
||||
|
||||
if (originalName != null && originalName.contains("(")) {
|
||||
int index = originalName.indexOf("(");
|
||||
name = originalName.substring(0, index);
|
||||
}
|
||||
|
||||
// 如果不是子网卡,则加入列表
|
||||
if (originalName == null || !NetworkNameUtil.isSubInterface(name)) {
|
||||
nonSubInterfaces.add(interfaceName);
|
||||
}
|
||||
}
|
||||
if (nonSubInterfaces.isEmpty()) {
|
||||
return nonSubInterfaces;
|
||||
}
|
||||
// 使用自定义排序
|
||||
return allInterfaceNameList.stream()
|
||||
return nonSubInterfaces.stream()
|
||||
.sorted((a, b) -> {
|
||||
boolean aMatched = isInterfaceMatched(a);
|
||||
boolean bMatched = isInterfaceMatched(b);
|
||||
// 根据实际业务逻辑判断是否匹配
|
||||
// 这里用接口名不为null且包含特定字符作为示例
|
||||
boolean aMatched = a.getInterfaceName() != null && a.getInterfaceName().contains("eth");
|
||||
boolean bMatched = b.getInterfaceName() != null && b.getInterfaceName().contains("eth");
|
||||
|
||||
// 匹配的排在前面(返回-1),不匹配的排在后面(返回1)
|
||||
if (aMatched && !bMatched) {
|
||||
|
||||
+33
-1
@@ -469,6 +469,12 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
|
||||
for (RmNetworkInterfaceRemote network : networkList) {
|
||||
if ("1".equals(network.getBindIp()) || "3".equals(network.getBindIp())) {
|
||||
// 查询是否存在子网卡
|
||||
int count = rmResourceRegistrationMapper.countChildNetwork(clientId, network.getInterfaceName());
|
||||
boolean isVirth = false;
|
||||
if(count > 0){
|
||||
isVirth = true;
|
||||
}
|
||||
// 业务IP处理
|
||||
if (businessIpCount > 3) {
|
||||
continue; // 最多只处理3个业务IP
|
||||
@@ -487,6 +493,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
registration.setIp1Ipv4Address(network.getIpv4Address());
|
||||
registration.setIp1Ipv6Address(network.getIpv6Address());
|
||||
registration.setIp1Gateway(network.getGateway());
|
||||
registration.setIp1IsVirth(isVirth);
|
||||
break;
|
||||
case 2:
|
||||
registration.setIp2Isp(network.getIsp());
|
||||
@@ -499,6 +506,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
registration.setIp2Ipv4Address(network.getIpv4Address());
|
||||
registration.setIp2Ipv6Address(network.getIpv6Address());
|
||||
registration.setIp2Gateway(network.getGateway());
|
||||
registration.setIp2IsVirth(isVirth);
|
||||
break;
|
||||
case 3:
|
||||
registration.setIp3Isp(network.getIsp());
|
||||
@@ -511,12 +519,19 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
registration.setIp3Ipv4Address(network.getIpv4Address());
|
||||
registration.setIp3Ipv6Address(network.getIpv6Address());
|
||||
registration.setIp3Gateway(network.getGateway());
|
||||
registration.setIp3IsVirth(isVirth);
|
||||
break;
|
||||
}
|
||||
|
||||
businessIpCount++;
|
||||
}
|
||||
if ("2".equals(network.getBindIp()) || "3".equals(network.getBindIp())) {
|
||||
// 查询是否存在子网卡
|
||||
int count = rmResourceRegistrationMapper.countChildNetwork(clientId, network.getInterfaceName());
|
||||
boolean isVirth = false;
|
||||
if(count > 0){
|
||||
isVirth = true;
|
||||
}
|
||||
// 管理网IP处理
|
||||
registration.setMgmtIsp(network.getIsp());
|
||||
registration.setMgmtProvince(network.getProvince());
|
||||
@@ -528,6 +543,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
registration.setMgmtIpv4Address(network.getIpv4Address());
|
||||
registration.setMgmtIpv6Address(network.getIpv6Address());
|
||||
registration.setMgmtGateway(network.getGateway());
|
||||
registration.setMgmIsVirth(isVirth);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1012,7 +1028,16 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
// 如果有符合条件的网络接口
|
||||
if (!filteredNetworks.isEmpty()) {
|
||||
updateData.setRegistrationStatus("1");
|
||||
|
||||
List<RmNetworkInterfaceRemote> childList = new ArrayList<>();
|
||||
filteredNetworks.forEach(netMsg -> {
|
||||
RmNetworkInterfaceRemote query = new RmNetworkInterfaceRemote();
|
||||
query.setClientId(clientId);
|
||||
query.setParentInterface(netMsg.getInterfaceName());
|
||||
R<List<RmNetworkInterfaceRemote>> children = remoteRocketMqService.innerGetChildList(query, SecurityConstants.INNER);
|
||||
if(children != null && children.getData()!=null && !children.getData().isEmpty()){
|
||||
childList.addAll(children.getData());
|
||||
}
|
||||
});
|
||||
// 拼接所有符合条件的网络接口名称,用分号隔开
|
||||
StringBuilder netNameBuilder = new StringBuilder();
|
||||
for (int i = 0; i < filteredNetworks.size(); i++) {
|
||||
@@ -1021,6 +1046,13 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
}
|
||||
netNameBuilder.append(filteredNetworks.get(i).getInterfaceName());
|
||||
}
|
||||
// 添加子接口名称
|
||||
for (int i = 0; i < childList.size(); i++) {
|
||||
if (netNameBuilder.length() > 0 || i > 0) {
|
||||
netNameBuilder.append(";");
|
||||
}
|
||||
netNameBuilder.append(childList.get(i).getInterfaceName());
|
||||
}
|
||||
String netName = netNameBuilder.toString();
|
||||
|
||||
// 发送注册响应
|
||||
|
||||
+4
@@ -275,4 +275,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update rm_resource_registration set reported_bandwidth = #{reportedBandwidth}
|
||||
where id =#{id}
|
||||
</update>
|
||||
<select id="countChildNetwork" resultType="java.lang.Integer">
|
||||
select count(1) from rm_network_interface_child
|
||||
where client_id = #{clientId} and parent_interface = #{interfaceName}
|
||||
</select>
|
||||
</mapper>
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.tongran.rocketmq.controller;
|
||||
|
||||
import com.tongran.common.core.domain.R;
|
||||
import com.tongran.common.core.web.controller.BaseController;
|
||||
import com.tongran.common.core.web.domain.AjaxResult;
|
||||
import com.tongran.common.security.annotation.InnerAuth;
|
||||
import com.tongran.common.security.annotation.RequiresPermissions;
|
||||
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
|
||||
import com.tongran.rocketmq.service.IRmNetworkInterfaceChildService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客户端网络接口子接口信息Controller
|
||||
*
|
||||
* @author gyt
|
||||
* @date 2025-12-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/networkInterfaceChild")
|
||||
@RequiresPermissions("system:registration")
|
||||
public class RmNetworkInterfaceChildController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IRmNetworkInterfaceChildService rmNetworkInterfaceChildService;
|
||||
|
||||
/**
|
||||
* 查询客户端网络接口子接口信息列表
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public AjaxResult list(@RequestBody RmNetworkInterfaceChild rmNetworkInterfaceChild)
|
||||
{
|
||||
List<RmNetworkInterfaceChild> list = rmNetworkInterfaceChildService.selectRmNetworkInterfaceChildList(rmNetworkInterfaceChild);
|
||||
return success(list);
|
||||
}
|
||||
/**
|
||||
* 查询客户端网络接口子接口信息列表
|
||||
*/
|
||||
@PostMapping("/innerGetChildList")
|
||||
@InnerAuth
|
||||
public R innerGetChildList(@RequestBody RmNetworkInterfaceChild rmNetworkInterfaceChild)
|
||||
{
|
||||
List<RmNetworkInterfaceChild> list = rmNetworkInterfaceChildService.selectRmNetworkInterfaceChildList(rmNetworkInterfaceChild);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package com.tongran.rocketmq.domain;
|
||||
|
||||
import com.tongran.common.core.annotation.Excel;
|
||||
import com.tongran.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 客户端网络接口子接口信息对象 rm_network_interface_child
|
||||
*
|
||||
* @author gyt
|
||||
* @date 2025-12-15
|
||||
*/
|
||||
@Data
|
||||
public class RmNetworkInterfaceChild extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
private Long id;
|
||||
|
||||
/** 客户端ID */
|
||||
@Excel(name = "客户端ID")
|
||||
private String clientId;
|
||||
/** 父接口名称 */
|
||||
private String parentInterface;
|
||||
|
||||
/** 运营商 */
|
||||
@Excel(name = "运营商")
|
||||
private String isp;
|
||||
|
||||
/** 省 */
|
||||
@Excel(name = "省")
|
||||
private String province;
|
||||
|
||||
/** 市 */
|
||||
@Excel(name = "市")
|
||||
private String city;
|
||||
|
||||
/** 公网IP */
|
||||
@Excel(name = "公网IP")
|
||||
private String publicIp;
|
||||
|
||||
/** 接口名称 */
|
||||
@Excel(name = "接口名称")
|
||||
private String interfaceName;
|
||||
|
||||
/** MAC地址 */
|
||||
@Excel(name = "MAC地址")
|
||||
private String macAddress;
|
||||
|
||||
/** 接口类型 */
|
||||
@Excel(name = "接口类型")
|
||||
private String interfaceType;
|
||||
|
||||
/** IPv4地址 */
|
||||
@Excel(name = "IPv4地址")
|
||||
private String ipv4Address;
|
||||
|
||||
/** IPv6地址 */
|
||||
@Excel(name = "IPv6地址")
|
||||
private String ipv6Address;
|
||||
|
||||
/** 网关 */
|
||||
@Excel(name = "网关")
|
||||
private String gateway;
|
||||
|
||||
/** 绑定公网ip类型(0未绑定,1业务ip,2管理ip,3管理和业务ip) */
|
||||
@Excel(name = "绑定公网ip类型(0未绑定,1业务ip,2管理ip,3管理和业务ip)")
|
||||
private String bindIp;
|
||||
|
||||
/** 是否为新的(0否 1是) */
|
||||
@Excel(name = "是否为新的(0否 1是)")
|
||||
private Integer newFlag;
|
||||
}
|
||||
@@ -89,6 +89,8 @@ public class MessageHandler {
|
||||
@Autowired
|
||||
private IRmNetworkInterfaceService rmNetworkInterfaceService;
|
||||
@Autowired
|
||||
private IRmNetworkInterfaceChildService rmNetworkInterfaceChildService;
|
||||
@Autowired
|
||||
private IRmMonitorPolicyService rmMonitorPolicyService;
|
||||
@Autowired
|
||||
private IRmDeploymentPolicyService rmDeploymentPolicyService;
|
||||
@@ -260,10 +262,10 @@ public class MessageHandler {
|
||||
temp.setClientId(clientId);
|
||||
List<InitialBandwidthTrafficTemp> tempList = initialBandwidthTrafficTempService.selectInitialBandwidthTrafficTempList(temp);
|
||||
if(!tempList.isEmpty()){
|
||||
// 1. 构建快速查找的Map
|
||||
// 1. 构建快速查找的Map,使用MAC地址+网卡名称作为唯一键
|
||||
Map<String, InitialBandwidthTrafficTemp> tempMap = tempList.stream()
|
||||
.collect(Collectors.toMap(
|
||||
InitialBandwidthTrafficTemp::getMac,
|
||||
tempItem -> generateKey(tempItem.getMac(), tempItem.getName()),
|
||||
Function.identity(),
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
@@ -290,7 +292,9 @@ public class MessageHandler {
|
||||
iface.setIpv6InSpeed(null);
|
||||
iface.setIpv6OutSpeed(null);
|
||||
|
||||
InitialBandwidthTrafficTemp tempInfo = tempMap.get(iface.getMac());
|
||||
// 使用MAC地址+网卡名称作为查找键
|
||||
String key = generateKey(iface.getMac(), iface.getName());
|
||||
InitialBandwidthTrafficTemp tempInfo = tempMap.get(key);
|
||||
if (tempInfo != null) {
|
||||
// 计算总流入速率
|
||||
if (iface.getTotalInSpeed() != null && tempInfo.getTotalInSpeed() != null) {
|
||||
@@ -387,6 +391,15 @@ public class MessageHandler {
|
||||
throw new RuntimeException("NET流量data数据为空");
|
||||
}
|
||||
}
|
||||
private String generateKey(String mac, String name) {
|
||||
if (mac == null) {
|
||||
mac = "";
|
||||
}
|
||||
if (name == null) {
|
||||
name = "";
|
||||
}
|
||||
return mac + "|" + name;
|
||||
}
|
||||
/**
|
||||
* docker数据入库
|
||||
* @param message
|
||||
@@ -1031,6 +1044,7 @@ public class MessageHandler {
|
||||
boolean isSingleInterface = networkInfoList.size() == 1;
|
||||
|
||||
for (NetworkInfo networkInfo : networkInfoList) {
|
||||
List<NetworkInfo> childList = networkInfo.getSubInterfaces();
|
||||
// 查询该网卡信息是否存在
|
||||
RmNetworkInterface queryParam = new RmNetworkInterface();
|
||||
queryParam.setClientId(clientId);
|
||||
@@ -1048,14 +1062,31 @@ public class MessageHandler {
|
||||
insertData.setBindIp("3");
|
||||
}
|
||||
rmNetworkInterfaceService.insertRmNetworkInterface(insertData);
|
||||
if(childList != null && !childList.isEmpty()){
|
||||
for (NetworkInfo info : childList) {
|
||||
RmNetworkInterfaceChild insertChild = new RmNetworkInterfaceChild();
|
||||
setNetworkInterfaceChildData(insertChild, info, clientId, networkInfo.getName());
|
||||
// 设置bindIp
|
||||
if (isSingleInterface) {
|
||||
insertChild.setBindIp("3");
|
||||
}
|
||||
rmNetworkInterfaceChildService.insertRmNetworkInterfaceChild(insertChild);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 更新网卡信息
|
||||
RmNetworkInterface oldInterfaceMsg = exits.get(0);
|
||||
|
||||
cleanChildOldRecords(clientId, networkInfo.getMac());
|
||||
// 判断是否需要创建新记录
|
||||
boolean needCreateNew = !StringUtils.equals(networkInfo.getName(), oldInterfaceMsg.getInterfaceName())
|
||||
|| !StringUtils.equals(networkInfo.getGateway(), oldInterfaceMsg.getGateway());
|
||||
|
||||
if(childList != null && !childList.isEmpty()){
|
||||
for (NetworkInfo info : childList) {
|
||||
RmNetworkInterfaceChild insertChild = new RmNetworkInterfaceChild();
|
||||
setNetworkInterfaceChildData(insertChild, info, clientId, networkInfo.getName());
|
||||
rmNetworkInterfaceChildService.insertRmNetworkInterfaceChild(insertChild);
|
||||
}
|
||||
}
|
||||
if(needCreateNew) {
|
||||
// 清理旧的历史数据
|
||||
cleanOldRecords(clientId, networkInfo.getMac());
|
||||
@@ -1095,6 +1126,20 @@ public class MessageHandler {
|
||||
networkInterface.setPublicIp(networkInfo.getPublicIp());
|
||||
networkInterface.setInterfaceType(networkInfo.getType());
|
||||
}
|
||||
private void setNetworkInterfaceChildData(RmNetworkInterfaceChild networkInterface, NetworkInfo networkInfo, String clientId, String parentName) {
|
||||
networkInterface.setClientId(clientId);
|
||||
networkInterface.setParentInterface(parentName);
|
||||
networkInterface.setIsp(networkInfo.getCarrier());
|
||||
networkInterface.setCity(networkInfo.getCity());
|
||||
networkInterface.setGateway(networkInfo.getGateway());
|
||||
networkInterface.setInterfaceName(networkInfo.getName());
|
||||
networkInterface.setIpv4Address(networkInfo.getIpv4());
|
||||
networkInterface.setIpv6Address(networkInfo.getIpv6());
|
||||
networkInterface.setMacAddress(networkInfo.getMac());
|
||||
networkInterface.setProvince(networkInfo.getProvince());
|
||||
networkInterface.setPublicIp(networkInfo.getPublicIp());
|
||||
networkInterface.setInterfaceType(networkInfo.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理旧记录
|
||||
@@ -1111,7 +1156,20 @@ public class MessageHandler {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理旧记录
|
||||
*/
|
||||
private void cleanChildOldRecords(String clientId, String macAddress) {
|
||||
RmNetworkInterfaceChild childQuery = new RmNetworkInterfaceChild();
|
||||
childQuery.setClientId(clientId);
|
||||
childQuery.setMacAddress(macAddress);
|
||||
List<RmNetworkInterfaceChild> oldChildExits = rmNetworkInterfaceChildService.selectRmNetworkInterfaceChildList(childQuery);
|
||||
if(!oldChildExits.isEmpty()) {
|
||||
oldChildExits.forEach(oldMsg -> {
|
||||
rmNetworkInterfaceChildService.deleteRmNetworkInterfaceChildById(oldMsg.getId());
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 更新网卡信息
|
||||
*/
|
||||
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.tongran.rocketmq.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
|
||||
|
||||
/**
|
||||
* 客户端网络接口子接口信息Mapper接口
|
||||
*
|
||||
* @author gyt
|
||||
* @date 2025-12-15
|
||||
*/
|
||||
public interface RmNetworkInterfaceChildMapper
|
||||
{
|
||||
/**
|
||||
* 查询客户端网络接口子接口信息
|
||||
*
|
||||
* @param id 客户端网络接口子接口信息主键
|
||||
* @return 客户端网络接口子接口信息
|
||||
*/
|
||||
public RmNetworkInterfaceChild selectRmNetworkInterfaceChildById(Long id);
|
||||
|
||||
/**
|
||||
* 查询客户端网络接口子接口信息列表
|
||||
*
|
||||
* @param rmNetworkInterfaceChild 客户端网络接口子接口信息
|
||||
* @return 客户端网络接口子接口信息集合
|
||||
*/
|
||||
public List<RmNetworkInterfaceChild> selectRmNetworkInterfaceChildList(RmNetworkInterfaceChild rmNetworkInterfaceChild);
|
||||
|
||||
/**
|
||||
* 新增客户端网络接口子接口信息
|
||||
*
|
||||
* @param rmNetworkInterfaceChild 客户端网络接口子接口信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertRmNetworkInterfaceChild(RmNetworkInterfaceChild rmNetworkInterfaceChild);
|
||||
|
||||
/**
|
||||
* 修改客户端网络接口子接口信息
|
||||
*
|
||||
* @param rmNetworkInterfaceChild 客户端网络接口子接口信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateRmNetworkInterfaceChild(RmNetworkInterfaceChild rmNetworkInterfaceChild);
|
||||
|
||||
/**
|
||||
* 删除客户端网络接口子接口信息
|
||||
*
|
||||
* @param id 客户端网络接口子接口信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmNetworkInterfaceChildById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除客户端网络接口子接口信息
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmNetworkInterfaceChildByIds(Long[] ids);
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.tongran.rocketmq.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
|
||||
|
||||
/**
|
||||
* 客户端网络接口子接口信息Service接口
|
||||
*
|
||||
* @author gyt
|
||||
* @date 2025-12-15
|
||||
*/
|
||||
public interface IRmNetworkInterfaceChildService
|
||||
{
|
||||
/**
|
||||
* 查询客户端网络接口子接口信息
|
||||
*
|
||||
* @param id 客户端网络接口子接口信息主键
|
||||
* @return 客户端网络接口子接口信息
|
||||
*/
|
||||
public RmNetworkInterfaceChild selectRmNetworkInterfaceChildById(Long id);
|
||||
|
||||
/**
|
||||
* 查询客户端网络接口子接口信息列表
|
||||
*
|
||||
* @param rmNetworkInterfaceChild 客户端网络接口子接口信息
|
||||
* @return 客户端网络接口子接口信息集合
|
||||
*/
|
||||
public List<RmNetworkInterfaceChild> selectRmNetworkInterfaceChildList(RmNetworkInterfaceChild rmNetworkInterfaceChild);
|
||||
|
||||
/**
|
||||
* 新增客户端网络接口子接口信息
|
||||
*
|
||||
* @param rmNetworkInterfaceChild 客户端网络接口子接口信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertRmNetworkInterfaceChild(RmNetworkInterfaceChild rmNetworkInterfaceChild);
|
||||
|
||||
/**
|
||||
* 修改客户端网络接口子接口信息
|
||||
*
|
||||
* @param rmNetworkInterfaceChild 客户端网络接口子接口信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateRmNetworkInterfaceChild(RmNetworkInterfaceChild rmNetworkInterfaceChild);
|
||||
|
||||
/**
|
||||
* 批量删除客户端网络接口子接口信息
|
||||
*
|
||||
* @param ids 需要删除的客户端网络接口子接口信息主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmNetworkInterfaceChildByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除客户端网络接口子接口信息信息
|
||||
*
|
||||
* @param id 客户端网络接口子接口信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmNetworkInterfaceChildById(Long id);
|
||||
}
|
||||
+69
-16
@@ -2,9 +2,12 @@ package com.tongran.rocketmq.service.impl;
|
||||
|
||||
import com.tongran.common.core.utils.DateUtils;
|
||||
import com.tongran.common.core.utils.EchartsDataUtils;
|
||||
import com.tongran.common.core.utils.EchartsMoreDataUtils;
|
||||
import com.tongran.common.core.utils.SpeedUtils;
|
||||
import com.tongran.rocketmq.domain.InitialBandwidthTraffic;
|
||||
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
|
||||
import com.tongran.rocketmq.mapper.InitialBandwidthTrafficMapper;
|
||||
import com.tongran.rocketmq.mapper.RmNetworkInterfaceChildMapper;
|
||||
import com.tongran.rocketmq.service.IInitialBandwidthTrafficService;
|
||||
import com.tongran.rocketmq.utils.TableRouterUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -34,6 +37,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
{
|
||||
@Autowired
|
||||
private InitialBandwidthTrafficMapper initialBandwidthTrafficMapper;
|
||||
@Autowired
|
||||
private RmNetworkInterfaceChildMapper rmNetworkInterfaceChildMapper;
|
||||
|
||||
/**
|
||||
* 查询初始带宽流量
|
||||
@@ -217,6 +222,11 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
.collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
private boolean isEthernetInterface(String name) {
|
||||
return name.startsWith("eth") || // Linux 传统
|
||||
name.startsWith("en") || // systemd 命名 (enp3s0)
|
||||
name.startsWith("em"); // 有些主板网卡
|
||||
}
|
||||
/**
|
||||
* 查询eth0流量信息并封装为多折线ECharts图表数据
|
||||
* @param initialBandwidthTraffic
|
||||
@@ -224,34 +234,77 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> netInterfaceTrafficEcharts(InitialBandwidthTraffic initialBandwidthTraffic) {
|
||||
// 流量信息
|
||||
List<InitialBandwidthTraffic> list = getListByTableName(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+"netInTraffic", name+"入站流量");
|
||||
showRealation.put(name+"netOutTraffic", name+"出站流量");
|
||||
|
||||
// 如果是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()){
|
||||
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()+"netInTraffic", child.getInterfaceName()+"入站流量");
|
||||
showRealation.put(child.getInterfaceName()+"netOutTraffic", child.getInterfaceName()+"出站流量");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
String unit = SpeedUtils.calculateUnitWithStringTraffic(list, "inSpeed", "outSpeed");
|
||||
// 计算单位
|
||||
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.getInSpeed() != null ? new BigDecimal(info.getInSpeed()) : null,
|
||||
info -> info.getOutSpeed() != null ? new BigDecimal(info.getOutSpeed()) : null,
|
||||
initialBandwidthTraffic.getStartTime(),
|
||||
initialBandwidthTraffic.getEndTime(),
|
||||
divisor
|
||||
);
|
||||
|
||||
resultMap.put("unit", unit);
|
||||
if(!showRealation.isEmpty()){
|
||||
showRealation.put("totalNetInTraffic", name+"总入站流量");
|
||||
showRealation.put("totalNetOutTraffic", name+"总出站流量");
|
||||
}
|
||||
resultMap.put("showRealation", showRealation);
|
||||
return resultMap;
|
||||
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return new HashMap<>();
|
||||
}
|
||||
return new HashMap<>();
|
||||
}
|
||||
// 安全转换方法(处理可能的NumberFormatException)
|
||||
private Double safeConvertToKB(String byteValue) {
|
||||
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package com.tongran.rocketmq.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.tongran.common.core.utils.DateUtils;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 客户端网络接口子接口信息Service业务层处理
|
||||
*
|
||||
* @author gyt
|
||||
* @date 2025-12-15
|
||||
*/
|
||||
@Service
|
||||
public class RmNetworkInterfaceChildServiceImpl implements IRmNetworkInterfaceChildService
|
||||
{
|
||||
@Autowired
|
||||
private RmNetworkInterfaceChildMapper rmNetworkInterfaceChildMapper;
|
||||
|
||||
/**
|
||||
* 查询客户端网络接口子接口信息
|
||||
*
|
||||
* @param id 客户端网络接口子接口信息主键
|
||||
* @return 客户端网络接口子接口信息
|
||||
*/
|
||||
@Override
|
||||
public RmNetworkInterfaceChild selectRmNetworkInterfaceChildById(Long id)
|
||||
{
|
||||
return rmNetworkInterfaceChildMapper.selectRmNetworkInterfaceChildById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询客户端网络接口子接口信息列表
|
||||
*
|
||||
* @param rmNetworkInterfaceChild 客户端网络接口子接口信息
|
||||
* @return 客户端网络接口子接口信息
|
||||
*/
|
||||
@Override
|
||||
public List<RmNetworkInterfaceChild> selectRmNetworkInterfaceChildList(RmNetworkInterfaceChild rmNetworkInterfaceChild)
|
||||
{
|
||||
return rmNetworkInterfaceChildMapper.selectRmNetworkInterfaceChildList(rmNetworkInterfaceChild);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增客户端网络接口子接口信息
|
||||
*
|
||||
* @param rmNetworkInterfaceChild 客户端网络接口子接口信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertRmNetworkInterfaceChild(RmNetworkInterfaceChild rmNetworkInterfaceChild)
|
||||
{
|
||||
rmNetworkInterfaceChild.setCreateTime(DateUtils.getNowDate());
|
||||
return rmNetworkInterfaceChildMapper.insertRmNetworkInterfaceChild(rmNetworkInterfaceChild);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改客户端网络接口子接口信息
|
||||
*
|
||||
* @param rmNetworkInterfaceChild 客户端网络接口子接口信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateRmNetworkInterfaceChild(RmNetworkInterfaceChild rmNetworkInterfaceChild)
|
||||
{
|
||||
rmNetworkInterfaceChild.setUpdateTime(DateUtils.getNowDate());
|
||||
return rmNetworkInterfaceChildMapper.updateRmNetworkInterfaceChild(rmNetworkInterfaceChild);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除客户端网络接口子接口信息
|
||||
*
|
||||
* @param ids 需要删除的客户端网络接口子接口信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteRmNetworkInterfaceChildByIds(Long[] ids)
|
||||
{
|
||||
return rmNetworkInterfaceChildMapper.deleteRmNetworkInterfaceChildByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除客户端网络接口子接口信息信息
|
||||
*
|
||||
* @param id 客户端网络接口子接口信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteRmNetworkInterfaceChildById(Long id)
|
||||
{
|
||||
return rmNetworkInterfaceChildMapper.deleteRmNetworkInterfaceChildById(id);
|
||||
}
|
||||
}
|
||||
+31
@@ -5,7 +5,9 @@ import com.tongran.common.core.enums.MsgEnum;
|
||||
import com.tongran.common.core.utils.DateUtils;
|
||||
import com.tongran.rocketmq.domain.DeviceMessage;
|
||||
import com.tongran.rocketmq.domain.RmNetworkInterface;
|
||||
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
|
||||
import com.tongran.rocketmq.domain.vo.PolicyTypeVo;
|
||||
import com.tongran.rocketmq.mapper.RmNetworkInterfaceChildMapper;
|
||||
import com.tongran.rocketmq.mapper.RmNetworkInterfaceMapper;
|
||||
import com.tongran.rocketmq.model.ProducerMode;
|
||||
import com.tongran.rocketmq.producer.MessageProducer;
|
||||
@@ -15,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -32,6 +35,8 @@ public class RmNetworkInterfaceServiceImpl implements IRmNetworkInterfaceService
|
||||
@Autowired
|
||||
private RmNetworkInterfaceMapper rmNetworkInterfaceMapper;
|
||||
@Autowired
|
||||
private RmNetworkInterfaceChildMapper rmNetworkInterfaceChildMapper;
|
||||
@Autowired
|
||||
private ProducerMode producerMode;
|
||||
|
||||
/**
|
||||
@@ -185,15 +190,41 @@ public class RmNetworkInterfaceServiceImpl implements IRmNetworkInterfaceService
|
||||
RmNetworkInterface rmNetworkInterface = new RmNetworkInterface();
|
||||
rmNetworkInterface.setClientIds(clientId);
|
||||
List<RmNetworkInterface> networkInterfaces = rmNetworkInterfaceMapper.selectRmNetworkInterfaceList(rmNetworkInterface);
|
||||
List<RmNetworkInterfaceChild> childList = new ArrayList<>();
|
||||
networkInterfaces.forEach(netMsg -> {
|
||||
RmNetworkInterfaceChild query = new RmNetworkInterfaceChild();
|
||||
query.setClientId(clientId);
|
||||
query.setParentInterface(netMsg.getInterfaceName());
|
||||
List<RmNetworkInterfaceChild> children = rmNetworkInterfaceChildMapper.selectRmNetworkInterfaceChildList(query);
|
||||
childList.addAll(children);
|
||||
});
|
||||
|
||||
// 拼接所有符合条件的网络接口名称,用分号隔开
|
||||
StringBuilder netNameBuilder = new StringBuilder();
|
||||
|
||||
// 添加父接口名称
|
||||
for (int i = 0; i < networkInterfaces.size(); i++) {
|
||||
if (i > 0) {
|
||||
netNameBuilder.append(";");
|
||||
}
|
||||
netNameBuilder.append(networkInterfaces.get(i).getInterfaceName());
|
||||
}
|
||||
|
||||
// 添加子接口名称
|
||||
for (int i = 0; i < childList.size(); i++) {
|
||||
if (netNameBuilder.length() > 0 || i > 0) {
|
||||
netNameBuilder.append(";");
|
||||
}
|
||||
netNameBuilder.append(childList.get(i).getInterfaceName());
|
||||
}
|
||||
|
||||
String netName = netNameBuilder.toString();
|
||||
|
||||
// 如果没有找到任何接口,可以设置为空或特定值
|
||||
if (netName.isEmpty()) {
|
||||
netName = ""; // 或者设置为 "none" 等其他标识
|
||||
}
|
||||
|
||||
MessageProducer messageProducer = new MessageProducer();
|
||||
PolicyTypeVo policyTypeVo = new PolicyTypeVo();
|
||||
policyTypeVo.setNetName(netName);
|
||||
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.tongran.rocketmq.mapper.RmNetworkInterfaceChildMapper">
|
||||
|
||||
<resultMap type="RmNetworkInterfaceChild" id="RmNetworkInterfaceChildResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="clientId" column="client_id" />
|
||||
<result property="parentInterface" column="parent_interface" />
|
||||
<result property="isp" column="isp" />
|
||||
<result property="province" column="province" />
|
||||
<result property="city" column="city" />
|
||||
<result property="publicIp" column="public_ip" />
|
||||
<result property="interfaceName" column="interface_name" />
|
||||
<result property="macAddress" column="mac_address" />
|
||||
<result property="interfaceType" column="interface_type" />
|
||||
<result property="ipv4Address" column="ipv4_address" />
|
||||
<result property="ipv6Address" column="ipv6_address" />
|
||||
<result property="gateway" column="gateway" />
|
||||
<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="bindIp" column="bind_ip" />
|
||||
<result property="newFlag" column="new_flag" />
|
||||
</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
|
||||
</sql>
|
||||
|
||||
<select id="selectRmNetworkInterfaceChildList" parameterType="RmNetworkInterfaceChild" resultMap="RmNetworkInterfaceChildResult">
|
||||
<include refid="selectRmNetworkInterfaceChildVo"/>
|
||||
<where>
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
<if test="parentInterface != null and parentInterface != ''"> and parent_interface = #{parentInterface}</if>
|
||||
<if test="isp != null and isp != ''"> and isp = #{isp}</if>
|
||||
<if test="province != null and province != ''"> and province = #{province}</if>
|
||||
<if test="city != null and city != ''"> and city = #{city}</if>
|
||||
<if test="publicIp != null and publicIp != ''"> and public_ip = #{publicIp}</if>
|
||||
<if test="interfaceName != null and interfaceName != ''"> and interface_name like concat('%', #{interfaceName}, '%')</if>
|
||||
<if test="macAddress != null and macAddress != ''"> and mac_address = #{macAddress}</if>
|
||||
<if test="interfaceType != null and interfaceType != ''"> and interface_type = #{interfaceType}</if>
|
||||
<if test="ipv4Address != null and ipv4Address != ''"> and ipv4_address = #{ipv4Address}</if>
|
||||
<if test="ipv6Address != null and ipv6Address != ''"> and ipv6_address = #{ipv6Address}</if>
|
||||
<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>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectRmNetworkInterfaceChildById" parameterType="Long" resultMap="RmNetworkInterfaceChildResult">
|
||||
<include refid="selectRmNetworkInterfaceChildVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertRmNetworkInterfaceChild" parameterType="RmNetworkInterfaceChild" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into rm_network_interface_child
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="clientId != null">client_id,</if>
|
||||
<if test="parentInterface != null">parent_interface,</if>
|
||||
<if test="isp != null">isp,</if>
|
||||
<if test="province != null">province,</if>
|
||||
<if test="city != null">city,</if>
|
||||
<if test="publicIp != null">public_ip,</if>
|
||||
<if test="interfaceName != null">interface_name,</if>
|
||||
<if test="macAddress != null">mac_address,</if>
|
||||
<if test="interfaceType != null">interface_type,</if>
|
||||
<if test="ipv4Address != null">ipv4_address,</if>
|
||||
<if test="ipv6Address != null">ipv6_address,</if>
|
||||
<if test="gateway != null">gateway,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="bindIp != null">bind_ip,</if>
|
||||
<if test="newFlag != null">new_flag,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="clientId != null">#{clientId},</if>
|
||||
<if test="parentInterface != null">#{parentInterface},</if>
|
||||
<if test="isp != null">#{isp},</if>
|
||||
<if test="province != null">#{province},</if>
|
||||
<if test="city != null">#{city},</if>
|
||||
<if test="publicIp != null">#{publicIp},</if>
|
||||
<if test="interfaceName != null">#{interfaceName},</if>
|
||||
<if test="macAddress != null">#{macAddress},</if>
|
||||
<if test="interfaceType != null">#{interfaceType},</if>
|
||||
<if test="ipv4Address != null">#{ipv4Address},</if>
|
||||
<if test="ipv6Address != null">#{ipv6Address},</if>
|
||||
<if test="gateway != null">#{gateway},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="bindIp != null">#{bindIp},</if>
|
||||
<if test="newFlag != null">#{newFlag},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateRmNetworkInterfaceChild" parameterType="RmNetworkInterfaceChild">
|
||||
update rm_network_interface_child
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="clientId != null">client_id = #{clientId},</if>
|
||||
<if test="parentInterface != null">parent_interface = #{parentInterface},</if>
|
||||
<if test="isp != null">isp = #{isp},</if>
|
||||
<if test="province != null">province = #{province},</if>
|
||||
<if test="city != null">city = #{city},</if>
|
||||
<if test="publicIp != null">public_ip = #{publicIp},</if>
|
||||
<if test="interfaceName != null">interface_name = #{interfaceName},</if>
|
||||
<if test="macAddress != null">mac_address = #{macAddress},</if>
|
||||
<if test="interfaceType != null">interface_type = #{interfaceType},</if>
|
||||
<if test="ipv4Address != null">ipv4_address = #{ipv4Address},</if>
|
||||
<if test="ipv6Address != null">ipv6_address = #{ipv6Address},</if>
|
||||
<if test="gateway != null">gateway = #{gateway},</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>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="bindIp != null">bind_ip = #{bindIp},</if>
|
||||
<if test="newFlag != null">new_flag = #{newFlag},</if>
|
||||
</trim>
|
||||
<where>
|
||||
<choose>
|
||||
<when test="id != null">
|
||||
and id = #{id}
|
||||
</when>
|
||||
<when test="clientId != null and macAddress != null">
|
||||
and mac_address = #{macAddress} and client_id = #{clientId}
|
||||
</when>
|
||||
<otherwise>
|
||||
and 1=0
|
||||
</otherwise>
|
||||
</choose>
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<delete id="deleteRmNetworkInterfaceChildById" parameterType="Long">
|
||||
delete from rm_network_interface_child where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteRmNetworkInterfaceChildByIds" parameterType="String">
|
||||
delete from rm_network_interface_child where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user