开发tcpdump策略表CRUD
This commit is contained in:
+4
@@ -21,6 +21,8 @@ public enum MsgEnum {
|
|||||||
|
|
||||||
iops结果上报("IOPS_RESULT"),
|
iops结果上报("IOPS_RESULT"),
|
||||||
|
|
||||||
|
tcpdump结果上报("TCPDUMP_RESULT"),
|
||||||
|
|
||||||
获取最新策略("GET_POLICY"),
|
获取最新策略("GET_POLICY"),
|
||||||
|
|
||||||
获取最新策略应答("GET_POLICY_RSP"),
|
获取最新策略应答("GET_POLICY_RSP"),
|
||||||
@@ -45,6 +47,8 @@ public enum MsgEnum {
|
|||||||
|
|
||||||
网络上报("NET"),
|
网络上报("NET"),
|
||||||
|
|
||||||
|
网络上报重试("NET_RECOVER"),
|
||||||
|
|
||||||
挂载上报("POINT"),
|
挂载上报("POINT"),
|
||||||
|
|
||||||
系统其他上报("OTHER_SYSTEM"),
|
系统其他上报("OTHER_SYSTEM"),
|
||||||
|
|||||||
@@ -125,7 +125,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.redisson</groupId>
|
<groupId>org.redisson</groupId>
|
||||||
<artifactId>redisson-spring-boot-starter</artifactId>
|
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||||
<version>3.27.2</version>
|
<version>3.18.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
+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 umountDisk;
|
||||||
/** 需要删除的时间戳 */
|
/** 需要删除的时间戳 */
|
||||||
private String trafficUsedTimestamp;
|
private String trafficUsedTimestamp;
|
||||||
|
/** tcpdump探测时间 */
|
||||||
|
private String tcpdumpTimes;
|
||||||
/** 时间戳 */
|
/** 时间戳 */
|
||||||
private Long timestamp = Instant.now().getEpochSecond();
|
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.RemoteRevenueConfigService;
|
||||||
import com.tongran.system.api.domain.*;
|
import com.tongran.system.api.domain.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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.RLock;
|
||||||
import org.redisson.api.RedissonClient;
|
import org.redisson.api.RedissonClient;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
@@ -33,6 +39,7 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -143,6 +150,33 @@ public class MessageHandler {
|
|||||||
registerHandler(MsgEnum.修改frp配置文件应答.getValue(), this::handleUpdateFrpMessage);
|
registerHandler(MsgEnum.修改frp配置文件应答.getValue(), this::handleUpdateFrpMessage);
|
||||||
registerHandler(MsgEnum.macvlan状态上报.getValue(), this::handleMacvlanMessage);
|
registerHandler(MsgEnum.macvlan状态上报.getValue(), this::handleMacvlanMessage);
|
||||||
registerHandler(MsgEnum.iops结果上报.getValue(), this::handleIopsResultMessage);
|
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) {
|
private void handleIopsResultMessage(DeviceMessage message) {
|
||||||
@@ -1805,4 +1839,122 @@ public class MessageHandler {
|
|||||||
rmNetworkInterfaceService.updateNetMsgByMac(updateData);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
+77
@@ -0,0 +1,77 @@
|
|||||||
|
<?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.tongran.rocketmq.mapper.RmOutboundTrafficStatisticsMapper">
|
||||||
|
|
||||||
|
<resultMap type="RmOutboundTrafficStatistics" id="RmOutboundTrafficStatisticsResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="clientId" column="client_id" />
|
||||||
|
<result property="description" column="description" />
|
||||||
|
<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="selectRmOutboundTrafficStatisticsVo">
|
||||||
|
select id, client_id, description, create_time, update_time, create_by, update_by from rm_outbound_traffic_statistics
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectRmOutboundTrafficStatisticsList" parameterType="RmOutboundTrafficStatistics" resultMap="RmOutboundTrafficStatisticsResult">
|
||||||
|
<include refid="selectRmOutboundTrafficStatisticsVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||||
|
<if test="description != null and description != ''"> and description = #{description}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectRmOutboundTrafficStatisticsById" parameterType="Long" resultMap="RmOutboundTrafficStatisticsResult">
|
||||||
|
<include refid="selectRmOutboundTrafficStatisticsVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertRmOutboundTrafficStatistics" parameterType="RmOutboundTrafficStatistics" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into rm_outbound_traffic_statistics
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="clientId != null and clientId != ''">client_id,</if>
|
||||||
|
<if test="description != null">description,</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="clientId != null and clientId != ''">#{clientId},</if>
|
||||||
|
<if test="description != null">#{description},</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="updateRmOutboundTrafficStatistics" parameterType="RmOutboundTrafficStatistics">
|
||||||
|
update rm_outbound_traffic_statistics
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="clientId != null and clientId != ''">client_id = #{clientId},</if>
|
||||||
|
<if test="description != null">description = #{description},</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="deleteRmOutboundTrafficStatisticsById" parameterType="Long">
|
||||||
|
delete from rm_outbound_traffic_statistics where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteRmOutboundTrafficStatisticsByIds" parameterType="String">
|
||||||
|
delete from rm_outbound_traffic_statistics where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
<?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.tongran.rocketmq.mapper.RmTcpdumpConfigMapper">
|
||||||
|
|
||||||
|
<resultMap type="RmTcpdumpConfig" id="RmTcpdumpConfigResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="clientId" column="client_id" />
|
||||||
|
<result property="detectFlag" column="detect_flag" />
|
||||||
|
<result property="frequency" column="frequency" />
|
||||||
|
<result property="detectTimes" column="detect_times" />
|
||||||
|
<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="selectRmTcpdumpConfigVo">
|
||||||
|
select id, client_id, detect_flag, frequency, detect_times, create_time, update_time, create_by, update_by from rm_tcpdump_config
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectRmTcpdumpConfigList" parameterType="RmTcpdumpConfig" resultMap="RmTcpdumpConfigResult">
|
||||||
|
<include refid="selectRmTcpdumpConfigVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||||
|
<if test="detectFlag != null "> and detect_flag = #{detectFlag}</if>
|
||||||
|
<if test="frequency != null and frequency != ''"> and frequency = #{frequency}</if>
|
||||||
|
<if test="detectTimes != null and detectTimes != ''"> and detect_times = #{detectTimes}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectRmTcpdumpConfigById" parameterType="Long" resultMap="RmTcpdumpConfigResult">
|
||||||
|
<include refid="selectRmTcpdumpConfigVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertRmTcpdumpConfig" parameterType="RmTcpdumpConfig" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into rm_tcpdump_config
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="clientId != null and clientId != ''">client_id,</if>
|
||||||
|
<if test="detectFlag != null">detect_flag,</if>
|
||||||
|
<if test="frequency != null">frequency,</if>
|
||||||
|
<if test="detectTimes != null">detect_times,</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="clientId != null and clientId != ''">#{clientId},</if>
|
||||||
|
<if test="detectFlag != null">#{detectFlag},</if>
|
||||||
|
<if test="frequency != null">#{frequency},</if>
|
||||||
|
<if test="detectTimes != null">#{detectTimes},</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>
|
||||||
|
on duplicate key update
|
||||||
|
<trim suffixOverrides=",">
|
||||||
|
<if test="detectFlag != null">detect_flag = #{detectFlag},</if>
|
||||||
|
<if test="frequency != null">frequency = #{frequency},</if>
|
||||||
|
detect_times = #{detectTimes},
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateRmTcpdumpConfig" parameterType="RmTcpdumpConfig">
|
||||||
|
update rm_tcpdump_config
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="clientId != null and clientId != ''">client_id = #{clientId},</if>
|
||||||
|
<if test="detectFlag != null">detect_flag = #{detectFlag},</if>
|
||||||
|
<if test="frequency != null">frequency = #{frequency},</if>
|
||||||
|
<if test="detectTimes != null">detect_times = #{detectTimes},</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="deleteRmTcpdumpConfigById" parameterType="Long">
|
||||||
|
delete from rm_tcpdump_config where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteRmTcpdumpConfigByIds" parameterType="String">
|
||||||
|
delete from rm_tcpdump_config where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
<select id="selectRmTcpdumpConfigByClientId" parameterType="String" resultMap="RmTcpdumpConfigResult">
|
||||||
|
<include refid="selectRmTcpdumpConfigVo"/>
|
||||||
|
where client_id = #{clientId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user