net类型新增speed,duplex字段,新增重新计算,相关数据,图形分析接口

This commit is contained in:
gaoyutao
2025-09-01 20:24:01 +08:00
parent 506fd1dcc1
commit 05e57a2fe7
21 changed files with 790 additions and 255 deletions

View File

@@ -14,10 +14,16 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
# server-addr: 127.0.0.1:8848
server-addr: 172.16.15.103:8848
username: ${spring.cloud.nacos.config.username}
password: ${spring.cloud.nacos.config.password}
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
# server-addr: 127.0.0.1:8848
server-addr: 172.16.15.103:8848
username: nacos
password: nacos
# 配置文件格式
file-extension: yml
# 共享配置

View File

@@ -56,7 +56,7 @@ public class TableScheduleConfig {
String dailyEndTime = yesterday.atTime(23, 59, 59).format(TIME_FORMAT); // 23:59:59
// 日
String dayOrMonth = "1";
// 有效-95带宽值/日
// 95带宽值/日
EpsInitialTrafficData queryParam = new EpsInitialTrafficData();
queryParam.setDayOrMonth(dayOrMonth);
epsInitialTrafficDataService.calculateBusiness95BandwidthDaily(queryParam, dailyStartTime, dailyEndTime);

View File

@@ -1,5 +1,7 @@
package com.ruoyi.system.controller;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
@@ -8,13 +10,25 @@ import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.EpsInitialTrafficData;
import com.ruoyi.system.domain.EpsNodeBandwidth;
import com.ruoyi.system.domain.InitialSwitchInfoDetails;
import com.ruoyi.system.service.EpsInitialTrafficDataService;
import com.ruoyi.system.service.IEpsNodeBandwidthService;
import com.ruoyi.system.service.IInitialSwitchInfoDetailsService;
import com.ruoyi.system.util.CalculateUtil;
import com.ruoyi.system.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.webjars.NotFoundException;
import javax.servlet.http.HttpServletResponse;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Map;
/**
* 节点带宽信息Controller
@@ -24,10 +38,18 @@ import java.util.List;
*/
@RestController
@RequestMapping("/bandwidth")
@Slf4j
public class EpsNodeBandwidthController extends BaseController
{
private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private static final ZoneId ZONE = ZoneId.of("Asia/Shanghai");
@Autowired
private IEpsNodeBandwidthService epsNodeBandwidthService;
@Autowired
private IInitialSwitchInfoDetailsService initialSwitchInfoDetailsService;
@Autowired
private EpsInitialTrafficDataService epsInitialTrafficDataService;
/**
* 查询节点带宽信息列表
@@ -41,6 +63,17 @@ public class EpsNodeBandwidthController extends BaseController
pageDomain.setPageNum(epsNodeBandwidth.getPageNum());
pageDomain.setPageSize(epsNodeBandwidth.getPageSize());
startPage(pageDomain);
// 获取时间类型 1--日, 2--月
if(epsNodeBandwidth.getBandwidthType() != null){
String type = CalculateUtil.getTypeByBandwidthType(epsNodeBandwidth.getBandwidthType());
// 获取开始时间 结束时间
DateUtil.TimeRange startTimeRange = DateUtil.getTimeRange(DateUtils.parseDate(epsNodeBandwidth.getStartTime()),type);
DateUtil.TimeRange endTimeRange = DateUtil.getTimeRange(DateUtils.parseDate(epsNodeBandwidth.getEndTime()),type);
String startTime = startTimeRange.getStart();
String endTime = endTimeRange.getEnd();
epsNodeBandwidth.setStartTime(startTime);
epsNodeBandwidth.setEndTime(endTime);
}
List<EpsNodeBandwidth> list = epsNodeBandwidthService.selectEpsNodeBandwidthList(epsNodeBandwidth);
return getDataTable(list);
}
@@ -97,26 +130,87 @@ public class EpsNodeBandwidthController extends BaseController
@GetMapping(value = "recalculate/{id}")
public AjaxResult recalculate(@PathVariable("id") Long id)
{
return success(epsNodeBandwidthService.selectEpsNodeBandwidthById(id));//TODO 待逻辑处理
// 获取需要重新计算的信息
EpsNodeBandwidth epsNodeBandwidth = epsNodeBandwidthService.selectEpsNodeBandwidthById(id);
if (epsNodeBandwidth == null) {
throw new NotFoundException("未找到ID为" + id + "的服务器信息");
}
// 获取时间类型 1--日, 2--月
String type = CalculateUtil.getTypeByBandwidthType(epsNodeBandwidth.getBandwidthType());
// 设置开始时间,结束时间
DateUtil.TimeRange timeRange = DateUtil.getTimeRange(epsNodeBandwidth.getCreateTime(),type);
String dailyStartTime = timeRange.getStart();
String dailyEndTime = timeRange.getEnd();
if("1".equals(epsNodeBandwidth.getResourceType())){
// 重新计算服务器95带宽值
epsInitialTrafficDataService.recalculateServer95Bandwidth(epsNodeBandwidth, dailyStartTime, dailyEndTime);
}else{
// 重新计算交换机95带宽值
initialSwitchInfoDetailsService.recalculateSwitch95Bandwidth(epsNodeBandwidth, dailyStartTime, dailyEndTime);
}
return success();
}
/**
* 相关数据
*/
@RequiresPermissions("system:bandwidth:query")
@GetMapping(value = "relatedData/{id}")
public AjaxResult relatedData(@PathVariable("id") Long id)
{
return success(epsNodeBandwidthService.relatedData(id));
}
/**
* 相关数据-月均日95值
* 根据ID获取相关数据
* @param id 资源ID
* @return 表格数据信息
*/
@RequiresPermissions("system:bandwidth:query")
@GetMapping(value = "getAvgDetailMsg/{id}")
public AjaxResult getAvgDetailMsg(@PathVariable("id") Long id)
{
return success(epsNodeBandwidthService.getAvgDetailMsg(id));
public TableDataInfo relatedData(@PathVariable("id") Long id) {
// 1. 参数校验
if (id == null || id <= 0) {
throw new IllegalArgumentException("无效的资源ID");
}
try {
// 2. 查询服务器信息
EpsNodeBandwidth epsNodeBandwidth = epsNodeBandwidthService.selectEpsNodeBandwidthById(id);
if (epsNodeBandwidth == null) {
log.warn("未找到ID为{}的服务器信息", id);
throw new NotFoundException("未找到ID为" + id + "的服务器信息");
}
// 3. 获取时间范围
String type = CalculateUtil.getTypeByBandwidthType(epsNodeBandwidth.getBandwidthType());
DateUtil.TimeRange timeRange = DateUtil.getTimeRange(epsNodeBandwidth.getCreateTime(), type);
String dailyStartTime = timeRange.getStart();
String dailyEndTime = timeRange.getEnd();
// 4. 设置分页参数
PageDomain pageDomain = new PageDomain();
pageDomain.setPageNum(epsNodeBandwidth.getPageNum());
pageDomain.setPageSize(epsNodeBandwidth.getPageSize());
startPage(pageDomain);
// 5. 根据资源类型处理不同数据
String resourceType = epsNodeBandwidth.getResourceType();
String bandwidthType = epsNodeBandwidth.getBandwidthType();
if ("4".equals(bandwidthType) || "7".equals(bandwidthType)) {
// 处理特定带宽类型数据
List<EpsNodeBandwidth> nodeBandwidthList = epsNodeBandwidthService.getAvgDetailMsg(id);
return getDataTable(nodeBandwidthList);
}
if ("1".equals(resourceType)) {
// 处理服务器流量数据
List<EpsInitialTrafficData> trafficList = epsNodeBandwidthService.relatedData(
epsNodeBandwidth, dailyStartTime, dailyEndTime);
return getDataTable(trafficList);
} else{
// 处理交换机信息
List<InitialSwitchInfoDetails> switchInfoDetails = initialSwitchInfoDetailsService.getRelevantSwitch(
epsNodeBandwidth, dailyStartTime, dailyEndTime);
return getDataTable(switchInfoDetails);
}
} catch (Exception e) {
log.error("获取ID为{}的相关数据失败", id, e);
throw new ServiceException("获取数据失败,请稍后重试");
}
}
/**
* 生成月均日95值
@@ -128,4 +222,89 @@ public class EpsNodeBandwidthController extends BaseController
{
return toAjax(epsNodeBandwidthService.calculateAvg(epsNodeBandwidth));
}
/**
* 图形分析-95带宽值mbps/日
*/
@RequiresPermissions("system:bandwidth:list")
@PostMapping("/graphicalAnalysisDaily")
public AjaxResult graphicalAnalysisDaily(@RequestBody EpsNodeBandwidth epsNodeBandwidth)
{
// 设置时间
DateUtil.setTimeDay(epsNodeBandwidth);
Map list = epsNodeBandwidthService.graphicalAnalysis(epsNodeBandwidth, "1", ChronoUnit.DAYS);
return success(list);
}
/**
* 图形分析-95带宽值mbps/月
*/
@RequiresPermissions("system:bandwidth:list")
@PostMapping("/graphicalAnalysisMonthly")
public AjaxResult graphicalAnalysisMonthly(@RequestBody EpsNodeBandwidth epsNodeBandwidth)
{
// 设置时间
DateUtil.setTimeMonth(epsNodeBandwidth);
Map list = epsNodeBandwidthService.graphicalAnalysis(epsNodeBandwidth, "2", ChronoUnit.MONTHS);
return success(list);
}
/**
* 图形分析-包端带宽值Mbps/日
*/
@RequiresPermissions("system:bandwidth:list")
@PostMapping("/graphicalAnalysisPackage")
public AjaxResult graphicalAnalysisPackage(@RequestBody EpsNodeBandwidth epsNodeBandwidth)
{
// 设置时间
DateUtil.setTimeDay(epsNodeBandwidth);
Map list = epsNodeBandwidthService.graphicalAnalysis(epsNodeBandwidth, "3", ChronoUnit.DAYS);
return success(list);
}
/**
* 图形分析-月均日95值
*/
@RequiresPermissions("system:bandwidth:list")
@PostMapping("/graphicalAnalysisAvgMonthly")
public AjaxResult graphicalAnalysisAvgMonthly(@RequestBody EpsNodeBandwidth epsNodeBandwidth)
{
// 设置时间
DateUtil.setTimeMonth(epsNodeBandwidth);
Map list = epsNodeBandwidthService.graphicalAnalysis(epsNodeBandwidth, "4", ChronoUnit.MONTHS);
return success(list);
}
/**
* 图形分析-有效-95带宽值Mbps/日
*/
@RequiresPermissions("system:bandwidth:list")
@PostMapping("/graphicalAnalysisEffectiveDaily")
public AjaxResult graphicalAnalysisEffectiveDaily(@RequestBody EpsNodeBandwidth epsNodeBandwidth)
{
// 设置时间
DateUtil.setTimeDay(epsNodeBandwidth);
Map list = epsNodeBandwidthService.graphicalAnalysis(epsNodeBandwidth, "5", ChronoUnit.DAYS);
return success(list);
}
/**
* 图形分析-有效-95带宽值Mbps/月
*/
@RequiresPermissions("system:bandwidth:list")
@PostMapping("/graphicalAnalysisEffectiveMonthly")
public AjaxResult graphicalAnalysisEffectiveMonthly(@RequestBody EpsNodeBandwidth epsNodeBandwidth)
{
// 设置时间
DateUtil.setTimeMonth(epsNodeBandwidth);
Map list = epsNodeBandwidthService.graphicalAnalysis(epsNodeBandwidth, "6", ChronoUnit.MONTHS);
return success(list);
}
/**
* 图形分析-有效-月均日95值
*/
@RequiresPermissions("system:bandwidth:list")
@PostMapping("/graphicalAnalysisEffectiveAvgMonthly")
public AjaxResult graphicalAnalysisEffectiveAvgMonthly(@RequestBody EpsNodeBandwidth epsNodeBandwidth)
{
// 设置时间
DateUtil.setTimeMonth(epsNodeBandwidth);
Map list = epsNodeBandwidthService.graphicalAnalysis(epsNodeBandwidth, "7", ChronoUnit.MONTHS);
return success(list);
}
}

View File

@@ -29,7 +29,6 @@ public class InitialSwitchInfoDetailsController extends BaseController
{
@Autowired
private IInitialSwitchInfoDetailsService initialSwitchInfoDetailsService;
/**
* 查询交换机监控信息列表
*/
@@ -106,15 +105,4 @@ public class InitialSwitchInfoDetailsController extends BaseController
{
return initialSwitchInfoDetailsService.autoSaveSwitchTraffic(initialSwitchInfoDetails);
}
/**
* 获取交换机监控信息详细信息
*/
@RequiresPermissions("system:switchInfoDetails:query")
@GetMapping(value = "recalculateSwitch/{id}")
public AjaxResult recalculateSwitch(@PathVariable("id") Long id)
{
initialSwitchInfoDetailsService.recalculateSwitch95Bandwidth(id);
return success();
}
}

View File

@@ -58,6 +58,12 @@ public class EpsInitialTrafficData {
@Excel(name = "发送带宽(Mbps)")
private String outSpeed;
/** 协商速度 */
private String speed;
/** 工作模式 */
private String duplex;
/** 业务代码 */
@Excel(name = "业务代码")
private String businessId;

View File

@@ -7,6 +7,7 @@ import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 节点带宽信息对象 eps_node_bandwidth
@@ -126,6 +127,11 @@ public class EpsNodeBandwidth extends BaseEntity
private String endTime;
/** 月份 */
private String monthTime;
/** 备注 */
private String remark1;
private List<String> nodeNames;
private List<String> switchNames;
}

View File

@@ -1,6 +1,7 @@
package com.ruoyi.system.service;
import com.ruoyi.system.domain.EpsInitialTrafficData;
import com.ruoyi.system.domain.EpsNodeBandwidth;
import java.util.List;
@@ -46,4 +47,12 @@ public interface EpsInitialTrafficDataService {
*/
void calculateBusiness95BandwidthDaily(EpsInitialTrafficData queryParam, String dailyStartTime, String dailyEndTime);
/**
* 重新计算服务器95带宽值
* @param epsNodeBandwidth 95带宽值收益详情
* @param dailyStartTime 开始时间
* @param dailyEndTime 结束时间
*/
void recalculateServer95Bandwidth(EpsNodeBandwidth epsNodeBandwidth, String dailyStartTime, String dailyEndTime);
}

View File

@@ -3,7 +3,9 @@ package com.ruoyi.system.service;
import com.ruoyi.system.domain.EpsInitialTrafficData;
import com.ruoyi.system.domain.EpsNodeBandwidth;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Map;
/**
* 节点带宽信息Service接口
@@ -23,10 +25,10 @@ public interface IEpsNodeBandwidthService
/**
* 相关数据
* @param id
* @param epsNodeBandwidth
* @return
*/
public List<EpsInitialTrafficData> relatedData(Long id);
public List<EpsInitialTrafficData> relatedData(EpsNodeBandwidth epsNodeBandwidth, String dailyStartTime, String dailyEndTime);
/**
* 查询节点带宽信息列表
@@ -77,4 +79,11 @@ public interface IEpsNodeBandwidthService
public int calculateAvg(EpsNodeBandwidth epsNodeBandwidth);
List<EpsNodeBandwidth> getAvgDetailMsg(Long id);
/**
* 图形分析
* @param epsNodeBandwidth
* @return
*/
Map graphicalAnalysis(EpsNodeBandwidth epsNodeBandwidth, String bandwidthType, ChronoUnit timeUnit);
}

View File

@@ -1,6 +1,7 @@
package com.ruoyi.system.service;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.domain.EpsNodeBandwidth;
import com.ruoyi.system.domain.InitialSwitchInfoDetails;
import java.util.List;
@@ -75,7 +76,16 @@ public interface IInitialSwitchInfoDetailsService
/**
* 重新计算交换机95带宽值
* @param id
* @param epsNodeBandwidth 95带宽值收益详情
* @param dailyStartTime 开始时间
* @param dailyEndTime 结束时间
*/
void recalculateSwitch95Bandwidth(Long id);
void recalculateSwitch95Bandwidth(EpsNodeBandwidth epsNodeBandwidth, String dailyStartTime, String dailyEndTime);
/**
* 获取交换机相关数据
* @param epsNodeBandwidth
* @return
*/
List<InitialSwitchInfoDetails> getRelevantSwitch(EpsNodeBandwidth epsNodeBandwidth, String dailyStartTime, String dailyEndTime);
}

