pppoe配置增加5个字段。
This commit is contained in:
+3
@@ -44,6 +44,9 @@ public class NetworkInfo {
|
|||||||
// 如果是子接口,存储父接口名称
|
// 如果是子接口,存储父接口名称
|
||||||
@JsonProperty("parentInterface")
|
@JsonProperty("parentInterface")
|
||||||
private String parentInterface;
|
private String parentInterface;
|
||||||
|
/** 网卡创建时间 */
|
||||||
|
@JsonProperty("netCreateTime")
|
||||||
|
private Long netCreateTime;
|
||||||
|
|
||||||
// 如果是父接口,存储子接口列表
|
// 如果是父接口,存储子接口列表
|
||||||
@JsonProperty("subInterfaces")
|
@JsonProperty("subInterfaces")
|
||||||
|
|||||||
+2
@@ -76,6 +76,8 @@ public class RmNetworkInterfaceChild extends BaseEntity
|
|||||||
/** 是否连通外网(0否,1是) */
|
/** 是否连通外网(0否,1是) */
|
||||||
@Excel(name = "是否连通外网(0否,1是)")
|
@Excel(name = "是否连通外网(0否,1是)")
|
||||||
private String status;
|
private String status;
|
||||||
|
/** 网卡创建时间 */
|
||||||
|
private Long netCreateTime;
|
||||||
/** 虚拟网卡上报带宽值(Mbps) */
|
/** 虚拟网卡上报带宽值(Mbps) */
|
||||||
private BigDecimal bandwidthResult;
|
private BigDecimal bandwidthResult;
|
||||||
/** 有ipv4的标识 */
|
/** 有ipv4的标识 */
|
||||||
|
|||||||
@@ -52,6 +52,20 @@ public class RmPppoeConfigSub extends BaseEntity
|
|||||||
private String clientId;
|
private String clientId;
|
||||||
/** 接口名称 */
|
/** 接口名称 */
|
||||||
private String interfaceName;
|
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() {
|
public RmPppoeConfigSubVo toVo() {
|
||||||
RmPppoeConfigSubVo vo = new RmPppoeConfigSubVo();
|
RmPppoeConfigSubVo vo = new RmPppoeConfigSubVo();
|
||||||
|
|||||||
@@ -1356,6 +1356,7 @@ public class MessageHandler {
|
|||||||
networkInterface.setPublicIp(networkInfo.getPublicIp());
|
networkInterface.setPublicIp(networkInfo.getPublicIp());
|
||||||
networkInterface.setInterfaceType(networkInfo.getType());
|
networkInterface.setInterfaceType(networkInfo.getType());
|
||||||
networkInterface.setStatus(networkInfo.getStatus());
|
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.alibaba.fastjson.JSONObject;
|
||||||
import com.tongran.common.core.enums.MsgEnum;
|
import com.tongran.common.core.enums.MsgEnum;
|
||||||
import com.tongran.common.core.utils.DateUtils;
|
import com.tongran.common.core.utils.DateUtils;
|
||||||
import com.tongran.rocketmq.domain.DeviceMessage;
|
import com.tongran.rocketmq.domain.*;
|
||||||
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
|
|
||||||
import com.tongran.rocketmq.domain.RmPppoeConfigMain;
|
|
||||||
import com.tongran.rocketmq.domain.RmPppoeConfigSub;
|
|
||||||
import com.tongran.rocketmq.domain.vo.PolicyTypeVo;
|
import com.tongran.rocketmq.domain.vo.PolicyTypeVo;
|
||||||
import com.tongran.rocketmq.domain.vo.PppoeVo;
|
import com.tongran.rocketmq.domain.vo.PppoeVo;
|
||||||
import com.tongran.rocketmq.domain.vo.RmPppoeConfigSubVo;
|
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.mapper.RmPppoeConfigSubMapper;
|
||||||
import com.tongran.rocketmq.model.ProducerMode;
|
import com.tongran.rocketmq.model.ProducerMode;
|
||||||
import com.tongran.rocketmq.producer.MessageProducer;
|
import com.tongran.rocketmq.producer.MessageProducer;
|
||||||
|
import com.tongran.rocketmq.service.IInitialBandwidthTrafficService;
|
||||||
import com.tongran.rocketmq.service.IRmPppoeConfigMainService;
|
import com.tongran.rocketmq.service.IRmPppoeConfigMainService;
|
||||||
import org.springframework.beans.BeanUtils;
|
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.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -41,10 +40,13 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
|
|||||||
private ProducerMode producerMode;
|
private ProducerMode producerMode;
|
||||||
@Autowired
|
@Autowired
|
||||||
private RmNetworkInterfaceChildMapper rmNetworkInterfaceChildMapper;
|
private RmNetworkInterfaceChildMapper rmNetworkInterfaceChildMapper;
|
||||||
|
@Autowired
|
||||||
|
private IInitialBandwidthTrafficService initialBandwidthTrafficService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RmPppoeConfigMain selectRmPppoeConfigMainByClientId(RmPppoeConfigMain rmPppoeConfigMain)
|
public RmPppoeConfigMain selectRmPppoeConfigMainByClientId(RmPppoeConfigMain rmPppoeConfigMain)
|
||||||
{
|
{
|
||||||
|
long nowTime = Instant.now().getEpochSecond();
|
||||||
RmPppoeConfigMain pppoeConfigMain = rmPppoeConfigMainMapper.selectRmPppoeConfigMainByClientId(rmPppoeConfigMain.getClientId());
|
RmPppoeConfigMain pppoeConfigMain = rmPppoeConfigMainMapper.selectRmPppoeConfigMainByClientId(rmPppoeConfigMain.getClientId());
|
||||||
if(pppoeConfigMain == null){
|
if(pppoeConfigMain == null){
|
||||||
pppoeConfigMain = new RmPppoeConfigMain();
|
pppoeConfigMain = new RmPppoeConfigMain();
|
||||||
@@ -53,7 +55,21 @@ 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("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<>();
|
subList = new ArrayList<>();
|
||||||
// 查询虚拟网卡信息
|
// 查询虚拟网卡信息
|
||||||
RmNetworkInterfaceChild childQuery = new RmNetworkInterfaceChild();
|
RmNetworkInterfaceChild childQuery = new RmNetworkInterfaceChild();
|
||||||
@@ -63,6 +79,11 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
|
|||||||
List<RmNetworkInterfaceChild> childList = rmNetworkInterfaceChildMapper.selectRmNetworkInterfaceChildList(childQuery);
|
List<RmNetworkInterfaceChild> childList = rmNetworkInterfaceChildMapper.selectRmNetworkInterfaceChildList(childQuery);
|
||||||
if(childList != null && !childList.isEmpty()){
|
if(childList != null && !childList.isEmpty()){
|
||||||
for (RmNetworkInterfaceChild child : childList) {
|
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();
|
RmPppoeConfigSub pppoeConfigSub = new RmPppoeConfigSub();
|
||||||
pppoeConfigSub.setClientId(child.getClientId());
|
pppoeConfigSub.setClientId(child.getClientId());
|
||||||
pppoeConfigSub.setInterfaceName(child.getInterfaceName());
|
pppoeConfigSub.setInterfaceName(child.getInterfaceName());
|
||||||
@@ -71,6 +92,28 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
|
|||||||
pppoeConfigSub.setIpv4Gateway(child.getGateway());
|
pppoeConfigSub.setIpv4Gateway(child.getGateway());
|
||||||
pppoeConfigSub.setStatus(child.getStatus());
|
pppoeConfigSub.setStatus(child.getStatus());
|
||||||
pppoeConfigSub.setBandwidthResult(child.getBandwidthResult());
|
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);
|
subList.add(pppoeConfigSub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,7 +121,30 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
|
|||||||
pppoeConfigMain.setSubList(subList);
|
pppoeConfigMain.setSubList(subList);
|
||||||
return pppoeConfigMain;
|
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配置主表列表
|
* 查询PPPoE配置主表列表
|
||||||
*
|
*
|
||||||
|
|||||||
+6
-1
@@ -26,10 +26,11 @@
|
|||||||
<result property="newFlag" column="new_flag" />
|
<result property="newFlag" column="new_flag" />
|
||||||
<result property="status" column="status" />
|
<result property="status" column="status" />
|
||||||
<result property="bandwidthResult" column="bandwidth_result" />
|
<result property="bandwidthResult" column="bandwidth_result" />
|
||||||
|
<result property="netCreateTime" column="net_create_time" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectRmNetworkInterfaceChildVo">
|
<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, status, bandwidth_result 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, bandwidth_result, net_create_time from rm_network_interface_child
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectRmNetworkInterfaceChildList" parameterType="RmNetworkInterfaceChild" resultMap="RmNetworkInterfaceChildResult">
|
<select id="selectRmNetworkInterfaceChildList" parameterType="RmNetworkInterfaceChild" resultMap="RmNetworkInterfaceChildResult">
|
||||||
@@ -82,6 +83,7 @@
|
|||||||
<if test="newFlag != null">new_flag,</if>
|
<if test="newFlag != null">new_flag,</if>
|
||||||
<if test="status != null">status,</if>
|
<if test="status != null">status,</if>
|
||||||
<if test="bandwidthResult != null">bandwidth_result,</if>
|
<if test="bandwidthResult != null">bandwidth_result,</if>
|
||||||
|
<if test="netCreateTime != null">net_create_time,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="clientId != null">#{clientId},</if>
|
<if test="clientId != null">#{clientId},</if>
|
||||||
@@ -104,6 +106,7 @@
|
|||||||
<if test="newFlag != null">#{newFlag},</if>
|
<if test="newFlag != null">#{newFlag},</if>
|
||||||
<if test="status != null">#{status},</if>
|
<if test="status != null">#{status},</if>
|
||||||
<if test="bandwidthResult != null">#{bandwidthResult},</if>
|
<if test="bandwidthResult != null">#{bandwidthResult},</if>
|
||||||
|
<if test="netCreateTime != null">#{netCreateTime},</if>
|
||||||
</trim>
|
</trim>
|
||||||
ON DUPLICATE KEY UPDATE
|
ON DUPLICATE KEY UPDATE
|
||||||
<trim suffixOverrides=",">
|
<trim suffixOverrides=",">
|
||||||
@@ -121,6 +124,7 @@
|
|||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
<if test="status != null">status = #{status},</if>
|
<if test="status != null">status = #{status},</if>
|
||||||
<if test="bandwidthResult != null">bandwidth_result = #{bandwidthResult},</if>
|
<if test="bandwidthResult != null">bandwidth_result = #{bandwidthResult},</if>
|
||||||
|
<if test="netCreateTime != null">net_create_time = #{netCreateTime},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@@ -147,6 +151,7 @@
|
|||||||
<if test="newFlag != null">new_flag = #{newFlag},</if>
|
<if test="newFlag != null">new_flag = #{newFlag},</if>
|
||||||
<if test="status != null">status = #{status},</if>
|
<if test="status != null">status = #{status},</if>
|
||||||
<if test="bandwidthResult != null">bandwidth_result = #{bandwidthResult},</if>
|
<if test="bandwidthResult != null">bandwidth_result = #{bandwidthResult},</if>
|
||||||
|
<if test="netCreateTime != null">net_create_time = #{netCreateTime},</if>
|
||||||
</trim>
|
</trim>
|
||||||
<where>
|
<where>
|
||||||
<choose>
|
<choose>
|
||||||
|
|||||||
@@ -38,8 +38,19 @@ 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,
|
||||||
|
b.interface_name interfaceName,
|
||||||
b.status status,
|
b.status status,
|
||||||
b.mac_address macAddress
|
b.mac_address macAddress,
|
||||||
|
b.net_create_time netCreateTime,
|
||||||
|
CASE
|
||||||
|
WHEN b.net_create_time IS NULL THEN NULL
|
||||||
|
ELSE CONCAT(
|
||||||
|
FLOOR((UNIX_TIMESTAMP() - b.net_create_time) / 3600), -- 计算小时
|
||||||
|
'h',
|
||||||
|
LPAD(FLOOR(((UNIX_TIMESTAMP() - b.net_create_time) % 3600) / 60), 2, '0'), -- 计算分钟
|
||||||
|
'm'
|
||||||
|
)
|
||||||
|
END as netRunTime
|
||||||
FROM
|
FROM
|
||||||
rm_pppoe_config_sub a
|
rm_pppoe_config_sub a
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
|
|||||||
Reference in New Issue
Block a user