系统状态

This commit is contained in:
xusd 2024-08-08 15:17:18 +08:00
parent 8bc8559586
commit c174ae9e71
5 changed files with 394 additions and 127 deletions

View File

@ -0,0 +1,121 @@
package com.ruoyi.web.controller.system;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.net.NetUtil;
import cn.hutool.system.HostInfo;
import cn.hutool.system.OsInfo;
import cn.hutool.system.SystemUtil;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.gateway.lora.domain.GatewayAgreement;
import com.ruoyi.gateway.lora.service.IGatewayAgreementService;
import com.ruoyi.system.service.ISysDictDataService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.*;
import java.util.stream.Collectors;
/**
* 首页
*
* @Author xusd
* @Date 2024/8/7 9:36
**/
@RestController
@RequestMapping("/main")
public class SysMainController {
@Resource
private IGatewayAgreementService agreementService;
@Resource
private ISysDictDataService dictDataService;
@GetMapping
public Map<String, Object> getData() {
Map<String, Object> map = new HashMap<>();
OsInfo osInfo = SystemUtil.getOsInfo();
map.put("osInfo", osInfo);
HostInfo hostInfo = SystemUtil.getHostInfo();
map.put("hostInfo", hostInfo);
map.put("macAddress", NetUtil.getLocalMacAddress());
map.put("UsableLocalPort", NetUtil.getUsableLocalPort());
//协议
GatewayAgreement gatewayAgreement = agreementService.selectGatewayAgreementById(null);
if (Objects.nonNull(gatewayAgreement)) {
String agreementType = gatewayAgreement.getAgreementType();
List<String> agreements = new ArrayList<>();
switch (agreementType) {
case "1":
map.put("agreementTypeName","MQTT");
agreements.add("服务器地址:" + gatewayAgreement.getMqttAddress());
agreements.add("服务器端口:" + gatewayAgreement.getMqttPort());
agreements.add("客户端标识符:" + gatewayAgreement.getMqttFlag());
agreements.add("用户名:" + gatewayAgreement.getMqttUser());
agreements.add("遗嘱消息:" + gatewayAgreement.getMqttDieMsg());
agreements.add("心跳时间:" + gatewayAgreement.getMqttHeartbeat());
agreements.add("主题:" + gatewayAgreement.getMqttTopic());
map.put("agreement",agreements);
break;
case "2":
map.put("agreementTypeName","Socket");
SysDictData dictData = new SysDictData();
dictData.setDictType("socket_domain");
List<SysDictData> sysDictData1 = dictDataService.selectDictDataList(dictData);
Map<String, String> collect1 = sysDictData1.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));
agreements.add("协议族:" + collect1.get(gatewayAgreement.getSocketDomain()));
dictData.setDictType("socket_type");
List<SysDictData> sysDictData2 = dictDataService.selectDictDataList(dictData);
Map<String, String> collect2 = sysDictData2.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));
agreements.add("套接字类型:" + collect2.get(gatewayAgreement.getSocketType()));
dictData.setDictType("socket_protocol");
List<SysDictData> sysDictData3 = dictDataService.selectDictDataList(dictData);
Map<String, String> collect3 = sysDictData3.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));
agreements.add("协议:" + collect3.get(gatewayAgreement.getSocketProtocol()));
agreements.add("地址:" + gatewayAgreement.getSocketAddress());
map.put("agreement",agreements);
break;
case "3":
map.put("agreementTypeName","Modbus RTU");
agreements.add("串口号:" + gatewayAgreement.getRtuSerialPort());
agreements.add("波特率:" + gatewayAgreement.getRtuBaud());
agreements.add("数据位:" + gatewayAgreement.getRtuDataBits());
agreements.add("校验位:" + gatewayAgreement.getRtuCheckBit());
agreements.add("停止位:" + gatewayAgreement.getRtuStopBit());
map.put("agreement",agreements);
break;
case "4":
map.put("agreementTypeName","Modbus TCP");
agreements.add("IP地址" + gatewayAgreement.getTcpAddress());
agreements.add("端口:" + gatewayAgreement.getTcpPort());
agreements.add("连接超时时间:" + gatewayAgreement.getTcpConnectionTimeout());
agreements.add("读取超时时间:" + gatewayAgreement.getTcpReadTimeout());
agreements.add("最大连接数:" + gatewayAgreement.getTcpMaxConnection());
agreements.add("心跳间隔:" + gatewayAgreement.getTcpHeartbeatInterval());
agreements.add("数据包最大长度:" + gatewayAgreement.getTcpMaxPpacket());
agreements.add("地址映射表:" + gatewayAgreement.getTcpAddressMapping());
map.put("agreement",agreements);
break;
case "5":
map.put("agreementTypeName","Fanuc");
agreements.add("IP地址" + gatewayAgreement.getFanucAddress());
agreements.add("子网掩码:" + gatewayAgreement.getFanucMask());
agreements.add("网关地址:" + gatewayAgreement.getFanucGatewayAddress());
agreements.add("DNS" + gatewayAgreement.getFanucDns());
agreements.add("VLAN" + gatewayAgreement.getFanucVlan());
agreements.add("SNMP" + gatewayAgreement.getFanucSnmp());
map.put("agreement",agreements);
break;
default:
break;
}
}
return map;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -83,7 +83,7 @@
<ul class="nav">
<li>
<a class="menuItem" th:href="@{/system/main}">
<i class="fa fa-home"></i> <span class="nav-label">首页</span></a>
<i class="fa fa-home"></i> <span class="nav-label">系统状态</span></a>
</li>
</ul>
</div>
@ -279,7 +279,7 @@
</button>
<nav class="page-tabs menuTabs">
<div class="page-tabs-content">
<a href="javascript:;" class="active menuTab" th:data-id="@{/system/main}">首页</a>
<a href="javascript:;" class="active menuTab" th:data-id="@{/system/main}">系统状态</a>
</div>
</nav>
<button class="roll-nav roll-right tabRight">