View File

@@ -206,6 +206,41 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
processDeviceBandwidth(queryParam, dailyStartTime, dailyEndTime);
});
}
/**
* 重新计算服务器95带宽值
* @param epsNodeBandwidth 95带宽值收益详情
* @param dailyStartTime 开始时间
* @param dailyEndTime 结束时间
*/
@Override
public void recalculateServer95Bandwidth(EpsNodeBandwidth epsNodeBandwidth, String dailyStartTime, String dailyEndTime) {
EpsInitialTrafficData epsInitialTrafficData = new EpsInitialTrafficData();
epsInitialTrafficData.setStartTime(dailyStartTime);
epsInitialTrafficData.setEndTime(dailyEndTime);
epsInitialTrafficData.setServiceSn(epsNodeBandwidth.getHardwareSn());
epsInitialTrafficData.setNodeName(epsNodeBandwidth.getNodeName());
epsInitialTrafficData.setBusinessName(epsNodeBandwidth.getBusinessName());
epsInitialTrafficData.setBusinessId(epsNodeBandwidth.getBusinessId());
List<EpsInitialTrafficData> dataList = query(epsInitialTrafficData);
if(!dataList.isEmpty()){
// 1. 提取并转换带宽值
List<BigDecimal> speedsInMbps = dataList.stream()
.map(data -> CalculateUtil.parseSpeedToMbps(data.getOutSpeed()))
.sorted()
.collect(Collectors.toList());
// 2. 计算95百分位
BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95);
// 3. 保存结果
EpsInitialTrafficData initialTrafficData = dataList.get(0);
initialTrafficData.setResourceType("1");
initialTrafficData.setBandwidthType(epsNodeBandwidth.getBandwidthType());
saveBandwidthResult(initialTrafficData, percentile95, dailyStartTime);
}
}
/**
* 处理单个设备的带宽计算
*/
@@ -285,11 +320,16 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
// 3. 保存结果
EpsInitialTrafficData epsInitialTrafficData = dataList.get(0);
epsInitialTrafficData.setResourceType("1");
if("1".equals(dayOrMonth)){
epsInitialTrafficData.setBandwidthType("1");
}
if("2".equals(dayOrMonth)){
epsInitialTrafficData.setBandwidthType("2");
if("2".equals(epsInitialTrafficData.getRevenueMethod())){
percentile95 = epsInitialTrafficData.getPackageBandwidth();
epsInitialTrafficData.setBandwidthType("3");
}else {
if("1".equals(dayOrMonth)){
epsInitialTrafficData.setBandwidthType("1");
}
if("2".equals(dayOrMonth)){
epsInitialTrafficData.setBandwidthType("2");
}
}
saveBandwidthResult(epsInitialTrafficData, percentile95, dateTime);
}
@@ -356,11 +396,16 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
// 服务器信息
EpsInitialTrafficData epsInitialTrafficData = dataList.get(0);
epsInitialTrafficData.setResourceType("1");
if("1".equals(dayOrMonth)){
epsInitialTrafficData.setBandwidthType("5");
}
if("2".equals(dayOrMonth)){
epsInitialTrafficData.setBandwidthType("6");
if("2".equals(epsInitialTrafficData.getRevenueMethod())){
dailyResult = epsInitialTrafficData.getPackageBandwidth();
epsInitialTrafficData.setBandwidthType("3");
}else{
if("1".equals(dayOrMonth)){
epsInitialTrafficData.setBandwidthType("5");
}
if("2".equals(dayOrMonth)){
epsInitialTrafficData.setBandwidthType("6");
}
}
saveBandwidthResult(epsInitialTrafficData, dailyResult, startTime);
}

