From 8bc8559586e33c9d82ad6293f50b114d0b185f71 Mon Sep 17 00:00:00 2001 From: xusd Date: Thu, 1 Aug 2024 14:41:13 +0800 Subject: [PATCH] =?UTF-8?q?MQTT=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E4=BF=A1=E6=81=AF=E3=80=81Topic=E9=85=8D=E7=BD=AE=20?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/GatewayMqttInfoController.java | 64 +++++++ .../GatewayMqttTopicController.java | 64 +++++++ .../internet/domain/GatewayMqttInfo.java | 33 ++++ .../internet/domain/GatewayMqttTopic.java | 107 ++++++++++++ .../mapper/GatewayMqttInfoMapper.java | 28 +++ .../mapper/GatewayMqttTopicMapper.java | 29 ++++ .../service/IGatewayMqttInfoService.java | 27 +++ .../service/IGatewayMqttTopicService.java | 29 ++++ .../impl/GatewayMqttInfoServiceImpl.java | 43 +++++ .../impl/GatewayMqttTopicServiceImpl.java | 45 +++++ .../mapper/internet/GatewayMqttInfoMapper.xml | 30 ++++ .../internet/GatewayMqttTopicMapper.xml | 37 ++++ .../templates/internet/mqtt/mqttInfo.html | 159 ++++++++++++++++++ 13 files changed, 695 insertions(+) create mode 100644 ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/controller/GatewayMqttInfoController.java create mode 100644 ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/controller/GatewayMqttTopicController.java create mode 100644 ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/domain/GatewayMqttInfo.java create mode 100644 ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/domain/GatewayMqttTopic.java create mode 100644 ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/mapper/GatewayMqttInfoMapper.java create mode 100644 ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/mapper/GatewayMqttTopicMapper.java create mode 100644 ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/service/IGatewayMqttInfoService.java create mode 100644 ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/service/IGatewayMqttTopicService.java create mode 100644 ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/service/impl/GatewayMqttInfoServiceImpl.java create mode 100644 ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/service/impl/GatewayMqttTopicServiceImpl.java create mode 100644 ruoyi-gateway/src/main/resources/mapper/internet/GatewayMqttInfoMapper.xml create mode 100644 ruoyi-gateway/src/main/resources/mapper/internet/GatewayMqttTopicMapper.xml create mode 100644 ruoyi-gateway/src/main/resources/templates/internet/mqtt/mqttInfo.html diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/controller/GatewayMqttInfoController.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/controller/GatewayMqttInfoController.java new file mode 100644 index 0000000..a000071 --- /dev/null +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/controller/GatewayMqttInfoController.java @@ -0,0 +1,64 @@ +package com.ruoyi.gateway.internet.controller; + +import com.ruoyi.gateway.internet.domain.GatewayMqttTopic; +import com.ruoyi.gateway.internet.service.IGatewayMqttTopicService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.gateway.internet.domain.GatewayMqttInfo; +import com.ruoyi.gateway.internet.service.IGatewayMqttInfoService; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; + +/** + * mqtt基础信息Controller + * + * @author ruoyi + * @date 2024-07-31 + */ +@Controller +@RequestMapping("/internet/mqttInfo") +public class GatewayMqttInfoController extends BaseController { + private String prefix = "internet/mqtt"; + + @Autowired + private IGatewayMqttInfoService gatewayMqttInfoService; + + @Autowired + private IGatewayMqttTopicService gatewayMqttTopicService; + + @RequiresPermissions("internet:mqttInfo:view") + @GetMapping() + public String mqttInfo(ModelMap mmap) { + GatewayMqttInfo gatewayMqttInfo = gatewayMqttInfoService.selectGatewayMqttInfo(); + mmap.put("gatewayMqttInfo", gatewayMqttInfo); + GatewayMqttTopic gatewayMqttTopic = gatewayMqttTopicService.selectGatewayMqttTopic(); + mmap.put("gatewayMqttTopic", gatewayMqttTopic); + return prefix + "/mqttInfo"; + } + + @RequiresPermissions("internet:mqttInfo:view") + @GetMapping("/detail") + @ResponseBody + public GatewayMqttInfo detail() { + return gatewayMqttInfoService.selectGatewayMqttInfo(); + } + + /** + * 修改保存mqtt基础信息 + */ + @RequiresPermissions("internet:mqttInfo:edit") + @Log(title = "mqtt基础信息", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(GatewayMqttInfo gatewayMqttInfo) { + return toAjax(gatewayMqttInfoService.updateGatewayMqttInfo(gatewayMqttInfo)); + } +} diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/controller/GatewayMqttTopicController.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/controller/GatewayMqttTopicController.java new file mode 100644 index 0000000..bb71581 --- /dev/null +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/controller/GatewayMqttTopicController.java @@ -0,0 +1,64 @@ +package com.ruoyi.gateway.internet.controller; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.gateway.internet.domain.GatewayMqttTopic; +import com.ruoyi.gateway.internet.service.IGatewayMqttTopicService; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * mqtt主题Controller + * + * @author ruoyi + * @date 2024-08-01 + */ +@Controller +@RequestMapping("/internet/topic") +public class GatewayMqttTopicController extends BaseController +{ + private String prefix = "internet/topic"; + + @Autowired + private IGatewayMqttTopicService gatewayMqttTopicService; + + @RequiresPermissions("internet:mqttInfo:view") + @GetMapping() + public String topic(ModelMap mmap) + { + GatewayMqttTopic gatewayMqttTopic = gatewayMqttTopicService.selectGatewayMqttTopic(); + mmap.put("gatewayMqttTopic", gatewayMqttTopic); + return prefix + "/topic"; + } + + @RequiresPermissions("internet:mqttInfo:view") + @GetMapping("/detail") + @ResponseBody + public GatewayMqttTopic detail() { + return gatewayMqttTopicService.selectGatewayMqttTopic(); + } + + /** + * 修改保存mqtt主题 + */ + @RequiresPermissions("internet:topic:edit") + @Log(title = "mqtt主题", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(GatewayMqttTopic gatewayMqttTopic) + { + return toAjax(gatewayMqttTopicService.updateGatewayMqttTopic(gatewayMqttTopic)); + } +} diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/domain/GatewayMqttInfo.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/domain/GatewayMqttInfo.java new file mode 100644 index 0000000..f3ed1d6 --- /dev/null +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/domain/GatewayMqttInfo.java @@ -0,0 +1,33 @@ +package com.ruoyi.gateway.internet.domain; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * mqtt基础信息对象 gateway_mqtt_info + * + * @author ruoyi + * @date 2024-07-31 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class GatewayMqttInfo extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** IP地址 */ + @Excel(name = "MQTT服务器地址") + private String address; + + /** 端口 */ + @Excel(name = "MQTT服务器接口") + private String port; + +} diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/domain/GatewayMqttTopic.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/domain/GatewayMqttTopic.java new file mode 100644 index 0000000..ecbbe1d --- /dev/null +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/domain/GatewayMqttTopic.java @@ -0,0 +1,107 @@ +package com.ruoyi.gateway.internet.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * mqtt主题对象 gateway_mqtt_topic + * + * @author ruoyi + * @date 2024-08-01 + */ +public class GatewayMqttTopic extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** Join Topic */ + @Excel(name = "Join Topic") + private String joinTopic; + + /** Uplink Topic */ + @Excel(name = "Uplink Topic") + private String uplinkTopic; + + /** Downlink Topic */ + @Excel(name = "Downlink Topic") + private String downlinkTopic; + + /** Ack Topic */ + @Excel(name = "Ack Topic") + private String ackTopic; + + /** Status Topic */ + @Excel(name = "Status Topic") + private String statusTopic; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setJoinTopic(String joinTopic) + { + this.joinTopic = joinTopic; + } + + public String getJoinTopic() + { + return joinTopic; + } + public void setUplinkTopic(String uplinkTopic) + { + this.uplinkTopic = uplinkTopic; + } + + public String getUplinkTopic() + { + return uplinkTopic; + } + public void setDownlinkTopic(String downlinkTopic) + { + this.downlinkTopic = downlinkTopic; + } + + public String getDownlinkTopic() + { + return downlinkTopic; + } + public void setAckTopic(String ackTopic) + { + this.ackTopic = ackTopic; + } + + public String getAckTopic() + { + return ackTopic; + } + public void setStatusTopic(String statusTopic) + { + this.statusTopic = statusTopic; + } + + public String getStatusTopic() + { + return statusTopic; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("joinTopic", getJoinTopic()) + .append("uplinkTopic", getUplinkTopic()) + .append("downlinkTopic", getDownlinkTopic()) + .append("ackTopic", getAckTopic()) + .append("statusTopic", getStatusTopic()) + .toString(); + } +} diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/mapper/GatewayMqttInfoMapper.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/mapper/GatewayMqttInfoMapper.java new file mode 100644 index 0000000..6aad831 --- /dev/null +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/mapper/GatewayMqttInfoMapper.java @@ -0,0 +1,28 @@ +package com.ruoyi.gateway.internet.mapper; + +import com.ruoyi.gateway.internet.domain.GatewayMqttInfo; + +/** + * mqtt基础信息Mapper接口 + * + * @author ruoyi + * @date 2024-07-31 + */ +public interface GatewayMqttInfoMapper +{ + /** + * 查询mqtt基础信息 + * + * @return mqtt基础信息 + */ + public GatewayMqttInfo selectGatewayMqttInfo(); + + /** + * 修改mqtt基础信息 + * + * @param gatewayMqttInfo mqtt基础信息 + * @return 结果 + */ + public int updateGatewayMqttInfo(GatewayMqttInfo gatewayMqttInfo); + +} diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/mapper/GatewayMqttTopicMapper.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/mapper/GatewayMqttTopicMapper.java new file mode 100644 index 0000000..1f50bdf --- /dev/null +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/mapper/GatewayMqttTopicMapper.java @@ -0,0 +1,29 @@ +package com.ruoyi.gateway.internet.mapper; + +import java.util.List; +import com.ruoyi.gateway.internet.domain.GatewayMqttTopic; + +/** + * mqtt主题Mapper接口 + * + * @author ruoyi + * @date 2024-08-01 + */ +public interface GatewayMqttTopicMapper +{ + /** + * 查询mqtt主题 + * + * @return mqtt主题 + */ + GatewayMqttTopic selectGatewayMqttTopic(); + + /** + * 修改mqtt主题 + * + * @param gatewayMqttTopic mqtt主题 + * @return 结果 + */ + int updateGatewayMqttTopic(GatewayMqttTopic gatewayMqttTopic); + +} diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/service/IGatewayMqttInfoService.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/service/IGatewayMqttInfoService.java new file mode 100644 index 0000000..b08af6c --- /dev/null +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/service/IGatewayMqttInfoService.java @@ -0,0 +1,27 @@ +package com.ruoyi.gateway.internet.service; + +import com.ruoyi.gateway.internet.domain.GatewayMqttInfo; + +/** + * mqtt基础信息Service接口 + * + * @author ruoyi + * @date 2024-07-31 + */ +public interface IGatewayMqttInfoService { + /** + * 查询mqtt基础信息 + * + * @return mqtt基础信息 + */ + public GatewayMqttInfo selectGatewayMqttInfo(); + + /** + * 修改mqtt基础信息 + * + * @param gatewayMqttInfo mqtt基础信息 + * @return 结果 + */ + public int updateGatewayMqttInfo(GatewayMqttInfo gatewayMqttInfo); + +} diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/service/IGatewayMqttTopicService.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/service/IGatewayMqttTopicService.java new file mode 100644 index 0000000..98c10e3 --- /dev/null +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/service/IGatewayMqttTopicService.java @@ -0,0 +1,29 @@ +package com.ruoyi.gateway.internet.service; + +import java.util.List; +import com.ruoyi.gateway.internet.domain.GatewayMqttTopic; + +/** + * mqtt主题Service接口 + * + * @author ruoyi + * @date 2024-08-01 + */ +public interface IGatewayMqttTopicService +{ + /** + * 查询mqtt主题 + * + * @return mqtt主题 + */ + GatewayMqttTopic selectGatewayMqttTopic(); + + /** + * 修改mqtt主题 + * + * @param gatewayMqttTopic mqtt主题 + * @return 结果 + */ + int updateGatewayMqttTopic(GatewayMqttTopic gatewayMqttTopic); + +} diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/service/impl/GatewayMqttInfoServiceImpl.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/service/impl/GatewayMqttInfoServiceImpl.java new file mode 100644 index 0000000..ef59d69 --- /dev/null +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/service/impl/GatewayMqttInfoServiceImpl.java @@ -0,0 +1,43 @@ +package com.ruoyi.gateway.internet.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.gateway.internet.mapper.GatewayMqttInfoMapper; +import com.ruoyi.gateway.internet.domain.GatewayMqttInfo; +import com.ruoyi.gateway.internet.service.IGatewayMqttInfoService; +/** + * mqtt基础信息Service业务层处理 + * + * @author ruoyi + * @date 2024-07-31 + */ +@Service +public class GatewayMqttInfoServiceImpl implements IGatewayMqttInfoService +{ + @Autowired + private GatewayMqttInfoMapper gatewayMqttInfoMapper; + + /** + * 查询mqtt基础信息 + * + * @return mqtt基础信息 + */ + @Override + public GatewayMqttInfo selectGatewayMqttInfo() + { + return gatewayMqttInfoMapper.selectGatewayMqttInfo(); + } + + /** + * 修改mqtt基础信息 + * + * @param gatewayMqttInfo mqtt基础信息 + * @return 结果 + */ + @Override + public int updateGatewayMqttInfo(GatewayMqttInfo gatewayMqttInfo) + { + return gatewayMqttInfoMapper.updateGatewayMqttInfo(gatewayMqttInfo); + } + +} diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/service/impl/GatewayMqttTopicServiceImpl.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/service/impl/GatewayMqttTopicServiceImpl.java new file mode 100644 index 0000000..b156e0e --- /dev/null +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/internet/service/impl/GatewayMqttTopicServiceImpl.java @@ -0,0 +1,45 @@ +package com.ruoyi.gateway.internet.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.gateway.internet.mapper.GatewayMqttTopicMapper; +import com.ruoyi.gateway.internet.domain.GatewayMqttTopic; +import com.ruoyi.gateway.internet.service.IGatewayMqttTopicService; +import com.ruoyi.common.core.text.Convert; + +/** + * mqtt主题Service业务层处理 + * + * @author ruoyi + * @date 2024-08-01 + */ +@Service("mqttTopicService") +public class GatewayMqttTopicServiceImpl implements IGatewayMqttTopicService +{ + @Autowired + private GatewayMqttTopicMapper gatewayMqttTopicMapper; + + /** + * 查询mqtt主题 + * + * @return mqtt主题 + */ + @Override + public GatewayMqttTopic selectGatewayMqttTopic() + { + return gatewayMqttTopicMapper.selectGatewayMqttTopic(); + } + + /** + * 修改mqtt主题 + * + * @param gatewayMqttTopic mqtt主题 + * @return 结果 + */ + @Override + public int updateGatewayMqttTopic(GatewayMqttTopic gatewayMqttTopic) + { + return gatewayMqttTopicMapper.updateGatewayMqttTopic(gatewayMqttTopic); + } +} diff --git a/ruoyi-gateway/src/main/resources/mapper/internet/GatewayMqttInfoMapper.xml b/ruoyi-gateway/src/main/resources/mapper/internet/GatewayMqttInfoMapper.xml new file mode 100644 index 0000000..cb8a3ca --- /dev/null +++ b/ruoyi-gateway/src/main/resources/mapper/internet/GatewayMqttInfoMapper.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + select id, address, port from gateway_mqtt_info + + + + + + update gateway_mqtt_info + + address = #{address}, + port = #{port}, + + + + \ No newline at end of file diff --git a/ruoyi-gateway/src/main/resources/mapper/internet/GatewayMqttTopicMapper.xml b/ruoyi-gateway/src/main/resources/mapper/internet/GatewayMqttTopicMapper.xml new file mode 100644 index 0000000..a554778 --- /dev/null +++ b/ruoyi-gateway/src/main/resources/mapper/internet/GatewayMqttTopicMapper.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + select id, join_topic, uplink_topic, downlink_topic, ack_topic, status_topic from gateway_mqtt_topic + + + + + + + update gateway_mqtt_topic + + join_topic = #{joinTopic}, + uplink_topic = #{uplinkTopic}, + downlink_topic = #{downlinkTopic}, + ack_topic = #{ackTopic}, + status_topic = #{statusTopic}, + + + + \ No newline at end of file diff --git a/ruoyi-gateway/src/main/resources/templates/internet/mqtt/mqttInfo.html b/ruoyi-gateway/src/main/resources/templates/internet/mqtt/mqttInfo.html new file mode 100644 index 0000000..39c0cbf --- /dev/null +++ b/ruoyi-gateway/src/main/resources/templates/internet/mqtt/mqttInfo.html @@ -0,0 +1,159 @@ + + + + + + +
+
基本设置
+
MQTT Topic Template Setup
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ 确定 +
+
+
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ 确定 +
+
+
+
+ + + + + \ No newline at end of file