优化交换机分表、新增丢包率clientId记录
This commit is contained in:
+62
-32
@@ -1,28 +1,50 @@
|
|||||||
package com.ruoyi.common.core.utils;
|
package com.ruoyi.common.core.utils;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
|
import java.sql.ResultSet;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class TableSubUtil {
|
public class TableSubUtil {
|
||||||
|
|
||||||
// 日期格式
|
// 日期格式
|
||||||
private static final String YEAR_MONTH_FORMAT = "yyyy_MM";
|
private static final String YEAR_MONTH_FORMAT = "yyyy_MM";
|
||||||
private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据创建时间获取表名
|
* 根据创建时间获取表名(过滤不存在的表)
|
||||||
* @param createTime 记录创建时间
|
*/
|
||||||
* @param prefix 表名前缀
|
public static String getExistingTableName(Date createTime, String prefix) {
|
||||||
* @return 对应的分表名称
|
String tableName = getTableName(createTime, prefix);
|
||||||
* @throws IllegalArgumentException 如果createTime为null
|
return tableExists(tableName) ? tableName : null;
|
||||||
*
|
}
|
||||||
* 示例:
|
|
||||||
* 2023-08-05 14:30:00 → rm_mtr_probe_result_2023_08_1_10
|
/**
|
||||||
* 2023-08-15 09:15:00 → rm_mtr_probe_result_2023_08_11_20
|
* 获取时间范围内涉及的所有存在的表名
|
||||||
* 2023-08-25 18:45:00 → rm_mtr_probe_result_2023_08_21_31
|
*/
|
||||||
|
public static Set<String> getExistingTableNamesBetween(String startTime, String endTime, String prefix) {
|
||||||
|
Set<String> allTables = getTableNamesBetween(startTime, endTime, prefix);
|
||||||
|
Set<String> existingTables = new LinkedHashSet<>();
|
||||||
|
|
||||||
|
for (String table : allTables) {
|
||||||
|
if (tableExists(table)) {
|
||||||
|
existingTables.add(table);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return existingTables;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据创建时间获取表名(原始方法)
|
||||||
*/
|
*/
|
||||||
public static String getTableName(Date createTime, String prefix) {
|
public static String getTableName(Date createTime, String prefix) {
|
||||||
if (createTime == null) {
|
if (createTime == null) {
|
||||||
@@ -35,18 +57,11 @@ public class TableSubUtil {
|
|||||||
SimpleDateFormat dayFormat = new SimpleDateFormat("dd");
|
SimpleDateFormat dayFormat = new SimpleDateFormat("dd");
|
||||||
int day = Integer.parseInt(dayFormat.format(createTime));
|
int day = Integer.parseInt(dayFormat.format(createTime));
|
||||||
|
|
||||||
return String.format("%s_%s_%s",
|
return String.format("%s_%s_%s", prefix, yearMonth, getDayRange(day));
|
||||||
prefix,
|
|
||||||
yearMonth,
|
|
||||||
getDayRange(day));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取时间范围内涉及的所有表名
|
* 获取时间范围内涉及的所有表名(原始方法)
|
||||||
* @param startTime 开始时间 (格式: "yyyy-MM-dd HH:mm:ss")
|
|
||||||
* @param endTime 结束时间 (格式: "yyyy-MM-dd HH:mm:ss")
|
|
||||||
* @param prefix 表名前缀
|
|
||||||
* @return 按时间顺序排列的表名集合
|
|
||||||
*/
|
*/
|
||||||
public static Set<String> getTableNamesBetween(String startTime, String endTime, String prefix) {
|
public static Set<String> getTableNamesBetween(String startTime, String endTime, String prefix) {
|
||||||
Date start = parseDateTime(startTime);
|
Date start = parseDateTime(startTime);
|
||||||
@@ -54,27 +69,45 @@ public class TableSubUtil {
|
|||||||
validateTimeRange(start, end);
|
validateTimeRange(start, end);
|
||||||
|
|
||||||
Set<String> tableNames = new LinkedHashSet<>();
|
Set<String> tableNames = new LinkedHashSet<>();
|
||||||
|
Calendar current = Calendar.getInstance();
|
||||||
// 使用java.util.Calendar进行日期操作
|
|
||||||
java.util.Calendar current = java.util.Calendar.getInstance();
|
|
||||||
current.setTime(start);
|
current.setTime(start);
|
||||||
current.set(java.util.Calendar.HOUR_OF_DAY, 0);
|
current.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
current.set(java.util.Calendar.MINUTE, 0);
|
current.set(Calendar.MINUTE, 0);
|
||||||
current.set(java.util.Calendar.SECOND, 0);
|
current.set(Calendar.SECOND, 0);
|
||||||
current.set(java.util.Calendar.MILLISECOND, 0);
|
current.set(Calendar.MILLISECOND, 0);
|
||||||
|
|
||||||
java.util.Calendar endCal = java.util.Calendar.getInstance();
|
Calendar endCal = Calendar.getInstance();
|
||||||
endCal.setTime(end);
|
endCal.setTime(end);
|
||||||
|
|
||||||
while (!current.after(endCal)) {
|
while (!current.after(endCal)) {
|
||||||
tableNames.add(getTableName(current.getTime(), prefix));
|
tableNames.add(getTableName(current.getTime(), prefix));
|
||||||
current.add(java.util.Calendar.DAY_OF_MONTH, 1);
|
current.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tableNames;
|
return tableNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析字符串为Date
|
/**
|
||||||
|
* 检查表是否存在
|
||||||
|
*/
|
||||||
|
private static boolean tableExists(String tableName) {
|
||||||
|
try {
|
||||||
|
// 直接从SpringUtils获取数据源
|
||||||
|
javax.sql.DataSource dataSource = SpringUtils.getBean(javax.sql.DataSource.class);
|
||||||
|
|
||||||
|
try (Connection conn = dataSource.getConnection()) {
|
||||||
|
DatabaseMetaData metaData = conn.getMetaData();
|
||||||
|
try (ResultSet rs = metaData.getTables(conn.getCatalog(), null, tableName, new String[]{"TABLE"})) {
|
||||||
|
return rs.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("检查表是否存在失败: " + tableName + ", error: " + e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 以下为原有辅助方法保持不变
|
||||||
private static Date parseDateTime(String dateTimeStr) {
|
private static Date parseDateTime(String dateTimeStr) {
|
||||||
if (dateTimeStr == null || dateTimeStr.trim().isEmpty()) {
|
if (dateTimeStr == null || dateTimeStr.trim().isEmpty()) {
|
||||||
throw new IllegalArgumentException("时间字符串不能为空");
|
throw new IllegalArgumentException("时间字符串不能为空");
|
||||||
@@ -87,18 +120,15 @@ public class TableSubUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取日期区间
|
|
||||||
private static String getDayRange(int day) {
|
private static String getDayRange(int day) {
|
||||||
if (day < 1 || day > 31) {
|
if (day < 1 || day > 31) {
|
||||||
throw new IllegalArgumentException("日期必须在1-31之间");
|
throw new IllegalArgumentException("日期必须在1-31之间");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (day <= 10) return "1_10";
|
if (day <= 10) return "1_10";
|
||||||
if (day <= 20) return "11_20";
|
if (day <= 20) return "11_20";
|
||||||
return "21_31";
|
return "21_31";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证时间范围
|
|
||||||
private static void validateTimeRange(Date start, Date end) {
|
private static void validateTimeRange(Date start, Date end) {
|
||||||
if (start == null || end == null) {
|
if (start == null || end == null) {
|
||||||
throw new IllegalArgumentException("时间范围参数不能为null");
|
throw new IllegalArgumentException("时间范围参数不能为null");
|
||||||
|
|||||||
+105
@@ -0,0 +1,105 @@
|
|||||||
|
package com.ruoyi.mtragent.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.io.IOException;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.ruoyi.mtragent.domain.AllMtrClient;
|
||||||
|
import com.ruoyi.mtragent.service.IAllMtrClientService;
|
||||||
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mtr探测丢包clinetId记录Controller
|
||||||
|
*
|
||||||
|
* @author gyt
|
||||||
|
* @date 2025-11-24
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/allMtrClient")
|
||||||
|
public class AllMtrClientController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private IAllMtrClientService allMtrClientService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询mtr探测丢包clinetId记录列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("mtragent:allMtrClient:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(AllMtrClient allMtrClient)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<AllMtrClient> list = allMtrClientService.selectAllMtrClientList(allMtrClient);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出mtr探测丢包clinetId记录列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("mtragent:allMtrClient:export")
|
||||||
|
@Log(title = "mtr探测丢包clinetId记录", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, AllMtrClient allMtrClient)
|
||||||
|
{
|
||||||
|
List<AllMtrClient> list = allMtrClientService.selectAllMtrClientList(allMtrClient);
|
||||||
|
ExcelUtil<AllMtrClient> util = new ExcelUtil<AllMtrClient>(AllMtrClient.class);
|
||||||
|
util.exportExcel(response, list, "mtr探测丢包clinetId记录数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取mtr探测丢包clinetId记录详细信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("mtragent:allMtrClient:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||||
|
{
|
||||||
|
return success(allMtrClientService.selectAllMtrClientById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增mtr探测丢包clinetId记录
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("mtragent:allMtrClient:add")
|
||||||
|
@Log(title = "mtr探测丢包clinetId记录", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody AllMtrClient allMtrClient)
|
||||||
|
{
|
||||||
|
return toAjax(allMtrClientService.insertAllMtrClient(allMtrClient));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改mtr探测丢包clinetId记录
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("mtragent:allMtrClient:edit")
|
||||||
|
@Log(title = "mtr探测丢包clinetId记录", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody AllMtrClient allMtrClient)
|
||||||
|
{
|
||||||
|
return toAjax(allMtrClientService.updateAllMtrClient(allMtrClient));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除mtr探测丢包clinetId记录
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("mtragent:allMtrClient:remove")
|
||||||
|
@Log(title = "mtr探测丢包clinetId记录", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] ids)
|
||||||
|
{
|
||||||
|
return toAjax(allMtrClientService.deleteAllMtrClientByIds(ids));
|
||||||
|
}
|
||||||
|
}
|
||||||
+34
@@ -8,6 +8,7 @@ import com.ruoyi.common.core.web.page.TableDataInfo;
|
|||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.ruoyi.mtragent.domain.AllMtrClient;
|
||||||
import com.ruoyi.mtragent.domain.RmMtrClientRegistration;
|
import com.ruoyi.mtragent.domain.RmMtrClientRegistration;
|
||||||
import com.ruoyi.mtragent.service.IRmMtrClientRegistrationService;
|
import com.ruoyi.mtragent.service.IRmMtrClientRegistrationService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -101,4 +102,37 @@ public class RmMtrClientRegistrationController extends BaseController
|
|||||||
int rows = rmMtrClientRegistrationService.addAgentUpdatePolicy(rmMtrClientRegistration);
|
int rows = rmMtrClientRegistrationService.addAgentUpdatePolicy(rmMtrClientRegistration);
|
||||||
return toAjax(rows);
|
return toAjax(rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有MTR客户端注册
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("mtragent:mtrClientRegistration:list")
|
||||||
|
@PostMapping("/getAllMtrMsg")
|
||||||
|
public AjaxResult getAllMtrMsg(@RequestBody RmMtrClientRegistration rmMtrClientRegistration)
|
||||||
|
{
|
||||||
|
List<RmMtrClientRegistration> list = rmMtrClientRegistrationService.selectRmMtrClientRegistrationList(rmMtrClientRegistration);
|
||||||
|
return success(list);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 查询MTR客户端注册列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("mtragent:mtrClientRegistration:list")
|
||||||
|
@PostMapping("/getAllLogicalNode")
|
||||||
|
public AjaxResult getAllLogicalNode(@RequestBody RmMtrClientRegistration rmMtrClientRegistration)
|
||||||
|
{
|
||||||
|
List<RmMtrClientRegistration> list = rmMtrClientRegistrationService.getAllLogicalNode(rmMtrClientRegistration);
|
||||||
|
return success(list);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 根据mtrClientId查询包含的clientId
|
||||||
|
* @param rmMtrClientRegistration
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("mtragent:mtrClientRegistration:list")
|
||||||
|
@PostMapping("/getClientIdByMtrClientId")
|
||||||
|
public AjaxResult getClientIdByMtrClientId(@RequestBody RmMtrClientRegistration rmMtrClientRegistration)
|
||||||
|
{
|
||||||
|
List<AllMtrClient> list = rmMtrClientRegistrationService.getClientIdByMtrClientId(rmMtrClientRegistration);
|
||||||
|
return success(list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+86
@@ -0,0 +1,86 @@
|
|||||||
|
package com.ruoyi.mtragent.domain;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mtr探测丢包clinetId记录对象 all_mtr_client
|
||||||
|
*
|
||||||
|
* @author gyt
|
||||||
|
* @date 2025-11-24
|
||||||
|
*/
|
||||||
|
public class AllMtrClient extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 主键ID */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** MTR客户端ID */
|
||||||
|
@Excel(name = "MTR客户端ID")
|
||||||
|
private String mtrClientId;
|
||||||
|
|
||||||
|
/** 客户端ID */
|
||||||
|
@Excel(name = "客户端ID")
|
||||||
|
private String clientId;
|
||||||
|
|
||||||
|
/** 公网IP地址 */
|
||||||
|
@Excel(name = "公网IP地址")
|
||||||
|
private String publicIp;
|
||||||
|
|
||||||
|
public void setId(Long id)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMtrClientId(String mtrClientId)
|
||||||
|
{
|
||||||
|
this.mtrClientId = mtrClientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMtrClientId()
|
||||||
|
{
|
||||||
|
return mtrClientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClientId(String clientId)
|
||||||
|
{
|
||||||
|
this.clientId = clientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClientId()
|
||||||
|
{
|
||||||
|
return clientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicIp(String publicIp)
|
||||||
|
{
|
||||||
|
this.publicIp = publicIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublicIp()
|
||||||
|
{
|
||||||
|
return publicIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("id", getId())
|
||||||
|
.append("mtrClientId", getMtrClientId())
|
||||||
|
.append("clientId", getClientId())
|
||||||
|
.append("publicIp", getPublicIp())
|
||||||
|
.append("createTime", getCreateTime())
|
||||||
|
.append("updateTime", getUpdateTime())
|
||||||
|
.append("createBy", getCreateBy())
|
||||||
|
.append("updateBy", getUpdateBy())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
-2
@@ -15,6 +15,7 @@ import com.ruoyi.mtragent.utils.JsonDataParser;
|
|||||||
import com.ruoyi.mtragent.utils.WeChatWorkBot;
|
import com.ruoyi.mtragent.utils.WeChatWorkBot;
|
||||||
import com.ruoyi.system.api.domain.NetworkInfo;
|
import com.ruoyi.system.api.domain.NetworkInfo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.data.redis.core.RedisOperations;
|
import org.springframework.data.redis.core.RedisOperations;
|
||||||
@@ -65,9 +66,9 @@ public class MessageHandler {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ProducerMode producerMode;
|
private ProducerMode producerMode;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IRmNetworkInterfaceService rmNetworkInterfaceService;
|
|
||||||
@Autowired
|
|
||||||
private IRmMtrProbeResultService rmMtrProbeResultService;
|
private IRmMtrProbeResultService rmMtrProbeResultService;
|
||||||
|
@Autowired
|
||||||
|
private IAllMtrClientService allMtrClientService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,6 +91,7 @@ public class MessageHandler {
|
|||||||
if(mtrResultVoList != null && !mtrResultVoList.isEmpty()){
|
if(mtrResultVoList != null && !mtrResultVoList.isEmpty()){
|
||||||
String mtrClientId = message.getClientId();
|
String mtrClientId = message.getClientId();
|
||||||
List<RmMtrProbeResult> rmMtrProbeResultList = new ArrayList<>();
|
List<RmMtrProbeResult> rmMtrProbeResultList = new ArrayList<>();
|
||||||
|
List<AllMtrClient> allMtrClientList = new ArrayList<>();
|
||||||
for (MtrResultVo mtrResultVo : mtrResultVoList) {
|
for (MtrResultVo mtrResultVo : mtrResultVoList) {
|
||||||
if(mtrResultVo.getFinalLossPercent() != -1.0){
|
if(mtrResultVo.getFinalLossPercent() != -1.0){
|
||||||
// 时间戳转换
|
// 时间戳转换
|
||||||
@@ -103,6 +105,9 @@ public class MessageHandler {
|
|||||||
rmMtrProbeResult.setPublicIp(mtrResultVo.getTargetIp());
|
rmMtrProbeResult.setPublicIp(mtrResultVo.getTargetIp());
|
||||||
rmMtrProbeResult.setPacketLossRate(new BigDecimal(mtrResultVo.getFinalLossPercent()));
|
rmMtrProbeResult.setPacketLossRate(new BigDecimal(mtrResultVo.getFinalLossPercent()));
|
||||||
rmMtrProbeResultList.add(rmMtrProbeResult);
|
rmMtrProbeResultList.add(rmMtrProbeResult);
|
||||||
|
AllMtrClient allMtrClient = new AllMtrClient();
|
||||||
|
BeanUtils.copyProperties(rmMtrProbeResult, allMtrClient);
|
||||||
|
allMtrClientList.add(allMtrClient);
|
||||||
}else{
|
}else{
|
||||||
log.debug("探测失败,失败原因:{}", mtrResultVo.getErrorMsg());
|
log.debug("探测失败,失败原因:{}", mtrResultVo.getErrorMsg());
|
||||||
}
|
}
|
||||||
@@ -111,6 +116,8 @@ public class MessageHandler {
|
|||||||
insertData.setList(rmMtrProbeResultList);
|
insertData.setList(rmMtrProbeResultList);
|
||||||
// 结果批量入库
|
// 结果批量入库
|
||||||
rmMtrProbeResultService.batchInsertRmMtrProbeResult(insertData);
|
rmMtrProbeResultService.batchInsertRmMtrProbeResult(insertData);
|
||||||
|
// 记录下发策略的clientId
|
||||||
|
allMtrClientService.batchInsertAllMtrClient(allMtrClientList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
package com.ruoyi.mtragent.mapper;
|
||||||
|
|
||||||
|
import com.ruoyi.mtragent.domain.AllMtrClient;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mtr探测丢包clinetId记录Mapper接口
|
||||||
|
*
|
||||||
|
* @author gyt
|
||||||
|
* @date 2025-11-24
|
||||||
|
*/
|
||||||
|
public interface AllMtrClientMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询mtr探测丢包clinetId记录
|
||||||
|
*
|
||||||
|
* @param id mtr探测丢包clinetId记录主键
|
||||||
|
* @return mtr探测丢包clinetId记录
|
||||||
|
*/
|
||||||
|
public AllMtrClient selectAllMtrClientById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询mtr探测丢包clinetId记录列表
|
||||||
|
*
|
||||||
|
* @param allMtrClient mtr探测丢包clinetId记录
|
||||||
|
* @return mtr探测丢包clinetId记录集合
|
||||||
|
*/
|
||||||
|
public List<AllMtrClient> selectAllMtrClientList(AllMtrClient allMtrClient);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增mtr探测丢包clinetId记录
|
||||||
|
*
|
||||||
|
* @param allMtrClient mtr探测丢包clinetId记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertAllMtrClient(AllMtrClient allMtrClient);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改mtr探测丢包clinetId记录
|
||||||
|
*
|
||||||
|
* @param allMtrClient mtr探测丢包clinetId记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateAllMtrClient(AllMtrClient allMtrClient);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除mtr探测丢包clinetId记录
|
||||||
|
*
|
||||||
|
* @param id mtr探测丢包clinetId记录主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAllMtrClientById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除mtr探测丢包clinetId记录
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAllMtrClientByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增
|
||||||
|
* @param allMtrClientList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int batchInsertAllMtrClient(List<AllMtrClient> allMtrClientList);
|
||||||
|
}
|
||||||
+16
-1
@@ -1,8 +1,9 @@
|
|||||||
package com.ruoyi.mtragent.mapper;
|
package com.ruoyi.mtragent.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import com.ruoyi.mtragent.domain.RmMtrClientRegistration;
|
import com.ruoyi.mtragent.domain.RmMtrClientRegistration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MTR客户端注册Mapper接口
|
* MTR客户端注册Mapper接口
|
||||||
*
|
*
|
||||||
@@ -58,4 +59,18 @@ public interface RmMtrClientRegistrationMapper
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteRmMtrClientRegistrationByIds(Long[] ids);
|
public int deleteRmMtrClientRegistrationByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有标识
|
||||||
|
* @param rmMtrClientRegistration
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<RmMtrClientRegistration> getAllLogicalNode(RmMtrClientRegistration rmMtrClientRegistration);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据mtrClientId查询mtr管理信息
|
||||||
|
* @param rmMtrClientRegistration
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
RmMtrClientRegistration getMsgByMtrClientId(RmMtrClientRegistration rmMtrClientRegistration);
|
||||||
}
|
}
|
||||||
|
|||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
package com.ruoyi.mtragent.service;
|
||||||
|
|
||||||
|
import com.ruoyi.mtragent.domain.AllMtrClient;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mtr探测丢包clinetId记录Service接口
|
||||||
|
*
|
||||||
|
* @author gyt
|
||||||
|
* @date 2025-11-24
|
||||||
|
*/
|
||||||
|
public interface IAllMtrClientService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询mtr探测丢包clinetId记录
|
||||||
|
*
|
||||||
|
* @param id mtr探测丢包clinetId记录主键
|
||||||
|
* @return mtr探测丢包clinetId记录
|
||||||
|
*/
|
||||||
|
public AllMtrClient selectAllMtrClientById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询mtr探测丢包clinetId记录列表
|
||||||
|
*
|
||||||
|
* @param allMtrClient mtr探测丢包clinetId记录
|
||||||
|
* @return mtr探测丢包clinetId记录集合
|
||||||
|
*/
|
||||||
|
public List<AllMtrClient> selectAllMtrClientList(AllMtrClient allMtrClient);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增mtr探测丢包clinetId记录
|
||||||
|
*
|
||||||
|
* @param allMtrClient mtr探测丢包clinetId记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertAllMtrClient(AllMtrClient allMtrClient);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改mtr探测丢包clinetId记录
|
||||||
|
*
|
||||||
|
* @param allMtrClient mtr探测丢包clinetId记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateAllMtrClient(AllMtrClient allMtrClient);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除mtr探测丢包clinetId记录
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的mtr探测丢包clinetId记录主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAllMtrClientByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除mtr探测丢包clinetId记录信息
|
||||||
|
*
|
||||||
|
* @param id mtr探测丢包clinetId记录主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAllMtrClientById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量插入client记录
|
||||||
|
* @param allMtrClientList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int batchInsertAllMtrClient(List<AllMtrClient> allMtrClientList);
|
||||||
|
}
|
||||||
+13
@@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.mtragent.service;
|
package com.ruoyi.mtragent.service;
|
||||||
|
|
||||||
|
import com.ruoyi.mtragent.domain.AllMtrClient;
|
||||||
import com.ruoyi.mtragent.domain.RmMtrClientRegistration;
|
import com.ruoyi.mtragent.domain.RmMtrClientRegistration;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -67,4 +68,16 @@ public interface IRmMtrClientRegistrationService
|
|||||||
*/
|
*/
|
||||||
int addAgentUpdatePolicy(RmMtrClientRegistration rmMtrClientRegistration);
|
int addAgentUpdatePolicy(RmMtrClientRegistration rmMtrClientRegistration);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有标识
|
||||||
|
* @param rmMtrClientRegistration
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<RmMtrClientRegistration> getAllLogicalNode(RmMtrClientRegistration rmMtrClientRegistration);
|
||||||
|
/**
|
||||||
|
* 根据mtrClientId查询包含的clientId
|
||||||
|
* @param rmMtrClientRegistration
|
||||||
|
* @return clientId列表
|
||||||
|
*/
|
||||||
|
List<AllMtrClient> getClientIdByMtrClientId(RmMtrClientRegistration rmMtrClientRegistration);
|
||||||
}
|
}
|
||||||
|
|||||||
+103
@@ -0,0 +1,103 @@
|
|||||||
|
package com.ruoyi.mtragent.service.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
|
import com.ruoyi.mtragent.domain.AllMtrClient;
|
||||||
|
import com.ruoyi.mtragent.mapper.AllMtrClientMapper;
|
||||||
|
import com.ruoyi.mtragent.service.IAllMtrClientService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mtr探测丢包clinetId记录Service业务层处理
|
||||||
|
*
|
||||||
|
* @author gyt
|
||||||
|
* @date 2025-11-24
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class AllMtrClientServiceImpl implements IAllMtrClientService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private AllMtrClientMapper allMtrClientMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询mtr探测丢包clinetId记录
|
||||||
|
*
|
||||||
|
* @param id mtr探测丢包clinetId记录主键
|
||||||
|
* @return mtr探测丢包clinetId记录
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AllMtrClient selectAllMtrClientById(Long id)
|
||||||
|
{
|
||||||
|
return allMtrClientMapper.selectAllMtrClientById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询mtr探测丢包clinetId记录列表
|
||||||
|
*
|
||||||
|
* @param allMtrClient mtr探测丢包clinetId记录
|
||||||
|
* @return mtr探测丢包clinetId记录
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AllMtrClient> selectAllMtrClientList(AllMtrClient allMtrClient)
|
||||||
|
{
|
||||||
|
return allMtrClientMapper.selectAllMtrClientList(allMtrClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增mtr探测丢包clinetId记录
|
||||||
|
*
|
||||||
|
* @param allMtrClient mtr探测丢包clinetId记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertAllMtrClient(AllMtrClient allMtrClient)
|
||||||
|
{
|
||||||
|
allMtrClient.setCreateTime(DateUtils.getNowDate());
|
||||||
|
return allMtrClientMapper.insertAllMtrClient(allMtrClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改mtr探测丢包clinetId记录
|
||||||
|
*
|
||||||
|
* @param allMtrClient mtr探测丢包clinetId记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateAllMtrClient(AllMtrClient allMtrClient)
|
||||||
|
{
|
||||||
|
allMtrClient.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
return allMtrClientMapper.updateAllMtrClient(allMtrClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除mtr探测丢包clinetId记录
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的mtr探测丢包clinetId记录主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteAllMtrClientByIds(Long[] ids)
|
||||||
|
{
|
||||||
|
return allMtrClientMapper.deleteAllMtrClientByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除mtr探测丢包clinetId记录信息
|
||||||
|
*
|
||||||
|
* @param id mtr探测丢包clinetId记录主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteAllMtrClientById(Long id)
|
||||||
|
{
|
||||||
|
return allMtrClientMapper.deleteAllMtrClientById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int batchInsertAllMtrClient(List<AllMtrClient> allMtrClientList) {
|
||||||
|
int rows = allMtrClientMapper.batchInsertAllMtrClient(allMtrClientList);
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
}
|
||||||
+18
@@ -3,11 +3,13 @@ package com.ruoyi.mtragent.service.impl;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ruoyi.common.core.enums.MsgEnum;
|
import com.ruoyi.common.core.enums.MsgEnum;
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
|
import com.ruoyi.mtragent.domain.AllMtrClient;
|
||||||
import com.ruoyi.mtragent.domain.DeviceMessage;
|
import com.ruoyi.mtragent.domain.DeviceMessage;
|
||||||
import com.ruoyi.mtragent.domain.RmMtrClientRegistration;
|
import com.ruoyi.mtragent.domain.RmMtrClientRegistration;
|
||||||
import com.ruoyi.mtragent.domain.vo.AgentUpdateMsgVo;
|
import com.ruoyi.mtragent.domain.vo.AgentUpdateMsgVo;
|
||||||
import com.ruoyi.mtragent.domain.vo.PolicyTypeVo;
|
import com.ruoyi.mtragent.domain.vo.PolicyTypeVo;
|
||||||
import com.ruoyi.mtragent.domain.vo.PolicyVo;
|
import com.ruoyi.mtragent.domain.vo.PolicyVo;
|
||||||
|
import com.ruoyi.mtragent.mapper.AllMtrClientMapper;
|
||||||
import com.ruoyi.mtragent.mapper.RmMtrClientRegistrationMapper;
|
import com.ruoyi.mtragent.mapper.RmMtrClientRegistrationMapper;
|
||||||
import com.ruoyi.mtragent.model.ProducerMode;
|
import com.ruoyi.mtragent.model.ProducerMode;
|
||||||
import com.ruoyi.mtragent.producer.MessageProducer;
|
import com.ruoyi.mtragent.producer.MessageProducer;
|
||||||
@@ -35,6 +37,8 @@ public class RmMtrClientRegistrationServiceImpl implements IRmMtrClientRegistrat
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RmMtrClientRegistrationMapper rmMtrClientRegistrationMapper;
|
private RmMtrClientRegistrationMapper rmMtrClientRegistrationMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private AllMtrClientMapper allMtrClientMapper;
|
||||||
|
@Autowired
|
||||||
private ProducerMode producerMode;
|
private ProducerMode producerMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -210,4 +214,18 @@ public class RmMtrClientRegistrationServiceImpl implements IRmMtrClientRegistrat
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RmMtrClientRegistration> getAllLogicalNode(RmMtrClientRegistration rmMtrClientRegistration) {
|
||||||
|
List<RmMtrClientRegistration> list = rmMtrClientRegistrationMapper.getAllLogicalNode(rmMtrClientRegistration);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AllMtrClient> getClientIdByMtrClientId(RmMtrClientRegistration rmMtrClientRegistration) {
|
||||||
|
AllMtrClient allMtrClient = new AllMtrClient();
|
||||||
|
allMtrClient.setMtrClientId(rmMtrClientRegistration.getMtrClientId());
|
||||||
|
List<AllMtrClient> allMtrClientList = allMtrClientMapper.selectAllMtrClientList(allMtrClient);
|
||||||
|
return allMtrClientList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -164,7 +164,7 @@ public class RmMtrProbeResultServiceImpl implements IRmMtrProbeResultService
|
|||||||
*/
|
*/
|
||||||
public List<RmMtrProbeResult> getListByTime(RmMtrProbeResult queryParam){
|
public List<RmMtrProbeResult> getListByTime(RmMtrProbeResult queryParam){
|
||||||
// 获取涉及的表名
|
// 获取涉及的表名
|
||||||
Set<String> tableNames = TableSubUtil.getTableNamesBetween(
|
Set<String> tableNames = TableSubUtil.getExistingTableNamesBetween(
|
||||||
queryParam.getStartTime(),
|
queryParam.getStartTime(),
|
||||||
queryParam.getEndTime(),
|
queryParam.getEndTime(),
|
||||||
TABLE_PREFIX
|
TABLE_PREFIX
|
||||||
|
|||||||
+92
@@ -0,0 +1,92 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.mtragent.mapper.AllMtrClientMapper">
|
||||||
|
|
||||||
|
<resultMap type="AllMtrClient" id="AllMtrClientResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="mtrClientId" column="mtr_client_id" />
|
||||||
|
<result property="clientId" column="client_id" />
|
||||||
|
<result property="publicIp" column="public_ip" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectAllMtrClientVo">
|
||||||
|
select id, mtr_client_id, client_id, public_ip, create_time, update_time, create_by, update_by from all_mtr_client
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectAllMtrClientList" parameterType="AllMtrClient" resultMap="AllMtrClientResult">
|
||||||
|
<include refid="selectAllMtrClientVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="mtrClientId != null and mtrClientId != ''"> and mtr_client_id = #{mtrClientId}</if>
|
||||||
|
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||||
|
<if test="publicIp != null and publicIp != ''"> and public_ip = #{publicIp}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectAllMtrClientById" parameterType="Long" resultMap="AllMtrClientResult">
|
||||||
|
<include refid="selectAllMtrClientVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertAllMtrClient" parameterType="AllMtrClient" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into all_mtr_client
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="mtrClientId != null and mtrClientId != ''">mtr_client_id,</if>
|
||||||
|
<if test="clientId != null and clientId != ''">client_id,</if>
|
||||||
|
<if test="publicIp != null and publicIp != ''">public_ip,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="mtrClientId != null and mtrClientId != ''">#{mtrClientId},</if>
|
||||||
|
<if test="clientId != null and clientId != ''">#{clientId},</if>
|
||||||
|
<if test="publicIp != null and publicIp != ''">#{publicIp},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateAllMtrClient" parameterType="AllMtrClient">
|
||||||
|
update all_mtr_client
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="mtrClientId != null and mtrClientId != ''">mtr_client_id = #{mtrClientId},</if>
|
||||||
|
<if test="clientId != null and clientId != ''">client_id = #{clientId},</if>
|
||||||
|
<if test="publicIp != null and publicIp != ''">public_ip = #{publicIp},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteAllMtrClientById" parameterType="Long">
|
||||||
|
delete from all_mtr_client where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteAllMtrClientByIds" parameterType="String">
|
||||||
|
delete from all_mtr_client where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
<insert id="batchInsertAllMtrClient" parameterType="java.util.List">
|
||||||
|
insert into all_mtr_client
|
||||||
|
(mtr_client_id, client_id, public_ip, create_by, update_by)
|
||||||
|
values
|
||||||
|
<foreach collection="list" item="item" separator=",">
|
||||||
|
(#{item.mtrClientId}, #{item.clientId}, #{item.publicIp}, #{item.createBy}, #{item.updateBy})
|
||||||
|
</foreach>
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
public_ip = IF(VALUES(public_ip) != public_ip, VALUES(public_ip), public_ip)
|
||||||
|
</insert>
|
||||||
|
</mapper>
|
||||||
+22
@@ -52,6 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="lastUpdateTime != null "> and last_update_time = #{lastUpdateTime}</if>
|
<if test="lastUpdateTime != null "> and last_update_time = #{lastUpdateTime}</if>
|
||||||
<if test="networkInfo != null and networkInfo != ''"> and network_info = #{networkInfo}</if>
|
<if test="networkInfo != null and networkInfo != ''"> and network_info = #{networkInfo}</if>
|
||||||
</where>
|
</where>
|
||||||
|
order by create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectRmMtrClientRegistrationById" parameterType="Long" resultMap="RmMtrClientRegistrationResult">
|
<select id="selectRmMtrClientRegistrationById" parameterType="Long" resultMap="RmMtrClientRegistrationResult">
|
||||||
@@ -156,4 +157,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
<select id="getAllLogicalNode" parameterType="RmMtrClientRegistration" resultMap="RmMtrClientRegistrationResult">
|
||||||
|
<include refid="selectRmMtrClientRegistrationVo"/>
|
||||||
|
<where>
|
||||||
|
and logical_node != ''
|
||||||
|
</where>
|
||||||
|
group by logical_node
|
||||||
|
</select>
|
||||||
|
<select id="getMsgByMtrClientId" parameterType="RmMtrClientRegistration" resultMap="RmMtrClientRegistrationResult">
|
||||||
|
<include refid="selectRmMtrClientRegistrationVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="mtrClientId != null and mtrClientId != ''"> and mtr_client_id = #{mtrClientId}</if>
|
||||||
|
<if test="description != null and description != ''"> and description = #{description}</if>
|
||||||
|
<if test="version != null and version != ''"> and version = #{version}</if>
|
||||||
|
<if test="logicalNode != null and logicalNode != ''"> and logical_node = #{logicalNode}</if>
|
||||||
|
<if test="registerTime != null "> and register_time = #{registerTime}</if>
|
||||||
|
<if test="registerStatus != null and registerStatus != ''"> and register_status = #{registerStatus}</if>
|
||||||
|
<if test="onlineStatus != null and onlineStatus != ''"> and online_status = #{onlineStatus}</if>
|
||||||
|
</where>
|
||||||
|
order by create_time desc
|
||||||
|
limit 1
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
+7
-22
@@ -10,8 +10,9 @@ import com.ruoyi.system.service.EpsInitialTrafficDataService;
|
|||||||
import com.ruoyi.system.service.IEpsServerRevenueConfigService;
|
import com.ruoyi.system.service.IEpsServerRevenueConfigService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.dao.DuplicateKeyException;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Isolation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -237,7 +238,8 @@ public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfi
|
|||||||
/**
|
/**
|
||||||
* 批量处理接口名称
|
* 批量处理接口名称
|
||||||
*/
|
*/
|
||||||
private void processInterfaceNames(List<EpsInitialTrafficData> trafficDataList) {
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.REPEATABLE_READ)
|
||||||
|
public void processInterfaceNames(List<EpsInitialTrafficData> trafficDataList) {
|
||||||
// 分类处理:新增列表 vs 更新列表
|
// 分类处理:新增列表 vs 更新列表
|
||||||
List<AllInterfaceName> namesToInsert = new ArrayList<>();
|
List<AllInterfaceName> namesToInsert = new ArrayList<>();
|
||||||
List<AllInterfaceName> namesToUpdate = new ArrayList<>();
|
List<AllInterfaceName> namesToUpdate = new ArrayList<>();
|
||||||
@@ -308,30 +310,13 @@ public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfi
|
|||||||
try {
|
try {
|
||||||
allInterfaceNameMapper.batchInsert(namesToInsert);
|
allInterfaceNameMapper.batchInsert(namesToInsert);
|
||||||
log.info("新增接口名称数量:{}", namesToInsert.size());
|
log.info("新增接口名称数量:{}", namesToInsert.size());
|
||||||
} catch (DuplicateKeyException e) {
|
} catch (Exception e) {
|
||||||
// 如果批量插入出现重复,转为逐条插入(带异常处理)
|
log.error("新增接口名称失败:{}", e.getMessage());
|
||||||
log.warn("批量插入出现重复,转为逐条处理");
|
|
||||||
namesToInsert.forEach(record -> {
|
|
||||||
try {
|
|
||||||
allInterfaceNameMapper.insertAllInterfaceName(record);
|
|
||||||
} catch (DuplicateKeyException ex) {
|
|
||||||
// 重复记录转为更新
|
|
||||||
AllInterfaceName query = new AllInterfaceName();
|
|
||||||
query.setInterfaceName(record.getInterfaceName());
|
|
||||||
query.setClientId(record.getClientId());
|
|
||||||
query.setServerIp(record.getServerIp());
|
|
||||||
|
|
||||||
List<AllInterfaceName> existing = allInterfaceNameMapper.selectByNames(query);
|
|
||||||
if (!existing.isEmpty()) {
|
|
||||||
record.setId(existing.get(0).getId());
|
|
||||||
allInterfaceNameMapper.updateAllInterfaceName(record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!namesToUpdate.isEmpty()) {
|
if (!namesToUpdate.isEmpty()) {
|
||||||
|
namesToUpdate.sort(Comparator.comparing(AllInterfaceName::getId));
|
||||||
allInterfaceNameMapper.batchUpdate(namesToUpdate);
|
allInterfaceNameMapper.batchUpdate(namesToUpdate);
|
||||||
log.info("更新接口名称数量:{}", namesToUpdate.size());
|
log.info("更新接口名称数量:{}", namesToUpdate.size());
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-27
@@ -13,7 +13,6 @@ import com.ruoyi.system.util.PaginationUtil;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.dao.DuplicateKeyException;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Isolation;
|
import org.springframework.transaction.annotation.Isolation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -225,7 +224,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
*/
|
*/
|
||||||
public List<InitialSwitchInfoDetails> getSwitchTrafficMsgSharding(InitialSwitchInfoDetails queryParam) {
|
public List<InitialSwitchInfoDetails> getSwitchTrafficMsgSharding(InitialSwitchInfoDetails queryParam) {
|
||||||
// 获取涉及的表名
|
// 获取涉及的表名
|
||||||
Set<String> tableNames = TableSubUtil.getTableNamesBetween(queryParam.getStartTime(), queryParam.getEndTime(), "initial_switch_info");
|
Set<String> tableNames = TableSubUtil.getExistingTableNamesBetween(queryParam.getStartTime(), queryParam.getEndTime(), "initial_switch_info");
|
||||||
|
|
||||||
// 并行查询各表
|
// 并行查询各表
|
||||||
return tableNames.parallelStream()
|
return tableNames.parallelStream()
|
||||||
@@ -353,6 +352,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
/**
|
/**
|
||||||
* 批量处理接口名称
|
* 批量处理接口名称
|
||||||
*/
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.REPEATABLE_READ)
|
||||||
private void processSwitchInterfaceNames(List<InitialSwitchInfoDetails> initialSwitchInfoDetails) {
|
private void processSwitchInterfaceNames(List<InitialSwitchInfoDetails> initialSwitchInfoDetails) {
|
||||||
// 分类处理:新增列表 vs 更新列表
|
// 分类处理:新增列表 vs 更新列表
|
||||||
List<AllInterfaceName> namesToInsert = new ArrayList<>();
|
List<AllInterfaceName> namesToInsert = new ArrayList<>();
|
||||||
@@ -421,33 +421,16 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
if (!namesToInsert.isEmpty()) {
|
if (!namesToInsert.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
allInterfaceNameMapper.batchInsert(namesToInsert);
|
allInterfaceNameMapper.batchInsert(namesToInsert);
|
||||||
log.info("新增接口名称数量:{}", namesToInsert.size());
|
log.info("交换机新增接口名称数量:{}", namesToInsert.size());
|
||||||
} catch (DuplicateKeyException e) {
|
} catch (Exception e) {
|
||||||
// 如果批量插入出现重复,转为逐条插入(带异常处理)
|
log.error("交换机接口名称批量插入失败:{}", e.getMessage());
|
||||||
log.warn("批量插入出现重复,转为逐条处理");
|
|
||||||
namesToInsert.forEach(record -> {
|
|
||||||
try {
|
|
||||||
allInterfaceNameMapper.insertAllInterfaceName(record);
|
|
||||||
} catch (DuplicateKeyException ex) {
|
|
||||||
// 重复记录转为更新
|
|
||||||
AllInterfaceName query = new AllInterfaceName();
|
|
||||||
query.setInterfaceName(record.getInterfaceName());
|
|
||||||
query.setClientId(record.getClientId());
|
|
||||||
query.setServerIp(record.getServerIp());
|
|
||||||
|
|
||||||
List<AllInterfaceName> existing = allInterfaceNameMapper.selectByNames(query);
|
|
||||||
if (!existing.isEmpty()) {
|
|
||||||
record.setId(existing.get(0).getId());
|
|
||||||
allInterfaceNameMapper.updateAllInterfaceName(record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!namesToUpdate.isEmpty()) {
|
if (!namesToUpdate.isEmpty()) {
|
||||||
|
namesToUpdate.sort(Comparator.comparing(AllInterfaceName::getId));
|
||||||
allInterfaceNameMapper.batchUpdate(namesToUpdate);
|
allInterfaceNameMapper.batchUpdate(namesToUpdate);
|
||||||
log.info("更新接口名称数量:{}", namesToUpdate.size());
|
log.info("交换机更新接口名称数量:{}", namesToUpdate.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1141,7 +1124,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
*/
|
*/
|
||||||
public List<InitialSwitchInfoDetails> getSwitchTrafficDetailsMsgSharding(InitialSwitchInfoDetails queryParam) {
|
public List<InitialSwitchInfoDetails> getSwitchTrafficDetailsMsgSharding(InitialSwitchInfoDetails queryParam) {
|
||||||
// 获取涉及的表名
|
// 获取涉及的表名
|
||||||
Set<String> tableNames = TableSubUtil.getTableNamesBetween(queryParam.getStartTime(), queryParam.getEndTime(), TABLE_PREFIX);
|
Set<String> tableNames = TableSubUtil.getExistingTableNamesBetween(queryParam.getStartTime(), queryParam.getEndTime(), TABLE_PREFIX);
|
||||||
|
|
||||||
// 并行查询各表
|
// 并行查询各表
|
||||||
return tableNames.parallelStream()
|
return tableNames.parallelStream()
|
||||||
@@ -1164,7 +1147,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
@Override
|
@Override
|
||||||
public List<InitialSwitchInfoDetails> sumSwitchTrafficDetailsSharding(InitialSwitchInfoDetails queryParam) {
|
public List<InitialSwitchInfoDetails> sumSwitchTrafficDetailsSharding(InitialSwitchInfoDetails queryParam) {
|
||||||
// 获取涉及的表名
|
// 获取涉及的表名
|
||||||
Set<String> tableNames = TableSubUtil.getTableNamesBetween(queryParam.getStartTime(), queryParam.getEndTime(), TABLE_PREFIX);
|
Set<String> tableNames = TableSubUtil.getExistingTableNamesBetween(queryParam.getStartTime(), queryParam.getEndTime(), TABLE_PREFIX);
|
||||||
|
|
||||||
// 并行查询各表
|
// 并行查询各表
|
||||||
return tableNames.parallelStream()
|
return tableNames.parallelStream()
|
||||||
@@ -1188,7 +1171,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
*/
|
*/
|
||||||
public List<InitialSwitchInfoDetails> getSwitchTrafficDetailsListSharding(InitialSwitchInfoDetails queryParam) {
|
public List<InitialSwitchInfoDetails> getSwitchTrafficDetailsListSharding(InitialSwitchInfoDetails queryParam) {
|
||||||
// 获取涉及的表名
|
// 获取涉及的表名
|
||||||
Set<String> tableNames = TableSubUtil.getTableNamesBetween(queryParam.getStartTime(), queryParam.getEndTime(), TABLE_PREFIX);
|
Set<String> tableNames = TableSubUtil.getExistingTableNamesBetween(queryParam.getStartTime(), queryParam.getEndTime(), TABLE_PREFIX);
|
||||||
|
|
||||||
// 并行查询各表
|
// 并行查询各表
|
||||||
return tableNames.parallelStream()
|
return tableNames.parallelStream()
|
||||||
|
|||||||
+2
-1
@@ -178,7 +178,7 @@ public class InitialSwitchInfoServiceImpl implements IInitialSwitchInfoService
|
|||||||
*/
|
*/
|
||||||
public List<InitialSwitchInfo> getSwitchMsgSharding(InitialSwitchInfo queryParam) {
|
public List<InitialSwitchInfo> getSwitchMsgSharding(InitialSwitchInfo queryParam) {
|
||||||
// 获取涉及的表名
|
// 获取涉及的表名
|
||||||
Set<String> tableNames = TableSubUtil.getTableNamesBetween(queryParam.getStartTime(), queryParam.getEndTime(), TABLE_PREFIX);
|
Set<String> tableNames = TableSubUtil.getExistingTableNamesBetween(queryParam.getStartTime(), queryParam.getEndTime(), TABLE_PREFIX);
|
||||||
|
|
||||||
// 并行查询各表
|
// 并行查询各表
|
||||||
return tableNames.parallelStream()
|
return tableNames.parallelStream()
|
||||||
@@ -186,6 +186,7 @@ public class InitialSwitchInfoServiceImpl implements IInitialSwitchInfoService
|
|||||||
InitialSwitchInfo condition = new InitialSwitchInfo();
|
InitialSwitchInfo condition = new InitialSwitchInfo();
|
||||||
condition.setTableName(tableName);
|
condition.setTableName(tableName);
|
||||||
condition.setClientId(queryParam.getClientId());
|
condition.setClientId(queryParam.getClientId());
|
||||||
|
condition.setName(queryParam.getName());
|
||||||
condition.setStartTime(queryParam.getStartTime());
|
condition.setStartTime(queryParam.getStartTime());
|
||||||
condition.setEndTime(queryParam.getEndTime());
|
condition.setEndTime(queryParam.getEndTime());
|
||||||
return initialSwitchInfoMapper.selectInitialSwitchInfoListSharding(condition).stream();
|
return initialSwitchInfoMapper.selectInitialSwitchInfoListSharding(condition).stream();
|
||||||
|
|||||||
Reference in New Issue
Block a user