完善初始流量数据库读取mq入库
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.system.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
@@ -77,9 +78,9 @@ public class EpsServerRevenueConfigController extends BaseController
|
||||
@Log(title = "流量相关数据入库", businessType = BusinessType.EXPORT)
|
||||
@InnerAuth
|
||||
@PostMapping("/autoSaveServiceTrafficData")
|
||||
public void autoSaveServiceTrafficData(@RequestBody EpsServerRevenueConfig epsServerRevenueConfig)
|
||||
public R<String> autoSaveServiceTrafficData(@RequestBody EpsServerRevenueConfig epsServerRevenueConfig)
|
||||
{
|
||||
epsServerRevenueConfigService.autoSaveServiceTrafficData(epsServerRevenueConfig);
|
||||
return epsServerRevenueConfigService.autoSaveServiceTrafficData(epsServerRevenueConfig);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -23,39 +24,39 @@ public class EpsInitialTrafficData {
|
||||
|
||||
/** 接口名称 */
|
||||
@Excel(name = "接口名称")
|
||||
private String interfaceName;
|
||||
private String name;
|
||||
|
||||
/** MAC地址 */
|
||||
@Excel(name = "MAC地址")
|
||||
private String macAddress;
|
||||
private String mac;
|
||||
|
||||
/** 运行状态 */
|
||||
@Excel(name = "运行状态")
|
||||
private String operationStatus;
|
||||
private String status;
|
||||
|
||||
/** 接口类型 */
|
||||
@Excel(name = "接口类型")
|
||||
private String interfaceType;
|
||||
private String type;
|
||||
|
||||
/** IPv4地址 */
|
||||
@Excel(name = "IPv4地址")
|
||||
private String ipv4Address;
|
||||
private String ipV4;
|
||||
|
||||
/** 入站丢包率(%) */
|
||||
@Excel(name = "入站丢包率(%)")
|
||||
private BigDecimal inboundPacketLoss;
|
||||
private BigDecimal inDropped;
|
||||
|
||||
/** 出站丢包率(%) */
|
||||
@Excel(name = "出站丢包率(%)")
|
||||
private BigDecimal outboundPacketLoss;
|
||||
private BigDecimal outDropped;
|
||||
|
||||
/** 接收带宽(Mbps) */
|
||||
@Excel(name = "接收带宽(Mbps)")
|
||||
private BigDecimal receiveBandwidth;
|
||||
private String inSpeed;
|
||||
|
||||
/** 发送带宽(Mbps) */
|
||||
@Excel(name = "发送带宽(Mbps)")
|
||||
private BigDecimal sendBandwidth;
|
||||
private String outSpeed;
|
||||
|
||||
/** 业务代码 */
|
||||
@Excel(name = "业务代码")
|
||||
@@ -93,18 +94,37 @@ public class EpsInitialTrafficData {
|
||||
private String clientId;
|
||||
|
||||
/** 流量统计开始时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime startTime;
|
||||
private String startTime;
|
||||
|
||||
/** 流量统计结束时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime endTime;
|
||||
private String endTime;
|
||||
|
||||
|
||||
/** 数据创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/** 创建者 */
|
||||
private String createBy;
|
||||
|
||||
/** 更新者 */
|
||||
private String updateBy;
|
||||
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
/** 当前记录起始索引 */
|
||||
private Integer pageNum;
|
||||
|
||||
/** 每页显示记录数 */
|
||||
private Integer pageSize;
|
||||
/**
|
||||
* 选中的属性名称
|
||||
*/
|
||||
private String[] properties;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 服务器收益方式配置对象 eps_server_revenue_config
|
||||
@@ -12,6 +12,7 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
* @author gyt
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
@Data
|
||||
public class EpsServerRevenueConfig extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -55,123 +56,8 @@ public class EpsServerRevenueConfig extends BaseEntity
|
||||
@Excel(name = "注册状态")
|
||||
private String registrationStatus;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setNodeName(String nodeName)
|
||||
{
|
||||
this.nodeName = nodeName;
|
||||
}
|
||||
|
||||
public String getNodeName()
|
||||
{
|
||||
return nodeName;
|
||||
}
|
||||
|
||||
public void setRevenueMethod(String revenueMethod)
|
||||
{
|
||||
this.revenueMethod = revenueMethod;
|
||||
}
|
||||
|
||||
public String getRevenueMethod()
|
||||
{
|
||||
return revenueMethod;
|
||||
}
|
||||
|
||||
public void setHardwareSn(String hardwareSn)
|
||||
{
|
||||
this.hardwareSn = hardwareSn;
|
||||
}
|
||||
|
||||
public String getHardwareSn()
|
||||
{
|
||||
return hardwareSn;
|
||||
}
|
||||
|
||||
public void setTrafficPort(String trafficPort)
|
||||
{
|
||||
this.trafficPort = trafficPort;
|
||||
}
|
||||
|
||||
public String getTrafficPort()
|
||||
{
|
||||
return trafficPort;
|
||||
}
|
||||
|
||||
public void setBandwidth95(BigDecimal bandwidth95)
|
||||
{
|
||||
this.bandwidth95 = bandwidth95;
|
||||
}
|
||||
|
||||
public BigDecimal getBandwidth95()
|
||||
{
|
||||
return bandwidth95;
|
||||
}
|
||||
|
||||
public void setPackageBandwidth(BigDecimal packageBandwidth)
|
||||
{
|
||||
this.packageBandwidth = packageBandwidth;
|
||||
}
|
||||
|
||||
public BigDecimal getPackageBandwidth()
|
||||
{
|
||||
return packageBandwidth;
|
||||
}
|
||||
|
||||
public void setBusinessName(String businessName)
|
||||
{
|
||||
this.businessName = businessName;
|
||||
}
|
||||
|
||||
public String getBusinessName()
|
||||
{
|
||||
return businessName;
|
||||
}
|
||||
|
||||
public void setBusinessCode(String businessCode)
|
||||
{
|
||||
this.businessCode = businessCode;
|
||||
}
|
||||
|
||||
public String getBusinessCode()
|
||||
{
|
||||
return businessCode;
|
||||
}
|
||||
|
||||
public void setRegistrationStatus(String registrationStatus)
|
||||
{
|
||||
this.registrationStatus = registrationStatus;
|
||||
}
|
||||
|
||||
public String getRegistrationStatus()
|
||||
{
|
||||
return registrationStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("nodeName", getNodeName())
|
||||
.append("revenueMethod", getRevenueMethod())
|
||||
.append("hardwareSn", getHardwareSn())
|
||||
.append("trafficPort", getTrafficPort())
|
||||
.append("bandwidth95", getBandwidth95())
|
||||
.append("packageBandwidth", getPackageBandwidth())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("businessName", getBusinessName())
|
||||
.append("businessCode", getBusinessCode())
|
||||
.append("registrationStatus", getRegistrationStatus())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.toString();
|
||||
}
|
||||
/** 开始时间 */
|
||||
private String startTime;
|
||||
/** 结束时间 */
|
||||
private String endTime;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public interface EpsServerRevenueConfigMapper
|
||||
* @param hardwareSn 服务器sn
|
||||
* @return 数据条数
|
||||
*/
|
||||
public int countBySn(@Param("hardwareSn") String hardwareSn);
|
||||
public EpsServerRevenueConfig countBySn(@Param("hardwareSn") String hardwareSn);
|
||||
|
||||
/**
|
||||
* 查询服务器信息
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.system.domain.EpsServerRevenueConfig;
|
||||
|
||||
import java.util.List;
|
||||
@@ -62,8 +63,7 @@ public interface IEpsServerRevenueConfigService
|
||||
|
||||
/**
|
||||
* 保存业务相关流量表
|
||||
* 每5分钟自动执行
|
||||
* @param epsServerRevenueConfig
|
||||
*/
|
||||
void autoSaveServiceTrafficData(EpsServerRevenueConfig epsServerRevenueConfig);
|
||||
R<String> autoSaveServiceTrafficData(EpsServerRevenueConfig epsServerRevenueConfig);
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
|
||||
// 获取涉及的表名
|
||||
Set<String> tableNames = TableRouterUtil.getTableNamesBetweenInitial(queryParam.getStartTime(), queryParam.getEndTime());
|
||||
|
||||
log.error("initial表名:{}",tableNames);
|
||||
// 并行查询各表
|
||||
return tableNames.parallelStream()
|
||||
.flatMap(tableName -> {
|
||||
@@ -176,7 +176,7 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
condition.setTableName(tableName);
|
||||
condition.setStartTime(queryParam.getStartTime());
|
||||
condition.setEndTime(queryParam.getEndTime());
|
||||
condition.setInterfaceName(queryParam.getInterfaceName());
|
||||
condition.setName(queryParam.getName());
|
||||
return epsInitialTrafficDataMapper.getAllTraficMsg(condition).stream();
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -187,16 +187,16 @@ public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService
|
||||
case "1":
|
||||
case "3":
|
||||
case "5": // 日带宽
|
||||
data.setStartTime(baseTime.with(LocalTime.MIN)); // 00:00:00
|
||||
data.setEndTime(baseTime.with(LocalTime.MAX).withNano(0)); // 23:59:59
|
||||
data.setStartTime(baseTime.with(LocalTime.MIN) + ""); // 00:00:00
|
||||
data.setEndTime(baseTime.with(LocalTime.MAX).withNano(0) + ""); // 23:59:59
|
||||
break;
|
||||
case "2":
|
||||
case "4":
|
||||
case "6":
|
||||
case "7": // 月带宽
|
||||
YearMonth month = YearMonth.from(baseTime);
|
||||
data.setStartTime(month.atDay(1).atStartOfDay()); // 当月第一天 00:00:00
|
||||
data.setEndTime(month.atEndOfMonth().atTime(23, 59, 59)); // 当月最后一天 23:59:59
|
||||
data.setStartTime(month.atDay(1).atStartOfDay() + ""); // 当月第一天 00:00:00
|
||||
data.setEndTime(month.atEndOfMonth().atTime(23, 59, 59) + ""); // 当月最后一天 23:59:59
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("不支持的带宽类型: " + bandwidthType);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.system.domain.EpsInitialTrafficData;
|
||||
@@ -8,10 +9,11 @@ import com.ruoyi.system.domain.EpsServerRevenueConfig;
|
||||
import com.ruoyi.system.mapper.EpsServerRevenueConfigMapper;
|
||||
import com.ruoyi.system.service.EpsInitialTrafficDataService;
|
||||
import com.ruoyi.system.service.IEpsServerRevenueConfigService;
|
||||
import com.ruoyi.system.util.DateUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -22,6 +24,7 @@ import java.util.Map;
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfigService
|
||||
{
|
||||
@Autowired
|
||||
@@ -124,17 +127,17 @@ public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfi
|
||||
* @param epsServerRevenueConfig
|
||||
*/
|
||||
private void saveServiceTrafficData(EpsServerRevenueConfig epsServerRevenueConfig) {
|
||||
// 查询初始流量数据
|
||||
// 初始流量数据
|
||||
EpsInitialTrafficData epsInitialTrafficData = new EpsInitialTrafficData();
|
||||
epsInitialTrafficData.setServiceSn(epsServerRevenueConfig.getHardwareSn());
|
||||
epsInitialTrafficData.setBusinessId(epsServerRevenueConfig.getBusinessCode());
|
||||
epsInitialTrafficData.setBusinessName(epsServerRevenueConfig.getBusinessName());
|
||||
epsInitialTrafficData.setInterfaceName(epsServerRevenueConfig.getTrafficPort());
|
||||
epsInitialTrafficData.setName(epsServerRevenueConfig.getTrafficPort());
|
||||
epsInitialTrafficData.setPackageBandwidth(epsServerRevenueConfig.getPackageBandwidth());
|
||||
epsInitialTrafficData.setRevenueMethod(epsServerRevenueConfig.getRevenueMethod());
|
||||
epsInitialTrafficData.setNodeName(epsServerRevenueConfig.getNodeName());
|
||||
epsInitialTrafficData.setStartTime(DateUtil.dateToLocalDateTime(epsServerRevenueConfig.getCreateTime()));
|
||||
epsInitialTrafficData.setEndTime(DateUtil.dateToLocalDateTime(epsServerRevenueConfig.getCreateTime()));
|
||||
epsInitialTrafficData.setStartTime(epsServerRevenueConfig.getCreateTime() + "");
|
||||
epsInitialTrafficData.setEndTime(epsServerRevenueConfig.getCreateTime() + "");
|
||||
epsInitialTrafficDataService.save(epsInitialTrafficData);
|
||||
|
||||
}
|
||||
@@ -144,26 +147,39 @@ public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfi
|
||||
* @param epsServerRevenueConfig
|
||||
*/
|
||||
@Override
|
||||
public void autoSaveServiceTrafficData(EpsServerRevenueConfig epsServerRevenueConfig) {
|
||||
public R<String> autoSaveServiceTrafficData(EpsServerRevenueConfig epsServerRevenueConfig) {
|
||||
// 查询初始流量数据
|
||||
EpsInitialTrafficData epsInitialTrafficData = new EpsInitialTrafficData();
|
||||
epsInitialTrafficData.setStartTime(DateUtil.dateToLocalDateTime(epsServerRevenueConfig.getCreateTime()));
|
||||
epsInitialTrafficData.setEndTime(DateUtil.dateToLocalDateTime(epsServerRevenueConfig.getCreateTime()));
|
||||
epsInitialTrafficData.setStartTime(epsServerRevenueConfig.getStartTime());
|
||||
epsInitialTrafficData.setEndTime(epsServerRevenueConfig.getEndTime());
|
||||
List<EpsInitialTrafficData> dataList = epsInitialTrafficDataService.getAllTraficMsg(epsInitialTrafficData);
|
||||
List<EpsInitialTrafficData> batchList = new ArrayList<>();
|
||||
for (EpsInitialTrafficData initialTrafficData : dataList) {
|
||||
// 根据ip查询节点名称
|
||||
String ip = initialTrafficData.getIpv4Address();
|
||||
String ip = initialTrafficData.getIpV4() == null ? "" : initialTrafficData.getIpV4();
|
||||
Map nodeMsg = epsServerRevenueConfigMapper.getNodeMsgByIp(ip);
|
||||
// 赋值
|
||||
initialTrafficData.setServiceSn(nodeMsg.get("hardwareSn") + "");
|
||||
initialTrafficData.setNodeName(nodeMsg.get("resourceName") + "");
|
||||
initialTrafficData.setRevenueMethod(nodeMsg.get("revenueMethod") + "");
|
||||
initialTrafficData.setBusinessId(nodeMsg.get("businessCode") + "");
|
||||
initialTrafficData.setBusinessName(nodeMsg.get("businessName") + "");
|
||||
initialTrafficData.setStartTime(initialTrafficData.getCreateTime());
|
||||
initialTrafficData.setEndTime(initialTrafficData.getCreateTime());
|
||||
// 流量相关数据入库
|
||||
epsInitialTrafficDataService.save(initialTrafficData);
|
||||
if(nodeMsg != null){
|
||||
initialTrafficData.setServiceSn(nodeMsg.get("hardwareSn") + "");
|
||||
initialTrafficData.setNodeName(nodeMsg.get("resourceName") + "");
|
||||
initialTrafficData.setRevenueMethod(nodeMsg.get("revenueMethod") + "");
|
||||
initialTrafficData.setBusinessId(nodeMsg.get("businessCode") + "");
|
||||
initialTrafficData.setBusinessName(nodeMsg.get("businessName") + "");
|
||||
}
|
||||
// id自增
|
||||
initialTrafficData.setId(null);
|
||||
batchList.add(initialTrafficData);
|
||||
}
|
||||
epsInitialTrafficData.setDataList(batchList);
|
||||
// 流量相关数据入库
|
||||
try {
|
||||
epsInitialTrafficDataService.saveBatch(epsInitialTrafficData);
|
||||
log.info("流量数据批量入库成功,数据量:{}", batchList.size());
|
||||
return R.ok("数据保存成功");
|
||||
} catch (Exception e) {
|
||||
log.error("流量数据入库失败,数据量:{},错误原因:{}",
|
||||
batchList.size(), e.getMessage(), e);
|
||||
return R.fail("数据保存失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -125,10 +125,12 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
epsServerRevenueConfig.setHardwareSn(rmResourceRegistration.getHardwareSn());
|
||||
epsServerRevenueConfig.setNodeName(rmResourceRegistration.getResourceName());
|
||||
epsServerRevenueConfig.setCreateTime(DateUtils.getNowDate());
|
||||
epsServerRevenueConfig.setRegistrationStatus(rmResourceRegistration.getRegistrationStatus());
|
||||
// 新增前判断是否存在
|
||||
int exits = epsServerRevenueConfigMapper.countBySn(epsServerRevenueConfig.getHardwareSn());
|
||||
if(exits>0){
|
||||
EpsServerRevenueConfig exits = epsServerRevenueConfigMapper.countBySn(epsServerRevenueConfig.getHardwareSn());
|
||||
if(exits != null){
|
||||
// 存在 修改
|
||||
epsServerRevenueConfig.setId(exits.getId());
|
||||
epsServerRevenueConfigMapper.updateEpsServerRevenueConfig(epsServerRevenueConfig);
|
||||
}else{
|
||||
// 不存在 新增
|
||||
|
||||
@@ -19,7 +19,8 @@ public class TableRouterUtil {
|
||||
// 日期格式
|
||||
private static final DateTimeFormatter YEAR_MONTH_FORMAT =
|
||||
DateTimeFormatter.ofPattern("yyyy_MM");
|
||||
|
||||
private static final DateTimeFormatter DATE_TIME_FORMATTER =
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
/**
|
||||
* 根据创建时间获取表名
|
||||
* @param createTime 记录创建时间
|
||||
@@ -60,17 +61,19 @@ public class TableRouterUtil {
|
||||
|
||||
/**
|
||||
* 获取时间范围内涉及的所有表名
|
||||
* @param startTime 开始时间(包含)
|
||||
* @param endTime 结束时间(包含)
|
||||
* @param startTime 开始时间 (格式: "yyyy-MM-dd HH:mm:ss")
|
||||
* @param endTime 结束时间 (格式: "yyyy-MM-dd HH:mm:ss")
|
||||
* @return 按时间顺序排列的表名集合
|
||||
*/
|
||||
public static Set<String> getTableNamesBetween(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
validateTimeRange(startTime, endTime);
|
||||
public static Set<String> getTableNamesBetween(String startTime, String endTime) {
|
||||
LocalDateTime start = parseDateTime(startTime);
|
||||
LocalDateTime end = parseDateTime(endTime);
|
||||
validateTimeRange(start, end);
|
||||
|
||||
Set<String> tableNames = new LinkedHashSet<>();
|
||||
LocalDateTime current = startTime.withHour(0).withMinute(0).withSecond(0);
|
||||
LocalDateTime current = start.withHour(0).withMinute(0).withSecond(0);
|
||||
|
||||
while (!current.isAfter(endTime)) {
|
||||
while (!current.isAfter(end)) {
|
||||
tableNames.add(getTableName(current));
|
||||
current = current.plusDays(1);
|
||||
}
|
||||
@@ -78,25 +81,37 @@ public class TableRouterUtil {
|
||||
return tableNames;
|
||||
}
|
||||
/**
|
||||
* 获取时间范围内涉及的所有表名
|
||||
* @param startTime 开始时间(包含)
|
||||
* @param endTime 结束时间(包含)
|
||||
* 获取时间范围内涉及的所有初始表名
|
||||
* @param startTime 开始时间 (格式: "yyyy-MM-dd HH:mm:ss")
|
||||
* @param endTime 结束时间 (格式: "yyyy-MM-dd HH:mm:ss")
|
||||
* @return 按时间顺序排列的表名集合
|
||||
*/
|
||||
public static Set<String> getTableNamesBetweenInitial(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
validateTimeRange(startTime, endTime);
|
||||
public static Set<String> getTableNamesBetweenInitial(String startTime, String endTime) {
|
||||
LocalDateTime start = parseDateTime(startTime);
|
||||
LocalDateTime end = parseDateTime(endTime);
|
||||
validateTimeRange(start, end);
|
||||
|
||||
Set<String> tableNames = new LinkedHashSet<>();
|
||||
LocalDateTime current = startTime.withHour(0).withMinute(0).withSecond(0);
|
||||
LocalDateTime current = start.withHour(0).withMinute(0).withSecond(0);
|
||||
|
||||
while (!current.isAfter(endTime)) {
|
||||
while (!current.isAfter(end)) {
|
||||
tableNames.add(getInitialTableName(current));
|
||||
current = current.plusDays(1);
|
||||
}
|
||||
|
||||
return tableNames;
|
||||
}
|
||||
|
||||
// 解析字符串为LocalDateTime
|
||||
private static LocalDateTime parseDateTime(String dateTimeStr) {
|
||||
if (dateTimeStr == null || dateTimeStr.trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("时间字符串不能为空");
|
||||
}
|
||||
try {
|
||||
return LocalDateTime.parse(dateTimeStr, DATE_TIME_FORMATTER);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("时间格式必须为: yyyy-MM-dd HH:mm:ss", e);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取日期区间
|
||||
private static String getDayRange(int day) {
|
||||
|
||||
@@ -54,18 +54,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
INDEX idx_name_time (`name`,create_time)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='初始带宽流量表';
|
||||
</update>
|
||||
<!-- 单条插入 -->
|
||||
<!-- 单条插入语句 -->
|
||||
<insert id="insert">
|
||||
INSERT INTO ${tableName} (
|
||||
interface_name,
|
||||
mac_address,
|
||||
operation_status,
|
||||
interface_type,
|
||||
ipv4_address,
|
||||
inbound_packet_loss,
|
||||
outbound_packet_loss,
|
||||
receive_bandwidth,
|
||||
send_bandwidth,
|
||||
`name`,
|
||||
`mac`,
|
||||
`status`,
|
||||
`type`,
|
||||
ipV4,
|
||||
`in_dropped`,
|
||||
`out_dropped`,
|
||||
`in_speed`,
|
||||
`out_speed`,
|
||||
business_id,
|
||||
business_name,
|
||||
service_sn,
|
||||
@@ -76,15 +76,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update_by,
|
||||
client_id
|
||||
) VALUES (
|
||||
#{interfaceName},
|
||||
#{macAddress},
|
||||
#{operationStatus},
|
||||
#{interfaceType},
|
||||
#{ipv4Address},
|
||||
#{inboundPacketLoss},
|
||||
#{outboundPacketLoss},
|
||||
#{receiveBandwidth},
|
||||
#{sendBandwidth},
|
||||
#{name},
|
||||
#{mac},
|
||||
#{status},
|
||||
#{type},
|
||||
#{ipV4},
|
||||
#{inDropped},
|
||||
#{outDropped},
|
||||
#{inSpeed},
|
||||
#{outSpeed},
|
||||
#{businessId},
|
||||
#{businessName},
|
||||
#{serviceSn},
|
||||
@@ -97,19 +97,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 批量插入 -->
|
||||
<!-- 批量插入语句 -->
|
||||
<insert id="batchInsert">
|
||||
INSERT INTO ${tableName} (
|
||||
id,
|
||||
interface_name,
|
||||
mac_address,
|
||||
operation_status,
|
||||
interface_type,
|
||||
ipv4_address,
|
||||
inbound_packet_loss,
|
||||
outbound_packet_loss,
|
||||
receive_bandwidth,
|
||||
send_bandwidth,
|
||||
`name`,
|
||||
`mac`,
|
||||
`status`,
|
||||
`type`,
|
||||
ipV4,
|
||||
`in_dropped`,
|
||||
`out_dropped`,
|
||||
`in_speed`,
|
||||
`out_speed`,
|
||||
business_id,
|
||||
business_name,
|
||||
service_sn,
|
||||
@@ -122,19 +122,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update_by,
|
||||
client_id
|
||||
) VALUES
|
||||
<foreach collection="list" item="data" separator=",">
|
||||
<foreach collection="dataList" item="data" separator=",">
|
||||
(
|
||||
#{data.id,jdbcType=BIGINT},
|
||||
#{data.interfaceName,jdbcType=VARCHAR},
|
||||
#{data.macAddress,jdbcType=CHAR},
|
||||
#{data.operationStatus,jdbcType=VARCHAR},
|
||||
#{data.interfaceType,jdbcType=VARCHAR},
|
||||
#{data.ipv4Address,jdbcType=VARCHAR},
|
||||
#{data.inboundPacketLoss,jdbcType=DECIMAL},
|
||||
#{data.outboundPacketLoss,jdbcType=DECIMAL},
|
||||
#{data.receiveBandwidth,jdbcType=DECIMAL},
|
||||
#{data.sendBandwidth,jdbcType=DECIMAL},
|
||||
#{data.businessId,jdbcType=CHAR},
|
||||
#{data.name,jdbcType=VARCHAR},
|
||||
#{data.mac,jdbcType=VARCHAR},
|
||||
#{data.status,jdbcType=VARCHAR},
|
||||
#{data.type,jdbcType=VARCHAR},
|
||||
#{data.ipV4,jdbcType=VARCHAR},
|
||||
#{data.inDropped,jdbcType=DECIMAL},
|
||||
#{data.outDropped,jdbcType=DECIMAL},
|
||||
#{data.inSpeed,jdbcType=VARCHAR},
|
||||
#{data.outSpeed,jdbcType=VARCHAR},
|
||||
#{data.businessId,jdbcType=VARCHAR},
|
||||
#{data.businessName,jdbcType=VARCHAR},
|
||||
#{data.serviceSn,jdbcType=VARCHAR},
|
||||
#{data.nodeName,jdbcType=VARCHAR},
|
||||
@@ -153,15 +153,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectByCondition" resultType="EpsInitialTrafficData">
|
||||
SELECT
|
||||
id,
|
||||
`name` AS interfaceName,
|
||||
`mac` AS macAddress,
|
||||
`status` AS operationStatus,
|
||||
`type` AS interfaceType,
|
||||
`ipV4` AS ipv4Address,
|
||||
`in_dropped` AS inboundPacketLoss,
|
||||
`out_dropped` AS outboundPacketLoss,
|
||||
`in_speed` AS receiveBandwidth,
|
||||
`out_speed` AS sendBandwidth,
|
||||
`name` AS name,
|
||||
`mac` AS mac,
|
||||
`status` AS status,
|
||||
`type` AS type,
|
||||
`ipV4` AS ipV4,
|
||||
`in_dropped` AS inDropped,
|
||||
`out_dropped` AS outDropped,
|
||||
`in_speed` AS inSpeed,
|
||||
`out_speed` AS outSpeed,
|
||||
business_id AS businessId,
|
||||
business_name AS businessName,
|
||||
service_sn AS serviceSn,
|
||||
@@ -193,15 +193,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="getAllTraficMsg" resultType="EpsInitialTrafficData">
|
||||
SELECT
|
||||
id,
|
||||
`name` AS interfaceName,
|
||||
`mac` AS macAddress,
|
||||
`status` AS operationStatus,
|
||||
`type` AS interfaceType,
|
||||
`ipV4` AS ipv4Address,
|
||||
`in_dropped` AS inboundPacketLoss,
|
||||
`out_dropped` AS outboundPacketLoss,
|
||||
`in_speed` AS receiveBandwidth,
|
||||
`out_speed` AS sendBandwidth,
|
||||
`name` AS name,
|
||||
`mac` AS mac,
|
||||
`status` AS status,
|
||||
`type` AS type,
|
||||
`ipV4` AS ipV4,
|
||||
`in_dropped` AS inDropped,
|
||||
`out_dropped` AS outDropped,
|
||||
`in_speed` AS inSpeed,
|
||||
`out_speed` AS outSpeed,
|
||||
create_time AS createTime,
|
||||
update_time AS updateTime,
|
||||
create_by AS createBy,
|
||||
|
||||
@@ -46,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
<select id="countBySn" parameterType="String">
|
||||
select count(1) from eps_server_revenue_config
|
||||
<include refid="selectEpsServerRevenueConfigVo"/>
|
||||
where hardware_sn = #{hardwareSn}
|
||||
</select>
|
||||
|
||||
@@ -132,7 +132,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
rrr.hardware_sn = esrc.hardware_sn
|
||||
<where>
|
||||
and rrr.registration_status = '1'
|
||||
<if test="ipAddress != null and ipAddress != ''"> and rrr.ip_address = #{ipAddress}</if>
|
||||
and rrr.ip_address = #{ipAddress}
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -64,6 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updaterId != null "> and updater_id = #{updaterId}</if>
|
||||
<if test="updaterName != null and updaterName != ''"> and updater_name like concat('%', #{updaterName}, '%')</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectRmResourceRegistrationById" parameterType="Long" resultMap="RmResourceRegistrationResult">
|
||||
|
||||
Reference in New Issue
Block a user