初始流量数据库读取mq入库
This commit is contained in:
@@ -78,5 +78,12 @@ public interface RemoteUserService
|
||||
*/
|
||||
@PostMapping("/batch")
|
||||
public R<Boolean> batchInitialTraffic(@RequestBody EpsInitialTrafficDataRemote queryParam, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
/**
|
||||
* 保存流量数据
|
||||
* @param queryParam 流量数据列表
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping("/revenueConfig/autoSaveServiceTrafficData")
|
||||
public R<Boolean> autoSaveServiceTrafficData(@RequestBody EpsInitialTrafficDataRemote queryParam, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
}
|
||||
|
||||
+35
-86
@@ -1,10 +1,10 @@
|
||||
package com.ruoyi.system.api.domain;
|
||||
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* EPS初始流量数据实体类
|
||||
@@ -12,98 +12,47 @@ import java.util.Set;
|
||||
* 支持按时间自动分表存储(每月分成3个表)
|
||||
*/
|
||||
@Data
|
||||
public class EpsInitialTrafficDataRemote {
|
||||
/** 主键ID */
|
||||
public class EpsInitialTrafficDataRemote extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 唯一标识ID */
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 动态表名
|
||||
* 格式:eps_traffic_[年]_[月]_[日期范围]
|
||||
* 示例:eps_traffic_2023_08_1_10
|
||||
*/
|
||||
private String tableName;
|
||||
/** 节点名称 */
|
||||
@Excel(name = "节点名称")
|
||||
private String nodeName;
|
||||
|
||||
/** 流量统计开始时间 */
|
||||
private LocalDateTime startTime;
|
||||
/** 收益方式(1.流量,2包端) */
|
||||
@Excel(name = "收益方式(1.流量,2包端)")
|
||||
private String revenueMethod;
|
||||
|
||||
/** 流量统计结束时间 */
|
||||
private LocalDateTime endTime;
|
||||
/** 硬件SN */
|
||||
@Excel(name = "硬件SN")
|
||||
private String hardwareSn;
|
||||
|
||||
/** 接收流量(单位:MB) */
|
||||
private Double receiveTraffic;
|
||||
/** 流量网口 */
|
||||
@Excel(name = "流量网口")
|
||||
private String trafficPort;
|
||||
|
||||
/** 发送流量(单位:MB) */
|
||||
private Double sendTraffic;
|
||||
/** 95带宽值(Mbps) */
|
||||
@Excel(name = "95带宽值(Mbps)")
|
||||
private BigDecimal bandwidth95;
|
||||
|
||||
/** 设备序列号 */
|
||||
private String deviceSn;
|
||||
/** 包端带宽值 */
|
||||
@Excel(name = "包端带宽值")
|
||||
private BigDecimal packageBandwidth;
|
||||
|
||||
/** 数据创建时间 */
|
||||
private LocalDateTime createTime;
|
||||
/** 业务名称 */
|
||||
@Excel(name = "业务名称")
|
||||
private String businessName;
|
||||
|
||||
/** 备用字段1 */
|
||||
private String remark1;
|
||||
/** 业务代码(12位) */
|
||||
@Excel(name = "业务代码(12位)")
|
||||
private String businessCode;
|
||||
|
||||
/** 备用字段2 */
|
||||
private String remark2;
|
||||
/** 注册状态 */
|
||||
@Excel(name = "注册状态")
|
||||
private String registrationStatus;
|
||||
|
||||
/** 备用字段3 */
|
||||
private String remark3;
|
||||
|
||||
/** 备用字段4 */
|
||||
private String remark4;
|
||||
|
||||
/**
|
||||
* 根据createTime自动计算表名
|
||||
* 分表规则:每月分成3个表(1-10日、11-20日、21-31日)
|
||||
*/
|
||||
public void calculateTableName() {
|
||||
if (this.createTime != null) {
|
||||
int year = createTime.getYear();
|
||||
int month = createTime.getMonthValue();
|
||||
int day = createTime.getDayOfMonth();
|
||||
|
||||
String range;
|
||||
if (day <= 10) {
|
||||
range = "1_10";
|
||||
} else if (day <= 20) {
|
||||
range = "11_20";
|
||||
} else {
|
||||
range = "21_31";
|
||||
}
|
||||
|
||||
this.tableName = String.format("eps_traffic_%d_%02d_%s", year, month, range);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取时间范围内涉及的所有表名
|
||||
* @param start 开始时间
|
||||
* @param end 结束时间
|
||||
* @return 涉及的动态表名集合
|
||||
*/
|
||||
public static Set<String> getAffectedTables(LocalDateTime start, LocalDateTime end) {
|
||||
Set<String> tables = new LinkedHashSet<>();
|
||||
LocalDateTime current = start;
|
||||
|
||||
while (!current.isAfter(end)) {
|
||||
int year = current.getYear();
|
||||
int month = current.getMonthValue();
|
||||
int day = current.getDayOfMonth();
|
||||
|
||||
String range;
|
||||
if (day <= 10) {
|
||||
range = "1_10";
|
||||
} else if (day <= 20) {
|
||||
range = "11_20";
|
||||
} else {
|
||||
range = "21_31";
|
||||
}
|
||||
|
||||
tables.add(String.format("eps_traffic_%d_%02d_%s", year, month, range));
|
||||
current = current.plusDays(1);
|
||||
}
|
||||
|
||||
return tables;
|
||||
}
|
||||
}
|
||||
+4
@@ -63,6 +63,10 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
||||
public R<Boolean> batchInitialTraffic(EpsInitialTrafficDataRemote queryParam, String source) {
|
||||
return R.fail("新增初始流量数据失败:" + throwable.getMessage());
|
||||
}
|
||||
@Override
|
||||
public R<Boolean> autoSaveServiceTrafficData(EpsInitialTrafficDataRemote queryParam, String source) {
|
||||
return R.fail("保存流量数据失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user