From a8f6dcf8821f9dc33c53bf10008bd6a4924f9dec Mon Sep 17 00:00:00 2001
From: kerwincui <164770707@qq.com>
Date: Fri, 10 Jun 2022 15:10:58 +0800
Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=B7=BB=E5=8A=A0=E7=A7=9F?=
=?UTF-8?q?=E6=88=B7=E5=92=8C=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/ruoyi/iot/domain/DeviceLog.java | 47 +++++++++++++++++++
.../ThingsModels/ThingsModelValuesOutput.java | 46 ++++++++++++++++++
.../java/com/ruoyi/iot/mqtt/EmqxService.java | 4 ++
.../iot/service/impl/DeviceServiceImpl.java | 8 ++++
.../resources/mapper/iot/DeviceLogMapper.xml | 18 ++++++-
.../resources/mapper/iot/DeviceMapper.xml | 6 ++-
vue/src/views/iot/device/mqtt-client.vue | 10 ++--
vue/src/views/login.vue | 6 +--
8 files changed, 137 insertions(+), 8 deletions(-)
diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/DeviceLog.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/DeviceLog.java
index 83f9c7c8..c4653738 100644
--- a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/DeviceLog.java
+++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/DeviceLog.java
@@ -50,6 +50,53 @@ public class DeviceLog extends BaseEntity
@Excel(name = "是否监测数据", readConverterExp = "1==是,0=否")
private Integer isMonitor;
+ /** 用户ID */
+ @Excel(name = "用户ID")
+ private Long userId;
+
+ /** 用户昵称 */
+ @Excel(name = "用户昵称")
+ private String userName;
+
+ /** 租户ID */
+ @Excel(name = "租户ID")
+ private Long tenantId;
+
+ /** 租户名称 */
+ @Excel(name = "租户名称")
+ private String tenantName;
+
+ public Long getUserId() {
+ return userId;
+ }
+
+ public void setUserId(Long userId) {
+ this.userId = userId;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public Long getTenantId() {
+ return tenantId;
+ }
+
+ public void setTenantId(Long tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getTenantName() {
+ return tenantName;
+ }
+
+ public void setTenantName(String tenantName) {
+ this.tenantName = tenantName;
+ }
public Date getTs() {
return ts;
diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/model/ThingsModels/ThingsModelValuesOutput.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/model/ThingsModels/ThingsModelValuesOutput.java
index 474ad0b4..942acfce 100644
--- a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/model/ThingsModels/ThingsModelValuesOutput.java
+++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/model/ThingsModels/ThingsModelValuesOutput.java
@@ -1,5 +1,7 @@
package com.ruoyi.iot.model.ThingsModels;
+import com.ruoyi.common.annotation.Excel;
+
/**
* 设备输入物模型值参数
*
@@ -24,9 +26,53 @@ public class ThingsModelValuesOutput
/** 设备ID **/
private String serialNumber;
+ /** 用户ID */
+ private Long userId;
+
+ /** 用户昵称 */
+ private String userName;
+
+ /** 租户ID */
+ private Long tenantId;
+
+ /** 租户名称 */
+ private String tenantName;
+
/** 设备物模型值 **/
private String thingsModelValue;
+ public Long getUserId() {
+ return userId;
+ }
+
+ public void setUserId(Long userId) {
+ this.userId = userId;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public Long getTenantId() {
+ return tenantId;
+ }
+
+ public void setTenantId(Long tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getTenantName() {
+ return tenantName;
+ }
+
+ public void setTenantName(String tenantName) {
+ this.tenantName = tenantName;
+ }
+
public int getIsShadow() {
return isShadow;
}
diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mqtt/EmqxService.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mqtt/EmqxService.java
index f37f7c8f..a55947f7 100644
--- a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mqtt/EmqxService.java
+++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mqtt/EmqxService.java
@@ -199,6 +199,10 @@ public class EmqxService {
deviceLog.setIdentity(thingsModelValueRemarkItems.get(i).getId());
deviceLog.setLogType(3);
deviceLog.setIsMonitor(0);
+ deviceLog.setUserId(device.getUserId());
+ deviceLog.setUserName(device.getUserName());
+ deviceLog.setTenantId(device.getTenantId());
+ deviceLog.setTenantName(device.getTenantName());
logService.saveDeviceLog(deviceLog);
}
} catch (Exception e) {
diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/DeviceServiceImpl.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/DeviceServiceImpl.java
index 42a57b5f..7f615748 100644
--- a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/DeviceServiceImpl.java
+++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/DeviceServiceImpl.java
@@ -238,6 +238,10 @@ public class DeviceServiceImpl implements IDeviceService {
deviceLog.setCreateTime(DateUtils.getNowDate());
deviceLog.setIsMonitor(valueList.get(k).getIsMonitor());
deviceLog.setLogType(type);
+ deviceLog.setUserId(deviceThings.getUserId());
+ deviceLog.setUserName(deviceThings.getUserName());
+ deviceLog.setTenantId(deviceThings.getTenantId());
+ deviceLog.setTenantName(deviceThings.getTenantName());
logService.saveDeviceLog(deviceLog);
break;
}
@@ -722,6 +726,10 @@ public class DeviceServiceImpl implements IDeviceService {
deviceLog.setDeviceName(device.getDeviceName());
deviceLog.setSerialNumber(device.getSerialNumber());
deviceLog.setIsMonitor(0);
+ deviceLog.setUserId(device.getUserId());
+ deviceLog.setUserName(device.getUserName());
+ deviceLog.setTenantId(device.getTenantId());
+ deviceLog.setTenantName(device.getTenantName());
if(device.getStatus()==3){
deviceLog.setLogValue("1");
deviceLog.setRemark("设备上线");
diff --git a/springboot/wumei-iot/src/main/resources/mapper/iot/DeviceLogMapper.xml b/springboot/wumei-iot/src/main/resources/mapper/iot/DeviceLogMapper.xml
index b4f04749..7cea29bd 100644
--- a/springboot/wumei-iot/src/main/resources/mapper/iot/DeviceLogMapper.xml
+++ b/springboot/wumei-iot/src/main/resources/mapper/iot/DeviceLogMapper.xml
@@ -20,11 +20,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+
+
+
+
- select log_id, log_type, log_value, device_id, device_name,serial_number, identity, create_by, is_monitor, create_time, remark from iot_device_log
+ select log_id, log_type, log_value, device_id, device_name,serial_number, identity, create_by, is_monitor, user_id, user_name, tenant_id, tenant_name, create_time, remark from iot_device_log
diff --git a/vue/src/views/iot/device/mqtt-client.vue b/vue/src/views/iot/device/mqtt-client.vue
index 59be124e..e3101dc3 100644
--- a/vue/src/views/iot/device/mqtt-client.vue
+++ b/vue/src/views/iot/device/mqtt-client.vue
@@ -38,7 +38,7 @@ export default {
methods: {
/** 连接Mqtt */
connectMqtt(subscribeTopics) {
- let randomClientId='web-' + Math.random().toString(16).substr(2);
+ let randomClientId = 'web-' + Math.random().toString(16).substr(2);
let options = {
username: "wumei-smart",
password: getToken(),
@@ -53,7 +53,7 @@ export default {
console.log("mqtt地址:", url);
this.client = mqtt.connect(url, options);
this.client.on("connect", (e) => {
- console.log("客户端:"+randomClientId+",成功连接服务器:", e);
+ console.log("客户端:" + randomClientId + ",成功连接服务器:", e);
// 订阅主题
if (subscribeTopics != '' && subscribeTopics.length > 0) {
this.client.subscribe(subscribeTopics, {
@@ -89,7 +89,11 @@ export default {
if (!err) {
console.log('成功发布主题:' + topic)
console.log('主题内容:' + message);
- this.$modal.notifySuccess("[ " + name + " ] 指令发送成功");
+ if (topic.indexOf('offline') > 0) {
+ this.$modal.notify("[ " + name + " ] 影子指令发送成功");
+ } else {
+ this.$modal.notifySuccess("[ " + name + " ] 指令发送成功");
+ }
}
})
},
diff --git a/vue/src/views/login.vue b/vue/src/views/login.vue
index 1de40ecb..bfc894dc 100644
--- a/vue/src/views/login.vue
+++ b/vue/src/views/login.vue
@@ -41,17 +41,17 @@
演 示 账 号 |
- 管理员 |
+ 受限管理 |
wumei |
123456 |
- | 租户账号 |
+ 租户账号 |
wumei-t1 |
123456 |
- | 普通用户 |
+ 普通用户 |
wumei-u1 |
123456 |