From 76bdd043d832be924556132dab0ac85365db87d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E6=B2=90?= Date: Wed, 24 Jul 2024 11:46:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/mysql/module/maku-module-iot.sql | 164 +++++++++------------ .../main/java/net/maku/iot/mqtt/MqttGateway.java | 5 - .../DeviceCommandResponseMqttMessageHandler.java | 8 +- .../maku/iot/mqtt/service/DeviceMqttService.java | 2 +- .../vo/DeviceCommandResponseAttributeDataVO.java | 4 +- .../main/java/net/maku/iot/vo/DeviceCommandVO.java | 4 +- .../maku/iot/vo/DeviceReportAttributeDataVO.java | 4 +- .../src/main/java/net/maku/iot/vo/IotDeviceVO.java | 3 +- .../src/main/resources/mapper/iot/IotDeviceDao.xml | 21 --- .../resources/mapper/iot/IotDeviceEventLogDao.xml | 16 -- .../mapper/iot/IotDeviceServiceLogDao.xml | 16 -- 11 files changed, 84 insertions(+), 163 deletions(-) diff --git a/db/mysql/module/maku-module-iot.sql b/db/mysql/module/maku-module-iot.sql index cd3eb8c..7d307ed 100644 --- a/db/mysql/module/maku-module-iot.sql +++ b/db/mysql/module/maku-module-iot.sql @@ -1,111 +1,92 @@ -- 表结构 -CREATE TABLE `iot_device` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID', - `code` varchar(255) NOT NULL COMMENT '编码', - `name` varchar(255) NOT NULL COMMENT '名称', - `type` int NOT NULL COMMENT '设备类型,1.手持设备,2.柜体,3传感设备', - `uid` varchar(255) NOT NULL COMMENT '唯一标识码', - `secret` varchar(255) DEFAULT NULL COMMENT '设备密钥', - `app_version` varchar(255) DEFAULT NULL COMMENT 'App版本号', - `battery_percent` varchar(10) DEFAULT NULL COMMENT '电池电量百分比', - `temperature` varchar(10) DEFAULT NULL COMMENT '温度', - `status` tinyint NOT NULL DEFAULT '1' COMMENT '状态,0禁用,1启用', - `running_status` int NOT NULL DEFAULT '0' COMMENT '运行状态,0.离线状态 1.在线状态 2.正常待机 3.用户使用中 4.OTA升级中', - `up_time` datetime DEFAULT NULL COMMENT '上线时间', - `down_time` datetime DEFAULT NULL COMMENT '下线时间', - `tenant_id` bigint DEFAULT NULL COMMENT '租户ID', - `creator` bigint DEFAULT NULL COMMENT '创建者', - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `updater` bigint DEFAULT NULL COMMENT '更新者', - `update_time` datetime DEFAULT NULL COMMENT '更新时间', - `version` int DEFAULT NULL COMMENT '版本号', - `deleted` tinyint DEFAULT NULL COMMENT '删除标识 0:正常 1:已删除', - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='设备表'; +CREATE TABLE iot_device ( + id bigint NOT NULL AUTO_INCREMENT COMMENT 'ID', + code varchar(255) NOT NULL COMMENT '编码', + name varchar(255) NOT NULL COMMENT '名称', + type int NOT NULL COMMENT '设备类型,1.手持设备,2.柜体,3传感设备', + uid varchar(255) NOT NULL COMMENT '唯一标识码', + secret varchar(255) DEFAULT NULL COMMENT '设备密钥', + app_version varchar(255) DEFAULT NULL COMMENT 'App版本号', + battery_percent varchar(10) DEFAULT NULL COMMENT '电池电量百分比', + temperature varchar(10) DEFAULT NULL COMMENT '温度', + status tinyint NOT NULL DEFAULT '1' COMMENT '状态,0禁用,1启用', + running_status int NOT NULL DEFAULT '0' COMMENT '运行状态,0.离线状态 1.在线状态 2.正常待机 3.用户使用中 4.OTA升级中', + up_time datetime DEFAULT NULL COMMENT '上线时间', + down_time datetime DEFAULT NULL COMMENT '下线时间', + tenant_id bigint DEFAULT NULL COMMENT '租户ID', + creator bigint DEFAULT NULL COMMENT '创建者', + create_time datetime DEFAULT NULL COMMENT '创建时间', + updater bigint DEFAULT NULL COMMENT '更新者', + update_time datetime DEFAULT NULL COMMENT '更新时间', + version int DEFAULT NULL COMMENT '版本号', + deleted tinyint DEFAULT NULL COMMENT '删除标识 0:正常 1:已删除', + PRIMARY KEY (id) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT='设备表'; -CREATE TABLE `iot_device_event_log` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id', - `device_id` bigint NOT NULL COMMENT '设备id', - `event_type` tinyint NOT NULL COMMENT '事件类型', - `event_uid` varchar(50) DEFAULT NULL COMMENT '事件标识id', - `event_payload` varchar(1000) DEFAULT NULL COMMENT '事件数据', - `event_time` datetime DEFAULT NULL COMMENT '事件时间', - `tenant_id` bigint DEFAULT NULL COMMENT '租户ID', - `version` int DEFAULT NULL COMMENT '版本号', - `deleted` tinyint DEFAULT NULL COMMENT '删除标识 0:正常 1:已删除', - `creator` bigint DEFAULT NULL COMMENT '创建者', - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `updater` bigint DEFAULT NULL COMMENT '更新者', - `update_time` datetime DEFAULT NULL COMMENT '更新时间', - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='设备事件日志'; +CREATE TABLE iot_device_event_log ( + id bigint NOT NULL AUTO_INCREMENT COMMENT 'id', + device_id bigint NOT NULL COMMENT '设备id', + event_type tinyint NOT NULL COMMENT '事件类型', + event_uid varchar(50) DEFAULT NULL COMMENT '事件标识id', + event_payload varchar(1000) DEFAULT NULL COMMENT '事件数据', + event_time datetime DEFAULT NULL COMMENT '事件时间', + tenant_id bigint DEFAULT NULL COMMENT '租户ID', + version int DEFAULT NULL COMMENT '版本号', + deleted tinyint DEFAULT NULL COMMENT '删除标识 0:正常 1:已删除', + creator bigint DEFAULT NULL COMMENT '创建者', + create_time datetime DEFAULT NULL COMMENT '创建时间', + updater bigint DEFAULT NULL COMMENT '更新者', + update_time datetime DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (id) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT='设备事件日志'; -CREATE TABLE `iot_device_service_log` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id', - `device_id` bigint NOT NULL COMMENT '设备id', - `service_type` tinyint NOT NULL COMMENT '服务类型', - `service_uid` varchar(50) DEFAULT NULL COMMENT '服务标识id', - `service_payload` varchar(1000) DEFAULT NULL COMMENT '服务数据', - `service_time` datetime DEFAULT NULL COMMENT '服务时间', - `tenant_id` bigint DEFAULT NULL COMMENT '租户ID', - `version` int DEFAULT NULL COMMENT '版本号', - `deleted` tinyint DEFAULT NULL COMMENT '删除标识 0:正常 1:已删除', - `creator` bigint DEFAULT NULL COMMENT '创建者', - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `updater` bigint DEFAULT NULL COMMENT '更新者', - `update_time` datetime DEFAULT NULL COMMENT '更新时间', - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='设备服务日志'; +CREATE TABLE iot_device_service_log ( + id bigint NOT NULL AUTO_INCREMENT COMMENT 'id', + device_id bigint NOT NULL COMMENT '设备id', + service_type tinyint NOT NULL COMMENT '服务类型', + service_uid varchar(50) DEFAULT NULL COMMENT '服务标识id', + service_payload varchar(1000) DEFAULT NULL COMMENT '服务数据', + service_time datetime DEFAULT NULL COMMENT '服务时间', + tenant_id bigint DEFAULT NULL COMMENT '租户ID', + version int DEFAULT NULL COMMENT '版本号', + deleted tinyint DEFAULT NULL COMMENT '删除标识 0:正常 1:已删除', + creator bigint DEFAULT NULL COMMENT '创建者', + create_time datetime DEFAULT NULL COMMENT '创建时间', + updater bigint DEFAULT NULL COMMENT '更新者', + update_time datetime DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (id) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT='设备服务日志'; -- 菜单,权限 INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES ( NULL, '物联网平台', NULL, NULL, 0, 0, 'icon-printer-fill', 6, 0, 0, 10000,now(), 10000, now()); SET @pid = @@identity; - -INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) -VALUES ((SELECT @pid) , '设备列表', 'iot/device/index', NULL, 0, 0, 'icon-menu', 0, 0, 0, 10000, now(), 10000, now()); +INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @pid) , '设备列表', 'iot/device/index', NULL, 0, 0, 'icon-menu', 0, 0, 0, 10000, now(), 10000, now()); SET @menuId = @@identity; - -INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) -VALUES (@menuId, '查看', '', 'iot:device:page', 1, 0, '', 0, 0, 0, 10000, now(), 10000, now()); - -INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) -VALUES (@menuId, '新增', '', 'iot:device:save', 1, 0, '', 1, 0, 0, 10000, now(), 10000, now()); - -INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) -VALUES (@menuId, '修改', '', 'iot:device:update,iot:device:info', 1, 0, '', 2, 0, 0, 10000, now(), 10000, now()); - -INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) -VALUES (@menuId, '删除', '', 'iot:device:delete', 1, 0, '', 3, 0, 0, 10000, now(), 10000, now()); - -INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) -VALUES (@menuId, '下发指令', '', 'iot:device:send', 1, 0, '', 4, 0, 0, 10000, now(), 10000, now()); - -INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) -VALUES (@menuId, '上报数据', '', 'iot:device:report', 1, 0, '', 5, 0, 0, 10000, now(), 10000, now()); - -INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) -VALUES (@menuId, '设备事件日志', '', 'iot:device_event_log:page', 1, 0, '', 5, 0, 0, 10000, now(), 10000, now()); - -INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) -VALUES (@menuId, '设备服务日志', '', 'iot:device_service_log:page', 1, 0, '', 5, 0, 0, 10000, now(), 10000, now()); +INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES (@menuId, '查看', '', 'iot:device:page', 1, 0, '', 0, 0, 0, 10000, now(), 10000, now()); +INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES (@menuId, '新增', '', 'iot:device:save', 1, 0, '', 1, 0, 0, 10000, now(), 10000, now()); +INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES (@menuId, '修改', '', 'iot:device:update,iot:device:info', 1, 0, '', 2, 0, 0, 10000, now(), 10000, now()); +INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES (@menuId, '删除', '', 'iot:device:delete', 1, 0, '', 3, 0, 0, 10000, now(), 10000, now()); +INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES (@menuId, '下发指令', '', 'iot:device:send', 1, 0, '', 4, 0, 0, 10000, now(), 10000, now()); +INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES (@menuId, '上报数据', '', 'iot:device:report', 1, 0, '', 5, 0, 0, 10000, now(), 10000, now()); +INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES (@menuId, '设备事件日志', '', 'iot:device_event_log:page', 1, 0, '', 5, 0, 0, 10000, now(), 10000, now()); +INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES (@menuId, '设备服务日志', '', 'iot:device_service_log:page', 1, 0, '', 5, 0, 0, 10000, now(), 10000, now()); -- 字典数据 -INSERT INTO sys_dict_type (dict_type,dict_name,remark,sort,tenant_id,version,deleted,creator,create_time,updater,update_time )VALUE( 'device_type', '设备类型', '设备类型', 0, 10000, 0, 0, 10000, now(), 10000, now() ); +INSERT INTO sys_dict_type (dict_type,dict_name,remark,sort,tenant_id,version,deleted,creator,create_time,updater,update_time )VALUE('device_type', '设备类型', '设备类型', 0, 10000, 0, 0, 10000, now(), 10000, now() ); SET @typeId = @@identity; INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), '手持设备', '1', 'primary', '', 0, 10000, 0, 0, 10000, now(), 10000, now()); INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), '柜体', '2', 'primary', '', 1, 10000, 0, 0, 10000, now(), 10000, now()); INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), '传感设备', '3', 'primary', '', 2, 10000, 0, 0, 10000, now(), 10000, now()); -INSERT INTO sys_dict_type (dict_type,dict_name,remark,sort,tenant_id,version,deleted,creator,create_time,updater,update_time )VALUES( 'device_running_status', '设备运行状态', '设备运行状态:离线|在线|待机|使用中|OTA升级中', 0, 10000, 0, 0, 10000, now(), 10000, now() ); +INSERT INTO sys_dict_type (dict_type,dict_name,remark,sort,tenant_id,version,deleted,creator,create_time,updater,update_time )VALUES('device_running_status', '设备运行状态', '设备运行状态:离线|在线|待机|使用中|OTA升级中', 0, 10000, 0, 0, 10000, now(), 10000, now() ); SET @typeId = @@identity; INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), '离线状态', '0', 'danger', NULL, 0, 10000, 0, 0, 10000, now(), 10000, now()); INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), '在线状态', '1', 'success', NULL, 1, 10000, 0, 0, 10000, now(), 10000, now()); - -INSERT INTO sys_dict_type (dict_type,dict_name,remark,sort,tenant_id,version,deleted,creator,create_time,updater,update_time )VALUES( 'device_command', '设备指令', '设备服务具备的功能', 0, 10000, 0, 0, 10000, now(), 10000, now() ); +INSERT INTO sys_dict_type (dict_type,dict_name,remark,sort,tenant_id,version,deleted,creator,create_time,updater,update_time )VALUES('device_command', '设备指令', '设备服务具备的功能', 0, 10000, 0, 0, 10000, now(), 10000, now() ); SET @typeId = @@identity; INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), '远程锁定', 'LOCK', NULL, NULL, 0, NULL, 0, 0, 10000, now(), 10000, now()); INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), '远程解锁', 'UNLOCK', NULL, NULL, 1, NULL, 0, 0, 10000, now(), 10000, now()); @@ -113,14 +94,14 @@ INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, r INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), '登出', 'SIGN_OFF', NULL, NULL, 3, NULL, 0, 1, 10000, now(), 10000, now()); INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), 'OTA升级', 'OTA_UPGRADE', NULL, NULL, 4, NULL, 0, 0, 10000, now(), 10000, now()); -INSERT INTO sys_dict_type (dict_type,dict_name,remark,sort,tenant_id,version,deleted,creator,create_time,updater,update_time )VALUES( 'device_property', '设备属性', '设备通用属性:运行状态|APP版本|电池电量百分比|温度', 0, 10000, 0, 0, 10000, now(), 10000, now() ); +INSERT INTO sys_dict_type (dict_type,dict_name,remark,sort,tenant_id,version,deleted,creator,create_time,updater,update_time )VALUES('device_property', '设备属性', '设备通用属性:运行状态|APP版本|电池电量百分比|温度', 0, 10000, 0, 0, 10000, now(), 10000, now() ); SET @typeId = @@identity; INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), '运行状态', 'RUNNING_STATUS', NULL, NULL, 0, NULL, 0, 0, 10000, now(), 10000, now()); INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), 'APP版本', 'APP_VERSION', NULL, NULL, 1, NULL, 0, 0, 10000, now(), 10000, now()); INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), '电池电量百分比', 'BATTERY_PERCENT', NULL, NULL, 2, NULL, 0, 0, 10000, now(), 10000, now()); INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), '温度', 'TEMPERATURE', NULL, NULL, 3, NULL, 0, 0, 10000, now(), 10000, now()); -INSERT INTO sys_dict_type (dict_type,dict_name,remark,sort,tenant_id,version,deleted,creator,create_time,updater,update_time )VALUES( 'device_event_type', '事件类型', '事件日志类型', 0, 10000, 0, 0, 10000, now(), 10000, now() ); +INSERT INTO sys_dict_type (dict_type,dict_name,remark,sort,tenant_id,version,deleted,creator,create_time,updater,update_time )VALUES('device_event_type', '事件类型', '事件日志类型', 0, 10000, 0, 0, 10000, now(), 10000, now() ); SET @typeId = @@identity; INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), '下线', 'OFFLINE', 'danger', NULL, 1, NULL, 0, 0, 10000, now(), 10000, now()); INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), '上线', 'ONLINE', 'primary', NULL, 2, NULL, 0, 0, 10000, now(), 10000, now()); @@ -132,10 +113,3 @@ INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, r INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), 'APP版本信息', 'APP_VERSION_REPORT', 'primary', NULL, 8, NULL, 0, 0, 10000, now(), 10000, now()); INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), '电池电量', 'BATTERY_PERCENT_REPORT', 'primary', NULL, 9, NULL, 0, 0, 10000, now(), 10000, now()); INSERT INTO sys_dict_data (dict_type_id, dict_label, dict_value, label_class, remark, sort, tenant_id, version, deleted, creator, create_time, updater, update_time) VALUES ((SELECT @typeId), '温度', 'TEMPERATURE_REPORT', 'primary', NULL, 0, NULL, 10, 0, 10000, now(), 10000, now()); - - - - - - - diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/mqtt/MqttGateway.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/mqtt/MqttGateway.java index a3114a1..e614f10 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/mqtt/MqttGateway.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/mqtt/MqttGateway.java @@ -16,26 +16,21 @@ import org.springframework.stereotype.Component; @Component @MessagingGateway(defaultRequestChannel = MqttConfig.OUTBOUND_CHANNEL) public class MqttGateway { - @Autowired private MqttConfig mqttConfig; - public void sendToMqtt(String payload) { mqttConfig.mqttOutboundHandler().handleMessage(MessageBuilder.withPayload(payload).build()); } - public void sendToMqtt(@Header(MqttHeaders.TOPIC) String topic, String payload) { mqttConfig.mqttOutboundHandler().handleMessage(MessageBuilder.withPayload(payload).setHeader(MqttHeaders.TOPIC, topic).build()); } - public void sendToMqtt(@Header(MqttHeaders.TOPIC) String topic, @Header(MqttHeaders.QOS) int qos, String payload) { mqttConfig.mqttOutboundHandler().handleMessage(MessageBuilder.withPayload(payload).setHeader(MqttHeaders.TOPIC, topic).setHeader(MqttHeaders.QOS, qos).build()); } - public void sendToMqtt(@Header(MqttHeaders.TOPIC) String topic, @Header(MqttHeaders.RETAINED) boolean retained, String payload) { mqttConfig.mqttOutboundHandler().handleMessage(MessageBuilder.withPayload(payload).setHeader(MqttHeaders.TOPIC, topic).setHeader(MqttHeaders.RETAINED, retained).build()); } diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/mqtt/handler/DeviceCommandResponseMqttMessageHandler.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/mqtt/handler/DeviceCommandResponseMqttMessageHandler.java index 775f84a..551a16b 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/mqtt/handler/DeviceCommandResponseMqttMessageHandler.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/mqtt/handler/DeviceCommandResponseMqttMessageHandler.java @@ -33,13 +33,13 @@ public class DeviceCommandResponseMqttMessageHandler implements MqttMessageHandl @Override public void handle(String topic, String message) { - DeviceCommandResponseDTO commanddResponseDTO = parseCommandReplyMessage(topic, message); - Optional.ofNullable(commanddResponseDTO.getCommand()) + DeviceCommandResponseDTO commandResponseDTO = parseCommandReplyMessage(topic, message); + Optional.ofNullable(commandResponseDTO.getCommand()) .orElseThrow(() -> new IllegalArgumentException(StrUtil.format("缺失指令类型! 主题:'{}',消息:{}", topic, message))); - Optional.ofNullable(commanddResponseDTO.getCommandId()) + Optional.ofNullable(commandResponseDTO.getCommandId()) .orElseThrow(() -> new IllegalArgumentException(StrUtil.format("缺失指令ID! 主题:'{}',消息:{}", topic, message))); - Optional.ofNullable(commanddResponseDTO) + Optional.ofNullable(commandResponseDTO) .ifPresent(responseDTO -> { // 调用设备命令执行器的命令响应处理逻辑 try { diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/mqtt/service/DeviceMqttService.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/mqtt/service/DeviceMqttService.java index e6f1973..83fc855 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/mqtt/service/DeviceMqttService.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/mqtt/service/DeviceMqttService.java @@ -34,7 +34,7 @@ public class DeviceMqttService { /** * 命令等待exchanger缓存,key: command id */ - private ConcurrentMap> commandExchangers = new ConcurrentHashMap<>(); + private final ConcurrentMap> commandExchangers = new ConcurrentHashMap<>(); /** * 异步发送命令,返回命令id diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/vo/DeviceCommandResponseAttributeDataVO.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/vo/DeviceCommandResponseAttributeDataVO.java index c5a5e2d..07cbf05 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/vo/DeviceCommandResponseAttributeDataVO.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/vo/DeviceCommandResponseAttributeDataVO.java @@ -5,6 +5,8 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import net.maku.iot.enums.DeviceCommandEnum; +import java.io.Serializable; + /** * 设备命令响应数据 * @@ -13,7 +15,7 @@ import net.maku.iot.enums.DeviceCommandEnum; @Data @Schema(description = "设备命令响应VO") @JsonIgnoreProperties(ignoreUnknown = true) -public class DeviceCommandResponseAttributeDataVO { +public class DeviceCommandResponseAttributeDataVO implements Serializable { private static final long serialVersionUID = 1L; @Schema(description = "设备ID") diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/vo/DeviceCommandVO.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/vo/DeviceCommandVO.java index cf27081..5de8e8a 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/vo/DeviceCommandVO.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/vo/DeviceCommandVO.java @@ -3,6 +3,8 @@ package net.maku.iot.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.io.Serializable; + /** * 设备指令 * @@ -10,7 +12,7 @@ import lombok.Data; */ @Data @Schema(description = "设备指令VO") -public class DeviceCommandVO { +public class DeviceCommandVO implements Serializable { private static final long serialVersionUID = 1L; @Schema(description = "设备ID") diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/vo/DeviceReportAttributeDataVO.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/vo/DeviceReportAttributeDataVO.java index 19ed341..58eb41c 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/vo/DeviceReportAttributeDataVO.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/vo/DeviceReportAttributeDataVO.java @@ -3,6 +3,8 @@ package net.maku.iot.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.io.Serializable; + /** * 设备上报属性数据 * @@ -10,7 +12,7 @@ import lombok.Data; */ @Data @Schema(description = "设备上报属性数据VO") -public class DeviceReportAttributeDataVO { +public class DeviceReportAttributeDataVO implements Serializable { private static final long serialVersionUID = 1L; @Schema(description = "设备ID") diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/vo/IotDeviceVO.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/vo/IotDeviceVO.java index 7e71b6e..80d60a4 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/vo/IotDeviceVO.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/vo/IotDeviceVO.java @@ -75,6 +75,5 @@ public class IotDeviceVO implements Serializable { @Schema(description = "更新时间") @JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN) private LocalDateTime updateTime; - - + } \ No newline at end of file diff --git a/maku-boot-module/maku-module-iot/src/main/resources/mapper/iot/IotDeviceDao.xml b/maku-boot-module/maku-module-iot/src/main/resources/mapper/iot/IotDeviceDao.xml index 6ca09fc..c6daa5a 100644 --- a/maku-boot-module/maku-module-iot/src/main/resources/mapper/iot/IotDeviceDao.xml +++ b/maku-boot-module/maku-module-iot/src/main/resources/mapper/iot/IotDeviceDao.xml @@ -3,25 +3,4 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/maku-boot-module/maku-module-iot/src/main/resources/mapper/iot/IotDeviceEventLogDao.xml b/maku-boot-module/maku-module-iot/src/main/resources/mapper/iot/IotDeviceEventLogDao.xml index ab0706f..f355fd9 100644 --- a/maku-boot-module/maku-module-iot/src/main/resources/mapper/iot/IotDeviceEventLogDao.xml +++ b/maku-boot-module/maku-module-iot/src/main/resources/mapper/iot/IotDeviceEventLogDao.xml @@ -3,20 +3,4 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/maku-boot-module/maku-module-iot/src/main/resources/mapper/iot/IotDeviceServiceLogDao.xml b/maku-boot-module/maku-module-iot/src/main/resources/mapper/iot/IotDeviceServiceLogDao.xml index 00a7a62..bffaf55 100644 --- a/maku-boot-module/maku-module-iot/src/main/resources/mapper/iot/IotDeviceServiceLogDao.xml +++ b/maku-boot-module/maku-module-iot/src/main/resources/mapper/iot/IotDeviceServiceLogDao.xml @@ -3,20 +3,4 @@ - - - - - - - - - - - - - - - - \ No newline at end of file