View File

@@ -8,7 +8,7 @@ import com.ruoyi.system.mapper.EpsNodeBandwidthMapper;
import com.ruoyi.system.mapper.EpsServerRevenueConfigMapper;
import com.ruoyi.system.service.EpsInitialTrafficDataService;
import com.ruoyi.system.service.IEpsNodeBandwidthService;
import com.ruoyi.system.util.DateUtil;
import com.ruoyi.system.util.EchartsDataConverter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -18,12 +18,10 @@ import org.webjars.NotFoundException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Optional;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
/**
* 节点带宽信息Service业务层处理
@@ -57,26 +55,18 @@ public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService
/**
* 查询节点带宽信息
*
* @param id 节点带宽信息主键
* @param epsNodeBandwidth 节点带宽信息
* @return 节点带宽信息
*/
@Override
public List<EpsInitialTrafficData> relatedData(Long id) {
// 1. 根据ID查询服务器信息
EpsNodeBandwidth epsNodeBandwidth = epsNodeBandwidthMapper.selectEpsNodeBandwidthById(id);
if (epsNodeBandwidth == null) {
throw new NotFoundException("未找到ID为" + id + "的服务器信息");
}
// 2. 设置查询条件
public List<EpsInitialTrafficData> relatedData(EpsNodeBandwidth epsNodeBandwidth,String dailyStartTime, String dailyEndTime) {
// 设置查询条件
EpsInitialTrafficData queryParams = new EpsInitialTrafficData();
queryParams.setServiceSn(epsNodeBandwidth.getHardwareSn());
// 3. 根据带宽类型设置时间范围
LocalDateTime createTime = DateUtil.dateToLocalDateTime(epsNodeBandwidth.getCreateTime());
setTimeRangeByBandwidthType(queryParams, epsNodeBandwidth.getBandwidthType(), createTime);
// 4. 查询并返回数据
queryParams.setBusinessId(epsNodeBandwidth.getBusinessId());
queryParams.setStartTime(dailyStartTime);
queryParams.setEndTime(dailyEndTime);
// 查询并返回数据
return epsInitialTrafficDataService.query(queryParams);
}
/**
@@ -262,30 +252,72 @@ public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService
}
return epsNodeBandwidthMapper.getAvgDetailMsg(epsNodeBandwidth);
}
@Override
public Map graphicalAnalysis(EpsNodeBandwidth epsNodeBandwidth, String bandwidthType, ChronoUnit timeUnit){
Map<String, Object> nodeData = new HashMap<>();
// 拿到列表
List<EpsNodeBandwidth> nodeBandwidthList = epsNodeBandwidthMapper.selectEpsNodeBandwidthList(epsNodeBandwidth);
Map<String, EpsNodeBandwidth> uniqueNodes = nodeBandwidthList.stream()
.collect(Collectors.toMap(
// Key生成策略根据条件动态构建复合键
item -> generateCompositeKey(item),
// Value转换创建简化对象
item -> createSimplifiedNode(item),
// 合并策略:保留第一个出现的记录
(existing, replacement) -> existing
));
uniqueNodes.values().forEach(node -> {
/**
* 根据带宽类型设置时间范围修复T分隔符问题
*/
private void setTimeRangeByBandwidthType(EpsInitialTrafficData data, String bandwidthType, LocalDateTime baseTime) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 基础信息
nodeData.put("nodeName", node.getNodeName());
nodeData.put("businessName", node.getBusinessName());
nodeData.put("switchName", node.getUplinkSwitch());
nodeData.put("interfaceName", node.getInterfaceName());
switch (bandwidthType) {
case "1":
case "3":
case "5": // 日带宽
data.setStartTime(baseTime.with(LocalTime.MIN).format(formatter)); // 00:00:00
data.setEndTime(baseTime.with(LocalTime.MAX).withNano(0).format(formatter)); // 23:59:59
break;
case "2":
case "4":
case "6":
case "7": // 月带宽
YearMonth month = YearMonth.from(baseTime);
data.setStartTime(month.atDay(1).atStartOfDay().format(formatter)); // 当月第一天 00:00:00
data.setEndTime(month.atEndOfMonth().atTime(23, 59, 59).format(formatter)); // 当月最后一天 23:59:59
break;
default:
throw new IllegalArgumentException("不支持的带宽类型: " + bandwidthType);
// 日带宽数据
nodeData.put("resultData", EchartsDataConverter.convertToLineChart(
nodeBandwidthList,
bandwidthType,
node.getBusinessName(),
epsNodeBandwidth.getStartTime(),
epsNodeBandwidth.getEndTime(),
timeUnit
));
});
return nodeData;
}
// 动态生成复合键
private String generateCompositeKey(EpsNodeBandwidth item) {
if ("2".equals(item.getResourceType()) && "2".equals(item.getInterfaceLinkDeviceType())) {
// 特殊条件忽略nodeName和businessName
return String.join("|",
item.getInterfaceName(),
item.getUplinkSwitch()
);
} else {
// 默认情况:使用完整字段
return String.join("|",
Objects.toString(item.getNodeName(), ""),
Objects.toString(item.getBusinessName(), ""),
item.getInterfaceName(),
item.getUplinkSwitch()
);
}
}
// 创建简化节点对象
private EpsNodeBandwidth createSimplifiedNode(EpsNodeBandwidth source) {
EpsNodeBandwidth simplified = new EpsNodeBandwidth();
simplified.setInterfaceName(source.getInterfaceName());
simplified.setUplinkSwitch(source.getUplinkSwitch());
// 仅当非特殊条件时复制这些字段
if (!("2".equals(source.getResourceType()) && "2".equals(source.getInterfaceLinkDeviceType()))) {
simplified.setNodeName(source.getNodeName());
simplified.setBusinessName(source.getBusinessName());
}
return simplified;
}
}

