开发tcpdump策略表CRUD
This commit is contained in:
+98
@@ -0,0 +1,98 @@
|
||||
package com.tongran.rocketmq.controller;
|
||||
|
||||
import com.tongran.common.core.utils.poi.ExcelUtil;
|
||||
import com.tongran.common.core.web.controller.BaseController;
|
||||
import com.tongran.common.core.web.domain.AjaxResult;
|
||||
import com.tongran.common.core.web.page.TableDataInfo;
|
||||
import com.tongran.common.log.annotation.Log;
|
||||
import com.tongran.common.log.enums.BusinessType;
|
||||
import com.tongran.common.security.annotation.RequiresPermissions;
|
||||
import com.tongran.rocketmq.domain.RmOutboundTrafficStatistics;
|
||||
import com.tongran.rocketmq.service.IRmOutboundTrafficStatisticsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 出省流量统计Controller
|
||||
*
|
||||
* @author tongran
|
||||
* @date 2026-01-21
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/rmOutboundTrafficStatistics")
|
||||
public class RmOutboundTrafficStatisticsController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IRmOutboundTrafficStatisticsService rmOutboundTrafficStatisticsService;
|
||||
|
||||
/**
|
||||
* 查询出省流量统计列表
|
||||
*/
|
||||
@RequiresPermissions("rocketmq:rmOutboundTrafficStatistics:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(RmOutboundTrafficStatistics rmOutboundTrafficStatistics)
|
||||
{
|
||||
startPage();
|
||||
List<RmOutboundTrafficStatistics> list = rmOutboundTrafficStatisticsService.selectRmOutboundTrafficStatisticsList(rmOutboundTrafficStatistics);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出出省流量统计列表
|
||||
*/
|
||||
@RequiresPermissions("rocketmq:rmOutboundTrafficStatistics:export")
|
||||
@Log(title = "出省流量统计", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, RmOutboundTrafficStatistics rmOutboundTrafficStatistics)
|
||||
{
|
||||
List<RmOutboundTrafficStatistics> list = rmOutboundTrafficStatisticsService.selectRmOutboundTrafficStatisticsList(rmOutboundTrafficStatistics);
|
||||
ExcelUtil<RmOutboundTrafficStatistics> util = new ExcelUtil<RmOutboundTrafficStatistics>(RmOutboundTrafficStatistics.class);
|
||||
util.exportExcel(response, list, "出省流量统计数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取出省流量统计详细信息
|
||||
*/
|
||||
@RequiresPermissions("rocketmq:rmOutboundTrafficStatistics:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(rmOutboundTrafficStatisticsService.selectRmOutboundTrafficStatisticsById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增出省流量统计
|
||||
*/
|
||||
@RequiresPermissions("rocketmq:rmOutboundTrafficStatistics:add")
|
||||
@Log(title = "出省流量统计", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody RmOutboundTrafficStatistics rmOutboundTrafficStatistics)
|
||||
{
|
||||
return toAjax(rmOutboundTrafficStatisticsService.insertRmOutboundTrafficStatistics(rmOutboundTrafficStatistics));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改出省流量统计
|
||||
*/
|
||||
@RequiresPermissions("rocketmq:rmOutboundTrafficStatistics:edit")
|
||||
@Log(title = "出省流量统计", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody RmOutboundTrafficStatistics rmOutboundTrafficStatistics)
|
||||
{
|
||||
return toAjax(rmOutboundTrafficStatisticsService.updateRmOutboundTrafficStatistics(rmOutboundTrafficStatistics));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除出省流量统计
|
||||
*/
|
||||
@RequiresPermissions("rocketmq:rmOutboundTrafficStatistics:remove")
|
||||
@Log(title = "出省流量统计", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(rmOutboundTrafficStatisticsService.deleteRmOutboundTrafficStatisticsByIds(ids));
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.tongran.rocketmq.controller;
|
||||
|
||||
import com.tongran.common.core.web.controller.BaseController;
|
||||
import com.tongran.common.core.web.domain.AjaxResult;
|
||||
import com.tongran.common.log.annotation.Log;
|
||||
import com.tongran.common.log.enums.BusinessType;
|
||||
import com.tongran.common.security.annotation.RequiresPermissions;
|
||||
import com.tongran.rocketmq.domain.RmTcpdumpConfig;
|
||||
import com.tongran.rocketmq.service.IRmTcpdumpConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* tcpdump探测策略Controller
|
||||
*
|
||||
* @author tongran
|
||||
* @date 2026-01-21
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/rmTcpdumpConfig")
|
||||
@RequiresPermissions("rocketmq:traffic")
|
||||
public class RmTcpdumpConfigController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IRmTcpdumpConfigService rmTcpdumpConfigService;
|
||||
|
||||
/**
|
||||
* 查询tcpdump探测策略列表
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public AjaxResult list(RmTcpdumpConfig rmTcpdumpConfig)
|
||||
{
|
||||
List<RmTcpdumpConfig> list = rmTcpdumpConfigService.selectRmTcpdumpConfigList(rmTcpdumpConfig);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取tcpdump探测策略详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{clientId}")
|
||||
public AjaxResult getInfo(@PathVariable("clientId") String clientId)
|
||||
{
|
||||
return success(rmTcpdumpConfigService.selectRmTcpdumpConfigByClientId(clientId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增tcpdump探测策略
|
||||
*/
|
||||
@Log(title = "tcpdump探测策略", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody RmTcpdumpConfig rmTcpdumpConfig)
|
||||
{
|
||||
return toAjax(rmTcpdumpConfigService.insertRmTcpdumpConfig(rmTcpdumpConfig));
|
||||
}
|
||||
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package com.tongran.rocketmq.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.tongran.common.core.annotation.Excel;
|
||||
import com.tongran.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 出省流量统计对象 rm_outbound_traffic_statistics
|
||||
*
|
||||
* @author tongran
|
||||
* @date 2026-01-21
|
||||
*/
|
||||
public class RmOutboundTrafficStatistics extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
private Long id;
|
||||
|
||||
/** 客户端ID */
|
||||
@Excel(name = "客户端ID")
|
||||
private String clientId;
|
||||
|
||||
/** 出省流量统计详情 */
|
||||
@Excel(name = "出省流量统计详情")
|
||||
private String description;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId)
|
||||
{
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public String getClientId()
|
||||
{
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("clientId", getClientId())
|
||||
.append("description", getDescription())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.tongran.rocketmq.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.tongran.common.core.annotation.Excel;
|
||||
import com.tongran.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* tcpdump探测策略对象 rm_tcpdump_config
|
||||
*
|
||||
* @author tongran
|
||||
* @date 2026-01-21
|
||||
*/
|
||||
public class RmTcpdumpConfig extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
private Long id;
|
||||
|
||||
/** 客户端ID */
|
||||
@Excel(name = "客户端ID")
|
||||
private String clientId;
|
||||
|
||||
/** 开启探测(0:否,1:是) */
|
||||
@Excel(name = "开启探测(0:否,1:是)")
|
||||
private Integer detectFlag;
|
||||
|
||||
/** 探测频率 */
|
||||
@Excel(name = "探测频率")
|
||||
private String frequency;
|
||||
|
||||
/** 探测时间列表(多个时间用;分隔) */
|
||||
@Excel(name = "探测时间列表(多个时间用;分隔)")
|
||||
private String detectTimes;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId)
|
||||
{
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public String getClientId()
|
||||
{
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setDetectFlag(Integer detectFlag)
|
||||
{
|
||||
this.detectFlag = detectFlag;
|
||||
}
|
||||
|
||||
public Integer getDetectFlag()
|
||||
{
|
||||
return detectFlag;
|
||||
}
|
||||
|
||||
public void setFrequency(String frequency)
|
||||
{
|
||||
this.frequency = frequency;
|
||||
}
|
||||
|
||||
public String getFrequency()
|
||||
{
|
||||
return frequency;
|
||||
}
|
||||
|
||||
public void setDetectTimes(String detectTimes)
|
||||
{
|
||||
this.detectTimes = detectTimes;
|
||||
}
|
||||
|
||||
public String getDetectTimes()
|
||||
{
|
||||
return detectTimes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("clientId", getClientId())
|
||||
.append("detectFlag", getDetectFlag())
|
||||
.append("frequency", getFrequency())
|
||||
.append("detectTimes", getDetectTimes())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,8 @@ public class PolicyTypeVo {
|
||||
private String umountDisk;
|
||||
/** 需要删除的时间戳 */
|
||||
private String trafficUsedTimestamp;
|
||||
/** tcpdump探测时间 */
|
||||
private String tcpdumpTimes;
|
||||
/** 时间戳 */
|
||||
private Long timestamp = Instant.now().getEpochSecond();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.tongran.rocketmq.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TcpdumpVo {
|
||||
/** ip地址 */
|
||||
private String ip;
|
||||
/** 出现次数 */
|
||||
private Integer count;
|
||||
}
|
||||
@@ -20,6 +20,12 @@ import com.tongran.rocketmq.utils.WeChatWorkBot;
|
||||
import com.tongran.system.api.RemoteRevenueConfigService;
|
||||
import com.tongran.system.api.domain.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -33,6 +39,7 @@ import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
@@ -143,6 +150,33 @@ public class MessageHandler {
|
||||
registerHandler(MsgEnum.修改frp配置文件应答.getValue(), this::handleUpdateFrpMessage);
|
||||
registerHandler(MsgEnum.macvlan状态上报.getValue(), this::handleMacvlanMessage);
|
||||
registerHandler(MsgEnum.iops结果上报.getValue(), this::handleIopsResultMessage);
|
||||
registerHandler(MsgEnum.tcpdump结果上报.getValue(), this::handleTcpdumpResultMessage);
|
||||
}
|
||||
|
||||
private void handleTcpdumpResultMessage(DeviceMessage message) {
|
||||
List<TcpdumpVo> tcpdumpVoList = JsonDataParser.parseJsonData(message.getData(), TcpdumpVo.class);
|
||||
if(tcpdumpVoList != null && !tcpdumpVoList.isEmpty()){
|
||||
for (TcpdumpVo tcpdumpVo : tcpdumpVoList) {
|
||||
String ip = tcpdumpVo.getIp();
|
||||
Integer count = tcpdumpVo.getCount();
|
||||
String type = checkIPVersion(ip);
|
||||
// 查询IP地址归属地信息
|
||||
Map<String, String> locationInfo = queryIpLocation(ip);
|
||||
if (locationInfo != null) {
|
||||
String operator = locationInfo.get("operator"); // 运营商
|
||||
String province = locationInfo.get("province"); // 省份
|
||||
|
||||
System.out.println("IP: " + ip +
|
||||
", 运营商: " + operator +
|
||||
", 省份: " + province +
|
||||
", 抓包数量: " + count);
|
||||
|
||||
// 设置到对象中(如果TcpdumpVo有这些字段)
|
||||
// tcpdumpVo.setOperator(operator);
|
||||
// tcpdumpVo.setProvince(province);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleIopsResultMessage(DeviceMessage message) {
|
||||
@@ -1805,4 +1839,122 @@ public class MessageHandler {
|
||||
rmNetworkInterfaceService.updateNetMsgByMac(updateData);
|
||||
}
|
||||
}
|
||||
public String checkIPVersion(String ipAddress) {
|
||||
// 检查是否为 IPv4 地址
|
||||
if (ipAddress.contains(".")) {
|
||||
// 简单的格式验证:IPv4 应该有 4 个部分,每个部分用点分隔
|
||||
String[] parts = ipAddress.split("\\.");
|
||||
if (parts.length == 4) {
|
||||
try {
|
||||
// 验证每个部分是否在 0-255 范围内
|
||||
for (String part : parts) {
|
||||
int num = Integer.parseInt(part);
|
||||
if (num < 0 || num > 255) {
|
||||
return "Invalid IP Address";
|
||||
}
|
||||
}
|
||||
return "IPv4";
|
||||
} catch (NumberFormatException e) {
|
||||
return "Invalid IP Address";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否为 IPv6 地址
|
||||
if (ipAddress.contains(":")) {
|
||||
// 简单的格式验证:IPv6 应该包含冒号分隔的十六进制数
|
||||
String[] parts = ipAddress.split(":");
|
||||
if (parts.length >= 3 && parts.length <= 8) {
|
||||
try {
|
||||
// 验证每个部分是否为有效的十六进制数
|
||||
for (String part : parts) {
|
||||
if (!part.isEmpty()) {
|
||||
// 允许空的部分(表示连续的零)
|
||||
Integer.parseInt(part, 16);
|
||||
}
|
||||
}
|
||||
return "IPv6";
|
||||
} catch (NumberFormatException e) {
|
||||
return "Invalid IP Address";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "Invalid IP Address";
|
||||
}
|
||||
/**
|
||||
* 查询IP地址归属地信息,返回运营商和省份
|
||||
*/
|
||||
private Map<String, String> queryIpLocation(String ip) {
|
||||
String apiUrl = "http://172.16.15.51:10000/?ip=" + ip;
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpGet httpGet = new HttpGet(apiUrl);
|
||||
|
||||
try {
|
||||
CloseableHttpResponse response = httpClient.execute(httpGet);
|
||||
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity != null) {
|
||||
String jsonResponse = EntityUtils.toString(entity, "UTF-8");
|
||||
|
||||
// 使用Map直接解析JSON
|
||||
Map<String, Object> resultMap = JsonDataParser.parseJsonData(jsonResponse, Map.class);
|
||||
if (resultMap != null) {
|
||||
return extractLocationInfo(resultMap);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.err.println("获取IP归属地信息失败,HTTP状态码: " + response.getStatusLine().getStatusCode());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("查询IP归属地时发生异常: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
httpClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从JSON Map中提取运营商和省份
|
||||
*/
|
||||
private Map<String, String> extractLocationInfo(Map<String, Object> resultMap) {
|
||||
Map<String, String> info = new HashMap<>();
|
||||
|
||||
// 提取运营商(从as.info获取中文名称)
|
||||
if (resultMap.containsKey("as")) {
|
||||
Object asObj = resultMap.get("as");
|
||||
if (asObj instanceof Map) {
|
||||
Map<?, ?> asMap = (Map<?, ?>) asObj;
|
||||
if (asMap.containsKey("info")) {
|
||||
info.put("operator", asMap.get("info").toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 提取省份
|
||||
if (resultMap.containsKey("regions_short")) {
|
||||
Object regionsObj = resultMap.get("regions_short");
|
||||
if (regionsObj instanceof List && ((List<?>) regionsObj).size() > 0) {
|
||||
info.put("province", ((List<?>) regionsObj).get(0).toString());
|
||||
}
|
||||
} else if (resultMap.containsKey("regions")) {
|
||||
Object regionsObj = resultMap.get("regions");
|
||||
if (regionsObj instanceof List && ((List<?>) regionsObj).size() > 0) {
|
||||
String province = ((List<?>) regionsObj).get(0).toString();
|
||||
// 处理"浙江省" -> "浙江"
|
||||
if (province.endsWith("省")) {
|
||||
province = province.substring(0, province.length() - 1);
|
||||
}
|
||||
info.put("province", province);
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.tongran.rocketmq.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.tongran.rocketmq.domain.RmOutboundTrafficStatistics;
|
||||
|
||||
/**
|
||||
* 出省流量统计Mapper接口
|
||||
*
|
||||
* @author tongran
|
||||
* @date 2026-01-21
|
||||
*/
|
||||
public interface RmOutboundTrafficStatisticsMapper
|
||||
{
|
||||
/**
|
||||
* 查询出省流量统计
|
||||
*
|
||||
* @param id 出省流量统计主键
|
||||
* @return 出省流量统计
|
||||
*/
|
||||
public RmOutboundTrafficStatistics selectRmOutboundTrafficStatisticsById(Long id);
|
||||
|
||||
/**
|
||||
* 查询出省流量统计列表
|
||||
*
|
||||
* @param rmOutboundTrafficStatistics 出省流量统计
|
||||
* @return 出省流量统计集合
|
||||
*/
|
||||
public List<RmOutboundTrafficStatistics> selectRmOutboundTrafficStatisticsList(RmOutboundTrafficStatistics rmOutboundTrafficStatistics);
|
||||
|
||||
/**
|
||||
* 新增出省流量统计
|
||||
*
|
||||
* @param rmOutboundTrafficStatistics 出省流量统计
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertRmOutboundTrafficStatistics(RmOutboundTrafficStatistics rmOutboundTrafficStatistics);
|
||||
|
||||
/**
|
||||
* 修改出省流量统计
|
||||
*
|
||||
* @param rmOutboundTrafficStatistics 出省流量统计
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateRmOutboundTrafficStatistics(RmOutboundTrafficStatistics rmOutboundTrafficStatistics);
|
||||
|
||||
/**
|
||||
* 删除出省流量统计
|
||||
*
|
||||
* @param id 出省流量统计主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmOutboundTrafficStatisticsById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除出省流量统计
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmOutboundTrafficStatisticsByIds(Long[] ids);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.tongran.rocketmq.mapper;
|
||||
|
||||
import com.tongran.rocketmq.domain.RmTcpdumpConfig;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* tcpdump探测策略Mapper接口
|
||||
*
|
||||
* @author tongran
|
||||
* @date 2026-01-21
|
||||
*/
|
||||
public interface RmTcpdumpConfigMapper
|
||||
{
|
||||
/**
|
||||
* 查询tcpdump探测策略
|
||||
*
|
||||
* @param id tcpdump探测策略主键
|
||||
* @return tcpdump探测策略
|
||||
*/
|
||||
public RmTcpdumpConfig selectRmTcpdumpConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 查询tcpdump探测策略列表
|
||||
*
|
||||
* @param rmTcpdumpConfig tcpdump探测策略
|
||||
* @return tcpdump探测策略集合
|
||||
*/
|
||||
public List<RmTcpdumpConfig> selectRmTcpdumpConfigList(RmTcpdumpConfig rmTcpdumpConfig);
|
||||
|
||||
/**
|
||||
* 新增tcpdump探测策略
|
||||
*
|
||||
* @param rmTcpdumpConfig tcpdump探测策略
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertRmTcpdumpConfig(RmTcpdumpConfig rmTcpdumpConfig);
|
||||
|
||||
/**
|
||||
* 修改tcpdump探测策略
|
||||
*
|
||||
* @param rmTcpdumpConfig tcpdump探测策略
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateRmTcpdumpConfig(RmTcpdumpConfig rmTcpdumpConfig);
|
||||
|
||||
/**
|
||||
* 删除tcpdump探测策略
|
||||
*
|
||||
* @param id tcpdump探测策略主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmTcpdumpConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除tcpdump探测策略
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmTcpdumpConfigByIds(Long[] ids);
|
||||
|
||||
RmTcpdumpConfig selectRmTcpdumpConfigByClientId(@Param("clientId") String clientId);
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.tongran.rocketmq.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.tongran.rocketmq.domain.RmOutboundTrafficStatistics;
|
||||
|
||||
/**
|
||||
* 出省流量统计Service接口
|
||||
*
|
||||
* @author tongran
|
||||
* @date 2026-01-21
|
||||
*/
|
||||
public interface IRmOutboundTrafficStatisticsService
|
||||
{
|
||||
/**
|
||||
* 查询出省流量统计
|
||||
*
|
||||
* @param id 出省流量统计主键
|
||||
* @return 出省流量统计
|
||||
*/
|
||||
public RmOutboundTrafficStatistics selectRmOutboundTrafficStatisticsById(Long id);
|
||||
|
||||
/**
|
||||
* 查询出省流量统计列表
|
||||
*
|
||||
* @param rmOutboundTrafficStatistics 出省流量统计
|
||||
* @return 出省流量统计集合
|
||||
*/
|
||||
public List<RmOutboundTrafficStatistics> selectRmOutboundTrafficStatisticsList(RmOutboundTrafficStatistics rmOutboundTrafficStatistics);
|
||||
|
||||
/**
|
||||
* 新增出省流量统计
|
||||
*
|
||||
* @param rmOutboundTrafficStatistics 出省流量统计
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertRmOutboundTrafficStatistics(RmOutboundTrafficStatistics rmOutboundTrafficStatistics);
|
||||
|
||||
/**
|
||||
* 修改出省流量统计
|
||||
*
|
||||
* @param rmOutboundTrafficStatistics 出省流量统计
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateRmOutboundTrafficStatistics(RmOutboundTrafficStatistics rmOutboundTrafficStatistics);
|
||||
|
||||
/**
|
||||
* 批量删除出省流量统计
|
||||
*
|
||||
* @param ids 需要删除的出省流量统计主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmOutboundTrafficStatisticsByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除出省流量统计信息
|
||||
*
|
||||
* @param id 出省流量统计主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmOutboundTrafficStatisticsById(Long id);
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package com.tongran.rocketmq.service;
|
||||
|
||||
import com.tongran.rocketmq.domain.RmTcpdumpConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* tcpdump探测策略Service接口
|
||||
*
|
||||
* @author tongran
|
||||
* @date 2026-01-21
|
||||
*/
|
||||
public interface IRmTcpdumpConfigService
|
||||
{
|
||||
/**
|
||||
* 查询tcpdump探测策略
|
||||
*
|
||||
* @param id tcpdump探测策略主键
|
||||
* @return tcpdump探测策略
|
||||
*/
|
||||
public RmTcpdumpConfig selectRmTcpdumpConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 查询tcpdump探测策略列表
|
||||
*
|
||||
* @param rmTcpdumpConfig tcpdump探测策略
|
||||
* @return tcpdump探测策略集合
|
||||
*/
|
||||
public List<RmTcpdumpConfig> selectRmTcpdumpConfigList(RmTcpdumpConfig rmTcpdumpConfig);
|
||||
|
||||
/**
|
||||
* 新增tcpdump探测策略
|
||||
*
|
||||
* @param rmTcpdumpConfig tcpdump探测策略
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertRmTcpdumpConfig(RmTcpdumpConfig rmTcpdumpConfig);
|
||||
|
||||
/**
|
||||
* 修改tcpdump探测策略
|
||||
*
|
||||
* @param rmTcpdumpConfig tcpdump探测策略
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateRmTcpdumpConfig(RmTcpdumpConfig rmTcpdumpConfig);
|
||||
|
||||
/**
|
||||
* 批量删除tcpdump探测策略
|
||||
*
|
||||
* @param ids 需要删除的tcpdump探测策略主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmTcpdumpConfigByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除tcpdump探测策略信息
|
||||
*
|
||||
* @param id tcpdump探测策略主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmTcpdumpConfigById(Long id);
|
||||
|
||||
RmTcpdumpConfig selectRmTcpdumpConfigByClientId(String clientId);
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package com.tongran.rocketmq.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.tongran.common.core.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.tongran.rocketmq.mapper.RmOutboundTrafficStatisticsMapper;
|
||||
import com.tongran.rocketmq.domain.RmOutboundTrafficStatistics;
|
||||
import com.tongran.rocketmq.service.IRmOutboundTrafficStatisticsService;
|
||||
|
||||
/**
|
||||
* 出省流量统计Service业务层处理
|
||||
*
|
||||
* @author tongran
|
||||
* @date 2026-01-21
|
||||
*/
|
||||
@Service
|
||||
public class RmOutboundTrafficStatisticsServiceImpl implements IRmOutboundTrafficStatisticsService
|
||||
{
|
||||
@Autowired
|
||||
private RmOutboundTrafficStatisticsMapper rmOutboundTrafficStatisticsMapper;
|
||||
|
||||
/**
|
||||
* 查询出省流量统计
|
||||
*
|
||||
* @param id 出省流量统计主键
|
||||
* @return 出省流量统计
|
||||
*/
|
||||
@Override
|
||||
public RmOutboundTrafficStatistics selectRmOutboundTrafficStatisticsById(Long id)
|
||||
{
|
||||
return rmOutboundTrafficStatisticsMapper.selectRmOutboundTrafficStatisticsById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询出省流量统计列表
|
||||
*
|
||||
* @param rmOutboundTrafficStatistics 出省流量统计
|
||||
* @return 出省流量统计
|
||||
*/
|
||||
@Override
|
||||
public List<RmOutboundTrafficStatistics> selectRmOutboundTrafficStatisticsList(RmOutboundTrafficStatistics rmOutboundTrafficStatistics)
|
||||
{
|
||||
return rmOutboundTrafficStatisticsMapper.selectRmOutboundTrafficStatisticsList(rmOutboundTrafficStatistics);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增出省流量统计
|
||||
*
|
||||
* @param rmOutboundTrafficStatistics 出省流量统计
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertRmOutboundTrafficStatistics(RmOutboundTrafficStatistics rmOutboundTrafficStatistics)
|
||||
{
|
||||
rmOutboundTrafficStatistics.setCreateTime(DateUtils.getNowDate());
|
||||
return rmOutboundTrafficStatisticsMapper.insertRmOutboundTrafficStatistics(rmOutboundTrafficStatistics);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改出省流量统计
|
||||
*
|
||||
* @param rmOutboundTrafficStatistics 出省流量统计
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateRmOutboundTrafficStatistics(RmOutboundTrafficStatistics rmOutboundTrafficStatistics)
|
||||
{
|
||||
rmOutboundTrafficStatistics.setUpdateTime(DateUtils.getNowDate());
|
||||
return rmOutboundTrafficStatisticsMapper.updateRmOutboundTrafficStatistics(rmOutboundTrafficStatistics);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除出省流量统计
|
||||
*
|
||||
* @param ids 需要删除的出省流量统计主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteRmOutboundTrafficStatisticsByIds(Long[] ids)
|
||||
{
|
||||
return rmOutboundTrafficStatisticsMapper.deleteRmOutboundTrafficStatisticsByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除出省流量统计信息
|
||||
*
|
||||
* @param id 出省流量统计主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteRmOutboundTrafficStatisticsById(Long id)
|
||||
{
|
||||
return rmOutboundTrafficStatisticsMapper.deleteRmOutboundTrafficStatisticsById(id);
|
||||
}
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
package com.tongran.rocketmq.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.tongran.common.core.enums.MsgEnum;
|
||||
import com.tongran.common.core.utils.DateUtils;
|
||||
import com.tongran.rocketmq.domain.DeviceMessage;
|
||||
import com.tongran.rocketmq.domain.RmTcpdumpConfig;
|
||||
import com.tongran.rocketmq.domain.vo.PolicyTypeVo;
|
||||
import com.tongran.rocketmq.mapper.RmTcpdumpConfigMapper;
|
||||
import com.tongran.rocketmq.model.ProducerMode;
|
||||
import com.tongran.rocketmq.producer.MessageProducer;
|
||||
import com.tongran.rocketmq.service.IRmTcpdumpConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* tcpdump探测策略Service业务层处理
|
||||
*
|
||||
* @author tongran
|
||||
* @date 2026-01-21
|
||||
*/
|
||||
@Service
|
||||
public class RmTcpdumpConfigServiceImpl implements IRmTcpdumpConfigService
|
||||
{
|
||||
@Autowired
|
||||
private RmTcpdumpConfigMapper rmTcpdumpConfigMapper;
|
||||
@Autowired
|
||||
private ProducerMode producerMode;
|
||||
|
||||
/**
|
||||
* 查询tcpdump探测策略
|
||||
*
|
||||
* @param id tcpdump探测策略主键
|
||||
* @return tcpdump探测策略
|
||||
*/
|
||||
@Override
|
||||
public RmTcpdumpConfig selectRmTcpdumpConfigById(Long id)
|
||||
{
|
||||
return rmTcpdumpConfigMapper.selectRmTcpdumpConfigById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询tcpdump探测策略列表
|
||||
*
|
||||
* @param rmTcpdumpConfig tcpdump探测策略
|
||||
* @return tcpdump探测策略
|
||||
*/
|
||||
@Override
|
||||
public List<RmTcpdumpConfig> selectRmTcpdumpConfigList(RmTcpdumpConfig rmTcpdumpConfig)
|
||||
{
|
||||
return rmTcpdumpConfigMapper.selectRmTcpdumpConfigList(rmTcpdumpConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增tcpdump探测策略
|
||||
*
|
||||
* @param rmTcpdumpConfig tcpdump探测策略
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertRmTcpdumpConfig(RmTcpdumpConfig rmTcpdumpConfig)
|
||||
{
|
||||
rmTcpdumpConfig.setCreateTime(DateUtils.getNowDate());
|
||||
rmTcpdumpConfigMapper.insertRmTcpdumpConfig(rmTcpdumpConfig);
|
||||
// 下发消息给agent
|
||||
PolicyTypeVo policyTypeVo = new PolicyTypeVo();
|
||||
if(rmTcpdumpConfig.getDetectFlag() == 1 && rmTcpdumpConfig.getDetectTimes() != null){
|
||||
policyTypeVo.setTcpdumpTimes(rmTcpdumpConfig.getDetectTimes());
|
||||
}else{
|
||||
policyTypeVo.setTcpdumpTimes("");
|
||||
}
|
||||
MessageProducer messageProducer = new MessageProducer();
|
||||
String configJson = JSONObject.toJSONString(policyTypeVo);
|
||||
DeviceMessage message = new DeviceMessage();
|
||||
message.setClientId(rmTcpdumpConfig.getClientId());
|
||||
message.setData(configJson);
|
||||
message.setDataType(MsgEnum.获取最新策略应答.getValue());
|
||||
|
||||
messageProducer.sendAsyncProducerMessage(
|
||||
producerMode.getAgentTopic(),
|
||||
"",
|
||||
"",
|
||||
JSONObject.toJSONString(message)
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改tcpdump探测策略
|
||||
*
|
||||
* @param rmTcpdumpConfig tcpdump探测策略
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateRmTcpdumpConfig(RmTcpdumpConfig rmTcpdumpConfig)
|
||||
{
|
||||
rmTcpdumpConfig.setUpdateTime(DateUtils.getNowDate());
|
||||
return rmTcpdumpConfigMapper.updateRmTcpdumpConfig(rmTcpdumpConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除tcpdump探测策略
|
||||
*
|
||||
* @param ids 需要删除的tcpdump探测策略主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteRmTcpdumpConfigByIds(Long[] ids)
|
||||
{
|
||||
return rmTcpdumpConfigMapper.deleteRmTcpdumpConfigByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除tcpdump探测策略信息
|
||||
*
|
||||
* @param id tcpdump探测策略主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteRmTcpdumpConfigById(Long id)
|
||||
{
|
||||
return rmTcpdumpConfigMapper.deleteRmTcpdumpConfigById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RmTcpdumpConfig selectRmTcpdumpConfigByClientId(String clientId) {
|
||||
return rmTcpdumpConfigMapper.selectRmTcpdumpConfigByClientId(clientId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user