diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMainController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMainController.java new file mode 100644 index 0000000..1558f40 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMainController.java @@ -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 getData() { + Map 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 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 sysDictData1 = dictDataService.selectDictDataList(dictData); + Map collect1 = sysDictData1.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel)); + agreements.add("协议族:" + collect1.get(gatewayAgreement.getSocketDomain())); + dictData.setDictType("socket_type"); + List sysDictData2 = dictDataService.selectDictDataList(dictData); + Map collect2 = sysDictData2.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel)); + agreements.add("套接字类型:" + collect2.get(gatewayAgreement.getSocketType())); + dictData.setDictType("socket_protocol"); + List sysDictData3 = dictDataService.selectDictDataList(dictData); + Map 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; + } +} diff --git a/ruoyi-admin/src/main/resources/static/img/jt.png b/ruoyi-admin/src/main/resources/static/img/jt.png new file mode 100644 index 0000000..0c2e4f6 Binary files /dev/null and b/ruoyi-admin/src/main/resources/static/img/jt.png differ diff --git a/ruoyi-admin/src/main/resources/templates/index-topnav.html b/ruoyi-admin/src/main/resources/templates/index-topnav.html index c38736e..b5c7fce 100644 --- a/ruoyi-admin/src/main/resources/templates/index-topnav.html +++ b/ruoyi-admin/src/main/resources/templates/index-topnav.html @@ -83,7 +83,7 @@ @@ -279,7 +279,7 @@