1、交换机管理增加下架接口。

2、流量图改为有ipv6展示,没有就不展示。
This commit is contained in:
gaoyutao
2026-04-01 17:46:23 +08:00
parent 4839ea178b
commit feaa0b4b97
7 changed files with 73 additions and 24 deletions
@@ -51,7 +51,7 @@ public class RmSwitchManagementController extends BaseController
*/
@Log(title = "交换机管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, RmSwitchManagement rmSwitchManagement)
public void export(HttpServletResponse response, @RequestBody RmSwitchManagement rmSwitchManagement)
{
List<RmSwitchManagement> list = rmSwitchManagementService.selectRmSwitchManagementList(rmSwitchManagement);
ExcelUtil<RmSwitchManagement> util = new ExcelUtil<RmSwitchManagement>(RmSwitchManagement.class);
@@ -103,6 +103,7 @@ public class RmSwitchManagementController extends BaseController
@PostMapping("/getAllSwitchName")
public AjaxResult getAllSwitchName(@RequestBody RmSwitchManagement rmSwitchManagement)
{
rmSwitchManagement.setDelFlag(0);
List<RmSwitchManagement> list = rmSwitchManagementService.selectRmSwitchManagementList(rmSwitchManagement);
return success(list);
}
@@ -113,6 +114,7 @@ public class RmSwitchManagementController extends BaseController
@PostMapping("/getSwitchNameByClientId")
public R<List<RmSwitchManagement>> getSwitchNameByClientId(@RequestBody RmSwitchManagement rmSwitchManagement)
{
rmSwitchManagement.setDelFlag(0);
List<RmSwitchManagement> list = rmSwitchManagementService.selectRmSwitchManagementList(rmSwitchManagement);
return R.ok(list);
}
@@ -134,4 +136,14 @@ public class RmSwitchManagementController extends BaseController
{
return R.ok(rmSwitchManagementService.updateRmSwitchManagement(rmSwitchManagement));
}
/**
* 下架
*/
@Log(title = "下架", businessType = BusinessType.UPDATE)
@PostMapping("/removeSwitch")
public AjaxResult removeSwitch(@RequestBody RmSwitchManagement rmSwitchManagement)
{
return toAjax(rmSwitchManagementService.removeSwitch(rmSwitchManagement.getIds()));
}
}
@@ -38,9 +38,10 @@ public class RmSwitchManagement extends BaseEntity
private Long snmpPort;
/** 在线状态(0-离线,1-在线) */
@Excel(name = "在线状态(0-离线,1-在线)")
@Excel(name = "在线状态", readConverterExp = "0=离线,1=在线")
private String onlineStatus;
/** 上机时间 */
@Excel(name = "上机时间")
private Date upTime;
/** 心跳监测次数 */
@Excel(name = "心跳监测次数")
@@ -55,19 +56,19 @@ public class RmSwitchManagement extends BaseEntity
private String heartbeatOid;
/** SNMP版本(v1/v2c/v3) */
@Excel(name = "SNMP版本(v1/v2c/v3)")
@Excel(name = "SNMP版本", readConverterExp = "1=华为SNMPv2,2=华为SNMPv3")
private String snmpVersion;
/** 读写权限 */
@Excel(name = "读写权限")
@Excel(name = "读写权限", readConverterExp = "1=只读,2=可读可写")
private String readWritePermission;
/** 安全级别 */
@Excel(name = "安全级别")
@Excel(name = "安全级别", readConverterExp = "1=noAuthNoPriv,2=authNoPriv,3=authPriv")
private String securityLevel;
/** 加密方式 */
@Excel(name = "加密方式")
@Excel(name = "加密方式", readConverterExp = "1=MD5,2=SHA")
private String encryptionMethod;
/** 团体名称 */
@@ -78,12 +79,15 @@ public class RmSwitchManagement extends BaseEntity
@Excel(name = "密码")
private String switchPassword;
/** 交换机类型 */
@Excel(name = "交换机类型", readConverterExp = "1=华为")
private String switchType;
/** 用户名 */
@Excel(name = "用户名")
private String switchUser;
/** 端口备注列表 */
private List<RmSwitchInterfaceInfo> switchInterfaceInfoList;
/** 自动生成客户端id(uuid) */
@Excel(name = "唯一标识")
private String clientId;
/** 查询条件 */
private String queryName;
@@ -93,5 +97,9 @@ public class RmSwitchManagement extends BaseEntity
private Long value;
/** 前端需要 name 别名 */
private String label;
/** 下架标识(0未下架,1已下架) */
private Integer delFlag;
private Long[] ids;
}
@@ -1,8 +1,9 @@
package com.tongran.system.mapper;
import java.util.List;
import com.tongran.system.domain.RmSwitchManagement;
import java.util.List;
/**
* 交换机管理Mapper接口
*
@@ -58,4 +59,6 @@ public interface RmSwitchManagementMapper
* @return 结果
*/
public int deleteRmSwitchManagementByIds(Long[] ids);
int removeSwitch(Long[] ids);
}
@@ -65,4 +65,6 @@ public interface IRmSwitchManagementService
* @return
*/
List<RmSwitchManagement> getAllSwitchNameTree();
int removeSwitch(Long[] ids);
}
@@ -160,7 +160,9 @@ public class RmSwitchManagementServiceImpl implements IRmSwitchManagementService
*/
@Override
public List<RmSwitchManagement> getAllSwitchNameTree() {
List<RmSwitchManagement> list = rmSwitchManagementMapper.selectRmSwitchManagementList(new RmSwitchManagement());
RmSwitchManagement queryCondition = new RmSwitchManagement();
queryCondition.setDelFlag(0);
List<RmSwitchManagement> list = rmSwitchManagementMapper.selectRmSwitchManagementList(queryCondition);
// 构建树形结构结果
for (RmSwitchManagement switchManagement : list) {
switchManagement.setValue(switchManagement.getId());
@@ -197,4 +199,9 @@ public class RmSwitchManagementServiceImpl implements IRmSwitchManagementService
}
return list;
}
@Override
public int removeSwitch(Long[] ids) {
return rmSwitchManagementMapper.removeSwitch(ids);
}
}
@@ -28,15 +28,17 @@
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="clientId" column="client_id" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectRmSwitchManagementVo">
select id, switch_type, switch_name, hardware_sn, snmp_address, snmp_port, online_status, heartbeat_count, heartbeat_interval, heartbeat_oid, snmp_version, up_time, read_write_permission, security_level, encryption_method, community_name, switch_user, switch_password, create_time, update_time, create_by, update_by, client_id from rm_switch_management
select id, switch_type, switch_name, hardware_sn, snmp_address, snmp_port, online_status, heartbeat_count, heartbeat_interval, heartbeat_oid, snmp_version, up_time, read_write_permission, security_level, encryption_method, community_name, switch_user, switch_password, create_time, update_time, create_by, update_by, client_id, del_flag from rm_switch_management
</sql>
<select id="selectRmSwitchManagementList" parameterType="RmSwitchManagement" resultMap="RmSwitchManagementResult">
<include refid="selectRmSwitchManagementVo"/>
<where>
<if test="delFlag != null"> and del_flag = #{delFlag}</if>
<if test="switchType != null and switchType != ''"> and switch_type = #{switchType}</if>
<if test="switchName != null and switchName != ''"> and switch_name like concat('%', #{switchName}, '%')</if>
<if test="hardwareSn != null and hardwareSn != ''"> and hardware_sn = #{hardwareSn}</if>
@@ -57,7 +59,7 @@
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="queryName != null and queryName != ''">
and (snmp_address = #{queryName} or switch_name like concat('%', #{queryName}, '%'))
</if>
</if>
</where>
order by create_time desc
</select>
@@ -92,6 +94,7 @@
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
<if test="clientId != null">client_id,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="switchType != null">#{switchType},</if>
@@ -116,6 +119,7 @@
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="clientId != null">#{clientId},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
@@ -143,6 +147,7 @@
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
<where>
<choose>
@@ -169,4 +174,10 @@
#{id}
</foreach>
</delete>
<update id="removeSwitch" parameterType="String">
update rm_switch_management set del_flag=1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>
@@ -454,8 +454,10 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
Map<String, String> showRealation = new HashMap<>();
interfaceDataMap.put(name, mainList);
String ipv4 = "";
String ipv6 = "";
if(mainList != null && !mainList.isEmpty()){
ipv4 = mainList.get(0).getIpV4();
ipv6 = mainList.get(0).getIpV6();
}
showRealation.put(name+"netInTraffic", name+"入站流量" + " IPv4: "+ipv4);
showRealation.put(name+"netOutTraffic", name+"出站流量" + " IPv4: "+ipv4);
@@ -490,8 +492,10 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
needAddIpv4Ipv6 = true;
showRealation.put(name+"netInTrafficIPv4", name+"IPv4入站流量" + " IPv4: "+ipv4);
showRealation.put(name+"netOutTrafficIPv4", name+"IPv4出站流量" + " IPv4: "+ipv4);
showRealation.put(name+"netInTrafficIPv6", name+"IPv6入站流量" + " IPv4: "+ipv4);
showRealation.put(name+"netOutTrafficIPv6", name+"IPv6站流量" + " IPv4: "+ipv4);
if(!"N/A".equals(ipv6) && StringUtils.isNoneBlank(ipv6)){
showRealation.put(name+"netInTrafficIPv6", name+"IPv6站流量" + " IPv6: "+ipv6);
showRealation.put(name+"netOutTrafficIPv6", name+"IPv6出站流量" + " IPv6: "+ipv6);
}
}
}
@@ -702,10 +706,12 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
displayName + " IPv4入站流量");
showRealation.put("business_" + businessPrefix + "_netIpv4OutSpeedData",
displayName + " IPv4出站流量");
showRealation.put("business_" + businessPrefix + "_netIpv6InSpeedData",
displayName + " IPv6入站流量");
showRealation.put("business_" + businessPrefix + "_netIpv6OutSpeedData",
displayName + " IPv6出站流量");
if(!"N/A".equals(ipv6) && StringUtils.isNoneBlank(ipv6)){
showRealation.put("business_" + businessPrefix + "_netIpv6InSpeedData",
displayName + " IPv6入站流量");
showRealation.put("business_" + businessPrefix + "_netIpv6OutSpeedData",
displayName + " IPv6出站流量");
}
}
}
} catch (Exception e) {
@@ -860,12 +866,12 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
// 展示关系
Map<String, String> showRealation = new HashMap<>();
interfaceDataMap.put(name, mainList);
String ipv4 = "";
String ipv6 = "";
if(mainList != null && !mainList.isEmpty()){
ipv4 = mainList.get(0).getIpV4();
ipv6 = mainList.get(0).getIpV6();
}
showRealation.put(name + "netInTraffic", name + "IPv6入站流量" + " IPv4: "+ipv4);
showRealation.put(name + "netOutTraffic", name + "IPv6出站流量" + " IPv4: "+ipv4);
showRealation.put(name + "netInTraffic", name + "IPv6入站流量" + " ipv6: "+ipv6);
showRealation.put(name + "netOutTraffic", name + "IPv6出站流量" + " ipv6: "+ipv6);
boolean hasSubInterface = false;
// 收集所有需要计算单位的流量数据
List<InitialBandwidthTraffic> allTrafficData = new ArrayList<>();
@@ -887,8 +893,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
if (childTrafficList != null && !childTrafficList.isEmpty()) {
allTrafficData.addAll(childTrafficList);
interfaceDataMap.put(child.getInterfaceName(), childTrafficList);
showRealation.put(child.getInterfaceName() + "netInTraffic", child.getInterfaceName() + "IPv6入站流量" + " IPv4: "+child.getIpv4Address());
showRealation.put(child.getInterfaceName() + "netOutTraffic", child.getInterfaceName() + "IPv6出站流量" + " IPv4: "+child.getIpv4Address());
showRealation.put(child.getInterfaceName() + "netInTraffic", child.getInterfaceName() + "IPv6入站流量" + " ipv6: "+child.getIpv6Address());
showRealation.put(child.getInterfaceName() + "netOutTraffic", child.getInterfaceName() + "IPv6出站流量" + " ipv6: "+child.getIpv6Address());
}
}
}
@@ -917,8 +923,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
resultMap.put("unit", unit);
if (!showRealation.isEmpty() && hasSubInterface) {
showRealation.put("totalNetInTraffic", name + "IPv6总入站流量" + " IPv4: "+ipv4);
showRealation.put("totalNetOutTraffic", name + "IPv6总出站流量" + " IPv4: "+ipv4);
showRealation.put("totalNetInTraffic", name + "IPv6总入站流量" + " ipv6: "+ipv6);
showRealation.put("totalNetOutTraffic", name + "IPv6总出站流量" + " ipv6: "+ipv6);
}
Map<String, String> sortedShowRealation = EchartsMoreDataUtils.sortInterfaceMap(showRealation, name, hasSubInterface);
resultMap.put("showRealation", sortedShowRealation);