相关接口增加ipv4、ipv6出入流量字段。
服务器管理列表新增字段和排序。 优化监控看板流量统计。
This commit is contained in:
+10
@@ -247,5 +247,15 @@ public class RmResourceRegistrationController extends BaseController
|
||||
{
|
||||
return toAjax(rmResourceRegistrationService.updateRemark(rmResourceRegistration));
|
||||
}
|
||||
/**
|
||||
* 添加上报带宽值
|
||||
*/
|
||||
@RequiresPermissions("system:registration:edit")
|
||||
@Log(title = "添加上报带宽值", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/addReportedBandwidth")
|
||||
public AjaxResult addReportedBandwidth(@RequestBody RmResourceRegistration rmResourceRegistration)
|
||||
{
|
||||
return toAjax(rmResourceRegistrationService.addReportedBandwidth(rmResourceRegistration));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+24
-2
@@ -117,6 +117,9 @@ public class RmResourceRegistration extends BaseEntity
|
||||
@Excel(name = "IP1-IPv4地址")
|
||||
private String ip1Ipv4Address; // IP1-IPv4地址
|
||||
|
||||
@Excel(name = "IP1-IPv6地址")
|
||||
private String ip1Ipv6Address; // IP1-IPv6地址
|
||||
|
||||
@Excel(name = "IP1-网关")
|
||||
private String ip1Gateway; // IP1-网关
|
||||
|
||||
@@ -145,6 +148,9 @@ public class RmResourceRegistration extends BaseEntity
|
||||
@Excel(name = "IP2-IPv4地址")
|
||||
private String ip2Ipv4Address;
|
||||
|
||||
@Excel(name = "IP2-IPv6地址")
|
||||
private String ip2Ipv6Address; // IP2-IPv6地址
|
||||
|
||||
@Excel(name = "IP2-网关")
|
||||
private String ip2Gateway;
|
||||
|
||||
@@ -173,6 +179,9 @@ public class RmResourceRegistration extends BaseEntity
|
||||
@Excel(name = "IP3-IPv4地址")
|
||||
private String ip3Ipv4Address;
|
||||
|
||||
@Excel(name = "IP3-IPv6地址")
|
||||
private String ip3Ipv6Address; // IP3-IPv6地址
|
||||
|
||||
@Excel(name = "IP3-网关")
|
||||
private String ip3Gateway;
|
||||
|
||||
@@ -200,8 +209,12 @@ public class RmResourceRegistration extends BaseEntity
|
||||
|
||||
@Excel(name = "管理网-IPv4地址")
|
||||
private String mgmtIpv4Address; // 管理网-IPv4地址
|
||||
|
||||
@Excel(name = "管理网-IPv6地址")
|
||||
private String mgmtIpv6Address; // 管理网-IPv6地址
|
||||
|
||||
@Excel(name = "管理网-网关")
|
||||
private String mgmtGateway; // 管理网-IPv4地址
|
||||
private String mgmtGateway; // 管理网-网关地址
|
||||
|
||||
/** 多条件查询 */
|
||||
private String queryParam;
|
||||
@@ -216,7 +229,7 @@ public class RmResourceRegistration extends BaseEntity
|
||||
private Date createTime;
|
||||
|
||||
/** 上机时间 */
|
||||
@Excel(name = "上机时间")
|
||||
@Excel(name = "上机时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date onboardTime;
|
||||
/** 服务器列表 */
|
||||
@@ -226,5 +239,14 @@ public class RmResourceRegistration extends BaseEntity
|
||||
/** 逻辑节点空标识 */
|
||||
private boolean logicalNodeEmpty;
|
||||
/** 昨日95值 */
|
||||
@Excel(name = "昨日95值(MBit)")
|
||||
private BigDecimal bandwidthResult;
|
||||
/** 上报带宽值(MBit) */
|
||||
@Excel(name = "上报带宽值(MBit)")
|
||||
private BigDecimal reportedBandwidth;
|
||||
/** 日95带宽值利用率 */
|
||||
@Excel(name = "日95带宽值利用率")
|
||||
private String bandwidthRate;
|
||||
/** 昨日95值排序 1正序 2倒叙 3不排序 */
|
||||
private Integer bandwidthResultSort;
|
||||
}
|
||||
+2
@@ -110,4 +110,6 @@ public interface RmResourceRegistrationMapper
|
||||
* @return
|
||||
*/
|
||||
int updateRemark(RmResourceRegistration rmResourceRegistration);
|
||||
|
||||
int addReportedBandwidth(RmResourceRegistration rmResourceRegistration);
|
||||
}
|
||||
|
||||
+7
@@ -132,4 +132,11 @@ public interface IRmResourceRegistrationService
|
||||
* @return
|
||||
*/
|
||||
int updateRemark(RmResourceRegistration rmResourceRegistration);
|
||||
|
||||
/**
|
||||
* 添加上报带宽值
|
||||
* @param rmResourceRegistration
|
||||
* @return
|
||||
*/
|
||||
int addReportedBandwidth(RmResourceRegistration rmResourceRegistration);
|
||||
}
|
||||
|
||||
+351
-81
@@ -20,6 +20,7 @@ import com.tongran.system.service.IRmResourceRegistrationService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
@@ -83,106 +84,199 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
* @return 资源注册
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getRegistrationTableInfoList(RmResourceRegistration rmResourceRegistration)
|
||||
{
|
||||
Map<String, Object> resultMap = new HashMap();
|
||||
if(rmResourceRegistration.getQueryParam() == null || rmResourceRegistration.getQueryParam() == ""){
|
||||
public Map<String, Object> getRegistrationTableInfoList(RmResourceRegistration rmResourceRegistration) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
// 获取参数
|
||||
String queryParam = rmResourceRegistration.getQueryParam();
|
||||
Integer bandwidthResultSort = rmResourceRegistration.getBandwidthResultSort();
|
||||
int pageNum = rmResourceRegistration.getPageNum() != null ? rmResourceRegistration.getPageNum() : 1;
|
||||
int pageSize = rmResourceRegistration.getPageSize() != null ? rmResourceRegistration.getPageSize() : 10;
|
||||
|
||||
// 判断是否有查询条件
|
||||
boolean hasQueryParam = queryParam != null && !queryParam.trim().isEmpty();
|
||||
String queryValue = hasQueryParam ? queryParam.trim().toLowerCase() : null;
|
||||
|
||||
// 情况1: 无查询参数且无特殊排序,使用数据库分页
|
||||
if (!hasQueryParam && (bandwidthResultSort == null || bandwidthResultSort == 3)) {
|
||||
PageDomain pageDomain = new PageDomain();
|
||||
pageDomain.setPageNum(rmResourceRegistration.getPageNum());
|
||||
pageDomain.setPageSize(rmResourceRegistration.getPageSize());
|
||||
pageDomain.setPageNum(pageNum);
|
||||
pageDomain.setPageSize(pageSize);
|
||||
startPage(pageDomain);
|
||||
|
||||
List<RmResourceRegistration> list = rmResourceRegistrationMapper.getRegistrationTableInfoList(rmResourceRegistration);
|
||||
|
||||
// 只处理当前页的数据
|
||||
processCurrentPageData(list);
|
||||
|
||||
resultMap.put("list", list);
|
||||
return resultMap;
|
||||
}
|
||||
List<RmResourceRegistration> rmResourceRegistrationList = rmResourceRegistrationMapper.getRegistrationTableInfoList(rmResourceRegistration);
|
||||
for (RmResourceRegistration resourceRegistration : rmResourceRegistrationList) {
|
||||
if(resourceRegistration.getClientId() != null){
|
||||
// 网卡信息
|
||||
setNetWorkMsg(resourceRegistration);
|
||||
// set昨日95值
|
||||
setBandwidthYestoday(resourceRegistration);
|
||||
|
||||
// 情况2: 有查询参数或需要排序,全量查询+内存处理
|
||||
List<RmResourceRegistration> allData = rmResourceRegistrationMapper.getRegistrationTableInfoList(rmResourceRegistration);
|
||||
|
||||
// 1. 过滤
|
||||
List<RmResourceRegistration> filteredList = allData;
|
||||
if (hasQueryParam) {
|
||||
filteredList = allData.stream()
|
||||
.filter(item -> item != null && quickMatches(item, queryValue))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// 2. 排序
|
||||
if (bandwidthResultSort != null && bandwidthResultSort != 3) {
|
||||
sortList(filteredList, bandwidthResultSort);
|
||||
}
|
||||
|
||||
// 3. 内存分页
|
||||
int total = filteredList.size();
|
||||
int fromIndex = Math.min((pageNum - 1) * pageSize, total);
|
||||
int toIndex = Math.min(fromIndex + pageSize, total);
|
||||
|
||||
// 注意:这里要用copy,因为后续要修改数据
|
||||
List<RmResourceRegistration> pageList = applyPagination(filteredList, rmResourceRegistration.getPageNum(), rmResourceRegistration.getPageSize());
|
||||
List<RmResourceRegistration> currentPageData = new ArrayList<>(pageList);
|
||||
|
||||
// 4. 只处理当前页数据
|
||||
processCurrentPageData(currentPageData);
|
||||
|
||||
resultMap.put("list", currentPageData);
|
||||
resultMap.put("total", total);
|
||||
|
||||
log.info("查询完成,总耗时: {}ms, 总条数: {}, 处理条数: {}",
|
||||
System.currentTimeMillis() - startTime, total, currentPageData.size());
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 只处理当前页的数据
|
||||
*/
|
||||
private void processCurrentPageData(List<RmResourceRegistration> pageList) {
|
||||
if (CollectionUtils.isEmpty(pageList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
for (RmResourceRegistration item : pageList) {
|
||||
if (item.getClientId() != null) {
|
||||
setNetWorkMsg(item);
|
||||
setBandwidthYestoday(item);
|
||||
}
|
||||
}
|
||||
if(rmResourceRegistration.getQueryParam() != null && !rmResourceRegistration.getQueryParam().trim().isEmpty()){
|
||||
String queryValue = rmResourceRegistration.getQueryParam().trim().toLowerCase(); // 转为小写便于模糊匹配
|
||||
|
||||
// 从rmResourceRegistrationList列表中筛选符合条件的数据
|
||||
List<RmResourceRegistration> filteredList = rmResourceRegistrationList.stream()
|
||||
.filter(item -> item != null)
|
||||
.filter(item -> {
|
||||
// 如果查询值为空,返回所有数据
|
||||
if (queryValue.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 检查公网IP (IP1-3和管理网)
|
||||
return (item.getIp1PublicIp() != null && item.getIp1PublicIp().toLowerCase().contains(queryValue)) ||
|
||||
(item.getIp2PublicIp() != null && item.getIp2PublicIp().toLowerCase().contains(queryValue)) ||
|
||||
(item.getIp3PublicIp() != null && item.getIp3PublicIp().toLowerCase().contains(queryValue)) ||
|
||||
(item.getMgmtPublicIp() != null && item.getMgmtPublicIp().toLowerCase().contains(queryValue)) ||
|
||||
|
||||
// 检查私网IP (IP1-3和管理网)
|
||||
(item.getIp1Ipv4Address() != null && item.getIp1Ipv4Address().toLowerCase().contains(queryValue)) ||
|
||||
(item.getIp2Ipv4Address() != null && item.getIp2Ipv4Address().toLowerCase().contains(queryValue)) ||
|
||||
(item.getIp3Ipv4Address() != null && item.getIp3Ipv4Address().toLowerCase().contains(queryValue)) ||
|
||||
(item.getMgmtIpv4Address() != null && item.getMgmtIpv4Address().toLowerCase().contains(queryValue)) ||
|
||||
|
||||
// 检查设备SN
|
||||
(item.getHardwareSn() != null && item.getHardwareSn().toLowerCase().contains(queryValue)) ||
|
||||
(item.getClientId() != null && item.getClientId().toLowerCase().contains(queryValue));
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<RmResourceRegistration> pageInfo = applyPagination(filteredList, rmResourceRegistration.getPageNum(), rmResourceRegistration.getPageSize());
|
||||
resultMap.put("list", pageInfo);
|
||||
resultMap.put("total", filteredList.size());
|
||||
return resultMap;
|
||||
long cost = System.currentTimeMillis() - startTime;
|
||||
if (cost > 1000) {
|
||||
log.info("处理{}条数据耗时较长: {}ms", pageList.size(), cost);
|
||||
} else if (cost > 100) {
|
||||
log.info("处理{}条数据耗时: {}ms", pageList.size(), cost);
|
||||
} else {
|
||||
resultMap.put("list", rmResourceRegistrationList);
|
||||
log.info("处理{}条数据耗时: {}ms", pageList.size(), cost);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
/**
|
||||
* 查询资源注册列表
|
||||
*
|
||||
*
|
||||
* @param rmResourceRegistration 资源注册
|
||||
* @return 资源注册
|
||||
*/
|
||||
@Override
|
||||
public List<RmResourceRegistration> selectRmResourceRegistrationList(RmResourceRegistration rmResourceRegistration)
|
||||
{
|
||||
List<RmResourceRegistration> rmResourceRegistrationList = rmResourceRegistrationMapper.getRegistrationTableInfoList(rmResourceRegistration);
|
||||
for (RmResourceRegistration resourceRegistration : rmResourceRegistrationList) {
|
||||
if(resourceRegistration.getClientId() != null){
|
||||
// 网卡信息
|
||||
setNetWorkMsg(resourceRegistration);
|
||||
public List<RmResourceRegistration> selectRmResourceRegistrationList(RmResourceRegistration rmResourceRegistration) {
|
||||
List<RmResourceRegistration> allData = rmResourceRegistrationMapper.getRegistrationTableInfoList(rmResourceRegistration);
|
||||
|
||||
// 获取参数
|
||||
String queryParam = rmResourceRegistration.getQueryParam();
|
||||
Integer bandwidthResultSort = rmResourceRegistration.getBandwidthResultSort();
|
||||
boolean hasQueryParam = queryParam != null && !queryParam.trim().isEmpty();
|
||||
String queryValue = hasQueryParam ? queryParam.trim().toLowerCase() : null;
|
||||
|
||||
// 过滤
|
||||
List<RmResourceRegistration> filteredList = allData;
|
||||
if (hasQueryParam) {
|
||||
filteredList = allData.stream()
|
||||
.filter(item -> item != null && quickMatches(item, queryValue))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// 排序
|
||||
if (bandwidthResultSort != null && bandwidthResultSort != 3) {
|
||||
sortList(filteredList, bandwidthResultSort);
|
||||
}
|
||||
|
||||
// 处理全部数据
|
||||
for (RmResourceRegistration item : filteredList) {
|
||||
if (item.getClientId() != null) {
|
||||
setNetWorkMsg(item);
|
||||
setBandwidthYestoday(item);
|
||||
}
|
||||
}
|
||||
if(rmResourceRegistration.getQueryParam() != null){
|
||||
String queryValue = rmResourceRegistration.getQueryParam().trim();
|
||||
// 筛选公网IP私网IP设备SN相等的数据
|
||||
// 从rmResourceRegistrationList列表中筛选符合条件的数据
|
||||
List<RmResourceRegistration> filteredList = rmResourceRegistrationList.stream()
|
||||
.filter(item -> item != null)
|
||||
.filter(item ->
|
||||
// 检查公网IP (IP1-3和管理网)
|
||||
queryValue.equals(item.getIp1PublicIp()) ||
|
||||
queryValue.equals(item.getIp2PublicIp()) ||
|
||||
queryValue.equals(item.getIp3PublicIp()) ||
|
||||
queryValue.equals(item.getMgmtPublicIp()) ||
|
||||
|
||||
// 检查私网IP (IP1-3和管理网)
|
||||
queryValue.equals(item.getIp1Ipv4Address()) ||
|
||||
queryValue.equals(item.getIp2Ipv4Address()) ||
|
||||
queryValue.equals(item.getIp3Ipv4Address()) ||
|
||||
queryValue.equals(item.getMgmtIpv4Address()) ||
|
||||
return filteredList;
|
||||
}
|
||||
|
||||
// 检查设备SN
|
||||
queryValue.equals(item.getHardwareSn()) ||
|
||||
queryValue.equals(item.getClientId())
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
return filteredList;
|
||||
/**
|
||||
* 快速匹配方法
|
||||
*/
|
||||
private boolean quickMatches(RmResourceRegistration item, String queryValue) {
|
||||
if (item == null || queryValue == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 优化检查顺序,先检查最可能匹配的字段
|
||||
String clientId = item.getClientId();
|
||||
String hardwareSn = item.getHardwareSn();
|
||||
|
||||
if ((clientId != null && clientId.toLowerCase().contains(queryValue)) ||
|
||||
(hardwareSn != null && hardwareSn.toLowerCase().contains(queryValue))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 检查IP地址
|
||||
return containsValue(item.getIp1PublicIp(), queryValue) ||
|
||||
containsValue(item.getIp2PublicIp(), queryValue) ||
|
||||
containsValue(item.getIp3PublicIp(), queryValue) ||
|
||||
containsValue(item.getMgmtPublicIp(), queryValue) ||
|
||||
containsValue(item.getIp1Ipv4Address(), queryValue) ||
|
||||
containsValue(item.getIp2Ipv4Address(), queryValue) ||
|
||||
containsValue(item.getIp3Ipv4Address(), queryValue) ||
|
||||
containsValue(item.getMgmtIpv4Address(), queryValue) ||
|
||||
containsValue(item.getIp1Ipv6Address(), queryValue) ||
|
||||
containsValue(item.getIp2Ipv6Address(), queryValue) ||
|
||||
containsValue(item.getIp3Ipv6Address(), queryValue) ||
|
||||
containsValue(item.getMgmtIpv6Address(), queryValue);
|
||||
}
|
||||
|
||||
private boolean containsValue(String value, String queryValue) {
|
||||
return value != null && value.toLowerCase().contains(queryValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 排序方法
|
||||
*/
|
||||
private void sortList(List<RmResourceRegistration> list, Integer sortType) {
|
||||
if (CollectionUtils.isEmpty(list) || sortType == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Comparator<RmResourceRegistration> comparator = null;
|
||||
|
||||
if (sortType == 1) {
|
||||
comparator = Comparator.comparing(
|
||||
RmResourceRegistration::getBandwidthResult,
|
||||
Comparator.nullsLast(Comparator.naturalOrder())
|
||||
);
|
||||
} else if (sortType == 2) {
|
||||
comparator = Comparator.comparing(
|
||||
RmResourceRegistration::getBandwidthResult,
|
||||
Comparator.nullsLast(Comparator.reverseOrder())
|
||||
);
|
||||
}
|
||||
|
||||
if (comparator != null) {
|
||||
list.sort(comparator);
|
||||
}
|
||||
return rmResourceRegistrationList;
|
||||
}
|
||||
/**
|
||||
* 内存分页
|
||||
@@ -200,6 +294,159 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
int toIndex = Math.min(fromIndex + pageSize, list.size());
|
||||
return list.subList(fromIndex, toIndex);
|
||||
}
|
||||
/**
|
||||
* 批量处理网络信息
|
||||
*/
|
||||
private void batchSetNetWorkMsg(List<RmResourceRegistration> pageList) {
|
||||
if (CollectionUtils.isEmpty(pageList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
// 收集所有需要查询的clientId,用逗号分隔
|
||||
String clientIdsStr = pageList.stream()
|
||||
.map(RmResourceRegistration::getClientId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.joining(","));
|
||||
|
||||
if (StringUtils.isBlank(clientIdsStr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.debug("批量查询网络信息,clientIds: {}", clientIdsStr);
|
||||
|
||||
try {
|
||||
// 使用批量查询接口
|
||||
RmNetworkInterfaceRemote queryParam = new RmNetworkInterfaceRemote();
|
||||
queryParam.setClientIds(clientIdsStr); // 这里是逗号分隔的字符串
|
||||
queryParam.setNewFlag(1);
|
||||
|
||||
R<List<RmNetworkInterfaceRemote>> result = remoteRocketMqService.getNetworkInterfaceList(queryParam, SecurityConstants.INNER);
|
||||
|
||||
if (result == null || result.getData() == null || result.getData().isEmpty()) {
|
||||
log.warn("批量查询网络信息返回为空,clientIds: {}", clientIdsStr);
|
||||
// 回退到单条查询
|
||||
fallbackSetNetworkInfo(pageList);
|
||||
return;
|
||||
}
|
||||
|
||||
List<RmNetworkInterfaceRemote> networkList = result.getData();
|
||||
|
||||
// 按clientId分组
|
||||
Map<String, List<RmNetworkInterfaceRemote>> networkMap = networkList.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(item -> item.getClientId() != null)
|
||||
.collect(Collectors.groupingBy(RmNetworkInterfaceRemote::getClientId));
|
||||
|
||||
// 批量设置
|
||||
for (RmResourceRegistration registration : pageList) {
|
||||
String clientId = registration.getClientId();
|
||||
if (clientId != null) {
|
||||
List<RmNetworkInterfaceRemote> clientNetworks = networkMap.get(clientId);
|
||||
if (clientNetworks != null && !clientNetworks.isEmpty()) {
|
||||
// 调用原有的setNetWorkMsg方法
|
||||
setNetWorkMsgWithNetworkList(registration, clientNetworks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.debug("批量处理网络信息完成,耗时: {}ms, 处理{}条记录, 返回{}条网络信息",
|
||||
System.currentTimeMillis() - startTime, pageList.size(), networkList.size());
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("批量查询网络信息异常", e);
|
||||
// 回退到单条查询
|
||||
fallbackSetNetworkInfo(pageList);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 使用批量查询的结果设置网络信息
|
||||
*/
|
||||
private void setNetWorkMsgWithNetworkList(RmResourceRegistration registration, List<RmNetworkInterfaceRemote> networkList) {
|
||||
if (registration == null || CollectionUtils.isEmpty(networkList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int businessIpCount = 1;
|
||||
|
||||
for (RmNetworkInterfaceRemote network : networkList) {
|
||||
if ("1".equals(network.getBindIp()) || "3".equals(network.getBindIp())) {
|
||||
// 业务IP处理
|
||||
if (businessIpCount > 3) {
|
||||
continue; // 最多只处理3个业务IP
|
||||
}
|
||||
|
||||
// 设置业务IP字段
|
||||
switch (businessIpCount) {
|
||||
case 1:
|
||||
registration.setIp1Isp(network.getIsp());
|
||||
registration.setIp1Province(network.getProvince());
|
||||
registration.setIp1City(network.getCity());
|
||||
registration.setIp1PublicIp(network.getPublicIp());
|
||||
registration.setIp1InterfaceName(network.getInterfaceName());
|
||||
registration.setIp1MacAddress(network.getMacAddress());
|
||||
registration.setIp1InterfaceType(network.getInterfaceType());
|
||||
registration.setIp1Ipv4Address(network.getIpv4Address());
|
||||
registration.setIp1Ipv6Address(network.getIpv6Address());
|
||||
registration.setIp1Gateway(network.getGateway());
|
||||
break;
|
||||
case 2:
|
||||
registration.setIp2Isp(network.getIsp());
|
||||
registration.setIp2Province(network.getProvince());
|
||||
registration.setIp2City(network.getCity());
|
||||
registration.setIp2PublicIp(network.getPublicIp());
|
||||
registration.setIp2InterfaceName(network.getInterfaceName());
|
||||
registration.setIp2MacAddress(network.getMacAddress());
|
||||
registration.setIp2InterfaceType(network.getInterfaceType());
|
||||
registration.setIp2Ipv4Address(network.getIpv4Address());
|
||||
registration.setIp2Ipv6Address(network.getIpv6Address());
|
||||
registration.setIp2Gateway(network.getGateway());
|
||||
break;
|
||||
case 3:
|
||||
registration.setIp3Isp(network.getIsp());
|
||||
registration.setIp3Province(network.getProvince());
|
||||
registration.setIp3City(network.getCity());
|
||||
registration.setIp3PublicIp(network.getPublicIp());
|
||||
registration.setIp3InterfaceName(network.getInterfaceName());
|
||||
registration.setIp3MacAddress(network.getMacAddress());
|
||||
registration.setIp3InterfaceType(network.getInterfaceType());
|
||||
registration.setIp3Ipv4Address(network.getIpv4Address());
|
||||
registration.setIp3Ipv6Address(network.getIpv6Address());
|
||||
registration.setIp3Gateway(network.getGateway());
|
||||
break;
|
||||
}
|
||||
|
||||
businessIpCount++;
|
||||
}
|
||||
if ("2".equals(network.getBindIp()) || "3".equals(network.getBindIp())) {
|
||||
// 管理网IP处理
|
||||
registration.setMgmtIsp(network.getIsp());
|
||||
registration.setMgmtProvince(network.getProvince());
|
||||
registration.setMgmtCity(network.getCity());
|
||||
registration.setMgmtPublicIp(network.getPublicIp());
|
||||
registration.setMgmtInterfaceName(network.getInterfaceName());
|
||||
registration.setMgmtMacAddress(network.getMacAddress());
|
||||
registration.setMgmtInterfaceType(network.getInterfaceType());
|
||||
registration.setMgmtIpv4Address(network.getIpv4Address());
|
||||
registration.setMgmtIpv6Address(network.getIpv6Address());
|
||||
registration.setMgmtGateway(network.getGateway());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 回退到单条查询
|
||||
*/
|
||||
private void fallbackSetNetworkInfo(List<RmResourceRegistration> pageList) {
|
||||
log.warn("批量查询失败,回退到单条查询");
|
||||
for (RmResourceRegistration registration : pageList) {
|
||||
if (registration.getClientId() != null) {
|
||||
setNetWorkMsg(registration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 网卡信息赋值
|
||||
@@ -246,6 +493,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
registration.setIp1MacAddress(network.getMacAddress());
|
||||
registration.setIp1InterfaceType(network.getInterfaceType());
|
||||
registration.setIp1Ipv4Address(network.getIpv4Address());
|
||||
registration.setIp1Ipv6Address(network.getIpv6Address());
|
||||
registration.setIp1Gateway(network.getGateway());
|
||||
break;
|
||||
case 2:
|
||||
@@ -257,6 +505,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
registration.setIp2MacAddress(network.getMacAddress());
|
||||
registration.setIp2InterfaceType(network.getInterfaceType());
|
||||
registration.setIp2Ipv4Address(network.getIpv4Address());
|
||||
registration.setIp2Ipv6Address(network.getIpv6Address());
|
||||
registration.setIp2Gateway(network.getGateway());
|
||||
break;
|
||||
case 3:
|
||||
@@ -268,6 +517,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
registration.setIp3MacAddress(network.getMacAddress());
|
||||
registration.setIp3InterfaceType(network.getInterfaceType());
|
||||
registration.setIp3Ipv4Address(network.getIpv4Address());
|
||||
registration.setIp3Ipv6Address(network.getIpv6Address());
|
||||
registration.setIp3Gateway(network.getGateway());
|
||||
break;
|
||||
}
|
||||
@@ -284,6 +534,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
registration.setMgmtMacAddress(network.getMacAddress());
|
||||
registration.setMgmtInterfaceType(network.getInterfaceType());
|
||||
registration.setMgmtIpv4Address(network.getIpv4Address());
|
||||
registration.setMgmtIpv6Address(network.getIpv6Address());
|
||||
registration.setMgmtGateway(network.getGateway());
|
||||
}
|
||||
}
|
||||
@@ -315,7 +566,18 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
List<EpsNodeBandwidth> nodeBandwidthList = epsNodeBandwidthMapper.selectEpsNodeBandwidthList(epsNodeBandwidth);
|
||||
if(nodeBandwidthList != null && !nodeBandwidthList.isEmpty()){
|
||||
EpsNodeBandwidth nodeBandwidth = nodeBandwidthList.get(0);
|
||||
registration.setBandwidthResult(nodeBandwidth.getBandwidthResult());
|
||||
BigDecimal bandwidthResult = nodeBandwidth.getBandwidthResult();
|
||||
registration.setBandwidthResult(bandwidthResult);
|
||||
BigDecimal reportedBandwidth = registration.getReportedBandwidth();
|
||||
if(reportedBandwidth != null){
|
||||
if(reportedBandwidth.compareTo(BigDecimal.ZERO) == 0){
|
||||
registration.setBandwidthRate("0%");
|
||||
}else{
|
||||
// 计算日95带宽值利用率
|
||||
BigDecimal bandwidthRate = bandwidthResult.multiply(new BigDecimal(100)).divide(reportedBandwidth, 1, RoundingMode.HALF_UP);
|
||||
registration.setBandwidthRate(bandwidthRate + "%");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -854,5 +1116,13 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
int rows = rmResourceRegistrationMapper.updateRemark(rmResourceRegistration);
|
||||
return rows;
|
||||
}
|
||||
@Override
|
||||
public int addReportedBandwidth(RmResourceRegistration rmResourceRegistration) {
|
||||
if(rmResourceRegistration.getId() == null){
|
||||
throw new RuntimeException("id不可为null");
|
||||
}
|
||||
int rows = rmResourceRegistrationMapper.addReportedBandwidth(rmResourceRegistration);
|
||||
return rows;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+17
-14
@@ -430,32 +430,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="getTrafficListByClientIds" resultType="EpsInitialTrafficData">
|
||||
SELECT
|
||||
CAST(sum(ifnull(in_speed,0)) AS DECIMAL(20,0)) AS inSpeed,
|
||||
CAST(sum(ifnull(out_speed,0)) AS DECIMAL(20,0)) AS outSpeed,
|
||||
CAST(sum(ifnull(ipv4_in_speed,0)) AS DECIMAL(20,0)) AS ipv4InSpeed,
|
||||
CAST(sum(ifnull(ipv4_out_speed,0)) AS DECIMAL(20,0)) AS ipv4OutSpeed,
|
||||
CAST(sum(ifnull(ipv6_in_speed,0)) AS DECIMAL(20,0)) AS ipv6InSpeed,
|
||||
CAST(sum(ifnull(ipv6_out_speed,0)) AS DECIMAL(20,0)) AS ipv6OutSpeed,
|
||||
create_time AS createTime
|
||||
FROM ${tableName}
|
||||
CAST(sum(ifnull(a.in_speed,0)) AS DECIMAL(20,0)) AS inSpeed,
|
||||
CAST(sum(ifnull(a.out_speed,0)) AS DECIMAL(20,0)) AS outSpeed,
|
||||
CAST(sum(ifnull(a.ipv4_in_speed,0)) AS DECIMAL(20,0)) AS ipv4InSpeed,
|
||||
CAST(sum(ifnull(a.ipv4_out_speed,0)) AS DECIMAL(20,0)) AS ipv4OutSpeed,
|
||||
CAST(sum(ifnull(a.ipv6_in_speed,0)) AS DECIMAL(20,0)) AS ipv6InSpeed,
|
||||
CAST(sum(ifnull(a.ipv6_out_speed,0)) AS DECIMAL(20,0)) AS ipv6OutSpeed,
|
||||
a.create_time AS createTime
|
||||
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
|
||||
<where>
|
||||
<if test="businessId != '' and businessId != null">
|
||||
and business_id = #{businessId}
|
||||
and a.business_id = #{businessId}
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
and create_time >= #{startTime}
|
||||
and a.create_time >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
and create_time <= #{endTime}
|
||||
and a.create_time <= #{endTime}
|
||||
</if>
|
||||
<if test="clientIds != null">
|
||||
and client_id in
|
||||
and a.client_id in
|
||||
<foreach collection="clientIds.split(',')" item="clientId" open="(" separator="," close=")">
|
||||
#{clientId}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
group by create_time
|
||||
ORDER BY out_speed desc
|
||||
group by a.create_time
|
||||
ORDER BY outSpeed desc
|
||||
</select>
|
||||
</mapper>
|
||||
+2
-2
@@ -320,8 +320,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="calculationMode != null and calculationMode != ''"> and calculation_mode = #{calculationMode}</if>
|
||||
<if test="bandwidthType != null and bandwidthType != ''"> and bandwidth_type = #{bandwidthType}</if>
|
||||
<if test="resourceType != null and resourceType != ''"> and resource_type = #{resourceType}</if>
|
||||
<if test="startTime != null and startTime != ''"> and create_time >= #{startTime}</if>
|
||||
<if test="endTime != null and endTime != ''"> and create_time <= #{endTime}</if>
|
||||
<if test="startTime != null and startTime != ''"> and create_time >= left(#{startTime},10)</if>
|
||||
<if test="endTime != null and endTime != ''"> and create_time <= left(#{endTime},10)</if>
|
||||
<if test="clientIds != '' and clientIds != null">
|
||||
and client_id in
|
||||
<foreach collection="clientIds.split(',')" item="clientId" open="(" separator="," close=")">
|
||||
|
||||
+11
-1
@@ -23,10 +23,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="reportedBandwidth" column="reported_bandwidth" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRmResourceRegistrationVo">
|
||||
select id, client_id, hardware_sn, business_name, logical_node_id, multi_public_ip_status, registration_status, online_status, resource_type, agent_version, create_time, update_time, heartbeat_count, heartbeat_interval, onboard_time, remark, create_by, update_by from rm_resource_registration
|
||||
select id, client_id, hardware_sn, business_name, logical_node_id, multi_public_ip_status, registration_status, online_status, resource_type, agent_version, create_time, update_time, heartbeat_count, heartbeat_interval, onboard_time, remark, create_by, update_by, reported_bandwidth from rm_resource_registration
|
||||
</sql>
|
||||
|
||||
<select id="selectRmResourceRegistrationList" parameterType="RmResourceRegistration" resultMap="RmResourceRegistrationResult">
|
||||
@@ -73,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="reportedBandwidth != null">reported_bandwidth,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="clientId != null">#{clientId},</if>
|
||||
@@ -92,6 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="reportedBandwidth != null">#{reportedBandwidth},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -115,6 +118,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="reportedBandwidth != null">reported_bandwidth = #{reportedBandwidth},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
@@ -153,6 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="reportedBandwidth != null">reported_bandwidth = #{reportedBandwidth},</if>
|
||||
</trim>
|
||||
<where>
|
||||
<choose>
|
||||
@@ -204,6 +209,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
a.heartbeat_interval as heartbeatInterval,
|
||||
a.onboard_time as onboardTime,
|
||||
a.remark as remark,
|
||||
a.reported_bandwidth as reportedBandwidth,
|
||||
b.machine_code as machineCode
|
||||
from rm_resource_registration a
|
||||
left join rm_registration_machine b on a.client_id = b.client_id
|
||||
@@ -240,4 +246,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{clientId}
|
||||
</foreach>
|
||||
</update>
|
||||
<update id="addReportedBandwidth" parameterType="RmResourceRegistration">
|
||||
update rm_resource_registration set reported_bandwidth = #{reportedBandwidth}
|
||||
where id =#{id}
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user