更改业务IP绑定、静态路由添加逻辑。

拓扑管理对端交换机名称处理
This commit is contained in:
gaoyutao
2025-12-12 15:43:16 +08:00
parent f3bdfbc6bf
commit 9a81408ada
5 changed files with 49 additions and 10 deletions
@@ -70,7 +70,7 @@ public interface RemoteRocketMqService {
* @return
*/
@GetMapping("/monitorPolicy/innerIssueSwitchPolicy")
public R<String> innerIssueSwitchPolicy(Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
public R<String> innerIssueSwitchPolicy(@RequestParam("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
* 查询策略信息
* @param rmMonitorPolicyRemote
@@ -95,7 +95,7 @@ public interface RemoteRocketMqService {
* @return
*/
@GetMapping("/monitorPolicy/issueDefaultPolicyByClientId")
public R<Integer> issueDefaultPolicyByClientId(String clientId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
public R<Integer> issueDefaultPolicyByClientId(@RequestParam("clientId") String clientId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@PostMapping("policy/addDeployScript")
R<Integer> addDeployScript(@RequestBody RmDeployScriptRemote addData, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
@@ -92,4 +92,6 @@ public class RmEpsTopologyManagement extends BaseEntity
* 服务器clientId
*/
private String serverClientId;
/** 对端交换机名称 */
private String peerName;
}
@@ -41,7 +41,8 @@ public class RmEpsTopologyManagementServiceImpl implements IRmEpsTopologyManagem
@Override
public List<RmEpsTopologyManagement> selectRmEpsTopologyManagementList(RmEpsTopologyManagement rmEpsTopologyManagement)
{
return rmEpsTopologyManagementMapper.selectRmEpsTopologyManagementList(rmEpsTopologyManagement);
List<RmEpsTopologyManagement> list = rmEpsTopologyManagementMapper.selectRmEpsTopologyManagementList(rmEpsTopologyManagement);
return list;
}
/**
@@ -961,8 +961,11 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
// 1. 处理IP绑定和记录
rmResourceRegistration.getBindNetworkMsg().forEach(map -> {
// 绑定IP
if (map.get("id") == null) {
return;
}
RmNetworkInterfaceRemote network = new RmNetworkInterfaceRemote();
network.setId((Long) map.get("id"));
network.setId(Long.parseLong(map.get("id").toString()));
network.setBindIp(map.get("status").toString());
remoteRocketMqService.bindPublicIp(network, SecurityConstants.INNER);
@@ -998,6 +1001,13 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
.filter(ni -> "1".equals(ni.getBindIp()) || "3".equals(ni.getBindIp()))
.collect(Collectors.toList()))
.orElse(Collections.emptyList());
// 管理网信息
List<RmNetworkInterfaceRemote> mtmNetworks = Optional.ofNullable(netList)
.map(R::getData)
.map(list -> list.stream()
.filter(ni -> "2".equals(ni.getBindIp()) || "3".equals(ni.getBindIp()))
.collect(Collectors.toList()))
.orElse(Collections.emptyList());
// 如果有符合条件的网络接口
if (!filteredNetworks.isEmpty()) {
@@ -1014,10 +1024,6 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
String netName = netNameBuilder.toString();
// 发送注册响应
RouteMsg routeMsg = new RouteMsg();
routeMsg.setName(filteredNetworks.get(0).getInterfaceName()); // 使用拼接后的网络接口名称
routeMsg.setGateway(filteredNetworks.get(0).getGateway()); // 使用第一个网络接口的网关,或者您可以根据需要调整
MessageVo messageVo = new MessageVo();
messageVo.setClientId(clientId);
messageVo.setDataType(MsgEnum.注册应答.getValue());
@@ -1025,7 +1031,15 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
RspVo rspVo = new RspVo();
rspVo.setResCode(1);
rspVo.setResMag("注册成功");
rspVo.setAddRoute(JSONObject.toJSONString(routeMsg));
if(mtmNetworks != null && !mtmNetworks.isEmpty()){
RouteMsg routeMsg = new RouteMsg();
String gateWay = mtmNetworks.get(0).getGateway();
routeMsg.setName(mtmNetworks.get(0).getInterfaceName()); // 使用拼接后的网络接口名称
routeMsg.setGateway(gateWay); // 使用第一个网络接口的网关,或者您可以根据需要调整
if(gateWay != null){
rspVo.setAddRoute(JSONObject.toJSONString(routeMsg));
}
}
rspVo.setNetName(netName);
messageVo.setData(JSONObject.toJSONString(rspVo));
@@ -24,10 +24,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="peerSwitchName" column="peer_switch_name" />
<result property="peerSwitchInterface" column="peer_switch_interface" />
<result property="serverClientId" column="server_client_id" />
<result property="peerName" column="peerName" />
</resultMap>
<sql id="selectRmEpsTopologyManagementVo">
select id, switch_name, client_id, switch_sn, interface_name, connected_device_type, server_name, server_sn, server_port, create_time, update_time, creator_id, creator_name, updater_id, updater_name, switch_ip_address, peer_switch_name, peer_switch_interface, server_client_id from rm_eps_topology_management
SELECT
id,
switch_name,
client_id,
switch_sn,
interface_name,
connected_device_type,
server_name,
server_sn,
server_port,
create_time,
update_time,
creator_id,
creator_name,
updater_id,
updater_name,
switch_ip_address,
peer_switch_name,
(SELECT switch_name FROM rm_switch_management WHERE client_id = rm_eps_topology_management.peer_switch_name) AS peerName,
peer_switch_interface,
server_client_id
FROM rm_eps_topology_management
</sql>
<select id="selectRmEpsTopologyManagementList" parameterType="RmEpsTopologyManagement" resultMap="RmEpsTopologyManagementResult">