View File

@@ -17,6 +17,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -183,6 +184,13 @@ public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfi
initialTrafficData.setRevenueMethod(nodeMsg.get("revenueMethod") + "");
initialTrafficData.setBusinessId(nodeMsg.get("businessCode") + "");
initialTrafficData.setBusinessName(nodeMsg.get("businessName") + "");
if("2".equals(String.valueOf(nodeMsg.get("revenueMethod")))
&& nodeMsg.containsKey("packageBandwidth")){
Object bandwidth = nodeMsg.get("packageBandwidth");
if (bandwidth instanceof BigDecimal) {
initialTrafficData.setPackageBandwidth((BigDecimal) bandwidth);
}
}
}
// id自增
initialTrafficData.setId(null);

View File

@@ -13,9 +13,6 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
@@ -284,24 +281,12 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
/**
* 重新计算交换机95带宽值
* @param id
* @param epsNodeBandwidth 95带宽值收益详情
* @param dailyStartTime 开始时间
* @param dailyEndTime 结束时间
*/
@Override
public void recalculateSwitch95Bandwidth(Long id) {
// 获取需要重新计算的信息
EpsNodeBandwidth epsNodeBandwidth = epsNodeBandwidthMapper.selectEpsNodeBandwidthById(id);
// 将Date转换为LocalDateTime
LocalDateTime createDateTime = epsNodeBandwidth.getCreateTime().toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDateTime();
// 获取当天的开始时间00:00:00
String dailyStartTime = createDateTime.with(LocalTime.MIN)
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
// 获取当天的结束时间23:59:59
String dailyEndTime = createDateTime.with(LocalTime.MAX)
.withNano(0) // 去除纳秒部分
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
public void recalculateSwitch95Bandwidth(EpsNodeBandwidth epsNodeBandwidth, String dailyStartTime, String dailyEndTime) {
InitialSwitchInfoDetails switchInfoDetails = new InitialSwitchInfoDetails();
switchInfoDetails.setStartTime(dailyStartTime);
switchInfoDetails.setEndTime(dailyEndTime);
@@ -314,31 +299,58 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
switchInfoDetails.setBusinessName(epsNodeBandwidth.getBusinessName());
List<InitialSwitchInfoDetails> dataList = initialSwitchInfoDetailsMapper
.selectInitialSwitchInfoDetailsList(switchInfoDetails);
// 1. 提取并转换带宽值
List<BigDecimal> speedsInMbps = dataList.stream()
.map(data -> {
// 根据 interfaceDeviceType 选择 inSpeed 或 outSpeed
String speed = ("1".equals(data.getInterfaceDeviceType())) ?
data.getInSpeed() + "" : data.getOutSpeed() + "";
// 如果 speed 是纯数字,补充单位 "B/S"Bytes/s
if (speed.matches("^\\d+(\\.\\d+)?$")) {
speed += " B/S";
}
return CalculateUtil.parseSpeedToMbps(speed);
})
.sorted()
.collect(Collectors.toList());
if(!dataList.isEmpty()){
// 1. 提取并转换带宽值
List<BigDecimal> speedsInMbps = dataList.stream()
.map(data -> {
// 根据 interfaceDeviceType 选择 inSpeed 或 outSpeed
String speed = ("1".equals(data.getInterfaceDeviceType())) ?
data.getInSpeed() + "" : data.getOutSpeed() + "";
// 如果 speed 是纯数字,补充单位 "B/S"Bytes/s
if (speed.matches("^\\d+(\\.\\d+)?$")) {
speed += " B/S";
}
return CalculateUtil.parseSpeedToMbps(speed);
})
.sorted()
.collect(Collectors.toList());
// 2. 计算95百分位
BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95);
// 2. 计算95百分位
BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95);
// 3. 保存结果
InitialSwitchInfoDetails switchInfo = dataList.get(0);
switchInfo.setResourceType("2");
switchInfo.setBandwidthType(epsNodeBandwidth.getBandwidthType());
saveSwitchBandwidthResult(switchInfo, percentile95, dailyStartTime);
// 3. 保存结果
InitialSwitchInfoDetails switchInfo = dataList.get(0);
switchInfo.setResourceType("2");
switchInfo.setBandwidthType(epsNodeBandwidth.getBandwidthType());
saveSwitchBandwidthResult(switchInfo, percentile95, dailyStartTime);
}
}
/**
* 交换机相关数据
* @param epsNodeBandwidth
* @param dailyStartTime
* @param dailyEndTime
* @return
*/
@Override
public List<InitialSwitchInfoDetails> getRelevantSwitch(EpsNodeBandwidth epsNodeBandwidth, String dailyStartTime, String dailyEndTime) {
InitialSwitchInfoDetails switchInfoDetails = new InitialSwitchInfoDetails();
switchInfoDetails.setStartTime(dailyStartTime);
switchInfoDetails.setEndTime(dailyEndTime);
switchInfoDetails.setSwitchSn(epsNodeBandwidth.getSwitchSn());
switchInfoDetails.setSwitchName(epsNodeBandwidth.getUplinkSwitch());
switchInfoDetails.setServerSn(epsNodeBandwidth.getHardwareSn());
switchInfoDetails.setInterfaceDeviceType(epsNodeBandwidth.getInterfaceLinkDeviceType());
switchInfoDetails.setName(epsNodeBandwidth.getInterfaceName());
switchInfoDetails.setBusinessCode(epsNodeBandwidth.getBusinessId());
switchInfoDetails.setBusinessName(epsNodeBandwidth.getBusinessName());
List<InitialSwitchInfoDetails> dataList = initialSwitchInfoDetailsMapper
.selectInitialSwitchInfoDetailsList(switchInfoDetails);
return dataList;
}
/**
* 处理单个交换机的带宽计算
*/

View File

