优化实时95值计算功能、服务器收益功能、用户自定义列展示、交换机基础数据采集

This commit is contained in:
gaoyutao
2025-10-31 21:46:17 +08:00
parent c0f057d7ed
commit 01c51b39fe
36 changed files with 964 additions and 452 deletions
@@ -1,6 +1,5 @@
package com.ruoyi.system.config;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.service.*;
import lombok.extern.slf4j.Slf4j;
@@ -73,7 +72,7 @@ public class TableScheduleConfig {
() -> initialSwitchInfoDetailsService.calculateSwitch95BandwidthDaily(initialSwitchInfoDetails, dailyStartTime, dailyEndTime, "1024")));
}
// 每天5点04执行 计算金山95带宽值/日
@Scheduled(cron = "0 4 5 * * ?", zone = "Asia/Shanghai")
// @Scheduled(cron = "0 4 5 * * ?", zone = "Asia/Shanghai")
public void calculateJinShan95() {
// 获取昨天的日期范围(北京时间)
LocalDate yesterday = LocalDate.now(ZoneId.of("Asia/Shanghai")).minusDays(1);
@@ -188,96 +187,87 @@ public class TableScheduleConfig {
* 处理单个服务器的平均带宽计算
*/
private void processServerAvgBandwidth(EpsNodeBandwidth epsNodeBandwidth, AllInterfaceName allInterfaceName, String calculationMode) {
final String deviceSn = allInterfaceName.getDeviceSn();
final String clientId = allInterfaceName.getClientId();
try {
// 1. 设置基础设备信息
epsNodeBandwidth.setHardwareSn(deviceSn);
epsNodeBandwidth.setClientId(clientId);
// 查询业务变更记录
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
changeQuery.setClientId(clientId);
changeQuery.setStartTime(epsNodeBandwidth.getStartTime());
changeQuery.setEndTime(epsNodeBandwidth.getEndTime());
// 2. 查询服务器配置
EpsServerRevenueConfig queryConfig = new EpsServerRevenueConfig();
queryConfig.setHardwareSn(deviceSn);
List<EpsServerRevenueConfig> configList = epsServerRevenueConfigService.selectEpsServerRevenueConfigList(queryConfig);
EpsServerRevenueConfig serverConfig = configList.isEmpty() ? new EpsServerRevenueConfig() : configList.get(0);
epsNodeBandwidth.setNodeName(serverConfig.getNodeName());
List<EpsMethodChangeRecord> records = epsMethodChangeRecordService.selectEpsMethodChangeRecordList(changeQuery);
// 3. 检查是否需要处理业务变更
boolean shouldProcessChange = serverConfig.getUpdateTime() != null
&& epsNodeBandwidth.getStartTime() != null
&& epsNodeBandwidth.getStartTime().length() >= 10
&& "1".equals(serverConfig.getChanged())
&& DateUtils.parseDateToStr("yyyy-MM", serverConfig.getUpdateTime())
.equals(epsNodeBandwidth.getStartTime().substring(0, 7));
// 按businessCode分组处理(修复null key问题)
if (!records.isEmpty()) {
Map<String, List<EpsMethodChangeRecord>> groupedRecords = records.stream()
.filter(record -> record.getBusinessCode() != null) // 过滤掉businessCode为null的记录
.collect(Collectors.groupingBy(EpsMethodChangeRecord::getBusinessCode));
// 4. 处理业务变更情况
if (shouldProcessChange) {
// 查询业务变更记录
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
changeQuery.setHardwareSn(deviceSn);
changeQuery.setStartTime(epsNodeBandwidth.getStartTime());
changeQuery.setEndTime(epsNodeBandwidth.getEndTime());
// 处理每个业务分组
for (Map.Entry<String, List<EpsMethodChangeRecord>> entry : groupedRecords.entrySet()) {
String businessCode = entry.getKey();
// 取第一个有效业务名称(同businessCode的业务名称应该相同)
String businessName = entry.getValue().stream()
.filter(r -> r.getBusinessName() != null)
.findFirst()
.map(EpsMethodChangeRecord::getBusinessName)
.orElse("未知业务");
List<EpsMethodChangeRecord> records = epsMethodChangeRecordService.selectEpsMethodChangeRecordList(changeQuery);
// 创建业务带宽对象
EpsNodeBandwidth bandwidthWithBiz = new EpsNodeBandwidth();
bandwidthWithBiz.setClientId(clientId);
bandwidthWithBiz.setCalculationMode(calculationMode);
bandwidthWithBiz.setStartTime(epsNodeBandwidth.getStartTime());
bandwidthWithBiz.setEndTime(epsNodeBandwidth.getEndTime());
bandwidthWithBiz.setBusinessId(businessCode);
bandwidthWithBiz.setBusinessName(businessName);
bandwidthWithBiz.setResourceType("1");
// 按businessCode分组处理(修复null key问题)
if (!records.isEmpty()) {
Map<String, List<EpsMethodChangeRecord>> groupedRecords = records.stream()
.filter(record -> record.getBusinessCode() != null) // 过滤掉businessCode为null的记录
.collect(Collectors.groupingBy(EpsMethodChangeRecord::getBusinessCode));
// 处理每个业务分组
for (Map.Entry<String, List<EpsMethodChangeRecord>> entry : groupedRecords.entrySet()) {
String businessCode = entry.getKey();
// 取第一个有效业务名称(同businessCode的业务名称应该相同)
String businessName = entry.getValue().stream()
.filter(r -> r.getBusinessName() != null)
.findFirst()
.map(EpsMethodChangeRecord::getBusinessName)
.orElse("未知业务");
// 创建业务带宽对象
EpsNodeBandwidth bandwidthWithBiz = new EpsNodeBandwidth();
bandwidthWithBiz.setHardwareSn(deviceSn);
bandwidthWithBiz.setCalculationMode(calculationMode);
bandwidthWithBiz.setNodeName(serverConfig.getNodeName());
bandwidthWithBiz.setStartTime(epsNodeBandwidth.getStartTime());
bandwidthWithBiz.setEndTime(epsNodeBandwidth.getEndTime());
bandwidthWithBiz.setBusinessId(businessCode);
bandwidthWithBiz.setBusinessName(businessName);
bandwidthWithBiz.setResourceType("1");
// 执行计算
epsNodeBandwidthService.calculateAvg(bandwidthWithBiz);
}
// 处理businessCode为null的记录(如果有)
List<EpsMethodChangeRecord> nullBusinessRecords = records.stream()
.filter(record -> record.getBusinessCode() == null)
.collect(Collectors.toList());
if (!nullBusinessRecords.isEmpty()) {
log.warn("服务器 {} 有 {} 条记录的businessCode为null", deviceSn, nullBusinessRecords.size());
// 可以选择记录日志或进行其他处理
}
return; // 业务变更处理完成后直接返回
// 执行计算
epsNodeBandwidthService.calculateAvg(bandwidthWithBiz);
}
}
// 处理businessCode为null的记录(如果有)
List<EpsMethodChangeRecord> nullBusinessRecords = records.stream()
.filter(record -> record.getBusinessCode() == null)
.collect(Collectors.toList());
if (!nullBusinessRecords.isEmpty()) {
log.warn("服务器 {} 有 {} 条记录的businessCode为null", clientId, nullBusinessRecords.size());
// 可以选择记录日志或进行其他处理
}
return; // 业务变更处理完成后直接返回
}
String businessCode = null;
String businessName = null;
// 查询绑定的业务
EpsMethodChangeRecord queryParam = new EpsMethodChangeRecord();
queryParam.setClientId(clientId);
List<EpsMethodChangeRecord> recordList = epsMethodChangeRecordService.selectEpsMethodChangeRecordList(queryParam);
if(!recordList.isEmpty()){
EpsMethodChangeRecord record = recordList.stream()
.findFirst()
.orElse(null);
businessCode = record.getBusinessCode();
businessName = record.getBusinessName();
}
// 5. 处理正常情况(无业务变更或无需处理变更)
EpsNodeBandwidth normalBandwidth = new EpsNodeBandwidth();
normalBandwidth.setHardwareSn(deviceSn);
normalBandwidth.setClientId(clientId);
normalBandwidth.setCalculationMode(calculationMode);
normalBandwidth.setNodeName(serverConfig.getNodeName());
normalBandwidth.setStartTime(epsNodeBandwidth.getStartTime());
normalBandwidth.setEndTime(epsNodeBandwidth.getEndTime());
normalBandwidth.setBusinessId(serverConfig.getBusinessCode());
normalBandwidth.setBusinessName(serverConfig.getBusinessName());
normalBandwidth.setBusinessId(businessCode);
normalBandwidth.setBusinessName(businessName);
normalBandwidth.setResourceType("1");
epsNodeBandwidthService.calculateAvg(normalBandwidth);
} catch (Exception e) {
log.error("处理服务器 {} 平均带宽失败", deviceSn, e);
log.error("处理服务器 {} 平均带宽失败", clientId, e);
}
}
@@ -305,131 +295,128 @@ public class TableScheduleConfig {
* 处理单个交换机的平均带宽计算
*/
private void processSwitchAvgBandwidth(EpsNodeBandwidth epsNodeBandwidth, AllInterfaceName switchSnMsg, String calculationMode) {
final String switchSn = switchSnMsg.getSwitchSn();
final String clientId = switchSnMsg.getClientId();
try {
// 1. 查询交换机拓扑信息
RmEpsTopologyManagement managementQuery = new RmEpsTopologyManagement();
managementQuery.setSwitchSn(switchSn);
managementQuery.setClientId(clientId);
List<RmEpsTopologyManagement> topologyList = rmEpsTopologyManagementService.selectRmEpsTopologyManagementList(managementQuery);
if(!topologyList.isEmpty()){
for (RmEpsTopologyManagement topology : topologyList) {
epsNodeBandwidth.setClientId(clientId);
epsNodeBandwidth.setInterfaceName(topology.getInterfaceName());
// 2. 设置基础信息
RmEpsTopologyManagement topology = topologyList.isEmpty() ? new RmEpsTopologyManagement() : topologyList.get(0);
epsNodeBandwidth.setSwitchSn(switchSn);
epsNodeBandwidth.setInterfaceName(topology.getInterfaceName());
// 3. 判断连接设备类型
boolean isServerConnected = "1".equals(topology.getConnectedDeviceType());
// 3. 判断连接设备类型
boolean isServerConnected = "1".equals(topology.getConnectedDeviceType());
// 4. 处理服务器连接的情况
if (isServerConnected && topology.getServerClientId() != null) {
String serverClientId = topology.getServerClientId();
String serverSn = topology.getServerSn();
// 查询业务变更记录
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
changeQuery.setClientId(serverClientId);
changeQuery.setStartTime(epsNodeBandwidth.getStartTime());
changeQuery.setEndTime(epsNodeBandwidth.getEndTime());
List<EpsMethodChangeRecord> records = epsMethodChangeRecordService.selectEpsMethodChangeRecordList(changeQuery);
// 4. 处理服务器连接的情况
if (isServerConnected && topology.getServerSn() != null) {
String serverSn = topology.getServerSn();
epsNodeBandwidth.setHardwareSn(serverSn);
// 查询服务器配置
EpsServerRevenueConfig queryConfig = new EpsServerRevenueConfig();
queryConfig.setHardwareSn(serverSn);
List<EpsServerRevenueConfig> configList = epsServerRevenueConfigService.selectEpsServerRevenueConfigList(queryConfig);
EpsServerRevenueConfig serverConfig = configList.isEmpty() ? new EpsServerRevenueConfig() : configList.get(0);
epsNodeBandwidth.setNodeName(serverConfig.getNodeName());
// 按businessCode分组处理
if (!records.isEmpty()) {
Map<String, List<EpsMethodChangeRecord>> groupedRecords = records.stream()
.filter(record -> record.getBusinessCode() != null) // 过滤掉businessCode为null的记录
.collect(Collectors.groupingBy(EpsMethodChangeRecord::getBusinessCode));
// 检查是否需要处理业务变更
boolean shouldProcessChange = serverConfig.getUpdateTime() != null
&& epsNodeBandwidth.getStartTime() != null
&& epsNodeBandwidth.getStartTime().length() >= 10
&& "1".equals(serverConfig.getChanged())
&& DateUtils.parseDateToStr("yyyy-MM", serverConfig.getUpdateTime())
.equals(epsNodeBandwidth.getStartTime().substring(0, 7));
// 处理每个业务分组
for (Map.Entry<String, List<EpsMethodChangeRecord>> entry : groupedRecords.entrySet()) {
String businessCode = entry.getKey();
List<EpsMethodChangeRecord> businessRecords = entry.getValue();
if(shouldProcessChange){
// 查询业务变更记录
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
changeQuery.setHardwareSn(serverSn);
changeQuery.setStartTime(epsNodeBandwidth.getStartTime());
changeQuery.setEndTime(epsNodeBandwidth.getEndTime());
// 取第一个有效业务名称
String businessName = businessRecords.stream()
.filter(r -> r.getBusinessName() != null)
.findFirst()
.map(EpsMethodChangeRecord::getBusinessName)
.orElse("未知业务");
List<EpsMethodChangeRecord> records = epsMethodChangeRecordService.selectEpsMethodChangeRecordList(changeQuery);
// 创建业务带宽对象
EpsNodeBandwidth bandwidthWithBiz = new EpsNodeBandwidth();
bandwidthWithBiz.setClientId(clientId);
bandwidthWithBiz.setCalculationMode(calculationMode);
bandwidthWithBiz.setInterfaceName(topology.getInterfaceName());
bandwidthWithBiz.setHardwareSn(serverSn);
bandwidthWithBiz.setUplinkSwitch(topology.getSwitchName());
bandwidthWithBiz.setInterfaceLinkDeviceType(topology.getConnectedDeviceType());
bandwidthWithBiz.setStartTime(epsNodeBandwidth.getStartTime());
bandwidthWithBiz.setEndTime(epsNodeBandwidth.getEndTime());
bandwidthWithBiz.setBusinessId(businessCode);
bandwidthWithBiz.setBusinessName(businessName);
bandwidthWithBiz.setResourceType("2");
bandwidthWithBiz.setServerClientId(serverClientId);
// 执行计算
epsNodeBandwidthService.calculateAvg(bandwidthWithBiz);
}
// businessCode分组处理
if (!records.isEmpty()) {
Map<String, List<EpsMethodChangeRecord>> groupedRecords = records.stream()
.filter(record -> record.getBusinessCode() != null) // 过滤掉businessCode为null的记录
.collect(Collectors.groupingBy(EpsMethodChangeRecord::getBusinessCode));
// 处理businessCode为null的记录(如果有)
List<EpsMethodChangeRecord> nullBusinessRecords = records.stream()
.filter(record -> record.getBusinessCode() == null)
.collect(Collectors.toList());
// 处理每个业务分组
for (Map.Entry<String, List<EpsMethodChangeRecord>> entry : groupedRecords.entrySet()) {
String businessCode = entry.getKey();
List<EpsMethodChangeRecord> businessRecords = entry.getValue();
if (!nullBusinessRecords.isEmpty()) {
log.warn("交换机 {} 有 {} 条记录的businessCode为null", clientId, nullBusinessRecords.size());
// 可以选择记录日志或进行其他处理
}
// 取第一个有效业务名称
String businessName = businessRecords.stream()
.filter(r -> r.getBusinessName() != null)
.findFirst()
.map(EpsMethodChangeRecord::getBusinessName)
.orElse("未知业务");
// 创建业务带宽对象
EpsNodeBandwidth bandwidthWithBiz = new EpsNodeBandwidth();
bandwidthWithBiz.setSwitchSn(switchSn);
bandwidthWithBiz.setCalculationMode(calculationMode);
bandwidthWithBiz.setInterfaceName(topology.getInterfaceName());
bandwidthWithBiz.setHardwareSn(serverSn);
bandwidthWithBiz.setNodeName(topology.getServerName());
bandwidthWithBiz.setUplinkSwitch(topology.getSwitchName());
bandwidthWithBiz.setInterfaceLinkDeviceType(topology.getConnectedDeviceType());
bandwidthWithBiz.setStartTime(epsNodeBandwidth.getStartTime());
bandwidthWithBiz.setEndTime(epsNodeBandwidth.getEndTime());
bandwidthWithBiz.setBusinessId(businessCode);
bandwidthWithBiz.setBusinessName(businessName);
bandwidthWithBiz.setResourceType("2");
// 执行计算
epsNodeBandwidthService.calculateAvg(bandwidthWithBiz);
return; // 业务变更处理完成后直接返回
}else{
String businessCode = null;
String businessName = null;
// 查询绑定的业务
EpsMethodChangeRecord queryParam = new EpsMethodChangeRecord();
queryParam.setClientId(clientId);
queryParam.setTrafficPort(topology.getServerPort());
List<EpsMethodChangeRecord> recordList = epsMethodChangeRecordService.selectEpsMethodChangeRecordList(queryParam);
if(!recordList.isEmpty()){
EpsMethodChangeRecord record = recordList.stream()
.findFirst()
.orElse(null);
businessCode = record.getBusinessCode();
businessName = record.getBusinessName();
}
// 5. 处理普通情况(无变更记录)
EpsNodeBandwidth normalBandwidth = new EpsNodeBandwidth();
normalBandwidth.setClientId(clientId);
normalBandwidth.setBusinessId(businessCode);
normalBandwidth.setBusinessName(businessName);
normalBandwidth.setCalculationMode(calculationMode);
normalBandwidth.setInterfaceName(topology.getInterfaceName());
normalBandwidth.setHardwareSn(topology.getServerSn());
normalBandwidth.setUplinkSwitch(topology.getSwitchName());
normalBandwidth.setInterfaceLinkDeviceType(topology.getConnectedDeviceType());
normalBandwidth.setStartTime(epsNodeBandwidth.getStartTime());
normalBandwidth.setEndTime(epsNodeBandwidth.getEndTime());
normalBandwidth.setResourceType("2");
normalBandwidth.setServerClientId(serverClientId);
epsNodeBandwidthService.calculateAvg(normalBandwidth);
return;
}
// 处理businessCode为null的记录(如果有)
List<EpsMethodChangeRecord> nullBusinessRecords = records.stream()
.filter(record -> record.getBusinessCode() == null)
.collect(Collectors.toList());
if (!nullBusinessRecords.isEmpty()) {
log.warn("交换机 {} 有 {} 条记录的businessCode为null", switchSn, nullBusinessRecords.size());
// 可以选择记录日志或进行其他处理
}
return; // 业务变更处理完成后直接返回
}
}else{
// 5. 处理普通情况(无变更记录)
// 5. 处理机房出口情况
EpsNodeBandwidth normalBandwidth = new EpsNodeBandwidth();
normalBandwidth.setSwitchSn(switchSn);
normalBandwidth.setClientId(clientId);
normalBandwidth.setCalculationMode(calculationMode);
normalBandwidth.setInterfaceName(topology.getInterfaceName());
normalBandwidth.setHardwareSn(topology.getServerSn());
normalBandwidth.setNodeName(topology.getServerName());
normalBandwidth.setUplinkSwitch(topology.getSwitchName());
normalBandwidth.setInterfaceLinkDeviceType(topology.getConnectedDeviceType());
normalBandwidth.setStartTime(epsNodeBandwidth.getStartTime());
normalBandwidth.setEndTime(epsNodeBandwidth.getEndTime());
normalBandwidth.setBusinessId(serverConfig.getBusinessCode());
normalBandwidth.setBusinessName(serverConfig.getBusinessName());
normalBandwidth.setResourceType("2");
epsNodeBandwidthService.calculateAvg(normalBandwidth);
}
}else{
log.warn("未检测到拓扑配置,交换机clientId:{}", clientId);
}
// 5. 处理机房出口情况
EpsNodeBandwidth normalBandwidth = new EpsNodeBandwidth();
normalBandwidth.setSwitchSn(switchSn);
normalBandwidth.setCalculationMode(calculationMode);
normalBandwidth.setInterfaceName(topology.getInterfaceName());
normalBandwidth.setInterfaceLinkDeviceType(topology.getConnectedDeviceType());
normalBandwidth.setStartTime(epsNodeBandwidth.getStartTime());
normalBandwidth.setEndTime(epsNodeBandwidth.getEndTime());
normalBandwidth.setResourceType("2");
epsNodeBandwidthService.calculateAvg(normalBandwidth);
} catch (Exception e) {
log.error("处理交换机 {} 平均带宽失败", switchSn, e);
log.error("处理交换机 {} 平均带宽失败", clientId, e);
}
}
}
@@ -19,7 +19,7 @@ import java.util.Map;
* 提供流量数据的REST接口
*/
@RestController
@RequestMapping("/eps-traffic-data")
@RequestMapping("/epsTrafficData")
@RequiredArgsConstructor
public class EpsInitialTrafficDataController {
@@ -144,4 +144,17 @@ public class EpsTaskStatisticsController extends BaseController
Map echartsMap = epsTaskStatisticsService.getRraphicalMsg(epsTaskStatistics);
return success(echartsMap);
}
/**
* 获取月均日95值的日列表
* @param epsTaskStatistics
* @return
*/
@RequiresPermissions("system:taskStatistics:list")
@PostMapping("/getAvgTimeList")
public AjaxResult getAvgTimeList(@RequestBody EpsTaskStatistics epsTaskStatistics)
{
List<String> avgTimeList = epsTaskStatisticsService.getAvgTimeList(epsTaskStatistics);
return success(avgTimeList);
}
}
@@ -25,13 +25,14 @@ public class UserTableColumnConfigController extends BaseController
/**
* 获取用户自定义列配置详细信息
* 根据获取用户id获取自定义列配置详细信息
*/
@RequiresPermissions("system:columnConfig:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
@PostMapping(value = "/getColumnConfigByUserId")
public AjaxResult getColumnConfigByUserId(@RequestBody UserTableColumnConfig userTableColumnConfig)
{
return success(userTableColumnConfigService.selectUserTableColumnConfigById(id));
UserTableColumnConfig columnConfig = userTableColumnConfigService.getColumnConfigByUserId(userTableColumnConfig);
return success(columnConfig);
}
/**
@@ -39,31 +40,11 @@ public class UserTableColumnConfigController extends BaseController
*/
@RequiresPermissions("system:columnConfig:add")
@Log(title = "用户自定义列配置", businessType = BusinessType.INSERT)
@PostMapping
@PostMapping("addColumnConfig")
public AjaxResult add(@RequestBody UserTableColumnConfig userTableColumnConfig)
{
return toAjax(userTableColumnConfigService.insertUserTableColumnConfig(userTableColumnConfig));
}
/**
* 修改用户自定义列配置
*/
@RequiresPermissions("system:columnConfig:edit")
@Log(title = "用户自定义列配置", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody UserTableColumnConfig userTableColumnConfig)
{
return toAjax(userTableColumnConfigService.updateUserTableColumnConfig(userTableColumnConfig));
}
/**
* 删除用户自定义列配置
*/
@RequiresPermissions("system:columnConfig:remove")
@Log(title = "用户自定义列配置", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(userTableColumnConfigService.deleteUserTableColumnConfigByIds(ids));
}
}
@@ -75,8 +75,8 @@ public class AllInterfaceName extends BaseEntity
private String serverIp;
/** 交换机接口别名 */
private String otherName;
/** 前端需要 id 别名 */
private Long value;
/** 业务需要 拼接id 交换机clientId,交换机接口名称值 别名 */
private String value;
/** 前端需要 name 别名 */
private String label;
@@ -118,6 +118,8 @@ public class EpsInitialTrafficData extends BaseEntity {
private boolean flag95 = false;
/** 计算方式 */
private String calculationMode;
/** 95值 */
private BigDecimal percentile95;
}
@@ -74,29 +74,10 @@ public class EpsNodeBandwidth extends BaseEntity
/** 金山流量Mbps/日 */
private BigDecimal machineFlow;
/** 设备业务客户id */
@Excel(name = "设备业务客户id")
private String customerId;
/** 设备业务客户名称 */
@Excel(name = "设备业务客户名称")
private String customerName;
/** 业务号 */
@Excel(name = "业务号")
private String serviceNumber;
/** 上联交换机 */
@Excel(name = "上联交换机")
private String uplinkSwitch;
/** 创建人id */
@Excel(name = "创建人id")
private Long creatorId;
/** 创建人名称 */
@Excel(name = "创建人名称")
private String creatorName;
/** 交换机sn */
@Excel(name = "交换机sn")
@@ -129,19 +110,22 @@ public class EpsNodeBandwidth extends BaseEntity
private String endTime;
/** 月份 */
private String monthTime;
/** 备注 */
/** 交换机接口名称别名 */
private String remark1;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createDatetime;
/** 节点名称集合 */
private List<String> nodeNames;
/** 交换机名称集合 */
private List<String> switchNames;
/** 计算方式 */
private String calculationMode;
/** 客户端id */
private String clientId;
/** 交换机连接的服务器客户端id */
private String serverClientId;
}
@@ -118,4 +118,10 @@ public class InitialSwitchInfoDetails extends BaseEntity
public String interfaceNames;
/** 是否95值 */
private boolean flag95 = false;
/** 服务器客户端id */
private String serverClientId;
/** 交换机接口别名 */
private String interfaceNameRemark;
/** 95值 */
private BigDecimal percentile95;
}
@@ -23,10 +23,8 @@ public class UserTableColumnConfig extends BaseEntity
private Long userId;
/** 页面路由标识(例如:system:user:list, business:order:manage */
@Excel(name = "页面路由标识", readConverterExp = "例=如:system:user:list,,b=usiness:order:manage")
private String pageRoute;
/** 列配置(JSON数组格式) */
@Excel(name = "列配置", readConverterExp = "J=SON数组格式")
private String columnConfig;
}
@@ -62,11 +62,38 @@ public interface IEpsTaskStatisticsService
*/
public int deleteEpsTaskStatisticsById(Long id);
/**
* 获取相关数据
* @param epsTaskStatistics
* @return
*/
PageInfo<?> getRelateData(EpsTaskStatistics epsTaskStatistics);
/**
* 修改相关数据
* @param epsTaskStatistics
* @return
*/
int updateRelateData(EpsTaskStatistics epsTaskStatistics);
/**
* 重新计算
* @param epsTaskStatistics
* @return
*/
int recaculate(EpsTaskStatistics epsTaskStatistics);
/**
* 图形分析
* @param epsTaskStatistics
* @return
*/
Map getRraphicalMsg(EpsTaskStatistics epsTaskStatistics);
/**
* 获取月均日95值的日期
* @param epsTaskStatistics
* @return
*/
List<String> getAvgTimeList(EpsTaskStatistics epsTaskStatistics);
}
@@ -62,7 +62,6 @@ public interface IRmSwitchManagementService
/**
* 交换机信息树形结构
* @param rmSwitchManagement
* @return
*/
List<RmSwitchManagement> getAllSwitchNameTree();
@@ -1,8 +1,9 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.UserTableColumnConfig;
import java.util.List;
/**
* 用户自定义列配置Service接口
*
@@ -58,4 +59,10 @@ public interface IUserTableColumnConfigService
* @return 结果
*/
public int deleteUserTableColumnConfigById(Long id);
/**
* 根据用户id获取自定义列详情
* @return
*/
UserTableColumnConfig getColumnConfigByUserId(UserTableColumnConfig userTableColumnConfig);
}
@@ -199,7 +199,9 @@ public class EpsBusinessDeployServiceImpl implements IEpsBusinessDeployService
changeRecord.setBusinessCode(businessCode);
changeRecord.setBusinessName(businessName);
changeRecord.setCreateTime(DateUtils.getNowDate());
changeRecord.setUpdateTime(DateUtils.getNowDate());
changeRecord.setCreatBy(SecurityUtils.getUsername());
changeRecord.setUpdateBy(SecurityUtils.getUsername());
// 修改内容
String content = "流量网口设置为" + interfaceName + ",业务为" + businessName;
changeRecord.setChangeContent(content);
@@ -34,6 +34,7 @@ import java.util.stream.Collectors;
@Slf4j
public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataService {
private static final String DATE_TIME_FORMATTER = "yyyy-MM-dd HH:mm:ss";
@Autowired
private EpsInitialTrafficDataMapper epsInitialTrafficDataMapper;
@Autowired
@@ -46,6 +47,8 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
private EpsMethodChangeRecordMapper epsMethodChangeRecordMapper;
@Autowired
private EpsBusinessDeployMapper epsBusinessDeployMapper;
@Autowired
private RmEpsTopologyManagementMapper rmEpsTopologyManagementMapper;
@Override
public void createNextMonthTables() {
LocalDate nextMonth = LocalDate.now().plusMonths(1);
@@ -258,7 +261,6 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
// 遍历处理每个设备
snList.forEach(interfaceName -> {
queryParam.setClientId(interfaceName.getClientId());
queryParam.setName(interfaceName.getInterfaceName());
calculateChangedDeviceBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
});
}
@@ -447,6 +449,8 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
BeanUtils.copyProperties(queryParam, dailyQuery); // 复制原有属性
dailyQuery.setStartTime(dayStart);
dailyQuery.setEndTime(dayEnd);
// 时间范围
String timeRange = "" + dayStart + "" + dayEnd;
// 根据clientId查询已经配置的接口
String clientIds = queryParam.getClientIds();
@@ -454,9 +458,8 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
if(clientIdArr != null){
for (String clientId : clientIdArr) {
try {
dailyQuery.setClientIds(clientId);
Map<String, Object> resultMap = serverNetSpeedEcharts(dailyQuery);
// 查询95值
BigDecimal percentile95 = BigDecimal.ZERO;
EpsNodeBandwidth bandwidthQuery = new EpsNodeBandwidth();
bandwidthQuery.setBandwidthType("1");
bandwidthQuery.setCreateTime(DateUtils.parseDate(date));
@@ -466,8 +469,10 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
if(!epsNodeBandwidthList.isEmpty()){
EpsNodeBandwidth nodeBandwidth = epsNodeBandwidthList.get(0);
resultMap.put("95value", nodeBandwidth.getBandwidthResult());
percentile95 = nodeBandwidth.getBandwidthResult();
}
dailyQuery.setClientIds(clientId);
Map<String, Object> resultMap = serverNetSpeedEcharts(dailyQuery, percentile95);
// 查询业务信息
String businessName = null;
EpsBusinessDeploy businessQuery = new EpsBusinessDeploy();
@@ -488,6 +493,7 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
}
String name = joiner.toString();
resultMap.put("name", name);
resultMap.put("timeRange", timeRange);
resultList.add(resultMap);
} catch (Exception e){
e.printStackTrace();
@@ -523,15 +529,15 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
BeanUtils.copyProperties(queryParam, dailyQuery); // 复制原有属性
dailyQuery.setStartTime(monthStart);
dailyQuery.setEndTime(monthEnd);
String timeRange = "" + monthStart + "" + monthEnd;
// 根据clientId查询已经配置的接口
String clientIds = queryParam.getClientIds();
String[] clientIdArr = clientIds.split(",");
if(clientIdArr != null){
for (String clientId : clientIdArr) {
try {
dailyQuery.setClientIds(clientId);
Map<String, Object> resultMap = serverNetSpeedEcharts(dailyQuery);
// 查询95值
BigDecimal percentile95 = BigDecimal.ZERO;
EpsNodeBandwidth bandwidthQuery = new EpsNodeBandwidth();
bandwidthQuery.setBandwidthType("1");
bandwidthQuery.setCreateTime(DateUtils.parseDate(monthStart));
@@ -541,8 +547,10 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
if(!epsNodeBandwidthList.isEmpty()){
EpsNodeBandwidth nodeBandwidth = epsNodeBandwidthList.get(0);
resultMap.put("95value", nodeBandwidth.getBandwidthResult());
percentile95 = nodeBandwidth.getBandwidthResult();
}
dailyQuery.setClientIds(clientId);
Map<String, Object> resultMap = serverNetSpeedEcharts(dailyQuery, percentile95);
// 查询业务信息
String businessName = null;
EpsBusinessDeploy businessQuery = new EpsBusinessDeploy();
@@ -563,6 +571,7 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
}
String name = joiner.toString();
resultMap.put("name", name);
resultMap.put("timeRange", timeRange);
resultList.add(resultMap);
} catch (Exception e){
e.printStackTrace();
@@ -577,22 +586,34 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
* @param epsInitialTrafficData
* @return
*/
public Map<String, Object> serverNetSpeedEcharts(EpsInitialTrafficData epsInitialTrafficData) {
public Map<String, Object> serverNetSpeedEcharts(EpsInitialTrafficData epsInitialTrafficData, BigDecimal percentile95) {
List<EpsInitialTrafficData> list = getTrafficListByClientIds(epsInitialTrafficData);
try {
SpeedUtils.SpeedResult result = SpeedUtils.calculateWithStringTraffic(list, "inSpeed", "outSpeed");
BigDecimal divisor = SpeedUtils.getDivisor(result.getRecommendedUnit());
Map<String, Function<EpsInitialTrafficData, ?>> extractors = new LinkedHashMap<>();
if(!list.isEmpty()){
try {
list.forEach(data -> data.setPercentile95(SpeedUtils.mbitToBit(percentile95)));
SpeedUtils.SpeedResult result = SpeedUtils.calculateWithStringTraffic(list, "inSpeed", "outSpeed");
BigDecimal divisor = SpeedUtils.getDivisor(result.getRecommendedUnit());
Map<String, Function<EpsInitialTrafficData, ?>> extractors = new LinkedHashMap<>();
extractors.put("netOutSpeedData", info ->
info != null && info.getOutSpeed() != null ?
new BigDecimal(info.getOutSpeed()).divide(divisor, 0, RoundingMode.HALF_UP) :
0);
Map<String, Object> resultMap = EchartsDataUtils.buildEchartsData(list, EpsInitialTrafficData::getCreateTime, extractors);
resultMap.put("other", result);
return resultMap;
} catch (Exception e){
e.printStackTrace();
extractors.put("netOutSpeedData", info ->
info != null && info.getOutSpeed() != null ?
new BigDecimal(info.getOutSpeed()).divide(divisor, 0, RoundingMode.HALF_UP) :
0);
extractors.put("netMachineFlowData", info ->
info != null && info.getMachineFlow() != null ?
new BigDecimal(info.getMachineFlow()).divide(divisor, 0, RoundingMode.HALF_UP) :
0);
extractors.put("percentile95", info ->
info != null && info.getPercentile95() != null ?
info.getPercentile95().divide(divisor, 2, RoundingMode.HALF_UP) :
0);
Map<String, Object> resultMap = EchartsDataUtils.buildEchartsData(list, EpsInitialTrafficData::getCreateTime, extractors);
resultMap.put("other", result);
resultMap.put("95value", percentile95);
return resultMap;
} catch (Exception e){
e.printStackTrace();
}
}
return new HashMap<>();
}
@@ -628,7 +649,6 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
// 1. 获取业务变更记录(按时间降序)
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
changeQuery.setClientId(queryParam.getClientId());
changeQuery.setTrafficPort(queryParam.getName());
changeQuery.setStartTime(dailyStartTime);
changeQuery.setEndTime(dailyEndTime);
List<EpsMethodChangeRecord> records = epsMethodChangeRecordMapper
@@ -693,15 +713,15 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
String dailyStartTime,
String dailyEndTime, String calculationMode) {
// 1. 处理变更时间段(从最新到最早)
String endTime = records.get(0).getCreateTime() + "";
String endTime = DateUtils.parseDateToStr(DATE_TIME_FORMATTER, records.get(0).getCreateTime());
for (int i = 1; i < records.size(); i++) {
String startTime = records.get(i).getCreateTime() + "";
String startTime = DateUtils.parseDateToStr(DATE_TIME_FORMATTER, records.get(i).getCreateTime());
calculateSegment95(queryParam, startTime, endTime, calculationMode);
endTime = startTime; // 移动时间窗口
}
// 2. 处理最早变更前的时间段(昨天00:00:00 ~ 最早变更时间)
String earliestChangeTime = records.get(records.size()-1).getCreateTime() + "";
String earliestChangeTime = DateUtils.parseDateToStr(DATE_TIME_FORMATTER, records.get(records.size()-1).getCreateTime());
calculateSegment95(queryParam, dailyStartTime, earliestChangeTime, calculationMode);
// 3. 处理最后变更后的时间段(最新变更时间 ~ 昨天23:59:59)
@@ -764,9 +784,7 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
EpsNodeBandwidth bandwidth = new EpsNodeBandwidth();
bandwidth.setClientId(data.getClientId());
bandwidth.setHardwareSn(data.getServiceSn());
bandwidth.setInterfaceName(data.getName());
bandwidth.setCalculationMode(calculationMode);
bandwidth.setNodeName(data.getNodeName());
bandwidth.setBusinessId(data.getBusinessId());
bandwidth.setBusinessName(data.getBusinessName());
bandwidth.setResourceType(data.getResourceType());
@@ -803,6 +821,15 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
default:
throw new IllegalArgumentException("Unknown bandwidthType: " + data.getBandwidthType());
}
// 根据clientId查询交换机上联
RmEpsTopologyManagement topologQuery = new RmEpsTopologyManagement();
topologQuery.setServerClientId(data.getClientId());
List<RmEpsTopologyManagement> topologyList = rmEpsTopologyManagementMapper.selectRmEpsTopologyManagementList(topologQuery);
if(!topologyList.isEmpty()){
RmEpsTopologyManagement rmEpsTopologyManagement = topologyList.get(0);
bandwidth.setUplinkSwitch(rmEpsTopologyManagement.getSwitchName());
bandwidth.setInterfaceName(rmEpsTopologyManagement.getInterfaceName());
}
if(!exitsList.isEmpty()){
bandwidth.setUpdateTime(DateUtils.getNowDate());
bandwidth.setId(exitsList.get(0).getId());
@@ -5,9 +5,11 @@ import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.web.page.PageDomain;
import com.ruoyi.system.domain.EpsInitialTrafficData;
import com.ruoyi.system.domain.EpsNodeBandwidth;
import com.ruoyi.system.domain.RmSwitchManagement;
import com.ruoyi.system.mapper.EpsMethodChangeRecordMapper;
import com.ruoyi.system.mapper.EpsNodeBandwidthMapper;
import com.ruoyi.system.mapper.EpsServerRevenueConfigMapper;
import com.ruoyi.system.mapper.RmSwitchManagementMapper;
import com.ruoyi.system.service.EpsInitialTrafficDataService;
import com.ruoyi.system.service.IEpsNodeBandwidthService;
import com.ruoyi.system.util.EchartsDataConverter;
@@ -45,6 +47,8 @@ public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService
private EpsServerRevenueConfigMapper epsServerRevenueConfigMapper;
@Autowired
private EpsMethodChangeRecordMapper epsMethodChangeRecordMapper;
@Autowired
private RmSwitchManagementMapper rmSwitchManagementMapper;
/**
* 查询节点带宽信息
@@ -183,7 +187,7 @@ public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService
// 3. 获取计算数据(防止空指针)
EpsNodeBandwidth calculatedData = epsNodeBandwidthMapper.calculateAvg(epsNodeBandwidth);
if (calculatedData == null) {
log.warn("未找到计算数据,硬件SN: {}", epsNodeBandwidth.getHardwareSn());
log.warn("未找到计算数据,clientId: {}", epsNodeBandwidth.getClientId());
return 0;
}
@@ -221,16 +225,20 @@ public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService
epsNodeBandwidth.setId(existingRecords.get(0).getId());
epsNodeBandwidth.setUpdateTime(DateUtils.getNowDate());
}else{
if(epsNodeBandwidth.getStartTime() == null){
epsNodeBandwidth.setCreateTime(DateUtils.parseDate(monthTime));
}else{
epsNodeBandwidth.setCreateTime(DateUtils.parseDate(epsNodeBandwidth.getStartTime()));
}
epsNodeBandwidth.setCreateTime(DateUtils.parseDate(monthTime));
}
// 月均日95值
BigDecimal avgMonthly = sum95Daily.divide(BigDecimal.valueOf(daysInMonth), 2, RoundingMode.HALF_UP);
epsNodeBandwidth.setAvgMonthlyBandwidth95(avgMonthly);
epsNodeBandwidth.setBandwidthResult(avgMonthly);
// 根据clientId查询交换机名称
RmSwitchManagement query = new RmSwitchManagement();
query.setClientId(epsNodeBandwidth.getClientId());
List<RmSwitchManagement> switchMsgList = rmSwitchManagementMapper.selectRmSwitchManagementList(query);
if(!switchMsgList.isEmpty()){
RmSwitchManagement switchManagement = switchMsgList.get(0);
epsNodeBandwidth.setUplinkSwitch(switchManagement.getSwitchName());
}
// 8. 执行插入或更新操作
return existingRecords.isEmpty() ?
epsNodeBandwidthMapper.insertEpsNodeBandwidth(epsNodeBandwidth) :
@@ -137,13 +137,24 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
processAvg95Data(epsTaskStatistics);
}
}else{
String resources = epsTaskStatistics.getIncludedResources();
String clientIds = Arrays.stream(resources.split(","))
.map(msg -> msg.split(";"))
.filter(resource -> resource.length >= 3)
.map(resource -> resource[1])
.collect(Collectors.joining(","));
String interfaceNames = Arrays.stream(resources.split(","))
.map(msg -> msg.split(";"))
.filter(resource -> resource.length >= 3)
.map(resource -> resource[2])
.collect(Collectors.joining(","));
if(StringUtils.equals(epsTaskStatistics.getCalculationType(), "1")){
InitialSwitchInfoDetails queryParam = new InitialSwitchInfoDetails();
queryParam.setStartTime(epsTaskStatistics.getStartTime());
queryParam.setEndTime(epsTaskStatistics.getEndTime());
queryParam.setBusinessCode(epsTaskStatistics.getBusinessCode());
queryParam.setClientIds(epsTaskStatistics.getIncludedResources());
queryParam.setInterfaceNames(epsTaskStatistics.getInterfaceNames());
queryParam.setClientIds(clientIds);
queryParam.setInterfaceNames(interfaceNames);
List<InitialSwitchInfoDetails> dataList = initialSwitchInfoDetailsMapper
.sumSwitchTrafficByclientIds(queryParam);
if(!dataList.isEmpty()){
@@ -166,8 +177,8 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
queryParam.setStartTime(timeRange.getStart());
queryParam.setEndTime(timeRange.getEnd());
queryParam.setBusinessCode(epsTaskStatistics.getBusinessCode());
queryParam.setClientIds(epsTaskStatistics.getIncludedResources());
queryParam.setInterfaceNames(epsTaskStatistics.getInterfaceNames());
queryParam.setClientIds(clientIds);
queryParam.setInterfaceNames(interfaceNames);
List<InitialSwitchInfoDetails> dataList = initialSwitchInfoDetailsMapper
.sumSwitchTrafficByclientIds(queryParam);
if(!dataList.isEmpty()){
@@ -350,6 +361,12 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
}
}
}else{
String resources = taskMsg.getIncludedResources();
String result = Arrays.stream(resources.split(","))
.map(msg -> msg.split(";"))
.filter(resource -> resource.length >= 4)
.map(resource -> "[" + resource[3] + "].[" + resource[2] + "]")
.collect(Collectors.joining(";"));
List<InitialSwitchInfoDetails> list = trafficRedisHashUtil.getListFromHash(taskId.toString(), InitialSwitchInfoDetails.class);
if(!list.isEmpty()){
if(StringUtils.equals("1", taskMsg.getCalculationType())){
@@ -361,7 +378,7 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
.limit(pageSize)
.collect(Collectors.toList());
for (InitialSwitchInfoDetails initialSwitchInfoDetails : pageList) {
initialSwitchInfoDetails.setName(taskMsg.getIncludedResources());
initialSwitchInfoDetails.setName(result);
}
PageInfo<InitialSwitchInfoDetails> pageInfo = new PageInfo<>();
pageInfo.setPageNum(pageNum);
@@ -389,6 +406,31 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
return new PageInfo<>();
}
/**
* 获取月均日数据的日期
* @param epsTaskStatistics
* @return
*/
public List<String> getAvgTimeList(EpsTaskStatistics epsTaskStatistics){
List<String> resultList = new ArrayList<>();
Long taskId = epsTaskStatistics.getId();
EpsTaskStatistics taskMsg = epsTaskStatisticsMapper.selectEpsTaskStatisticsById(taskId);
if(StringUtils.equals(taskMsg.getCalculationType(), "2")){
List<EpsInitialTrafficData> list = trafficRedisHashUtil.getListFromHash(taskId.toString(), EpsInitialTrafficData.class);
if(!list.isEmpty()){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
resultList = list.stream()
.map(data -> sdf.format(data.getCreateTime()))
.distinct()
.sorted()
.collect(Collectors.toList());
}
}
return resultList;
}
@Override
public int updateRelateData(EpsTaskStatistics epsTaskStatistics) {
// 查询任务详情
@@ -442,10 +484,22 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
// 查询任务详情
Long taskId = epsTaskStatistics.getId();
EpsTaskStatistics taskMsg = epsTaskStatisticsMapper.selectEpsTaskStatisticsById(taskId);
String startTime = taskMsg.getStartTime();
String endTime = taskMsg.getEndTime();
String timeRange = "";
if(endTime == null){
timeRange = startTime;
}else{
timeRange = startTime + "~" + endTime;
}
if(StringUtils.equals("1", taskMsg.getResourceType())){
List<EpsInitialTrafficData> list = trafficRedisHashUtil.getListFromHash(taskId.toString(), EpsInitialTrafficData.class);
if(!list.isEmpty()){
try{
BigDecimal percentile95 = "1".equals(taskMsg.getCalculationType())
? taskMsg.getPercentile95()
: taskMsg.getMonthlyAvgPercentile95();
list.forEach(data -> data.setPercentile95(SpeedUtils.mbitToBit(percentile95)));
SpeedUtils.SpeedResult result = SpeedUtils.calculateWithStringTraffic(list, "inSpeed", "outSpeed");
BigDecimal divisor = SpeedUtils.getDivisor(result.getRecommendedUnit());
Map<String, Function<EpsInitialTrafficData, ?>> extractors = new LinkedHashMap<>();
@@ -454,13 +508,14 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
info != null && info.getOutSpeed() != null ?
new BigDecimal(info.getOutSpeed()).divide(divisor, 0, RoundingMode.HALF_UP) :
0);
extractors.put("percentile95", info ->
info != null && info.getPercentile95() != null ?
info.getPercentile95().divide(divisor, 2, RoundingMode.HALF_UP) :
0);
Map<String, Object> resultMap = EchartsDataUtils.buildEchartsData(list, EpsInitialTrafficData::getCreateTime, extractors);
resultMap.put("other", result);
if(StringUtils.equals("1", taskMsg.getCalculationType())){
resultMap.put("percentile95", taskMsg.getPercentile95());
}else{
resultMap.put("percentile95", taskMsg.getMonthlyAvgPercentile95());
}
resultMap.put("percentile95", percentile95);
resultMap.put("timeRange", timeRange);
return resultMap;
}catch (Exception e){
System.err.println(e.getMessage());
@@ -470,6 +525,10 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
List<InitialSwitchInfoDetails> list = trafficRedisHashUtil.getListFromHash(taskId.toString(), InitialSwitchInfoDetails.class);
if(!list.isEmpty()){
try{
BigDecimal percentile95 = "1".equals(taskMsg.getCalculationType())
? taskMsg.getPercentile95()
: taskMsg.getMonthlyAvgPercentile95();
list.forEach(data -> data.setPercentile95(SpeedUtils.mbitToBit(percentile95)));
SpeedUtils.SpeedResult result = SpeedUtils.calculateWithAverageBasedUnit(list, "inSpeed", "outSpeed");
BigDecimal divisor = SpeedUtils.getDivisor(result.getRecommendedUnit());
Map<String, Function<InitialSwitchInfoDetails, ?>> extractors = new LinkedHashMap<>();
@@ -482,6 +541,10 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
info != null && info.getOutSpeed() != null ?
info.getOutSpeed().divide(divisor, 0, RoundingMode.HALF_UP) :
0);
extractors.put("percentile95", info ->
info != null && info.getPercentile95() != null ?
info.getPercentile95().divide(divisor, 2, RoundingMode.HALF_UP) :
0);
Map<String, Object> resultMap = EchartsDataUtils.buildEchartsData(list, InitialSwitchInfoDetails::getCreateTime, extractors);
resultMap.put("other", result);
if(StringUtils.equals("1", taskMsg.getCalculationType())){
@@ -489,6 +552,7 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
}else{
resultMap.put("percentile95", taskMsg.getMonthlyAvgPercentile95());
}
resultMap.put("timeRange", timeRange);
return resultMap;
}catch (Exception e){
System.err.println(e.getMessage());
@@ -43,6 +43,8 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
@Autowired
private RmEpsTopologyManagementMapper rmEpsTopologyManagementMapper;
@Autowired
private RmSwitchManagementMapper rmSwitchManagementMapper;
@Autowired
private AllInterfaceNameMapper allInterfaceNameMapper;
@Autowired
private EpsServerRevenueConfigMapper epsServerRevenueConfigMapper;
@@ -55,6 +57,8 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
@Autowired
private EpsBusinessDeployMapper epsBusinessDeployMapper;
private static final String DATE_TIME_FORMATTER = "yyyy-MM-dd HH:mm:ss";
/**
* 查询交换机监控信息
*
@@ -147,31 +151,37 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
String interfaceName = details.getName();
RmEpsTopologyManagement rmEpsTopologyManagement = new RmEpsTopologyManagement();
rmEpsTopologyManagement.setInterfaceName(interfaceName);
rmEpsTopologyManagement.setSwitchIpAddress(details.getSwitchIp());
rmEpsTopologyManagement.setClientId(details.getClientId());
List<RmEpsTopologyManagement> managements = rmEpsTopologyManagementMapper.selectRmEpsTopologyManagementList(rmEpsTopologyManagement);
// 赋值
if(!managements.isEmpty()){
for (RmEpsTopologyManagement management : managements) {
if("1".equals(management.getConnectedDeviceType())){
details.setOutSpeed(null);
}else{
details.setInSpeed(null);
}
details.setSwitchSn(management.getSwitchSn());
details.setSwitchName(management.getSwitchName());
details.setInterfaceDeviceType(management.getConnectedDeviceType());
details.setServerName(management.getServerName());
details.setServerPort(management.getServerPort());
details.setServerSn(management.getServerSn());
details.setServerClientId(management.getServerClientId());
// 查询端口备注信息
RmSwitchInterfaceInfo queryOtheName = new RmSwitchInterfaceInfo();
queryOtheName.setClientId(details.getClientId());
queryOtheName.setInterfaceName(management.getInterfaceName());
List<RmSwitchInterfaceInfo> interfaceInfos = rmSwitchInterfaceInfoMapper.selectRmSwitchInterfaceInfoList(queryOtheName);
if(!interfaceInfos.isEmpty()){
// 接口别名
details.setInterfaceNameRemark(interfaceInfos.get(0).getInterfaceRemark());
}
// 根据服务器sn查询业务
if(management.getServerSn() != null){
EpsServerRevenueConfig epsServerRevenueConfig = new EpsServerRevenueConfig();
epsServerRevenueConfig.setHardwareSn(management.getServerSn());
List<EpsServerRevenueConfig> businessList = epsServerRevenueConfigMapper.selectEpsServerRevenueConfigList(epsServerRevenueConfig);
if(!businessList.isEmpty()){
EpsServerRevenueConfig revenueConfig = businessList.get(0);
details.setBusinessName(revenueConfig.getBusinessName());
details.setBusinessCode(revenueConfig.getBusinessCode());
if(management.getServerClientId() != null){
String serverClientId = management.getServerClientId();
// 查询业务信息
EpsBusinessDeploy queryBD = new EpsBusinessDeploy();
queryBD.setClientId(serverClientId);
queryBD.setReviewStatus(ReviewEnum.通过.getCode());
List<EpsBusinessDeploy> businessDeploys = epsBusinessDeployMapper.selectEpsBusinessDeployList(queryBD);
if(!businessDeploys.isEmpty()){
details.setBusinessCode(businessDeploys.get(0).getBusinessCode());
details.setBusinessName(businessDeploys.get(0).getBusinessName());
}
}else {
details.setBusinessCode(null);
@@ -353,7 +363,6 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
// 遍历处理每个交换机
switchSnList.forEach(interfaceName -> {
queryParam.setClientId(interfaceName.getClientId());
queryParam.setSwitchIp(interfaceName.getSwitchIp());
processSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
});
}
@@ -474,17 +483,16 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
// 根据交换机sn查询连接的服务器sn
RmEpsTopologyManagement management = new RmEpsTopologyManagement();
management.setClientId(queryParam.getClientId());
management.setSwitchIpAddress(queryParam.getSwitchIp());
List<RmEpsTopologyManagement> serverSnList = rmEpsTopologyManagementMapper.selectRmEpsTopologyManagementList(management);
if(!serverSnList.isEmpty()){
for (RmEpsTopologyManagement rmEpsTopologyManagement : serverSnList) {
queryParam.setName(rmEpsTopologyManagement.getInterfaceName());
if("1".equals(rmEpsTopologyManagement.getConnectedDeviceType())){
queryParam.setServerSn(rmEpsTopologyManagement.getServerSn());
queryParam.setServerClientId(rmEpsTopologyManagement.getServerClientId());
// 根据业务变更情况选择计算方式
calculateChangedSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
}else{
queryParam.setServerSn(null);
queryParam.setServerClientId(null);
calculateNormalSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
}
}
@@ -507,7 +515,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
String dailyEndTime, String calculationMode) {
// 获取业务变更记录(按时间降序)
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
changeQuery.setClientId(queryParam.getClientId());
changeQuery.setClientId(queryParam.getServerClientId());
changeQuery.setStartTime(dailyStartTime);
changeQuery.setEndTime(dailyEndTime);
List<EpsMethodChangeRecord> records = epsMethodChangeRecordMapper
@@ -584,15 +592,15 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
String dailyStartTime,
String dailyEndTime, String calculationMode) {
// 1. 处理变更时间段(从最新到最早)
String endTime = records.get(0).getCreateTime() + "";
String endTime = DateUtils.parseDateToStr(DATE_TIME_FORMATTER, records.get(0).getCreateTime());
for (int i = 1; i < records.size(); i++) {
String startTime = records.get(i).getCreateTime() + "";
String startTime = DateUtils.parseDateToStr(DATE_TIME_FORMATTER, records.get(i).getCreateTime());
calculateSwitchSegment95(queryParam, startTime, endTime, calculationMode);
endTime = startTime; // 移动时间窗口
}
// 2. 处理最早变更前的时间段(昨天00:00:00 ~ 最早变更时间)
String earliestChangeTime = records.get(records.size()-1).getCreateTime() + "";
String earliestChangeTime = DateUtils.parseDateToStr(DATE_TIME_FORMATTER, records.get(records.size()-1).getCreateTime());
calculateSwitchSegment95(queryParam, dailyStartTime, earliestChangeTime, calculationMode);
// 3. 处理最后变更后的时间段(最新变更时间 ~ 昨天23:59:59)
@@ -653,15 +661,23 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
BigDecimal result,
String dateTime, String calculationMode) {
EpsNodeBandwidth bandwidth = new EpsNodeBandwidth();
// 根据clientId查询交换机名称
RmSwitchManagement query = new RmSwitchManagement();
query.setClientId(data.getClientId());
List<RmSwitchManagement> switchMsgList = rmSwitchManagementMapper.selectRmSwitchManagementList(query);
if(!switchMsgList.isEmpty()){
RmSwitchManagement switchManagement = switchMsgList.get(0);
bandwidth.setUplinkSwitch(switchManagement.getSwitchName());
}
bandwidth.setBusinessName(data.getBusinessName());
bandwidth.setBusinessId(data.getBusinessCode());
bandwidth.setClientId(data.getClientId());
bandwidth.setHardwareSn(data.getServerSn());
bandwidth.setCalculationMode(calculationMode);
bandwidth.setSwitchSn(data.getSwitchSn());
bandwidth.setNodeName(data.getServerName());
bandwidth.setUplinkSwitch(data.getSwitchName());
bandwidth.setInterfaceName(data.getName());
bandwidth.setRemark1(data.getInterfaceNameRemark());
bandwidth.setServerClientId(data.getServerClientId());
bandwidth.setResourceType(data.getResourceType());
bandwidth.setBandwidthType(data.getBandwidthType());
bandwidth.setInterfaceLinkDeviceType(data.getInterfaceDeviceType());
@@ -722,7 +738,8 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
// 构造当天的开始和结束时间(精确到秒)
String dayStart = date.atStartOfDay().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
String dayEnd = date.atTime(23, 59, 59).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
// 时间范围
String timeRange = "" + dayStart + "" + dayEnd;
// 创建当天的查询条件
InitialSwitchInfoDetails dailyQuery = new InitialSwitchInfoDetails();
BeanUtils.copyProperties(initialSwitchInfoDetails, dailyQuery); // 复制原有属性
@@ -739,9 +756,8 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
if(!rmEpsTopologyManagements.isEmpty()){
for (RmEpsTopologyManagement rmEpsTopologyManagement : rmEpsTopologyManagements) {
try {
dailyQuery.setName(rmEpsTopologyManagement.getInterfaceName());
Map<String, Object> resultMap = switchNetSpeedEcharts(dailyQuery);
// 查询95值
BigDecimal percentile95 = BigDecimal.ZERO;
EpsNodeBandwidth query = new EpsNodeBandwidth();
query.setBandwidthType("1");
query.setCreateTime(DateUtils.parseDate(date));
@@ -751,8 +767,10 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
List<EpsNodeBandwidth> epsNodeBandwidthList = epsNodeBandwidthMapper.selectEpsNodeBandwidthList(query);
if(!epsNodeBandwidthList.isEmpty()){
EpsNodeBandwidth nodeBandwidth = epsNodeBandwidthList.get(0);
resultMap.put("95value", nodeBandwidth.getBandwidthResult());
percentile95 = nodeBandwidth.getBandwidthResult();
}
dailyQuery.setName(rmEpsTopologyManagement.getInterfaceName());
Map<String, Object> resultMap = switchNetSpeedEcharts(dailyQuery, percentile95);
// 查询端口备注信息
RmSwitchInterfaceInfo queryOtheName = new RmSwitchInterfaceInfo();
queryOtheName.setClientId(clientId);
@@ -786,6 +804,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
}
String name = joiner.toString();
resultMap.put("name", name);
resultMap.put("timeRange", timeRange);
resultList.add(resultMap);
} catch (Exception e){
e.printStackTrace();
@@ -822,6 +841,8 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
BeanUtils.copyProperties(initialSwitchInfoDetails, dailyQuery); // 复制原有属性
dailyQuery.setStartTime(monthStart);
dailyQuery.setEndTime(monthEnd);
// 时间范围
String timeRange = "" + monthStart + "" + monthEnd;
// 根据交换机名称查询clientId
String clientIds = initialSwitchInfoDetails.getClientIds();
String[] clientIdArr = clientIds.split(",");
@@ -833,9 +854,8 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
if(!rmEpsTopologyManagements.isEmpty()){
for (RmEpsTopologyManagement rmEpsTopologyManagement : rmEpsTopologyManagements) {
try {
dailyQuery.setName(rmEpsTopologyManagement.getInterfaceName());
Map<String, Object> resultMap = switchNetSpeedEcharts(dailyQuery);
// 查询95值
BigDecimal percentile95 = BigDecimal.ZERO;
EpsNodeBandwidth query = new EpsNodeBandwidth();
query.setBandwidthType("1");
query.setCreateTime(DateUtils.parseDate(monthStart));
@@ -844,8 +864,10 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
List<EpsNodeBandwidth> epsNodeBandwidthList = epsNodeBandwidthMapper.selectEpsNodeBandwidthList(query);
if(!epsNodeBandwidthList.isEmpty()){
EpsNodeBandwidth nodeBandwidth = epsNodeBandwidthList.get(0);
resultMap.put("95value", nodeBandwidth.getBandwidthResult());
percentile95 = nodeBandwidth.getBandwidthResult();
}
dailyQuery.setName(rmEpsTopologyManagement.getInterfaceName());
Map<String, Object> resultMap = switchNetSpeedEcharts(dailyQuery, percentile95);
// 查询端口备注信息
RmSwitchInterfaceInfo queryOtheName = new RmSwitchInterfaceInfo();
queryOtheName.setClientId(clientId);
@@ -879,6 +901,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
}
String name = joiner.toString();
resultMap.put("name", name);
resultMap.put("timeRange", timeRange);
resultList.add(resultMap);
} catch (Exception e){
e.printStackTrace();
@@ -894,9 +917,10 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
* @param initialSwitchInfoDetails
* @return
*/
public Map<String, Object> switchNetSpeedEcharts(InitialSwitchInfoDetails initialSwitchInfoDetails) {
public Map<String, Object> switchNetSpeedEcharts(InitialSwitchInfoDetails initialSwitchInfoDetails, BigDecimal percentile95) {
List<InitialSwitchInfoDetails> list = initialSwitchInfoDetailsMapper.getswitchDetailList(initialSwitchInfoDetails);
try {
list.forEach(data -> data.setPercentile95(SpeedUtils.mbitToBit(percentile95)));
SpeedUtils.SpeedResult result = SpeedUtils.calculateWithAverageBasedUnit(list, "inSpeed", "outSpeed");
BigDecimal divisor = SpeedUtils.getDivisor(result.getRecommendedUnit());
Map<String, Function<InitialSwitchInfoDetails, ?>> extractors = new LinkedHashMap<>();
@@ -909,8 +933,13 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
info != null && info.getOutSpeed() != null ?
info.getOutSpeed().divide(divisor, 0, RoundingMode.HALF_UP) :
0);
extractors.put("percentile95", info ->
info != null && info.getPercentile95() != null ?
info.getPercentile95().divide(divisor, 2, RoundingMode.HALF_UP) :
0);
Map<String, Object> resultMap = EchartsDataUtils.buildEchartsData(list, InitialSwitchInfoDetails::getCreateTime, extractors);
resultMap.put("other", result);
resultMap.put("95value", percentile95);
return resultMap;
} catch (Exception e){
e.printStackTrace();
@@ -527,6 +527,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
recordAddData.setClientId(registerMsg.getClientId());
recordAddData.setTrafficPort(networkInfo.getName());
recordAddData.setUpdateTime(DateUtils.getNowDate());
recordAddData.setCreateTime(DateUtils.getNowDate());
recordAddData.setUpdateBy(SecurityUtils.getUsername());
recordAddData.setCreatBy(SecurityUtils.getUsername());
StringBuilder content = new StringBuilder();
@@ -636,6 +637,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
EpsMethodChangeRecord record = new EpsMethodChangeRecord();
record.setClientId(clientId);
record.setTrafficPort(map.get("interfaceName").toString());
record.setCreateTime(now);
record.setUpdateTime(now);
record.setUpdateBy(username);
record.setCreatBy(username);
@@ -720,7 +722,9 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
changeRecord.setBusinessCode(rmResourceRegistration.getBusinessCode());
changeRecord.setBusinessName(rmResourceRegistration.getBusinessName());
changeRecord.setCreateTime(DateUtils.getNowDate());
changeRecord.setUpdateTime(DateUtils.getNowDate());
changeRecord.setCreatBy(SecurityUtils.getUsername());
changeRecord.setUpdateBy(SecurityUtils.getUsername());
// 修改内容
String content = "业务为" + rmResourceRegistration.getBusinessName();
changeRecord.setChangeContent(content);
@@ -167,20 +167,31 @@ public class RmSwitchManagementServiceImpl implements IRmSwitchManagementService
switchManagement.setLabel(switchManagement.getSwitchName());
// 该交换机的所有接口信息
String clientId = switchManagement.getClientId();
String switchName = switchManagement.getSwitchName();
AllInterfaceName allInterfaceName = new AllInterfaceName();
allInterfaceName.setClientId(clientId);
List<AllInterfaceName> interfaceNameList = allInterfaceNameMapper.selectAllInterfaceNameList(allInterfaceName);
for (AllInterfaceName interfaceName : interfaceNameList) {
interfaceName.setValue(interfaceName.getId());
String valueStr = String.join(";",
interfaceName.getId().toString(),
clientId,
interfaceName.getInterfaceName(),
switchName
);
interfaceName.setValue(valueStr);
interfaceName.setLabel(interfaceName.getInterfaceName());
// 查询别名
RmSwitchInterfaceInfo query = new RmSwitchInterfaceInfo();
query.setInterfaceName(interfaceName.getInterfaceName());
query.setClientId(clientId);
List<RmSwitchInterfaceInfo> interfaceInfos = rmSwitchInterfaceInfoMapper.selectRmSwitchInterfaceInfoList(query);
String otherName = "";
if(!interfaceInfos.isEmpty()){
interfaceName.setOtherName(interfaceInfos.get(0).getInterfaceRemark());
otherName = interfaceInfos.get(0).getInterfaceRemark();
interfaceName.setOtherName(otherName);
}
String labelStr = String.join(" ",interfaceName.getInterfaceName(), otherName);
interfaceName.setLabel(labelStr);
}
switchManagement.setChildren(interfaceNameList);
}
@@ -1,12 +1,14 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.domain.UserTableColumnConfig;
import com.ruoyi.system.mapper.UserTableColumnConfigMapper;
import com.ruoyi.system.service.IUserTableColumnConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.UserTableColumnConfigMapper;
import com.ruoyi.system.domain.UserTableColumnConfig;
import com.ruoyi.system.service.IUserTableColumnConfigService;
import java.util.List;
/**
* 用户自定义列配置Service业务层处理
@@ -53,8 +55,28 @@ public class UserTableColumnConfigServiceImpl implements IUserTableColumnConfigS
@Override
public int insertUserTableColumnConfig(UserTableColumnConfig userTableColumnConfig)
{
Long userId = userTableColumnConfig.getUserId();
if(userId == null){
System.err.println("用户不存在");
return 0;
}
if(userTableColumnConfig.getPageRoute() == null){
System.err.println("路由不存在");
return 0;
}
userTableColumnConfig.setCreateTime(DateUtils.getNowDate());
return userTableColumnConfigMapper.insertUserTableColumnConfig(userTableColumnConfig);
userTableColumnConfig.setUserId(userId);
// 查询该用户是否已存在配置
UserTableColumnConfig configQuery = new UserTableColumnConfig();
configQuery.setUserId(userId);
configQuery.setPageRoute(userTableColumnConfig.getPageRoute());
List<UserTableColumnConfig> exits = userTableColumnConfigMapper.selectUserTableColumnConfigList(configQuery);
if(exits.isEmpty()){
userTableColumnConfigMapper.insertUserTableColumnConfig(userTableColumnConfig);
}else{
userTableColumnConfigMapper.updateUserTableColumnConfig(userTableColumnConfig);
}
return 1;
}
/**
@@ -93,4 +115,16 @@ public class UserTableColumnConfigServiceImpl implements IUserTableColumnConfigS
{
return userTableColumnConfigMapper.deleteUserTableColumnConfigById(id);
}
@Override
public UserTableColumnConfig getColumnConfigByUserId(UserTableColumnConfig userTableColumnConfig) {
UserTableColumnConfig configQuery = new UserTableColumnConfig();
configQuery.setUserId(SecurityUtils.getUserId());
configQuery.setPageRoute(userTableColumnConfig.getPageRoute());
List<UserTableColumnConfig> userTableColumnConfigList = userTableColumnConfigMapper.selectUserTableColumnConfigList(configQuery);
if(!userTableColumnConfigList.isEmpty()){
return userTableColumnConfigList.get(0);
}
return new UserTableColumnConfig();
}
}
@@ -198,13 +198,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getAllDeviceSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
SELECT
client_id AS clientId, interface_name interfaceName
client_id AS clientId
FROM
all_interface_name
<where>
and resource_type = '1' and interface_name != ''
and resource_type = '1' and client_id != ''
</where>
group by interface_name
group by client_id
</select>
<select id="getAllSwitchSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
SELECT
@@ -175,8 +175,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
`ipV4` AS ipV4,
`in_dropped` AS inDropped,
`out_dropped` AS outDropped,
`in_speed` AS inSpeed,
`out_speed` AS outSpeed,
sum(ifnull(`in_speed`,0)) AS inSpeed,
sum(ifnull(`out_speed`,0)) AS outSpeed,
`machine_flow` AS machineFlow,
`speed` AS speed,
`duplex` AS duplex,
@@ -213,7 +213,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</where>
ORDER BY create_time desc
group BY create_time desc
</select>
<!-- 条件查询 -->
@@ -16,14 +16,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="avgMonthlyBandwidth95" column="avg_monthly_bandwidth_95" />
<result property="packageBandwidthDaily" column="package_bandwidth_daily" />
<result property="machineFlow" column="machine_flow" />
<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="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="creatorId" column="creator_id" />
<result property="creatorName" column="creator_name" />
<result property="switchSn" column="switch_sn" />
<result property="interfaceName" column="interface_name" />
<result property="resourceType" column="resource_type" />
@@ -36,22 +31,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remark1" column="remark1" />
<result property="createDatetime" column="create_datetime" />
<result property="clientId" column="client_id" />
<result property="serverClientId" column="server_client_id" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectEpsNodeBandwidthVo">
select id, node_name, hardware_sn, calculation_mode, bandwidth_type, bandwidth_result, bandwidth_95_daily,
bandwidth_95_monthly, avg_monthly_bandwidth_95, package_bandwidth_daily, machine_flow, 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, create_datetime, client_id from eps_node_bandwidth
select id, node_name, hardware_sn, calculation_mode, bandwidth_type, bandwidth_result, bandwidth_95_daily, bandwidth_95_monthly, avg_monthly_bandwidth_95, package_bandwidth_daily, machine_flow, uplink_switch, create_time, update_time, 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, create_datetime, client_id, server_client_id, create_by, update_by from eps_node_bandwidth
</sql>
<select id="selectEpsNodeBandwidthList" parameterType="EpsNodeBandwidth" resultMap="EpsNodeBandwidthResult">
<include refid="selectEpsNodeBandwidthVo"/>
<where>
<if test="nodeName != null and nodeName != ''"> and node_name like concat('%', #{nodeName}, '%')</if>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="hardwareSn != null and hardwareSn != ''"> and hardware_sn = #{hardwareSn}</if>
<if test="calculationMode != null and calculationMode != ''"> and calculation_mode = #{calculationMode}</if>
<if test="bandwidthType != null and bandwidthType != ''"> and bandwidth_type = #{bandwidthType}</if>
@@ -60,12 +52,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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="machineFlow != null "> and machine_flow = #{machineFlow}</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="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>
@@ -76,6 +64,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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="createDatetime != null "> and create_datetime = #{createDatetime}</if>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="serverClientId != null and serverClientId != ''"> and server_client_id = #{serverClientId}</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="createTime != null"> and create_time = #{createTime}</if>
@@ -112,14 +103,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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="machineFlow != null">machine_flow,</if>
<if test="uplinkSwitch != null">uplink_switch,</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="switchSn != null">switch_sn,</if>
<if test="interfaceName != null">interface_name,</if>
<if test="resourceType != null">resource_type,</if>
@@ -130,8 +115,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="businessName != null">business_name,</if>
<if test="businessId != null">business_id,</if>
<if test="remark1 != null">remark1,</if>
<if test="createDatetime != null">create_datetime,</if>
<if test="clientId != null">client_id,</if>
create_datetime,
<if test="serverClientId != null">server_client_id,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
create_time,
update_time,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="nodeName != null">#{nodeName},</if>
@@ -143,14 +133,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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="machineFlow != null">#{machineFlow},</if>
<if test="uplinkSwitch != null">#{uplinkSwitch},</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="switchSn != null">#{switchSn},</if>
<if test="interfaceName != null">#{interfaceName},</if>
<if test="resourceType != null">#{resourceType},</if>
@@ -161,8 +145,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="businessName != null">#{businessName},</if>
<if test="businessId != null">#{businessId},</if>
<if test="remark1 != null">#{remark1},</if>
<if test="createDatetime != null">#{createDatetime},</if>
<if test="clientId != null">#{clientId},</if>
NOW(),
<if test="serverClientId != null">#{serverClientId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<choose>
<when test="createTime != null">
#{createTime},
</when>
<otherwise>
NOW(),
</otherwise>
</choose>
<choose>
<when test="updateTime != null">
#{updateTime},
</when>
<otherwise>
NOW(),
</otherwise>
</choose>
</trim>
</insert>
@@ -178,14 +181,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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="machineFlow != null">machine_flow = #{machineFlow},</if>
<if test="uplinkSwitch != null">uplink_switch = #{uplinkSwitch},</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="switchSn != null">switch_sn = #{switchSn},</if>
<if test="interfaceName != null">interface_name = #{interfaceName},</if>
<if test="resourceType != null">resource_type = #{resourceType},</if>
@@ -198,6 +197,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark1 != null">remark1 = #{remark1},</if>
<if test="createDatetime != null">create_datetime = #{createDatetime},</if>
<if test="clientId != null">client_id = #{clientId},</if>
<if test="serverClientId != null">server_client_id = #{serverClientId},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
</update>
@@ -14,7 +14,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="type" column="type" />
<result property="inSpeed" column="in_speed" />
<result property="outSpeed" column="out_speed" />
<result property="maxSpeed" column="max_speed" />
<result property="switchIp" column="switch_ip" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
@@ -34,10 +33,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="ifInErrors" column="if_in_errors" />
<result property="ifOutErrors" column="if_out_errors" />
<result property="ifIndex" column="if_index" />
<result property="maxSpeed" column="max_speed" />
<result property="interfaceNameRemark" column="interface_name_remark" />
<result property="serverClientId" column="server_client_id" />
</resultMap>
<sql id="selectInitialSwitchInfoDetailsVo">
select id, client_id, name, in_bytes, out_bytes, status, type, in_speed, out_speed, max_speed, switch_ip, 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, if_speed, if_in_discards, if_out_discards, if_in_errors, if_out_errors, if_index from initial_switch_info_details
select id, client_id, name, in_bytes, out_bytes, status, type, in_speed, out_speed, switch_ip, 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, if_speed, if_in_discards, if_out_discards, if_in_errors, if_out_errors, if_index, max_speed, interface_name_remark, server_client_id from initial_switch_info_details
</sql>
<select id="selectInitialSwitchInfoDetailsList" parameterType="InitialSwitchInfoDetails" resultMap="InitialSwitchInfoDetailsResult">
@@ -60,6 +62,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="switchSn != null and switchSn != ''"> and switch_sn = #{switchSn}</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="interfaceNameRemark != null and interfaceNameRemark != ''"> and interface_name_remark = #{interfaceNameRemark}</if>
<if test="serverClientId != null and serverClientId != ''"> and server_client_id = #{serverClientId}</if>
<if test="startTime != null">
and create_time &gt;= #{startTime}
</if>
@@ -86,7 +90,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="type != null">type,</if>
<if test="inSpeed != null">in_speed,</if>
<if test="outSpeed != null">out_speed,</if>
<if test="maxSpeed != null">max_speed,</if>
<if test="switchIp != null">switch_ip,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
@@ -105,7 +108,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ifOutDiscards != null">if_out_discards,</if>
<if test="ifInErrors != null">if_in_errors,</if>
<if test="ifOutErrors != null">if_out_errors,</if>
<if test="ifIndex != null and ifIndex != ''">if_index,</if>
<if test="ifIndex != null">if_index,</if>
<if test="maxSpeed != null">max_speed,</if>
<if test="interfaceNameRemark != null">interface_name_remark,</if>
<if test="serverClientId != null">server_client_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clientId != null and clientId != ''">#{clientId},</if>
@@ -116,7 +122,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="type != null">#{type},</if>
<if test="inSpeed != null">#{inSpeed},</if>
<if test="outSpeed != null">#{outSpeed},</if>
<if test="maxSpeed != null">#{maxSpeed},</if>
<if test="switchIp != null">#{switchIp},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
@@ -135,7 +140,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ifOutDiscards != null">#{ifOutDiscards},</if>
<if test="ifInErrors != null">#{ifInErrors},</if>
<if test="ifOutErrors != null">#{ifOutErrors},</if>
<if test="ifIndex != null and ifIndex != ''">#{ifIndex},</if>
<if test="ifIndex != null">#{ifIndex},</if>
<if test="maxSpeed != null">#{maxSpeed},</if>
<if test="interfaceNameRemark != null">#{interfaceNameRemark},</if>
<if test="serverClientId != null">#{serverClientId},</if>
</trim>
</insert>
@@ -150,7 +158,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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="maxSpeed != null">max_speed = #{maxSpeed},</if>
<if test="switchIp != null">switch_ip = #{switchIp},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
@@ -169,7 +176,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ifOutDiscards != null">if_out_discards = #{ifOutDiscards},</if>
<if test="ifInErrors != null">if_in_errors = #{ifInErrors},</if>
<if test="ifOutErrors != null">if_out_errors = #{ifOutErrors},</if>
<if test="ifIndex != null and ifIndex != ''">if_index = #{ifIndex},</if>
<if test="ifIndex != null">if_index = #{ifIndex},</if>
<if test="maxSpeed != null">max_speed = #{maxSpeed},</if>
<if test="interfaceNameRemark != null">interface_name_remark = #{interfaceNameRemark},</if>
<if test="serverClientId != null">server_client_id = #{serverClientId},</if>
</trim>
where id = #{id}
</update>
@@ -196,7 +206,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
`type`,
in_speed AS inSpeed,
out_speed AS outSpeed,
max_speed AS maxSpeed,
switch_ip AS switchIp,
if_index AS ifIndex,
if_speed AS ifSpeed,
@@ -248,7 +257,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
create_by,
update_by,
create_time,
update_time
update_time,
interface_name_remark,
server_client_id
)
VALUES
<foreach collection="dataList" item="item" separator=",">
@@ -294,7 +305,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<otherwise>
NOW()
</otherwise>
</choose>
</choose>,
#{item.interfaceNameRemark},
#{item.serverClientId}
)
</foreach>
</insert>
@@ -359,7 +359,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and client_id = #{clientId}
</when>
<otherwise>
1=0 <!-- 如果两个条件都不满足,则不更新任何记录 -->
and 1=0 <!-- 如果两个条件都不满足,则不更新任何记录 -->
</otherwise>
</choose>
</where>
@@ -61,7 +61,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateUserTableColumnConfig" parameterType="UserTableColumnConfig">
update user_table_column_config
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="pageRoute != null and pageRoute != ''">page_route = #{pageRoute},</if>
<if test="columnConfig != null and columnConfig != ''">column_config = #{columnConfig},</if>
<if test="createBy != null">create_by = #{createBy},</if>
@@ -70,7 +69,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
<where>
<choose>
<when test="id != null">
and id = #{id}
</when>
<when test="userId != null">
and user_id = #{userId}
</when>
<otherwise>
and 1=0 <!-- 如果两个条件都不满足,则不更新任何记录 -->
</otherwise>
</choose>
</where>
</update>
<delete id="deleteUserTableColumnConfigById" parameterType="Long">