交换机管理图形监控只展示端口为up的。

优化frp信息上报
This commit is contained in:
gaoyutao
2025-12-24 19:55:47 +08:00
parent 5eda46802e
commit 30373bbb1e
13 changed files with 120 additions and 44 deletions
@@ -83,5 +83,7 @@ public class AllInterfaceName extends BaseEntity
private boolean expand;
/** 是否业务网卡 */
private boolean businessFlag;
/** 端口状态 1up 2down */
private String portStatus;
}
@@ -56,6 +56,10 @@ public class AllInterfaceNameServiceImpl implements IAllInterfaceNameService
@Override
public List<AllInterfaceName> selectAllInterfaceNameList(AllInterfaceName allInterfaceName)
{
if ("2".equals(allInterfaceName.getResourceType())) {
// 交换机类型,只返回端口为up的
allInterfaceName.setPortStatus("1");
}
List<AllInterfaceName> allInterfaceNameList = allInterfaceNameMapper.selectAllInterfaceNameList(allInterfaceName);
if (allInterfaceNameList == null || allInterfaceNameList.isEmpty()) {
return allInterfaceNameList;
@@ -150,7 +154,6 @@ public class AllInterfaceNameServiceImpl implements IAllInterfaceNameService
interfaceName.getInterfaceName() != null && topologyManagement.getInterfaceName() != null &&
interfaceName.getInterfaceName().equalsIgnoreCase(topologyManagement.getInterfaceName())
);
// 如果匹配成功,设置 expand 属性为 true
if (isMatched) {
interfaceName.setExpand(true);
@@ -405,6 +405,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
record.setSwitchName(data.getSwitchName());
record.setSwitchSn(data.getSwitchSn());
record.setSwitchIp(data.getSwitchIp());
record.setPortStatus(data.getStatus());
return record;
}
private void fillBusinessInfo(AllInterfaceName record, String serverSn) {
@@ -1,7 +1,7 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tongran.system.mapper.AllInterfaceNameMapper">
<resultMap type="AllInterfaceName" id="AllInterfaceNameResult">
@@ -23,10 +23,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="switchSn" column="switch_sn" />
<result property="switchIp" column="switch_ip" />
<result property="serverIp" column="server_ip" />
<result property="portStatus" column="port_status" />
</resultMap>
<sql id="selectAllInterfaceNameVo">
select id, client_id, interface_name, device_sn, node_name, business_code, business_name, resource_type, create_time, update_time, create_by, update_by, switch_name, interface_device_type, server_port, switch_sn, switch_ip, server_ip from all_interface_name
select id, client_id, interface_name, device_sn, node_name, business_code, business_name, resource_type, create_time, update_time, create_by, update_by, switch_name, interface_device_type, server_port, switch_sn, switch_ip, server_ip, port_status from all_interface_name
</sql>
<select id="selectAllInterfaceNameList" parameterType="AllInterfaceName" resultMap="AllInterfaceNameResult">
@@ -45,6 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="switchSn != null and switchSn != ''"> and switch_sn = #{switchSn}</if>
<if test="switchIp != null and switchIp != ''"> and switch_ip = #{switchIp}</if>
<if test="serverIp != null and serverIp != ''"> and server_ip = #{serverIp}</if>
<if test="portStatus != null and portStatus != ''"> and port_status = #{portStatus}</if>
</where>
</select>
@@ -73,6 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="switchSn != null">switch_sn,</if>
<if test="switchIp != null">switch_ip,</if>
<if test="serverIp != null">server_ip,</if>
<if test="portStatus != null">port_status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clientId != null and clientId != ''">#{clientId},</if>
@@ -92,6 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="switchSn != null">#{switchSn},</if>
<if test="switchIp != null">#{switchIp},</if>
<if test="serverIp != null">#{serverIp},</if>
<if test="portStatus != null">#{portStatus},</if>
</trim>
</insert>
@@ -115,6 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="switchSn != null">switch_sn = #{switchSn},</if>
<if test="switchIp != null">switch_ip = #{switchIp},</if>
<if test="serverIp != null">server_ip = #{serverIp},</if>
<if test="portStatus != null">port_status = #{portStatus},</if>
</trim>
where id = #{id}
</update>
@@ -145,7 +150,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
server_port AS serverPort,
switch_sn AS switchSn,
switch_ip AS switchIp,
server_ip AS serverIp
server_ip AS serverIp,
port_status AS portStatus
FROM
all_interface_name
<where>
@@ -175,7 +181,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
node_name,
business_code,
business_name,
switch_name, interface_device_type, server_port, switch_sn, switch_ip, server_ip,
switch_name, interface_device_type, server_port, switch_sn, switch_ip, server_ip, port_status,
create_time,
update_time
)
@@ -189,7 +195,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.nodeName},
#{item.businessCode},
#{item.businessName},
#{item.switchName}, #{item.interfaceDeviceType}, #{item.serverPort}, #{item.switchSn}, #{item.switchIp}, #{item.serverIp},
#{item.switchName}, #{item.interfaceDeviceType}, #{item.serverPort}, #{item.switchSn}, #{item.switchIp}, #{item.serverIp}, #{item.portStatus},
NOW(),
NOW()
)
@@ -240,6 +246,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
THEN VALUES(switch_ip)
ELSE switch_ip
END,
server_ip = CASE
WHEN server_ip != VALUES(server_ip) OR (server_ip IS NULL AND VALUES(server_ip) IS NOT NULL)
THEN VALUES(server_ip)
ELSE server_ip
END,
port_status = CASE
WHEN port_status != VALUES(port_status) OR (port_status IS NULL AND VALUES(port_status) IS NOT NULL)
THEN VALUES(port_status)
ELSE port_status
END,
update_time = CASE
WHEN device_sn != VALUES(device_sn) OR (device_sn IS NULL AND VALUES(device_sn) IS NOT NULL)
OR node_name != VALUES(node_name) OR (node_name IS NULL AND VALUES(node_name) IS NOT NULL)
@@ -250,6 +266,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
OR server_port != VALUES(server_port) OR (server_port IS NULL AND VALUES(server_port) IS NOT NULL)
OR switch_sn != VALUES(switch_sn) OR (switch_sn IS NULL AND VALUES(switch_sn) IS NOT NULL)
OR switch_ip != VALUES(switch_ip) OR (switch_ip IS NULL AND VALUES(switch_ip) IS NOT NULL)
OR server_ip != VALUES(server_ip) OR (server_ip IS NULL AND VALUES(server_ip) IS NOT NULL)
OR port_status != VALUES(port_status) OR (port_status IS NULL AND VALUES(port_status) IS NOT NULL)
THEN NOW()
ELSE update_time
END
@@ -257,13 +275,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getAllDeviceSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
SELECT
client_id AS clientId
client_id AS clientId
FROM
all_interface_name
all_interface_name
<where>
and resource_type = '1' and client_id != ''
</where>
group by client_id
group by client_id
</select>
<select id="getAllSwitchSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
SELECT
@@ -290,7 +308,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
switch_name = #{item.switchName},
switch_sn = #{item.switchSn},
switch_ip = #{item.switchIp},
server_ip = #{item.serverIp}
server_ip = #{item.serverIp},
port_status = #{item.portStatus}
WHERE id = #{item.id}
</foreach>
</update>