服务器注册 agent更新

This commit is contained in:
gaoyutao
2025-10-24 09:34:32 +08:00
parent 31d8114c05
commit 37eff51e48
21 changed files with 536 additions and 135 deletions

View File

@@ -1,15 +0,0 @@
package com.ruoyi.system;
import lombok.Getter;
@Getter
public enum ReviewEnum {
未提交(0),
待审核(1),
通过(2),
驳回(3);
private Integer code;
ReviewEnum(Integer code){
this.code = code;
}
}

View File

@@ -1,15 +1,17 @@
package com.ruoyi.system.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import lombok.Data;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 资源注册对象 rm_resource_registration
*
*
* @author gyt
* @date 2025-08-12
*/
@@ -21,25 +23,25 @@ public class RmResourceRegistration extends BaseEntity
/** id */
private Long id;
/** clientID */
@Excel(name = "clientID")
private String clientId;
/** 硬件SN */
@Excel(name = "硬件SN")
@Excel(name = "设备SN")
private String hardwareSn;
/** 资源类型
* 1 服务器2 交换机*/
@Excel(name = "资源类型",readConverterExp = "1=服务器,2=交换机")
private String resourceType;
/** 资源名称 */
@Excel(name = "资源名称")
private String resourceName;
/** IP地址 */
@Excel(name = "IP地址")
private String ipAddress;
/** 端口1.162(SNMP),2.其他 */
@Excel(name = "端口")
private String resourcePort;
/**其他端口名称 */
@@ -49,70 +51,58 @@ public class RmResourceRegistration extends BaseEntity
@Excel(name = "agent版本")
private String agentVersion;
/** 协议 1.TCP,2.UDP */
@Excel(name = "协议",readConverterExp = "1=TCP,2=UDP")
private String protocol;
/** SNMP探测 0=否,1=是 */
@Excel(name = "",readConverterExp = "0=否,1=是")
private String snmpDetect;
/** 版本(1.SNMPv2,2.SNMPv3) */
@Excel(name = "SNMP版本",readConverterExp = "1=华为SNMPv2c,2=华为SNMPv3")
private String resourceVersion;
/** 读写权限(1.RW,2.ReadOnly) */
@Excel(name = "读写权限",readConverterExp = "1=只读,2=可读可写")
private String rwPermission;
/** 团体名称 */
@Excel(name = "团体名称")
private String teamName;
/** SNMP采集地址 */
@Excel(name = "SNMP采集地址")
private String snmpCollectAddr;
/** SNMP采集端口 */
@Excel(name = "SNMP采集端口")
private String snmpCollectPort;
/** 安全级别(1.authPriv、2.authNoPriv3.noAuthNoPriv) */
@Excel(name = "安全级别",readConverterExp = "1=authPriv,2=authNoPriv,3=noAuthNoPriv")
private String securityLevel;
/** 加密方式 1.md5,2.SHA */
@Excel(name = "加密方式",readConverterExp = "1=MD5,2=SHA")
private String encryption;
/** 用户名 */
@Excel(name = "用户名")
private String resourceUserName;
/** 密码 */
@Excel(name = "密码")
/** 密码 */
private String resourcePwd;
/** 注册状态 0-未注册1-已注册 */
@Excel(name = "注册状态",readConverterExp = "0=未注册,1=已注册")
private String registrationStatus;
/** 在线状态 0-离线1-在线 */
@Excel(name = "在线状态",readConverterExp = "0=离线,1=在线")
@Excel(name = "在线状态")
private String onlineStatus;
@Excel(name = "交换机在线状态",readConverterExp = "0=离线,1=在线")
private String switchOnlineStatus;
/** 描述 */
@Excel(name = "描述")
private String description;
/** 设备业务客户id */
private Long customerId;
/** 设备业务客户名称 */
@Excel(name = "设备业务客户")
private String customerName;
/** 业务号 */
@Excel(name = "业务号")
private String serviceNumber;
/** 创建人id */
@@ -126,16 +116,15 @@ public class RmResourceRegistration extends BaseEntity
/** 修改人名称 */
private String updaterName;
/** 监控项 */
private String monitorItems;
/** 自动发现项 */
private String discoveryRules;
/** 查询名称 */
private String queryName;
/**
* 客户端ID
*/
private String clientId;
/**
* 运营商
@@ -155,11 +144,13 @@ public class RmResourceRegistration extends BaseEntity
/**
* 业务名称
*/
@Excel(name = "业务名称")
private String businessName;
/**
* 逻辑节点标识
*/
@Excel(name = "逻辑节点标识")
private String logicalNodeId;
/**
@@ -170,12 +161,141 @@ public class RmResourceRegistration extends BaseEntity
/**
* 心跳次数
*/
@Excel(name = "心跳次数")
private Integer heartbeatCount;
/**
* 心跳周期(单位:秒)
*/
@Excel(name = "心跳时间间隔")
private Integer heartbeatInterval;
/** 需要绑定的网卡信息 */
private List<Map> bindNetworkMsg;
}
// IP1 相关字段
@Excel(name = "IP1-运营商")
private String ip1Isp; // IP1-运营商
@Excel(name = "IP1-省")
private String ip1Province; // IP1-省
@Excel(name = "IP1-市")
private String ip1City; // IP1-市
@Excel(name = "IP1-业务公网")
private String ip1PublicIp; // IP1-业务公网
@Excel(name = "IP1-接口名称")
private String ip1InterfaceName; // IP1-接口名称
@Excel(name = "IP1-mac地址")
private String ip1MacAddress; // IP1-mac地址
@Excel(name = "IP1-接口类型")
private String ip1InterfaceType; // IP1-接口类型
@Excel(name = "IP1-IPv4地址")
private String ip1Ipv4Address; // IP1-IPv4地址
@Excel(name = "IP1-网关")
private String ip1Gateway; // IP1-网关
// IP2 相关字段
@Excel(name = "IP2-运营商")
private String ip2Isp;
@Excel(name = "IP2-省")
private String ip2Province;
@Excel(name = "IP2-市")
private String ip2City;
@Excel(name = "IP2-业务公网")
private String ip2PublicIp;
@Excel(name = "IP2-接口名称")
private String ip2InterfaceName;
@Excel(name = "IP2-mac地址")
private String ip2MacAddress;
@Excel(name = "IP2-接口类型")
private String ip2InterfaceType;
@Excel(name = "IP2-IPv4地址")
private String ip2Ipv4Address;
@Excel(name = "IP2-网关")
private String ip2Gateway;
// IP3 相关字段
@Excel(name = "IP3-运营商")
private String ip3Isp;
@Excel(name = "IP3-省")
private String ip3Province;
@Excel(name = "IP3-市")
private String ip3City;
@Excel(name = "IP3-业务公网")
private String ip3PublicIp;
@Excel(name = "IP3-接口名称")
private String ip3InterfaceName;
@Excel(name = "IP3-mac地址")
private String ip3MacAddress;
@Excel(name = "IP3-接口类型")
private String ip3InterfaceType;
@Excel(name = "IP3-IPv4地址")
private String ip3Ipv4Address;
@Excel(name = "IP3-网关")
private String ip3Gateway;
// 管理网相关字段
@Excel(name = "管理网-运营商")
private String mgmtIsp; // 管理网-运营商
@Excel(name = "管理网-省")
private String mgmtProvince; // 管理网-省
@Excel(name = "管理网-市")
private String mgmtCity; // 管理网-市
@Excel(name = "管理网-公网IP")
private String mgmtPublicIp; // 管理网-公网IP
@Excel(name = "管理网-接口名称")
private String mgmtInterfaceName; // 管理网-接口名称
@Excel(name = "管理网-mac地址")
private String mgmtMacAddress; // 管理网-mac地址
@Excel(name = "管理网-接口类型")
private String mgmtInterfaceType; // 管理网-接口类型
@Excel(name = "管理网-IPv4地址")
private String mgmtIpv4Address; // 管理网-IPv4地址
/** 多条件查询 */
private String queryParam;
/** 金山machineCode */
@Excel(name = "金山machineCode")
private String machineCode;
/** 注册时间 */
@Excel(name = "注册时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 上机时间 */
@Excel(name = "上机时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date onboardTime;
}

View File

@@ -0,0 +1,15 @@
package com.ruoyi.system.enums;
import lombok.Getter;
@Getter
public enum ReviewEnum {
未提交("0"),
待审核("1"),
通过("2"),
驳回("3");
private String code;
ReviewEnum(String code){
this.code = code;
}
}

View File

@@ -4,6 +4,7 @@ import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.enums.ReviewEnum;
import com.ruoyi.system.api.RemoteRocketMqService;
import com.ruoyi.system.api.domain.RmNetworkInterfaceRemote;
import com.ruoyi.system.domain.EpsBusinessDeploy;
@@ -63,9 +64,9 @@ public class EpsBusinessDeployServiceImpl implements IEpsBusinessDeployService
RmResourceRegistration publicIpVo = rmResourceRegistrationMapper.selectRegistMsgByClientId(rmResourceRegistration);
String processedClientId;
if (publicIpVo != null && StringUtils.isNotBlank(publicIpVo.getPublicIp())) {
if (publicIpVo != null && StringUtils.isNotBlank(publicIpVo.getIp1PublicIp())) {
// 如果有公网IP格式为公网IP + 空格 + 原clientId
processedClientId = publicIpVo.getPublicIp() + " " + clientId.trim();
processedClientId = publicIpVo.getIp1PublicIp() + " " + clientId.trim();
} else {
// 如果没有公网IP保持原样
processedClientId = clientId.trim();
@@ -158,38 +159,45 @@ public class EpsBusinessDeployServiceImpl implements IEpsBusinessDeployService
epsBusinessDeploy.setReviewBy(SecurityUtils.getUsername());
epsBusinessDeploy.setReviewTime(DateUtils.getNowDate());
int rows = epsBusinessDeployMapper.updateEpsBusinessDeploy(epsBusinessDeploy);
// 根据id查询业务信息
EpsBusinessDeploy businessMsg = epsBusinessDeployMapper.selectEpsBusinessDeployById(epsBusinessDeploy.getId());
String businessCode = businessMsg.getBusinessCode();
String businessName = businessMsg.getBusinessName();
String clientIdStr = businessMsg.getDeployDevice();
String[] clientIds = clientIdStr.split("\n");
// 保存业务修改记录
for (String clientId : clientIds) {
// 根据clientId查询网卡接口名称
RmNetworkInterfaceRemote queryParam = new RmNetworkInterfaceRemote();
queryParam.setClientId(clientId);
List<RmNetworkInterfaceRemote> interfaceList = remoteRocketMqService.getNetworkInterfaceList(queryParam, SecurityConstants.INNER).getData();
String interfaceName = "";
if (interfaceList != null && !interfaceList.isEmpty()) {
interfaceName = interfaceList.stream()
.filter(interfaceRemote -> "1".equals(interfaceRemote.getBindIp()))
.map(RmNetworkInterfaceRemote::getInterfaceName)
.filter(name -> name != null && !name.trim().isEmpty())
.collect(Collectors.joining(","));
if(StringUtils.equals(ReviewEnum.通过.getCode(), epsBusinessDeploy.getReviewStatus())){
// 根据id查询业务信息
EpsBusinessDeploy businessMsg = epsBusinessDeployMapper.selectEpsBusinessDeployById(epsBusinessDeploy.getId());
String businessCode = businessMsg.getBusinessCode();
String businessName = businessMsg.getBusinessName();
String clientIdStr = businessMsg.getDeployDevice();
String[] clientIds = clientIdStr.split("\n");
// 保存业务修改记录
for (String clientId : clientIds) {
// 根据clientId查询网卡接口名称
RmNetworkInterfaceRemote queryParam = new RmNetworkInterfaceRemote();
queryParam.setClientId(clientId);
List<RmNetworkInterfaceRemote> interfaceList = remoteRocketMqService.getNetworkInterfaceList(queryParam, SecurityConstants.INNER).getData();
String interfaceName = "";
if (interfaceList != null && !interfaceList.isEmpty()) {
interfaceName = interfaceList.stream()
.filter(interfaceRemote -> "1".equals(interfaceRemote.getBindIp()))
.map(RmNetworkInterfaceRemote::getInterfaceName)
.filter(name -> name != null && !name.trim().isEmpty())
.collect(Collectors.joining(","));
}
EpsMethodChangeRecord changeRecord = new EpsMethodChangeRecord();
// 设置基本信息
changeRecord.setClientId(clientId);
changeRecord.setTrafficPort(interfaceName);
changeRecord.setBusinessCode(businessCode);
changeRecord.setBusinessName(businessName);
changeRecord.setCreateTime(DateUtils.getNowDate());
changeRecord.setCreatBy(SecurityUtils.getUsername());
// 修改内容
String content = "流量网口设置为" + interfaceName + ",业务为" + businessName;
// 保存数据
epsMethodChangeRecordMapper.insertEpsMethodChangeRecord(changeRecord);
// 绑定业务名称
RmResourceRegistration updateData = new RmResourceRegistration();
updateData.setBusinessName(businessName);
updateData.setClientId(clientId);
rmResourceRegistrationMapper.updateStatusByResource(updateData);
}
EpsMethodChangeRecord changeRecord = new EpsMethodChangeRecord();
// 设置基本信息
changeRecord.setClientId(clientId);
changeRecord.setTrafficPort(interfaceName);
changeRecord.setBusinessCode(businessCode);
changeRecord.setBusinessName(businessName);
changeRecord.setCreateTime(DateUtils.getNowDate());
changeRecord.setCreatBy(SecurityUtils.getUsername());
// 修改内容
String content = "流量网口设置为" + interfaceName + ",业务为" + businessName;
// 保存数据
epsMethodChangeRecordMapper.insertEpsMethodChangeRecord(changeRecord);
}
return 1;
}

View File

@@ -13,17 +13,11 @@ import com.ruoyi.system.api.domain.NetworkInfo;
import com.ruoyi.system.api.domain.RmNetworkInterfaceRemote;
import com.ruoyi.system.api.domain.RmRegisterMsgRemote;
import com.ruoyi.system.api.domain.RmResourceRegistrationRemote;
import com.ruoyi.system.domain.EpsNodeBandwidth;
import com.ruoyi.system.domain.EpsServerRevenueConfig;
import com.ruoyi.system.domain.RmEpsTopologyManagement;
import com.ruoyi.system.domain.RmResourceRegistration;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.vo.MessageVo;
import com.ruoyi.system.domain.vo.ResourceVo;
import com.ruoyi.system.domain.vo.RspVo;
import com.ruoyi.system.mapper.EpsNodeBandwidthMapper;
import com.ruoyi.system.mapper.EpsServerRevenueConfigMapper;
import com.ruoyi.system.mapper.RmEpsTopologyManagementMapper;
import com.ruoyi.system.mapper.RmResourceRegistrationMapper;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.service.IRmResourceRegistrationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -35,6 +29,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 资源注册Service业务层处理
@@ -56,6 +51,10 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
private EpsNodeBandwidthMapper epsNodeBandwidthMapper;
@Autowired
private RemoteRocketMqService remoteRocketMqService;
@Autowired
private EpsMethodChangeRecordMapper epsMethodChangeRecordMapper;
@Autowired
private RmRegistrationMachineMapper rmRegistrationMachineMapper;
/**
* 查询资源注册
@@ -66,7 +65,12 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
@Override
public RmResourceRegistration selectRmResourceRegistrationById(Long id)
{
return rmResourceRegistrationMapper.selectRmResourceRegistrationById(id);
RmResourceRegistration rmResourceRegistration = rmResourceRegistrationMapper.selectRmResourceRegistrationById(id);
if(rmResourceRegistration.getClientId()!= null){
// set网卡信息
setNetWorkMsg(rmResourceRegistration);
}
return rmResourceRegistration;
}
/**
@@ -79,9 +83,132 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
public List<RmResourceRegistration> selectRmResourceRegistrationList(RmResourceRegistration rmResourceRegistration)
{
List<RmResourceRegistration> rmResourceRegistrationList = rmResourceRegistrationMapper.selectRmResourceRegistrationList(rmResourceRegistration);
for (RmResourceRegistration resourceRegistration : rmResourceRegistrationList) {
if(resourceRegistration.getClientId() != null){
// 网卡信息
setNetWorkMsg(resourceRegistration);
}
}
if(rmResourceRegistration.getQueryParam() != null){
String queryValue = rmResourceRegistration.getQueryParam().trim();
// 筛选公网IP私网IP设备SN相等的数据
// 从rmResourceRegistrationList列表中筛选符合条件的数据
List<RmResourceRegistration> filteredList = rmResourceRegistrationList.stream()
.filter(item -> item != null)
.filter(item ->
// 检查公网IP (IP1-3和管理网)
queryValue.equals(item.getIp1PublicIp()) ||
queryValue.equals(item.getIp2PublicIp()) ||
queryValue.equals(item.getIp3PublicIp()) ||
queryValue.equals(item.getMgmtPublicIp()) ||
// 检查私网IP (IP1-3和管理网)
queryValue.equals(item.getIp1Ipv4Address()) ||
queryValue.equals(item.getIp2Ipv4Address()) ||
queryValue.equals(item.getIp3Ipv4Address()) ||
queryValue.equals(item.getMgmtIpv4Address()) ||
// 检查设备SN
queryValue.equals(item.getHardwareSn()))
.collect(Collectors.toList());
return filteredList;
}
return rmResourceRegistrationList;
}
/**
* 网卡信息赋值
* @param registration
*/
public void setNetWorkMsg(RmResourceRegistration registration) {
String clientId = registration.getClientId();
// 根据clientId查询网卡信息
RmNetworkInterfaceRemote queryParam = new RmNetworkInterfaceRemote();
queryParam.setClientId(clientId);
// 安全获取网络接口列表
R<List<RmNetworkInterfaceRemote>> result = remoteRocketMqService.getNetworkInterfaceList(queryParam, SecurityConstants.INNER);
// 多层安全判断
if (result == null || result.getData() == null) {
log.warn("获取网络接口列表为空clientId: {}", clientId);
return;
}
List<RmNetworkInterfaceRemote> networkList = result.getData();
if (networkList == null || networkList.isEmpty()) {
return;
}
// 初始化业务IP计数器
int businessIpCount = 1;
for (RmNetworkInterfaceRemote network : networkList) {
if ("1".equals(network.getBindIp())) {
// 业务IP处理
if (businessIpCount > 3) {
continue; // 最多只处理3个业务IP
}
// 设置业务IP字段
switch (businessIpCount) {
case 1:
registration.setIp1Isp(network.getIsp());
registration.setIp1Province(network.getProvince());
registration.setIp1City(network.getCity());
registration.setIp1PublicIp(network.getPublicIp());
registration.setIp1InterfaceName(network.getInterfaceName());
registration.setIp1MacAddress(network.getMacAddress());
registration.setIp1InterfaceType(network.getInterfaceType());
registration.setIp1Ipv4Address(network.getIpv4Address());
registration.setIp1Gateway(network.getGateway());
break;
case 2:
registration.setIp2Isp(network.getIsp());
registration.setIp2Province(network.getProvince());
registration.setIp2City(network.getCity());
registration.setIp2PublicIp(network.getPublicIp());
registration.setIp2InterfaceName(network.getInterfaceName());
registration.setIp2MacAddress(network.getMacAddress());
registration.setIp2InterfaceType(network.getInterfaceType());
registration.setIp2Ipv4Address(network.getIpv4Address());
registration.setIp2Gateway(network.getGateway());
break;
case 3:
registration.setIp3Isp(network.getIsp());
registration.setIp3Province(network.getProvince());
registration.setIp3City(network.getCity());
registration.setIp3PublicIp(network.getPublicIp());
registration.setIp3InterfaceName(network.getInterfaceName());
registration.setIp3MacAddress(network.getMacAddress());
registration.setIp3InterfaceType(network.getInterfaceType());
registration.setIp3Ipv4Address(network.getIpv4Address());
registration.setIp3Gateway(network.getGateway());
break;
}
businessIpCount++;
} else if ("2".equals(network.getBindIp())) {
// 管理网IP处理
registration.setMgmtIsp(network.getIsp());
registration.setMgmtProvince(network.getProvince());
registration.setMgmtCity(network.getCity());
registration.setMgmtPublicIp(network.getPublicIp());
registration.setMgmtInterfaceName(network.getInterfaceName());
registration.setMgmtMacAddress(network.getMacAddress());
registration.setMgmtInterfaceType(network.getInterfaceType());
registration.setMgmtIpv4Address(network.getIpv4Address());
}
}
// 设置金山machineCode
RmRegistrationMachine rmRegistrationMachine = new RmRegistrationMachine();
rmRegistrationMachine.setClientId(clientId);
List<RmRegistrationMachine> machineList = rmRegistrationMachineMapper.selectRmRegistrationMachineList(rmRegistrationMachine);
if(!machineList.isEmpty()){
RmRegistrationMachine machineMsg = machineList.get(0);
registration.setMachineCode(machineMsg.getMachineCode());
}
}
/**
* 新增资源注册
*
@@ -384,6 +511,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
try {
// 如果网卡信息只有1条自动绑定多公网IP
if(networkInfoList.size()==1){
NetworkInfo networkInfo = networkInfoList.get(0);
insertData.setClientId(registerMsg.getClientId());
insertData.setHardwareSn(registerMsg.getSn());
insertData.setRegistrationStatus("1");
@@ -391,6 +519,17 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
insertData.setResourceType("1");
insertData.setCreateTime(createTime);
rmResourceRegistrationMapper.insertRmResourceRegistration(insertData);
// 添加业务变更记录
EpsMethodChangeRecord recordAddData = new EpsMethodChangeRecord();
recordAddData.setClientId(registerMsg.getClientId());
recordAddData.setTrafficPort(networkInfo.getName());
recordAddData.setUpdateTime(DateUtils.getNowDate());
recordAddData.setUpdateBy(SecurityUtils.getUsername());
recordAddData.setCreatBy(SecurityUtils.getUsername());
StringBuilder content = new StringBuilder();
content.append("流量网口设置为").append(networkInfo.getName());
recordAddData.setChangeContent(content.toString());
epsMethodChangeRecordMapper.insertEpsMethodChangeRecord(recordAddData);
}else{
insertData.setClientId(registerMsg.getClientId());
insertData.setHardwareSn(registerMsg.getSn());
@@ -411,6 +550,8 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
remoteRocketMqService.sendAsyncProducerMessage(
"tr_agent_down", "", "", JSONObject.toJSONString(messageVo), SecurityConstants.INNER
);
// 第一次注册
return 2;
}catch (Exception e){
log.error("注册服务器失败:{}",e.getMessage());
// 构建注册应答信息
@@ -424,6 +565,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
remoteRocketMqService.sendAsyncProducerMessage(
"tr_agent_down", "", "", JSONObject.toJSONString(messageVo), SecurityConstants.INNER
);
return 0;
}
}
}
@@ -449,6 +591,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
RmResourceRegistration updateData = new RmResourceRegistration();
updateData.setId(exits.getId());
updateData.setLogicalNodeId(rmResourceRegistration.getLogicalNodeId());
updateData.setOnboardTime(DateUtils.getNowDate());
rmResourceRegistrationMapper.updateRmResourceRegistration(updateData);
log.info("设备:{},逻辑节点增加成功",rmResourceRegistration.getClientId());
return 1;
@@ -464,11 +607,23 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
// id
Long id = (Long) map.get("id");
String status = map.get("status").toString();
String interfaceName = map.get("interfaceName").toString();
// 绑定ip
RmNetworkInterfaceRemote rmNetworkInterfaceRemote = new RmNetworkInterfaceRemote();
rmNetworkInterfaceRemote.setId(id);
rmNetworkInterfaceRemote.setBindIp(status);
remoteRocketMqService.bindPublicIp(rmNetworkInterfaceRemote, SecurityConstants.INNER);
// 添加业务变更记录
EpsMethodChangeRecord recordAddData = new EpsMethodChangeRecord();
recordAddData.setClientId(rmResourceRegistration.getClientId());
recordAddData.setTrafficPort(interfaceName);
recordAddData.setUpdateTime(DateUtils.getNowDate());
recordAddData.setUpdateBy(SecurityUtils.getUsername());
recordAddData.setCreatBy(SecurityUtils.getUsername());
StringBuilder content = new StringBuilder();
content.append("流量网口设置为").append(interfaceName);
recordAddData.setChangeContent(content.toString());
epsMethodChangeRecordMapper.insertEpsMethodChangeRecord(recordAddData);
}
// 修改多公网IP状态为已绑定
RmResourceRegistration updateData = new RmResourceRegistration();

View File

@@ -46,10 +46,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="multiPublicIpStatus" column="multi_public_ip_status" />
<result property="heartbeatCount" column="heartbeat_count" />
<result property="heartbeatInterval" column="heartbeat_interval" />
<result property="onboardTime" column="onboard_time" />
</resultMap>
<sql id="selectRmResourceRegistrationVo">
select id, hardware_sn, resource_type, resource_name, ip_address, resource_port, other_port_name, agent_version, protocol, resource_version, rw_permission, snmp_detect, team_name, snmp_collect_addr, snmp_collect_port, security_level, encryption, resource_user_name, resource_pwd, registration_status, online_status, switch_online_status, description, customer_id, customer_name, service_number, create_time, update_time, creator_id, creator_name, updater_id, updater_name, client_id, operator, province, public_ip, business_name, logical_node_id, multi_public_ip_status, heartbeat_count, heartbeat_interval from rm_resource_registration
select id, hardware_sn, resource_type, resource_name, ip_address, resource_port, other_port_name,
agent_version, protocol, resource_version, rw_permission, snmp_detect, team_name, snmp_collect_addr,
snmp_collect_port, security_level, encryption, resource_user_name, resource_pwd, registration_status,
online_status, switch_online_status, description, customer_id, customer_name, service_number,
create_time, update_time, creator_id, creator_name, updater_id, updater_name, client_id, operator,
province, public_ip, business_name, logical_node_id, multi_public_ip_status, heartbeat_count,
heartbeat_interval, onboard_time from rm_resource_registration
</sql>
<select id="selectRmResourceRegistrationList" parameterType="RmResourceRegistration" resultMap="RmResourceRegistrationResult">
@@ -144,6 +151,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="multiPublicIpStatus != null">multi_public_ip_status,</if>
<if test="heartbeatCount != null">heartbeat_count,</if>
<if test="heartbeatInterval != null">heartbeat_interval,</if>
<if test="onboardTime != null">onboard_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="hardwareSn != null">#{hardwareSn},</if>
@@ -186,6 +194,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="multiPublicIpStatus != null">#{multiPublicIpStatus},</if>
<if test="heartbeatCount != null">#{heartbeatCount},</if>
<if test="heartbeatInterval != null">#{heartbeatInterval},</if>
<if test="onboardTime != null">#{onboardTime},</if>
</trim>
</insert>
@@ -232,6 +241,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="multiPublicIpStatus != null">multi_public_ip_status = #{multiPublicIpStatus},</if>
<if test="heartbeatCount != null">heartbeat_count = #{heartbeatCount},</if>
<if test="heartbeatInterval != null">heartbeat_interval = #{heartbeatInterval},</if>
<if test="onboardTime != null">onboard_time = #{onboardTime},</if>
</trim>
where id = #{id}
</update>
@@ -329,19 +339,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="creatorName != null">creator_name = #{creatorName},</if>
<if test="updaterId != null">updater_id = #{updaterId},</if>
<if test="updaterName != null">updater_name = #{updaterName},</if>
<if test="onboardTime != null">onboard_time = #{onboardTime},</if>
</trim>
where hardware_sn = #{hardwareSn}
<choose>
<when test="hardwareSn != null">
hardware_sn = #{hardwareSn}
</when>
<when test="clientId != null">
client_id = #{clientId}
</when>
<otherwise>
1=0 <!-- 如果两个条件都不满足,则不更新任何记录 -->
</otherwise>
</choose>
<where>
<choose>
<when test="hardwareSn != null">
and hardware_sn = #{hardwareSn}
</when>
<when test="clientId != null">
and client_id = #{clientId}
</when>
<otherwise>
1=0 <!-- 如果两个条件都不满足,则不更新任何记录 -->
</otherwise>
</choose>
</where>
</update>
<select id="getRegistrationByIds" parameterType="String" resultMap="RmResourceRegistrationResult">
<include refid="selectRmResourceRegistrationVo"/>