@@ -68,4 +68,23 @@ public class CalculateUtil {
position = Math.max(0, Math.min(position, total - 1));
return sortedValues.get(position).setScale(2, RoundingMode.HALF_UP);
}
/**
* 根据带宽类型设置时间范围修复T分隔符问题
*/
public static String getTypeByBandwidthType(String bandwidthType) {
switch (bandwidthType) {
case "1":
case "3":
case "5": // 日带宽
return "1";
case "2":
case "4":
case "6":
case "7": // 月带宽
return "2";
default:
throw new IllegalArgumentException("不支持的带宽类型: " + bandwidthType);
}
}
}

View File

@@ -1,11 +1,58 @@
package com.ruoyi.system.util;
import java.time.LocalDateTime;
import java.time.ZoneId;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.system.domain.EpsNodeBandwidth;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.Date;
public class DateUtil {
private static final DateTimeFormatter FORMATTER =
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private static final ZoneId ZONE = ZoneId.of("Asia/Shanghai");
public static class TimeRange {
private String start;
private String end;
// 构造器
public TimeRange(String start, String end) {
this.start = start;
this.end = end;
}
// Getter
public String getStart() { return start; }
public String getEnd() { return end; }
}
/**
* 获取当天/当月日期
* @param createTime
* @param type
* @return
*/
public static TimeRange getTimeRange(Date createTime, String type) {
LocalDateTime baseTime = createTime.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDateTime();
if ("1".equals(type)) {
return new TimeRange(
baseTime.with(LocalTime.MIN).format(FORMATTER),
baseTime.with(LocalTime.MAX).withNano(0).format(FORMATTER)
);
} else {
YearMonth month = YearMonth.from(baseTime);
return new TimeRange(
month.atDay(1).atStartOfDay().format(FORMATTER),
month.atEndOfMonth().atTime(23, 59, 59).format(FORMATTER)
);
}
}
/**
* Date 类型 转为 LocalDateTime 类型
* @param date
@@ -16,4 +63,50 @@ public class DateUtil {
.atZone(ZoneId.systemDefault())
.toLocalDateTime();
}
public static void setTimeDay(EpsNodeBandwidth epsNodeBandwidth){
if(epsNodeBandwidth.getStartTime() == null || epsNodeBandwidth.getEndTime() == null) {
// 获取这个月第一天
LocalDate lastMonth = LocalDate.now(ZoneId.of("Asia/Shanghai")).minusMonths(0);
LocalDate firstDayOfMonth = lastMonth.withDayOfMonth(1);
LocalDate lastDayOfMonth = lastMonth.withDayOfMonth(lastMonth.lengthOfMonth());
String monthlyStartTime = firstDayOfMonth.atStartOfDay().format(FORMATTER);
String monthlyEndTime = lastDayOfMonth.atTime(23, 59, 59).format(FORMATTER);
epsNodeBandwidth.setStartTime(monthlyStartTime);
epsNodeBandwidth.setEndTime(monthlyEndTime);
}
// 获取时间类型 1--日, 2--月
String type = "1";
processTime(epsNodeBandwidth, type);
}
public static void setTimeMonth(EpsNodeBandwidth epsNodeBandwidth){
if(epsNodeBandwidth.getStartTime() == null || epsNodeBandwidth.getEndTime() == null) {
// 获取今年第一个月第一天
// 当年1月1日 00:00:00
LocalDateTime startOfYear = LocalDate.now(ZONE)
.withMonth(1)
.withDayOfMonth(1)
.atStartOfDay();
// 上个月最后一天 23:59:59
LocalDateTime endOfLastMonth = LocalDate.now(ZONE)
.minusMonths(1)
.with(TemporalAdjusters.lastDayOfMonth())
.atTime(23, 59, 59);
epsNodeBandwidth.setStartTime(startOfYear.format(FORMATTER));
epsNodeBandwidth.setEndTime(endOfLastMonth.format(FORMATTER));
}
// 获取时间类型 1--日, 2--月
String type = "2";
processTime(epsNodeBandwidth, type);
}
public static void processTime(EpsNodeBandwidth epsNodeBandwidth, String type){
// 获取开始时间 结束时间
DateUtil.TimeRange startTimeRange = DateUtil.getTimeRange(DateUtils.parseDate(epsNodeBandwidth.getStartTime()),type);
DateUtil.TimeRange endTimeRange = DateUtil.getTimeRange(DateUtils.parseDate(epsNodeBandwidth.getEndTime()),type);
String startTime = startTimeRange.getStart();
String endTime = endTimeRange.getEnd();
epsNodeBandwidth.setStartTime(startTime);
epsNodeBandwidth.setEndTime(endTime);
}
}

View File

@@ -0,0 +1,104 @@
package com.ruoyi.system.util;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.system.domain.EpsNodeBandwidth;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
public class EchartsDataConverter {
/**
* 转换为ECharts折线图数据
* @param dataList 原始数据列表
* @return { lineXData: [], data: [] }
*/
public static Map<String, Object> convertToLineChart(
List<EpsNodeBandwidth> dataList,
String bandwidthType, String businessName, String startTime, String endTime, ChronoUnit timeUnit
) {
// 定义时间格式化器
SimpleDateFormat sdf = new SimpleDateFormat(
timeUnit == ChronoUnit.DAYS ? "yyyy-MM-dd" : "yyyy-MM"
);
// 2. 生成完整时间序列
List<Date> fullSeries = generateTimeSeries(DateUtils.parseDate(startTime), DateUtils.parseDate(endTime), timeUnit);
// 过滤+排序
List<EpsNodeBandwidth> validList = dataList.stream()
.filter(item ->
item.getCreateTime() != null &&
item.getBandwidthResult() != null &&
(bandwidthType == null || bandwidthType.equals(item.getBandwidthType())) &&
(businessName == null || businessName.equals(item.getBusinessName()))
)
.sorted(Comparator.comparing(EpsNodeBandwidth::getCreateTime))
.collect(Collectors.toList());
// 3. 创建数据映射
Map<Date, BigDecimal> dataMap = createDataMap(validList);
// 4. 补全数据
List<String> xData = new ArrayList<>();
List<BigDecimal> yData = new ArrayList<>();
for (Date time : fullSeries) {
xData.add(sdf.format(time));
yData.add(dataMap.getOrDefault(time, BigDecimal.ZERO));
}
Map map = new HashMap();
map.put("lineXData", xData);
map.put("data", yData);
return map;
}
private static List<Date> generateTimeSeries(Date start, Date end, ChronoUnit unit) {
List<Date> series = new ArrayList<>();
Calendar cal = Calendar.getInstance();
cal.setTime(start);
// 重置到时间单位起始点
switch (unit) {
case DAYS:
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
break;
case MONTHS:
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
break;
default:
throw new IllegalArgumentException("仅支持 DAYS 或 MONTHS 单位");
}
// 生成序列
while (!cal.getTime().after(end)) {
series.add(cal.getTime());
switch (unit) {
case DAYS:
cal.add(Calendar.DATE, 1); // 按天递增
break;
case MONTHS:
cal.add(Calendar.MONTH, 1); // 按月递增
break;
}
}
return series;
}
private static Map<Date, BigDecimal> createDataMap(List<EpsNodeBandwidth> dataList) {
return dataList.stream()
.collect(Collectors.toMap(
EpsNodeBandwidth::getCreateTime,
EpsNodeBandwidth::getBandwidthResult,
(v1, v2) -> v1 // 如果参数冲突 保留有值的 补充x轴
));
}
}

View File

