This commit is contained in:
阿沐 2024-07-24 11:46:27 +08:00
parent cff74f78e6
commit 76bdd043d8
11 changed files with 84 additions and 163 deletions

View File

@ -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());

View File

@ -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());
}

View File

@ -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 {

View File

@ -34,7 +34,7 @@ public class DeviceMqttService {
/**
* 命令等待exchanger缓存key: command id
*/
private ConcurrentMap<String, Exchanger<Object>> commandExchangers = new ConcurrentHashMap<>();
private final ConcurrentMap<String, Exchanger<Object>> commandExchangers = new ConcurrentHashMap<>();
/**
* 异步发送命令返回命令id

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -75,6 +75,5 @@ public class IotDeviceVO implements Serializable {
@Schema(description = "更新时间")
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
private LocalDateTime updateTime;
}

View File

@ -3,25 +3,4 @@
<mapper namespace="net.maku.iot.dao.IotDeviceDao">
<resultMap type="net.maku.iot.entity.IotDeviceEntity" id="iotDeviceMap">
<result property="id" column="id"/>
<result property="code" column="code"/>
<result property="name" column="name"/>
<result property="type" column="type"/>
<result property="uid" column="uid"/>
<result property="secret" column="secret"/>
<result property="appVersion" column="app_version"/>
<result property="batteryPercent" column="battery_percent"/>
<result property="temperature" column="temperature"/>
<result property="status" column="status"/>
<result property="runningStatus" column="running_status"/>
<result property="upTime" column="up_time"/>
<result property="downTime" column="down_time"/>
<result property="tenantId" column="tenant_id"/>
<result property="creator" column="creator"/>
<result property="createTime" column="create_time"/>
<result property="updater" column="updater"/>
<result property="updateTime" column="update_time"/>
</resultMap>
</mapper>

View File

@ -3,20 +3,4 @@
<mapper namespace="net.maku.iot.dao.IotDeviceEventLogDao">
<resultMap type="net.maku.iot.entity.IotDeviceEventLogEntity" id="iotDeviceEventLogMap">
<result property="id" column="id"/>
<result property="deviceId" column="device_id"/>
<result property="eventType" column="event_type"/>
<result property="eventUid" column="event_uid"/>
<result property="eventPayload" column="event_payload"/>
<result property="eventTime" column="event_time"/>
<result property="tenantId" column="tenant_id"/>
<result property="version" column="version"/>
<result property="deleted" column="deleted"/>
<result property="creator" column="creator"/>
<result property="createTime" column="create_time"/>
<result property="updater" column="updater"/>
<result property="updateTime" column="update_time"/>
</resultMap>
</mapper>

View File

@ -3,20 +3,4 @@
<mapper namespace="net.maku.iot.dao.IotDeviceServiceLogDao">
<resultMap type="net.maku.iot.entity.IotDeviceServiceLogEntity" id="iotDeviceServiceLogMap">
<result property="id" column="id"/>
<result property="deviceId" column="device_id"/>
<result property="serviceType" column="service_type"/>
<result property="serviceUid" column="service_uid"/>
<result property="servicePayload" column="service_payload"/>
<result property="serviceTime" column="service_time"/>
<result property="tenantId" column="tenant_id"/>
<result property="version" column="version"/>
<result property="deleted" column="deleted"/>
<result property="creator" column="creator"/>
<result property="createTime" column="create_time"/>
<result property="updater" column="updater"/>
<result property="updateTime" column="update_time"/>
</resultMap>
</mapper>