pppoe配置增加5个字段。
This commit is contained in:
+2
@@ -76,6 +76,8 @@ public class RmNetworkInterfaceChild extends BaseEntity
|
||||
/** 是否连通外网(0否,1是) */
|
||||
@Excel(name = "是否连通外网(0否,1是)")
|
||||
private String status;
|
||||
/** 网卡创建时间 */
|
||||
private Long netCreateTime;
|
||||
/** 虚拟网卡上报带宽值(Mbps) */
|
||||
private BigDecimal bandwidthResult;
|
||||
/** 有ipv4的标识 */
|
||||
|
||||
@@ -52,6 +52,20 @@ public class RmPppoeConfigSub extends BaseEntity
|
||||
private String clientId;
|
||||
/** 接口名称 */
|
||||
private String interfaceName;
|
||||
/** 网卡创建时间 */
|
||||
private Long netCreateTime;
|
||||
/** 网卡运行时间 */
|
||||
private String netRunTime;
|
||||
/** 接收带宽(bit) */
|
||||
private String inSpeed;
|
||||
|
||||
/** 发送带宽(bit) */
|
||||
private String outSpeed;
|
||||
/** 总接收带宽 */
|
||||
private String totalInSpeed;
|
||||
|
||||
/** 总发送带宽 */
|
||||
private String totalOutSpeed;
|
||||
|
||||
public RmPppoeConfigSubVo toVo() {
|
||||
RmPppoeConfigSubVo vo = new RmPppoeConfigSubVo();
|
||||
|
||||
@@ -1356,6 +1356,7 @@ public class MessageHandler {
|
||||
networkInterface.setPublicIp(networkInfo.getPublicIp());
|
||||
networkInterface.setInterfaceType(networkInfo.getType());
|
||||
networkInterface.setStatus(networkInfo.getStatus());
|
||||
networkInterface.setNetCreateTime(networkInfo.getNetCreateTime());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+71
-5
@@ -3,10 +3,7 @@ package com.tongran.rocketmq.service.impl;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.RmNetworkInterfaceChild;
|
||||
import com.tongran.rocketmq.domain.RmPppoeConfigMain;
|
||||
import com.tongran.rocketmq.domain.RmPppoeConfigSub;
|
||||
import com.tongran.rocketmq.domain.*;
|
||||
import com.tongran.rocketmq.domain.vo.PolicyTypeVo;
|
||||
import com.tongran.rocketmq.domain.vo.PppoeVo;
|
||||
import com.tongran.rocketmq.domain.vo.RmPppoeConfigSubVo;
|
||||
@@ -15,11 +12,13 @@ import com.tongran.rocketmq.mapper.RmPppoeConfigMainMapper;
|
||||
import com.tongran.rocketmq.mapper.RmPppoeConfigSubMapper;
|
||||
import com.tongran.rocketmq.model.ProducerMode;
|
||||
import com.tongran.rocketmq.producer.MessageProducer;
|
||||
import com.tongran.rocketmq.service.IInitialBandwidthTrafficService;
|
||||
import com.tongran.rocketmq.service.IRmPppoeConfigMainService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -41,10 +40,13 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
|
||||
private ProducerMode producerMode;
|
||||
@Autowired
|
||||
private RmNetworkInterfaceChildMapper rmNetworkInterfaceChildMapper;
|
||||
@Autowired
|
||||
private IInitialBandwidthTrafficService initialBandwidthTrafficService;
|
||||
|
||||
@Override
|
||||
public RmPppoeConfigMain selectRmPppoeConfigMainByClientId(RmPppoeConfigMain rmPppoeConfigMain)
|
||||
{
|
||||
long nowTime = Instant.now().getEpochSecond();
|
||||
RmPppoeConfigMain pppoeConfigMain = rmPppoeConfigMainMapper.selectRmPppoeConfigMainByClientId(rmPppoeConfigMain.getClientId());
|
||||
if(pppoeConfigMain == null){
|
||||
pppoeConfigMain = new RmPppoeConfigMain();
|
||||
@@ -53,7 +55,21 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
|
||||
RmPppoeConfigSub rmPppoeConfigSub = new RmPppoeConfigSub();
|
||||
rmPppoeConfigSub.setClientId(rmPppoeConfigMain.getClientId());
|
||||
List<RmPppoeConfigSub> subList = rmPppoeConfigSubMapper.selectRmPppoeConfigSubList(rmPppoeConfigSub);
|
||||
if("2".equals(pppoeConfigMain.getPppoeConfigMode())){
|
||||
if("1".equals(pppoeConfigMain.getPppoeConfigMode())){
|
||||
for (RmPppoeConfigSub pppoeConfigSub : subList) {
|
||||
// 查询流量信息
|
||||
InitialBandwidthTraffic initialBandwidthTraffic = new InitialBandwidthTraffic();
|
||||
initialBandwidthTraffic.setClientId(pppoeConfigSub.getClientId());
|
||||
initialBandwidthTraffic.setName(pppoeConfigSub.getInterfaceName());
|
||||
InitialBandwidthTraffic netMsg = initialBandwidthTrafficService.getNetInterfaceDetailsMsg(initialBandwidthTraffic);
|
||||
if(netMsg != null){
|
||||
pppoeConfigSub.setInSpeed(convert(netMsg.getInSpeed(), "mbps"));
|
||||
pppoeConfigSub.setOutSpeed(convert(netMsg.getOutSpeed(), "mbps"));
|
||||
pppoeConfigSub.setTotalInSpeed(convert(netMsg.getTotalInSpeed(),"gb"));
|
||||
pppoeConfigSub.setTotalOutSpeed(convert(netMsg.getTotalOutSpeed(),"gb"));
|
||||
}
|
||||
}
|
||||
}else if("2".equals(pppoeConfigMain.getPppoeConfigMode())){
|
||||
subList = new ArrayList<>();
|
||||
// 查询虚拟网卡信息
|
||||
RmNetworkInterfaceChild childQuery = new RmNetworkInterfaceChild();
|
||||
@@ -63,6 +79,11 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
|
||||
List<RmNetworkInterfaceChild> childList = rmNetworkInterfaceChildMapper.selectRmNetworkInterfaceChildList(childQuery);
|
||||
if(childList != null && !childList.isEmpty()){
|
||||
for (RmNetworkInterfaceChild child : childList) {
|
||||
// 查询流量信息
|
||||
InitialBandwidthTraffic initialBandwidthTraffic = new InitialBandwidthTraffic();
|
||||
initialBandwidthTraffic.setClientId(child.getClientId());
|
||||
initialBandwidthTraffic.setName(child.getInterfaceName());
|
||||
InitialBandwidthTraffic netMsg = initialBandwidthTrafficService.getNetInterfaceDetailsMsg(initialBandwidthTraffic);
|
||||
RmPppoeConfigSub pppoeConfigSub = new RmPppoeConfigSub();
|
||||
pppoeConfigSub.setClientId(child.getClientId());
|
||||
pppoeConfigSub.setInterfaceName(child.getInterfaceName());
|
||||
@@ -71,6 +92,28 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
|
||||
pppoeConfigSub.setIpv4Gateway(child.getGateway());
|
||||
pppoeConfigSub.setStatus(child.getStatus());
|
||||
pppoeConfigSub.setBandwidthResult(child.getBandwidthResult());
|
||||
if(netMsg != null){
|
||||
pppoeConfigSub.setInSpeed(convert(netMsg.getInSpeed(), "mbps"));
|
||||
pppoeConfigSub.setOutSpeed(convert(netMsg.getOutSpeed(), "mbps"));
|
||||
pppoeConfigSub.setTotalInSpeed(convert(netMsg.getTotalInSpeed(),"gb"));
|
||||
pppoeConfigSub.setTotalOutSpeed(convert(netMsg.getTotalOutSpeed(),"gb"));
|
||||
}
|
||||
// 计算运行时间
|
||||
if (child.getNetCreateTime() != null) {
|
||||
long createTime = child.getNetCreateTime(); // 秒级时间戳
|
||||
long uptimeSeconds = nowTime - createTime;
|
||||
|
||||
if (uptimeSeconds > 0) {
|
||||
long hours = uptimeSeconds / 3600;
|
||||
long minutes = (uptimeSeconds % 3600) / 60;
|
||||
String runTime = String.format("%dh%02dm", hours, minutes);
|
||||
pppoeConfigSub.setNetRunTime(runTime);
|
||||
} else {
|
||||
pppoeConfigSub.setNetRunTime("0h00m");
|
||||
}
|
||||
} else {
|
||||
pppoeConfigSub.setNetRunTime(null);
|
||||
}
|
||||
subList.add(pppoeConfigSub);
|
||||
}
|
||||
}
|
||||
@@ -78,7 +121,30 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
|
||||
pppoeConfigMain.setSubList(subList);
|
||||
return pppoeConfigMain;
|
||||
}
|
||||
/**
|
||||
* 转换bit值
|
||||
* @param bitStr bit值的字符串
|
||||
* @param toUnit 目标单位:"Mbps" 或 "GB"(不区分大小写)
|
||||
* @return 转换后的值字符串,保留两位小数
|
||||
*/
|
||||
public String convert(String bitStr, String toUnit) {
|
||||
if (bitStr == null || bitStr.trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("bit值不能为空");
|
||||
}
|
||||
|
||||
double bits = Double.parseDouble(bitStr.trim());
|
||||
double result;
|
||||
|
||||
if ("mbps".equalsIgnoreCase(toUnit)) {
|
||||
result = bits / 1_000_000.0; // 1 Mbps = 1,000,000 bits
|
||||
} else if ("gb".equalsIgnoreCase(toUnit)) {
|
||||
result = bits / 8_000_000_000.0; // 1 GB = 8,000,000,000 bits (1000³ * 8)
|
||||
} else {
|
||||
throw new IllegalArgumentException("单位只支持 Mbps 或 GB");
|
||||
}
|
||||
|
||||
return String.format("%.2f", result);
|
||||
}
|
||||
/**
|
||||
* 查询PPPoE配置主表列表
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user