@@ -14,8 +14,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ipV4 VARCHAR(20) COMMENT 'IPv4地址',
`in_dropped` DECIMAL(5,2) COMMENT '入站丢包率(%)',
`out_dropped` DECIMAL(5,2) COMMENT '出站丢包率(%)',
`in_speed` varchar(20) COMMENT '接收带宽(Mbps)',
`out_speed` varchar(20) COMMENT '发送带宽(Mbps)',
`in_speed` varchar(50) COMMENT '接收带宽(Mbps)',
`out_speed` varchar(50) COMMENT '发送带宽(Mbps)',
`speed` varchar(100) COMMENT '协商速度',
`duplex` varchar(100) COMMENT '工作模式',
business_id varchar(50) COMMENT '业务代码',
business_name varchar(200) COMMENT '业务名称',
service_sn varchar(64) COMMENT '服务器SN',
@@ -45,6 +47,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
`out_dropped` DECIMAL(5,2) COMMENT '出站丢包率(%)',
`in_speed` VARCHAR(20) COMMENT '接收带宽(Mbps)',
`out_speed` VARCHAR(20) COMMENT '发送带宽(Mbps)',
`speed` varchar(100) COMMENT '协商速度',
`duplex` varchar(100) COMMENT '工作模式',
create_time DATETIME COMMENT '创建时间',
update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
create_by VARCHAR(50) COMMENT '创建人',
@@ -66,6 +70,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
`out_dropped`,
`in_speed`,
`out_speed`,
`speed`,
`duplex`,
business_id,
business_name,
service_sn,
@@ -85,6 +91,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{outDropped},
#{inSpeed},
#{outSpeed},
#{speed},
#{duplex},
#{businessId},
#{businessName},
#{serviceSn},
@@ -110,6 +118,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
`out_dropped`,
`in_speed`,
`out_speed`,
`speed`,
`duplex`,
business_id,
business_name,
service_sn,
@@ -134,6 +144,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{data.outDropped,jdbcType=DECIMAL},
#{data.inSpeed,jdbcType=VARCHAR},
#{data.outSpeed,jdbcType=VARCHAR},
#{data.speed,jdbcType=VARCHAR},
#{data.duplex,jdbcType=VARCHAR},
#{data.businessId,jdbcType=VARCHAR},
#{data.businessName,jdbcType=VARCHAR},
#{data.serviceSn,jdbcType=VARCHAR},
@@ -162,6 +174,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
`out_dropped` AS outDropped,
`in_speed` AS inSpeed,
`out_speed` AS outSpeed,
`speed` AS speed,
`duplex` AS duplex,
business_id AS businessId,
business_name AS businessName,
service_sn AS serviceSn,
@@ -205,6 +219,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
`out_dropped` AS outDropped,
`in_speed` AS inSpeed,
`out_speed` AS outSpeed,
`speed` AS speed,
`duplex` AS duplex,
create_time AS createTime,
update_time AS updateTime,
create_by AS createBy,

View File