View File

@ -47,7 +47,7 @@
<!-- </div>-->
<!-- </li>-->
<li>
<a class="menuItem" th:href="@{/system/main}"><i class="fa fa-home"></i> <span class="nav-label">首页</span> </a>
<a class="menuItem" th:href="@{/system/main}"><i class="fa fa-home"></i> <span class="nav-label">系统状态</span> </a>
</li>
<li th:each="menu : ${menus}">
<a th:class="@{${!#strings.isEmpty(menu.url) && menu.url != '#'} ? ${menu.target}}" th:href="@{${#strings.isEmpty(menu.url)} ? |#| : ${menu.url}}" th:data-refresh="${menu.isRefresh == '0'}">
@ -229,7 +229,7 @@
</button>
<nav class="page-tabs menuTabs">
<div class="page-tabs-content">
<a href="javascript:;" class="active menuTab" th:data-id="@{/system/main}">首页</a>
<a href="javascript:;" class="active menuTab" th:data-id="@{/system/main}">系统状态</a>
</div>
</nav>
<button class="roll-nav roll-right tabRight">

View File

@ -12,139 +12,285 @@
<link href="../static/css/main/style.min862f.css" th:href="@{/css/main/style.min862f.css}" rel="stylesheet"/>
</head>
<body class="gray-bg">
<div class="row border-bottom white-bg dashboard-header">
<div class="col-sm-4">
<blockquote class="text-warning" style="font-size:14px">
<br>
<h3 class="text-danger">云服务器推荐(新用户更优惠):</h3><br>
<h4 class="text-muted">【阿里云】2021上云采购季新人爆款抢先购</h4>
<a target="_blank" href="https://www.aliyun.com/minisite/goods?userCode=vvwubb2a">☛☛点我前往☚☚</a><br>
<h4 class="text-muted">【腾讯云】2021新春采购节爆款产品特惠助力企业上云</h4>
<a target="_blank" href="https://cloud.tencent.com/act/cps/redirect?redirect=1078&cps_key=86eaf6934c31445e209ce1dacfc62db0&from=console">☛☛点我前往☚☚</a><br>
</blockquote>
</div>
<div class="col-sm-5">
<h2>智产网关介绍</h2>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;前段时间做了一个路由认证项目网上查了好久终于在gitee上找到了jamiesun大佬开源的<a href="https://gitee.com/jamiesun/ToughRADIUS.git" target="_blank">ToughRADIUS</a>,基本上符合项目的需求,但还是不能完全满足,以前一直用的若依大佬开源的<a href="https://gitee.com/y_project/RuoYi.git" target="_blank">若依后台管理框架</a>最后把2个大佬的项目合并再添加项目的新功能形成了本项目最终框架。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;此框架继承了2个框架的优点<a href="https://gitee.com/y_project/RuoYi.git" target="_blank">若依后台管理框架V4.6.0</a>做为基础框架,实现了<a href="https://gitee.com/jamiesun/ToughRADIUS.git" target="_blank">ToughRADIUS</a>大部分功能,支持<b>标准RADIUS协议RFC 2865, RFC 2866</b>,提供<b>完整的AAA实现</b>。可运用于<b>酒店WIFI认证</b><b>公司局域网权限认证</b><b>商场WIFI认证</b><b>其它公共场所</b>等等,当然,您也可以对她进行深度定制,以做出更强系统。所有前端后台代码封装过后十分精简易上手,出错概率低。系统会陆续更新一些实用功能。</p>
<p>
<b>当前版本:</b><span>v[[${version}]]</span>
</p>
<br>
</div>
<div class="col-sm-3">
<h4>技术选型:</h4>
<ol>
<li>核心框架若依后台管理系统V4.6.0</li>
<li>Radius框架ToughRADIUS</li>
<li>数据库MySQL5.7</li>
<li>JDK1.8</li>
<li>路由器MikroTik RouterOS V6.47.4</li>
<li>更多……</li>
</ol>
</div>
</div>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-4">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>联系信息</h5>
<div >
<div class="row border-bottom white-bg dashboard-header">
<div style="border-bottom: darkgray 1px solid;">
<div style="width: 100px;height: 30px;background: darkgray;text-align: center;line-height: 30px;user-select: none;">状态</div>
</div>
<div style="width: 100%;height:465px;font-size: 0">
<div style="text-align: center;font-size: 14px;">
<div style="margin-bottom: 5px">
<span>IP地址</span>
<span id="ipAddress"></span>
</div>
<div class="ibox-content">
<br>
<p><i class="fa fa-qq"></i> QQ群<a href="https://jq.qq.com/?_wv=1027&k=qgmFICdY" target="_blank">5475847</a>
</p>
<br>
<p>
<a class="btn btn-success btn-outline" href="https://gitee.com/panweilei/ruoyi-radius.git" target="_blank">
<i class="fa fa-cloud"> </i> 智产网关源码
</a>
</p>
<p>
<a class="btn btn-success btn-outline" href="https://gitee.com/y_project/RuoYi.git" target="_blank">
<i class="fa fa-cloud"> </i> 若依后台管理系统源码
</a>
</p>
<p>
<a class="btn btn-success btn-outline" href="https://gitee.com/jamiesun/ToughRADIUS.git" target="_blank">
<i class="fa fa-cloud"> </i> ToughRADIUS源码
</a>
</p>
<div style="margin-bottom: 5px">
<span>系统:</span>
<span id="sysName"></span>
</div>
<div style="margin-bottom: 5px">
<span>MAC地址</span>
<span id="macAddress"></span>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>更新日志</h5>
</div>
<div class="ibox-content no-padding">
<div class="panel-body">
<div class="panel-group" id="version">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#version" href="#v00">v1.0.0</a><code class="pull-right">2021.03.15</code>
</h4>
</div>
<div id="v00" class="panel-collapse collapse in">
<div class="panel-body">
<ol>
<li>智产网关正式发布。</li>
<li>新增套餐管理</li>
<li>新增设备管理</li>
<li>新增用户管理</li>
<li>新增订单管理</li>
<li>新增在线管理</li>
<li>新增微信、支付宝H5支付</li>
<li>实现用户上线请求认证、动态授权、限速、强制下线</li>
<li>实现上网时间到期后自动下线</li>
</ol>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>捐赠</h5>
</div>
<div class="ibox-content">
<div class="alert alert-warning">
请作者喝杯咖啡(点击图片放大)
<div class="leftJT"></div>
<div class="outImgDiv">
<div class="inImgDiv1"></div>
<div style="text-align: center;font-size: 16px">
<div style="margin-bottom: 5px">
<span>协议类型:</span>
<span id="agreementType2"></span>
</div>
<div style="font-size: 14px;visibility: hidden">
<ul id="agreementItem1" style="list-style-type:none;padding:0;margin:0">
</ul>
</div>
<p id="pay-qrcode">
<a href="javascript:;"><img th:src="@{/img/pay.jpg}" width="100%" alt="请使用手机支付宝或者微信扫码支付">
</a>
</p>
</div>
</div>
<div class="outImgDiv">
<div class="inImgDiv2"></div>
<div style="width: 100%;font-size: 0;">
<div style="width: 50%;display: inline-block;font-size: 14px;">
<div style="text-align: center;font-size: 16px">
<div style="margin-bottom: 5px">
<span>协议类型:</span>
<span id="agreementType1"></span>
</div>
<div style="font-size: 14px">
<ul id="agreementItem3" style="list-style-type:none;padding:0;margin:0">
</ul>
</div>
</div>
</div>
<div style="width: 50%;display: inline-block;font-size: 14px;">
<div style="text-align: center;font-size: 16px">
<div style="margin-bottom: 5px">
<span>状态:</span>
<span>已连接</span>
</div>
<div style="font-size: 14px;visibility: hidden">
<ul id="agreementItem2" style="list-style-type:none;padding:0;margin:0">
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="rightJT"></div>
<div class="outImgDiv">
<div class="inImgDiv3"></div>
<div style="text-align: center;font-size: 16px">
<div style="margin-bottom: 5px">
<span>设备状态:</span>
<span>在线</span>
</div>
<div style="font-size: 14px;visibility: hidden">
<ul id="agreementItem4" style="list-style-type:none;padding:0;margin:0">
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="row border-bottom white-bg dashboard-header">
<div style="border-bottom: darkgray 1px solid;">
<div style="width: 100px;height: 30px;background: darkgray;text-align: center;line-height: 30px;user-select: none;">网络</div>
</div>
<div class="wrapper wrapper-content" style="background-color: #f3f3f4">
<div class="row">
<div class="col-sm-3">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>IP地址</h5>
</div>
<div class="ibox-content">
<h1 id="H1IPAddress" class="no-margins"></h1>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>主机名</h5>
</div>
<div class="ibox-content">
<h1 id="H1HostName" class="no-margins"></h1>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>Mac地址</h5>
</div>
<div class="ibox-content">
<h1 id="H1MacAddress" class="no-margins"></h1>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>可用端口</h5>
</div>
<div class="ibox-content">
<h1 id="H1UsableLocalPort" class="no-margins"></h1>
</div>
</div>
</div>
</div>
<!-- <div class="row">-->
<!-- <div class="col-sm-3">-->
<!-- <div class="ibox float-e-margins">-->
<!-- <div class="ibox-title">-->
<!-- &lt;!&ndash; <span class="label label-success pull-right">全部</span>&ndash;&gt;-->
<!-- <h5>访客</h5>-->
<!-- </div>-->
<!-- <div class="ibox-content">-->
<!-- <h1 class="no-margins">0</h1>-->
<!-- &lt;!&ndash;<div class="stat-percent font-bold text-navy">44% <i class="fa fa-level-up"></i>-->
<!-- </div>&ndash;&gt;-->
<!-- &lt;!&ndash; <small>总访客</small>&ndash;&gt;-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="col-sm-3">-->
<!-- <div class="ibox float-e-margins">-->
<!-- <div class="ibox-title">-->
<!-- &lt;!&ndash; <span class="label label-success pull-right">全部</span>&ndash;&gt;-->
<!-- <h5>注册用户</h5>-->
<!-- </div>-->
<!-- <div class="ibox-content">-->
<!-- <h1 class="no-margins">0</h1>-->
<!-- &lt;!&ndash;<div class="stat-percent font-bold text-danger">38% <i class="fa fa-level-down"></i>-->
<!-- </div>&ndash;&gt;-->
<!-- &lt;!&ndash; <small>总注册用户</small>&ndash;&gt;-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="col-sm-3">-->
<!-- <div class="ibox float-e-margins">-->
<!-- <div class="ibox-title">-->
<!--&lt;!&ndash; <span class="label label-primary pull-right">实时</span>&ndash;&gt;-->
<!-- <h5>连接访客</h5>-->
<!-- </div>-->
<!-- <div class="ibox-content">-->
<!-- <h1 class="no-margins">0</h1>-->
<!-- &lt;!&ndash;<div class="stat-percent font-bold text-navy">44% <i class="fa fa-level-up"></i>-->
<!-- </div>&ndash;&gt;-->
<!--&lt;!&ndash; <small>连接中</small>&ndash;&gt;-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="col-sm-3">-->
<!-- <div class="ibox float-e-margins">-->
<!-- <div class="ibox-title">-->
<!--&lt;!&ndash; <span class="label label-primary pull-right">实时</span>&ndash;&gt;-->
<!-- <h5>连接用户</h5>-->
<!-- </div>-->
<!-- <div class="ibox-content">-->
<!-- <h1 class="no-margins">0</h1>-->
<!-- &lt;!&ndash;<div class="stat-percent font-bold text-danger">38% <i class="fa fa-level-down"></i>-->
<!-- </div>&ndash;&gt;-->
<!--&lt;!&ndash; <small>连接中</small>&ndash;&gt;-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
</div>
</div>
</div>
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
<script type="text/javascript">
$('#pay-qrcode').click(function(){
var html=$(this).html();
parent.layer.open({
title: false,
type: 1,
closeBtn:false,
shadeClose:true,
area: ['600px', '360px'],
content: html
});
});
<script th:inline="javascript">
$(document).ready(function (){
console.log(111)
$.ajax({
type:"GET",
url: "/main",
success: function (data){
console.log(data)
document.getElementById("ipAddress").innerHTML = data.hostInfo.address;
document.getElementById("H1IPAddress").innerHTML = data.hostInfo.address;
document.getElementById("H1HostName").innerHTML = data.hostInfo.name;
document.getElementById("H1UsableLocalPort").innerHTML = data.UsableLocalPort + "(个)";
document.getElementById("sysName").innerHTML = data.osInfo.name;
document.getElementById("macAddress").innerHTML = data.macAddress;
document.getElementById("H1MacAddress").innerHTML = data.macAddress;
document.getElementById("agreementType1").innerHTML = data.agreementTypeName;
document.getElementById("agreementType2").innerHTML = data.agreementTypeName;
const agreements = data.agreement;
agreements.forEach(item=>{
// 创建一个新的 li 元素
var li1 = document.createElement("li");
var li2 = document.createElement("li");
var li3 = document.createElement("li");
var li4 = document.createElement("li");
// 设置 li 元素的内容
li1.textContent = item;
li2.textContent = item;
li3.textContent = item;
li4.textContent = item;
// 获取要添加 li 元素的 ul 列表
var ul1 = document.getElementById("agreementItem1");
var ul2 = document.getElementById("agreementItem2");
var ul3 = document.getElementById("agreementItem3");
var ul4 = document.getElementById("agreementItem4");
// 将 li 元素添加到 ul 列表的末尾
ul1.appendChild(li1);
ul2.appendChild(li2);
ul3.appendChild(li3);
ul4.appendChild(li4);
})
}
})
})
</script>
</body>
</html>
<style>
.outImgDiv{
font-size: 10px;
display: inline-block;
width: 33%;
height: 400px;
}
.inImgDiv1{
background: url("../img/com1.png") repeat;
margin:0 auto;
width: 150px;
height: 120px;
}
.inImgDiv2{
background: url("../img/com2.png") repeat;
margin:0 auto;
width: 150px;
height: 120px;
}
.inImgDiv3{
background: url("../img/com3.png") repeat;
margin:0 auto;
width: 150px;
height: 120px;
}
.leftJT{
background: url("../img/jt.png") no-repeat center center;
background-size: cover;
position: absolute;
top: 180px;
left: 360px;
width: 400px;
height: 20px;
float: left;
z-index: 9999;
}
.rightJT{
background: url("../img/jt.png") no-repeat center center;
background-size: cover;
position: absolute;
top: 180px;
right: 360px;
width: 400px;
height: 20px;
float: left;
z-index: 9999;
}
</style>