@@ -31,10 +31,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="effectiveAvgMonthlyBandwidth95" column="effective_avg_monthly_bandwidth_95" />
<result property="businessName" column="business_name" />
<result property="businessId" column="business_id" />
<result property="remark1" column="remark1" />
</resultMap>
<sql id="selectEpsNodeBandwidthVo">
select id, node_name, hardware_sn, bandwidth_type, bandwidth_result, bandwidth_95_daily, bandwidth_95_monthly, avg_monthly_bandwidth_95, package_bandwidth_daily, customer_id, customer_name, service_number, uplink_switch, create_time, update_time, creator_id, creator_name, switch_sn, interface_name, resource_type, interface_link_device_type, effective_bandwidth_95_daily, effective_bandwidth_95_monthly, effective_avg_monthly_bandwidth_95, business_name, business_id from eps_node_bandwidth
select id, node_name, hardware_sn, bandwidth_type, bandwidth_result, bandwidth_95_daily, bandwidth_95_monthly, avg_monthly_bandwidth_95, package_bandwidth_daily, customer_id, customer_name, service_number, uplink_switch, create_time, update_time, creator_id, creator_name, switch_sn, interface_name, resource_type, interface_link_device_type, effective_bandwidth_95_daily, effective_bandwidth_95_monthly, effective_avg_monthly_bandwidth_95, business_name, business_id, remark1 from eps_node_bandwidth
</sql>
<select id="selectEpsNodeBandwidthList" parameterType="EpsNodeBandwidth" resultMap="EpsNodeBandwidthResult">
@@ -55,7 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="creatorId != null "> and creator_id = #{creatorId}</if>
<if test="creatorName != null and creatorName != ''"> and creator_name like concat('%', #{creatorName}, '%')</if>
<if test="switchSn != null and switchSn != ''"> and switch_sn = #{switchSn}</if>
<if test="interfaceName != null and interfaceName != ''"> and interface_name = #{interfaceName}</if>
<if test="interfaceName != null and interfaceName != ''"> and interface_name like concat('%', #{interfaceName}, '%')</if>
<if test="resourceType != null and resourceType != ''"> and resource_type = #{resourceType}</if>
<if test="interfaceLinkDeviceType != null and interfaceLinkDeviceType != ''"> and interface_link_device_type = #{interfaceLinkDeviceType}</if>
<if test="effectiveBandwidth95Daily != null "> and effective_bandwidth_95_daily = #{effectiveBandwidth95Daily}</if>
@@ -63,8 +64,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="effectiveAvgMonthlyBandwidth95 != null "> and effective_avg_monthly_bandwidth_95 = #{effectiveAvgMonthlyBandwidth95}</if>
<if test="businessName != null and businessName != ''"> and business_name like concat('%', #{businessName}, '%')</if>
<if test="businessId != null and businessId != ''"> and business_id = #{businessId}</if>
<if test="remark1 != null and remark1 != ''"> and remark1 = #{remark1}</if>
<if test="startTime != null and startTime != ''"> and create_time &gt;= #{startTime}</if>
<if test="endTime != null and endTime != ''"> and create_time &lt;= #{endTime}</if>
<if test="nodeNames != null and nodeNames.size() > 0">
AND node_name IN
<foreach collection="nodeNames" item="name" open="(" separator="," close=")">
#{name}
</foreach>
</if>
<if test="switchNames != null and switchNames.size() > 0">
AND uplink_switch IN
<foreach collection="switchNames" item="switchName" open="(" separator="," close=")">
#{switchName}
</foreach>
</if>
</where>
</select>
@@ -101,6 +115,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="effectiveAvgMonthlyBandwidth95 != null">effective_avg_monthly_bandwidth_95,</if>
<if test="businessName != null">business_name,</if>
<if test="businessId != null">business_id,</if>
<if test="remark1 != null">remark1,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="nodeName != null">#{nodeName},</if>
@@ -128,6 +143,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="effectiveAvgMonthlyBandwidth95 != null">#{effectiveAvgMonthlyBandwidth95},</if>
<if test="businessName != null">#{businessName},</if>
<if test="businessId != null">#{businessId},</if>
<if test="remark1 != null">#{remark1},</if>
</trim>
</insert>
@@ -159,6 +175,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="effectiveAvgMonthlyBandwidth95 != null">effective_avg_monthly_bandwidth_95 = #{effectiveAvgMonthlyBandwidth95},</if>
<if test="businessName != null">business_name = #{businessName},</if>
<if test="businessId != null">business_id = #{businessId},</if>
<if test="remark1 != null">remark1 = #{remark1},</if>
</trim>
where id = #{id}
</update>
@@ -215,6 +232,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">
and left(create_time,7) = left(#{createTime},7)
</if>
<if test="hardwareSn != '' and hardwareSn != null">
and hardware_sn = #{hardwareSn}
</if>
<if test="nodeName != '' and nodeName != null">
and node_name = #{nodeName}
</if>

View File

@@ -128,7 +128,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
rrr.resource_name AS resourceName,
esrc.revenue_method AS revenueMethod,
esrc.business_code AS businessCode,
esrc.business_name AS businessName
esrc.business_name AS businessName,
esrc.package_bandwidth AS packageBandwidth
FROM
rm_resource_registration rrr
LEFT JOIN

View File

@@ -4,174 +4,142 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.InitialSwitchInfoDetailsMapper">
<resultMap type="EpsNodeBandwidth" id="EpsNodeBandwidthResult">
<resultMap type="InitialSwitchInfoDetails" id="InitialSwitchInfoDetailsResult">
<result property="id" column="id" />
<result property="nodeName" column="node_name" />
<result property="hardwareSn" column="hardware_sn" />
<result property="bandwidthType" column="bandwidth_type" />
<result property="bandwidthResult" column="bandwidth_result" />
<result property="bandwidth95Daily" column="bandwidth_95_daily" />
<result property="bandwidth95Monthly" column="bandwidth_95_monthly" />
<result property="avgMonthlyBandwidth95" column="avg_monthly_bandwidth_95" />
<result property="packageBandwidthDaily" column="package_bandwidth_daily" />
<result property="customerId" column="customer_id" />
<result property="customerName" column="customer_name" />
<result property="serviceNumber" column="service_number" />
<result property="uplinkSwitch" column="uplink_switch" />
<result property="clientId" column="client_id" />
<result property="name" column="name" />
<result property="inBytes" column="in_bytes" />
<result property="outBytes" column="out_bytes" />
<result property="status" column="status" />
<result property="type" column="type" />
<result property="inSpeed" column="in_speed" />
<result property="outSpeed" column="out_speed" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="creatorId" column="creator_id" />
<result property="creatorName" column="creator_name" />
<result property="switchName" column="switch_name" />
<result property="interfaceDeviceType" column="interface_device_type" />
<result property="serverName" column="server_name" />
<result property="serverPort" column="server_port" />
<result property="serverSn" column="server_sn" />
<result property="switchSn" column="switch_sn" />
<result property="interfaceName" column="interface_name" />
<result property="resourceType" column="resource_type" />
<result property="interfaceLinkDeviceType" column="interface_link_device_type" />
<result property="effectiveBandwidth95Daily" column="effective_bandwidth_95_daily" />
<result property="effectiveBandwidth95Monthly" column="effective_bandwidth_95_monthly" />
<result property="effectiveAvgMonthlyBandwidth95" column="effective_avg_monthly_bandwidth_95" />
<result property="businessCode" column="business_code" />
<result property="businessName" column="business_name" />
<result property="businessId" column="business_id" />
<result property="remark1" column="remark1" />
</resultMap>
<sql id="selectEpsNodeBandwidthVo">
select id, node_name, hardware_sn, bandwidth_type, bandwidth_result, bandwidth_95_daily, bandwidth_95_monthly, avg_monthly_bandwidth_95, package_bandwidth_daily, customer_id, customer_name, service_number, uplink_switch, create_time, update_time, creator_id, creator_name, switch_sn, interface_name, resource_type, interface_link_device_type, effective_bandwidth_95_daily, effective_bandwidth_95_monthly, effective_avg_monthly_bandwidth_95, business_name, business_id, remark1 from eps_node_bandwidth
<sql id="selectInitialSwitchInfoDetailsVo">
select id, client_id, name, in_bytes, out_bytes, status, type, in_speed, out_speed, create_by, update_by, create_time, update_time, switch_name, interface_device_type, server_name, server_port, server_sn, switch_sn, business_code, business_name from initial_switch_info_details
</sql>
<select id="selectEpsNodeBandwidthList" parameterType="EpsNodeBandwidth" resultMap="EpsNodeBandwidthResult">
<include refid="selectEpsNodeBandwidthVo"/>
<select id="selectInitialSwitchInfoDetailsList" parameterType="InitialSwitchInfoDetails" resultMap="InitialSwitchInfoDetailsResult">
<include refid="selectInitialSwitchInfoDetailsVo"/>
<where>
<if test="nodeName != null and nodeName != ''"> and node_name like concat('%', #{nodeName}, '%')</if>
<if test="hardwareSn != null and hardwareSn != ''"> and hardware_sn = #{hardwareSn}</if>
<if test="bandwidthType != null and bandwidthType != ''"> and bandwidth_type = #{bandwidthType}</if>
<if test="bandwidthResult != null "> and bandwidth_result = #{bandwidthResult}</if>
<if test="bandwidth95Daily != null "> and bandwidth_95_daily = #{bandwidth95Daily}</if>
<if test="bandwidth95Monthly != null "> and bandwidth_95_monthly = #{bandwidth95Monthly}</if>
<if test="avgMonthlyBandwidth95 != null "> and avg_monthly_bandwidth_95 = #{avgMonthlyBandwidth95}</if>
<if test="packageBandwidthDaily != null "> and package_bandwidth_daily = #{packageBandwidthDaily}</if>
<if test="customerId != null and customerId != ''"> and customer_id = #{customerId}</if>
<if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
<if test="serviceNumber != null and serviceNumber != ''"> and service_number = #{serviceNumber}</if>
<if test="uplinkSwitch != null and uplinkSwitch != ''"> and uplink_switch like concat('%', #{uplinkSwitch}, '%')</if>
<if test="creatorId != null "> and creator_id = #{creatorId}</if>
<if test="creatorName != null and creatorName != ''"> and creator_name like concat('%', #{creatorName}, '%')</if>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="inBytes != null "> and in_bytes = #{inBytes}</if>
<if test="outBytes != null "> and out_bytes = #{outBytes}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="inSpeed != null "> and in_speed = #{inSpeed}</if>
<if test="outSpeed != null "> and out_speed = #{outSpeed}</if>
<if test="switchName != null and switchName != ''"> and switch_name like concat('%', #{switchName}, '%')</if>
<if test="interfaceDeviceType != null and interfaceDeviceType != ''"> and interface_device_type = #{interfaceDeviceType}</if>
<if test="serverName != null and serverName != ''"> and server_name like concat('%', #{serverName}, '%')</if>
<if test="serverPort != null and serverPort != ''"> and server_port = #{serverPort}</if>
<if test="serverSn != null and serverSn != ''"> and server_sn = #{serverSn}</if>
<if test="switchSn != null and switchSn != ''"> and switch_sn = #{switchSn}</if>
<if test="interfaceName != null and interfaceName != ''"> and interface_name like concat('%', #{interfaceName}, '%')</if>
<if test="resourceType != null and resourceType != ''"> and resource_type = #{resourceType}</if>
<if test="interfaceLinkDeviceType != null and interfaceLinkDeviceType != ''"> and interface_link_device_type = #{interfaceLinkDeviceType}</if>
<if test="effectiveBandwidth95Daily != null "> and effective_bandwidth_95_daily = #{effectiveBandwidth95Daily}</if>
<if test="effectiveBandwidth95Monthly != null "> and effective_bandwidth_95_monthly = #{effectiveBandwidth95Monthly}</if>
<if test="effectiveAvgMonthlyBandwidth95 != null "> and effective_avg_monthly_bandwidth_95 = #{effectiveAvgMonthlyBandwidth95}</if>
<if test="businessCode != null and businessCode != ''"> and business_code = #{businessCode}</if>
<if test="businessName != null and businessName != ''"> and business_name like concat('%', #{businessName}, '%')</if>
<if test="businessId != null and businessId != ''"> and business_id = #{businessId}</if>
<if test="remark1 != null and remark1 != ''"> and remark1 = #{remark1}</if>
</where>
</select>
<select id="selectEpsNodeBandwidthById" parameterType="Long" resultMap="EpsNodeBandwidthResult">
<include refid="selectEpsNodeBandwidthVo"/>
<select id="selectInitialSwitchInfoDetailsById" parameterType="Long" resultMap="InitialSwitchInfoDetailsResult">
<include refid="selectInitialSwitchInfoDetailsVo"/>
where id = #{id}
</select>
<insert id="insertEpsNodeBandwidth" parameterType="EpsNodeBandwidth" useGeneratedKeys="true" keyProperty="id">
insert into eps_node_bandwidth
<insert id="insertInitialSwitchInfoDetails" parameterType="InitialSwitchInfoDetails" useGeneratedKeys="true" keyProperty="id">
insert into initial_switch_info_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="nodeName != null">node_name,</if>
<if test="hardwareSn != null">hardware_sn,</if>
<if test="bandwidthType != null">bandwidth_type,</if>
<if test="bandwidthResult != null">bandwidth_result,</if>
<if test="bandwidth95Daily != null">bandwidth_95_daily,</if>
<if test="bandwidth95Monthly != null">bandwidth_95_monthly,</if>
<if test="avgMonthlyBandwidth95 != null">avg_monthly_bandwidth_95,</if>
<if test="packageBandwidthDaily != null">package_bandwidth_daily,</if>
<if test="customerId != null">customer_id,</if>
<if test="customerName != null">customer_name,</if>
<if test="serviceNumber != null">service_number,</if>
<if test="uplinkSwitch != null">uplink_switch,</if>
<if test="clientId != null and clientId != ''">client_id,</if>
<if test="name != null and name != ''">name,</if>
<if test="inBytes != null">in_bytes,</if>
<if test="outBytes != null">out_bytes,</if>
<if test="status != null">status,</if>
<if test="type != null">type,</if>
<if test="inSpeed != null">in_speed,</if>
<if test="outSpeed != null">out_speed,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="creatorId != null">creator_id,</if>
<if test="creatorName != null">creator_name,</if>
<if test="switchName != null">switch_name,</if>
<if test="interfaceDeviceType != null">interface_device_type,</if>
<if test="serverName != null">server_name,</if>
<if test="serverPort != null">server_port,</if>
<if test="serverSn != null">server_sn,</if>
<if test="switchSn != null">switch_sn,</if>
<if test="interfaceName != null">interface_name,</if>
<if test="resourceType != null">resource_type,</if>
<if test="interfaceLinkDeviceType != null">interface_link_device_type,</if>
<if test="effectiveBandwidth95Daily != null">effective_bandwidth_95_daily,</if>
<if test="effectiveBandwidth95Monthly != null">effective_bandwidth_95_monthly,</if>
<if test="effectiveAvgMonthlyBandwidth95 != null">effective_avg_monthly_bandwidth_95,</if>
<if test="businessCode != null">business_code,</if>
<if test="businessName != null">business_name,</if>
<if test="businessId != null">business_id,</if>
<if test="remark1 != null">remark1,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="nodeName != null">#{nodeName},</if>
<if test="hardwareSn != null">#{hardwareSn},</if>
<if test="bandwidthType != null">#{bandwidthType},</if>
<if test="bandwidthResult != null">#{bandwidthResult},</if>
<if test="bandwidth95Daily != null">#{bandwidth95Daily},</if>
<if test="bandwidth95Monthly != null">#{bandwidth95Monthly},</if>
<if test="avgMonthlyBandwidth95 != null">#{avgMonthlyBandwidth95},</if>
<if test="packageBandwidthDaily != null">#{packageBandwidthDaily},</if>
<if test="customerId != null">#{customerId},</if>
<if test="customerName != null">#{customerName},</if>
<if test="serviceNumber != null">#{serviceNumber},</if>
<if test="uplinkSwitch != null">#{uplinkSwitch},</if>
<if test="clientId != null and clientId != ''">#{clientId},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="inBytes != null">#{inBytes},</if>
<if test="outBytes != null">#{outBytes},</if>
<if test="status != null">#{status},</if>
<if test="type != null">#{type},</if>
<if test="inSpeed != null">#{inSpeed},</if>
<if test="outSpeed != null">#{outSpeed},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="creatorId != null">#{creatorId},</if>
<if test="creatorName != null">#{creatorName},</if>
<if test="switchName != null">#{switchName},</if>
<if test="interfaceDeviceType != null">#{interfaceDeviceType},</if>
<if test="serverName != null">#{serverName},</if>
<if test="serverPort != null">#{serverPort},</if>
<if test="serverSn != null">#{serverSn},</if>
<if test="switchSn != null">#{switchSn},</if>
<if test="interfaceName != null">#{interfaceName},</if>
<if test="resourceType != null">#{resourceType},</if>
<if test="interfaceLinkDeviceType != null">#{interfaceLinkDeviceType},</if>
<if test="effectiveBandwidth95Daily != null">#{effectiveBandwidth95Daily},</if>
<if test="effectiveBandwidth95Monthly != null">#{effectiveBandwidth95Monthly},</if>
<if test="effectiveAvgMonthlyBandwidth95 != null">#{effectiveAvgMonthlyBandwidth95},</if>
<if test="businessCode != null">#{businessCode},</if>
<if test="businessName != null">#{businessName},</if>
<if test="businessId != null">#{businessId},</if>
<if test="remark1 != null">#{remark1},</if>
</trim>
</insert>
<update id="updateEpsNodeBandwidth" parameterType="EpsNodeBandwidth">
update eps_node_bandwidth
<update id="updateInitialSwitchInfoDetails" parameterType="InitialSwitchInfoDetails">
update initial_switch_info_details
<trim prefix="SET" suffixOverrides=",">
<if test="nodeName != null">node_name = #{nodeName},</if>
<if test="hardwareSn != null">hardware_sn = #{hardwareSn},</if>
<if test="bandwidthType != null">bandwidth_type = #{bandwidthType},</if>
<if test="bandwidthResult != null">bandwidth_result = #{bandwidthResult},</if>
<if test="bandwidth95Daily != null">bandwidth_95_daily = #{bandwidth95Daily},</if>
<if test="bandwidth95Monthly != null">bandwidth_95_monthly = #{bandwidth95Monthly},</if>
<if test="avgMonthlyBandwidth95 != null">avg_monthly_bandwidth_95 = #{avgMonthlyBandwidth95},</if>
<if test="packageBandwidthDaily != null">package_bandwidth_daily = #{packageBandwidthDaily},</if>
<if test="customerId != null">customer_id = #{customerId},</if>
<if test="customerName != null">customer_name = #{customerName},</if>
<if test="serviceNumber != null">service_number = #{serviceNumber},</if>
<if test="uplinkSwitch != null">uplink_switch = #{uplinkSwitch},</if>
<if test="clientId != null and clientId != ''">client_id = #{clientId},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="inBytes != null">in_bytes = #{inBytes},</if>
<if test="outBytes != null">out_bytes = #{outBytes},</if>
<if test="status != null">status = #{status},</if>
<if test="type != null">type = #{type},</if>
<if test="inSpeed != null">in_speed = #{inSpeed},</if>
<if test="outSpeed != null">out_speed = #{outSpeed},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="creatorId != null">creator_id = #{creatorId},</if>
<if test="creatorName != null">creator_name = #{creatorName},</if>
<if test="switchName != null">switch_name = #{switchName},</if>
<if test="interfaceDeviceType != null">interface_device_type = #{interfaceDeviceType},</if>
<if test="serverName != null">server_name = #{serverName},</if>
<if test="serverPort != null">server_port = #{serverPort},</if>
<if test="serverSn != null">server_sn = #{serverSn},</if>
<if test="switchSn != null">switch_sn = #{switchSn},</if>
<if test="interfaceName != null">interface_name = #{interfaceName},</if>
<if test="resourceType != null">resource_type = #{resourceType},</if>
<if test="interfaceLinkDeviceType != null">interface_link_device_type = #{interfaceLinkDeviceType},</if>
<if test="effectiveBandwidth95Daily != null">effective_bandwidth_95_daily = #{effectiveBandwidth95Daily},</if>
<if test="effectiveBandwidth95Monthly != null">effective_bandwidth_95_monthly = #{effectiveBandwidth95Monthly},</if>
<if test="effectiveAvgMonthlyBandwidth95 != null">effective_avg_monthly_bandwidth_95 = #{effectiveAvgMonthlyBandwidth95},</if>
<if test="businessCode != null">business_code = #{businessCode},</if>
<if test="businessName != null">business_name = #{businessName},</if>
<if test="businessId != null">business_id = #{businessId},</if>
<if test="remark1 != null">remark1 = #{remark1},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEpsNodeBandwidthById" parameterType="Long">
delete from eps_node_bandwidth where id = #{id}
<delete id="deleteInitialSwitchInfoDetailsById" parameterType="Long">
delete from initial_switch_info_details where id = #{id}
</delete>
<delete id="deleteEpsNodeBandwidthByIds" parameterType="String">
delete from eps_node_bandwidth where id in
<delete id="deleteInitialSwitchInfoDetailsByIds" parameterType="String">
delete from initial_switch_info_details where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>

View File

@@ -64,5 +64,9 @@ public class InitialBandwidthTraffic extends BaseEntity
private String clientId;
/** 初始带宽流量集合 */
private List<InitialBandwidthTraffic> list;
/** 工作模式 */
private String duplex;
/** 协商速度 */
private String speed;
}