This commit is contained in:
parent
cff74f78e6
commit
76bdd043d8
|
|
@ -1,96 +1,78 @@
|
||||||
-- 表结构
|
-- 表结构
|
||||||
CREATE TABLE `iot_device` (
|
CREATE TABLE iot_device (
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
id bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||||
`code` varchar(255) NOT NULL COMMENT '编码',
|
code varchar(255) NOT NULL COMMENT '编码',
|
||||||
`name` varchar(255) NOT NULL COMMENT '名称',
|
name varchar(255) NOT NULL COMMENT '名称',
|
||||||
`type` int NOT NULL COMMENT '设备类型,1.手持设备,2.柜体,3传感设备',
|
type int NOT NULL COMMENT '设备类型,1.手持设备,2.柜体,3传感设备',
|
||||||
`uid` varchar(255) NOT NULL COMMENT '唯一标识码',
|
uid varchar(255) NOT NULL COMMENT '唯一标识码',
|
||||||
`secret` varchar(255) DEFAULT NULL COMMENT '设备密钥',
|
secret varchar(255) DEFAULT NULL COMMENT '设备密钥',
|
||||||
`app_version` varchar(255) DEFAULT NULL COMMENT 'App版本号',
|
app_version varchar(255) DEFAULT NULL COMMENT 'App版本号',
|
||||||
`battery_percent` varchar(10) DEFAULT NULL COMMENT '电池电量百分比',
|
battery_percent varchar(10) DEFAULT NULL COMMENT '电池电量百分比',
|
||||||
`temperature` varchar(10) DEFAULT NULL COMMENT '温度',
|
temperature varchar(10) DEFAULT NULL COMMENT '温度',
|
||||||
`status` tinyint NOT NULL DEFAULT '1' COMMENT '状态,0禁用,1启用',
|
status tinyint NOT NULL DEFAULT '1' COMMENT '状态,0禁用,1启用',
|
||||||
`running_status` int NOT NULL DEFAULT '0' COMMENT '运行状态,0.离线状态 1.在线状态 2.正常待机 3.用户使用中 4.OTA升级中',
|
running_status int NOT NULL DEFAULT '0' COMMENT '运行状态,0.离线状态 1.在线状态 2.正常待机 3.用户使用中 4.OTA升级中',
|
||||||
`up_time` datetime DEFAULT NULL COMMENT '上线时间',
|
up_time datetime DEFAULT NULL COMMENT '上线时间',
|
||||||
`down_time` datetime DEFAULT NULL COMMENT '下线时间',
|
down_time datetime DEFAULT NULL COMMENT '下线时间',
|
||||||
`tenant_id` bigint DEFAULT NULL COMMENT '租户ID',
|
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
|
||||||
`creator` bigint DEFAULT NULL COMMENT '创建者',
|
creator bigint DEFAULT NULL COMMENT '创建者',
|
||||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
create_time datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
`updater` bigint DEFAULT NULL COMMENT '更新者',
|
updater bigint DEFAULT NULL COMMENT '更新者',
|
||||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
update_time datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
`version` int DEFAULT NULL COMMENT '版本号',
|
version int DEFAULT NULL COMMENT '版本号',
|
||||||
`deleted` tinyint DEFAULT NULL COMMENT '删除标识 0:正常 1:已删除',
|
deleted tinyint DEFAULT NULL COMMENT '删除标识 0:正常 1:已删除',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (id)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='设备表';
|
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT='设备表';
|
||||||
|
|
||||||
CREATE TABLE `iot_device_event_log` (
|
CREATE TABLE iot_device_event_log (
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
|
id bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||||
`device_id` bigint NOT NULL COMMENT '设备id',
|
device_id bigint NOT NULL COMMENT '设备id',
|
||||||
`event_type` tinyint NOT NULL COMMENT '事件类型',
|
event_type tinyint NOT NULL COMMENT '事件类型',
|
||||||
`event_uid` varchar(50) DEFAULT NULL COMMENT '事件标识id',
|
event_uid varchar(50) DEFAULT NULL COMMENT '事件标识id',
|
||||||
`event_payload` varchar(1000) DEFAULT NULL COMMENT '事件数据',
|
event_payload varchar(1000) DEFAULT NULL COMMENT '事件数据',
|
||||||
`event_time` datetime DEFAULT NULL COMMENT '事件时间',
|
event_time datetime DEFAULT NULL COMMENT '事件时间',
|
||||||
`tenant_id` bigint DEFAULT NULL COMMENT '租户ID',
|
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
|
||||||
`version` int DEFAULT NULL COMMENT '版本号',
|
version int DEFAULT NULL COMMENT '版本号',
|
||||||
`deleted` tinyint DEFAULT NULL COMMENT '删除标识 0:正常 1:已删除',
|
deleted tinyint DEFAULT NULL COMMENT '删除标识 0:正常 1:已删除',
|
||||||
`creator` bigint DEFAULT NULL COMMENT '创建者',
|
creator bigint DEFAULT NULL COMMENT '创建者',
|
||||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
create_time datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
`updater` bigint DEFAULT NULL COMMENT '更新者',
|
updater bigint DEFAULT NULL COMMENT '更新者',
|
||||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
update_time datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (id)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='设备事件日志';
|
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT='设备事件日志';
|
||||||
|
|
||||||
CREATE TABLE `iot_device_service_log` (
|
CREATE TABLE iot_device_service_log (
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
|
id bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||||
`device_id` bigint NOT NULL COMMENT '设备id',
|
device_id bigint NOT NULL COMMENT '设备id',
|
||||||
`service_type` tinyint NOT NULL COMMENT '服务类型',
|
service_type tinyint NOT NULL COMMENT '服务类型',
|
||||||
`service_uid` varchar(50) DEFAULT NULL COMMENT '服务标识id',
|
service_uid varchar(50) DEFAULT NULL COMMENT '服务标识id',
|
||||||
`service_payload` varchar(1000) DEFAULT NULL COMMENT '服务数据',
|
service_payload varchar(1000) DEFAULT NULL COMMENT '服务数据',
|
||||||
`service_time` datetime DEFAULT NULL COMMENT '服务时间',
|
service_time datetime DEFAULT NULL COMMENT '服务时间',
|
||||||
`tenant_id` bigint DEFAULT NULL COMMENT '租户ID',
|
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
|
||||||
`version` int DEFAULT NULL COMMENT '版本号',
|
version int DEFAULT NULL COMMENT '版本号',
|
||||||
`deleted` tinyint DEFAULT NULL COMMENT '删除标识 0:正常 1:已删除',
|
deleted tinyint DEFAULT NULL COMMENT '删除标识 0:正常 1:已删除',
|
||||||
`creator` bigint DEFAULT NULL COMMENT '创建者',
|
creator bigint DEFAULT NULL COMMENT '创建者',
|
||||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
create_time datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
`updater` bigint DEFAULT NULL COMMENT '更新者',
|
updater bigint DEFAULT NULL COMMENT '更新者',
|
||||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
update_time datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (id)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='设备服务日志';
|
) 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());
|
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;
|
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;
|
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)
|
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());
|
||||||
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: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)
|
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());
|
||||||
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: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)
|
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());
|
||||||
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() );
|
||||||
|
|
@ -104,7 +86,6 @@ 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), '离线状态', '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_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;
|
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), '远程锁定', 'LOCK', NULL, NULL, 0, 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), '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), '电池电量', '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());
|
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());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,26 +16,21 @@ import org.springframework.stereotype.Component;
|
||||||
@Component
|
@Component
|
||||||
@MessagingGateway(defaultRequestChannel = MqttConfig.OUTBOUND_CHANNEL)
|
@MessagingGateway(defaultRequestChannel = MqttConfig.OUTBOUND_CHANNEL)
|
||||||
public class MqttGateway {
|
public class MqttGateway {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MqttConfig mqttConfig;
|
private MqttConfig mqttConfig;
|
||||||
|
|
||||||
|
|
||||||
public void sendToMqtt(String payload) {
|
public void sendToMqtt(String payload) {
|
||||||
mqttConfig.mqttOutboundHandler().handleMessage(MessageBuilder.withPayload(payload).build());
|
mqttConfig.mqttOutboundHandler().handleMessage(MessageBuilder.withPayload(payload).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void sendToMqtt(@Header(MqttHeaders.TOPIC) String topic, String payload) {
|
public void sendToMqtt(@Header(MqttHeaders.TOPIC) String topic, String payload) {
|
||||||
mqttConfig.mqttOutboundHandler().handleMessage(MessageBuilder.withPayload(payload).setHeader(MqttHeaders.TOPIC, topic).build());
|
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) {
|
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());
|
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) {
|
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());
|
mqttConfig.mqttOutboundHandler().handleMessage(MessageBuilder.withPayload(payload).setHeader(MqttHeaders.TOPIC, topic).setHeader(MqttHeaders.RETAINED, retained).build());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,13 @@ public class DeviceCommandResponseMqttMessageHandler implements MqttMessageHandl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(String topic, String message) {
|
public void handle(String topic, String message) {
|
||||||
DeviceCommandResponseDTO commanddResponseDTO = parseCommandReplyMessage(topic, message);
|
DeviceCommandResponseDTO commandResponseDTO = parseCommandReplyMessage(topic, message);
|
||||||
Optional.ofNullable(commanddResponseDTO.getCommand())
|
Optional.ofNullable(commandResponseDTO.getCommand())
|
||||||
.orElseThrow(() -> new IllegalArgumentException(StrUtil.format("缺失指令类型! 主题:'{}',消息:{}", topic, message)));
|
.orElseThrow(() -> new IllegalArgumentException(StrUtil.format("缺失指令类型! 主题:'{}',消息:{}", topic, message)));
|
||||||
Optional.ofNullable(commanddResponseDTO.getCommandId())
|
Optional.ofNullable(commandResponseDTO.getCommandId())
|
||||||
.orElseThrow(() -> new IllegalArgumentException(StrUtil.format("缺失指令ID! 主题:'{}',消息:{}", topic, message)));
|
.orElseThrow(() -> new IllegalArgumentException(StrUtil.format("缺失指令ID! 主题:'{}',消息:{}", topic, message)));
|
||||||
|
|
||||||
Optional.ofNullable(commanddResponseDTO)
|
Optional.ofNullable(commandResponseDTO)
|
||||||
.ifPresent(responseDTO -> {
|
.ifPresent(responseDTO -> {
|
||||||
// 调用设备命令执行器的命令响应处理逻辑
|
// 调用设备命令执行器的命令响应处理逻辑
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ public class DeviceMqttService {
|
||||||
/**
|
/**
|
||||||
* 命令等待exchanger缓存,key: command id
|
* 命令等待exchanger缓存,key: command id
|
||||||
*/
|
*/
|
||||||
private ConcurrentMap<String, Exchanger<Object>> commandExchangers = new ConcurrentHashMap<>();
|
private final ConcurrentMap<String, Exchanger<Object>> commandExchangers = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 异步发送命令,返回命令id
|
* 异步发送命令,返回命令id
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.maku.iot.enums.DeviceCommandEnum;
|
import net.maku.iot.enums.DeviceCommandEnum;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备命令响应数据
|
* 设备命令响应数据
|
||||||
*
|
*
|
||||||
|
|
@ -13,7 +15,7 @@ import net.maku.iot.enums.DeviceCommandEnum;
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "设备命令响应VO")
|
@Schema(description = "设备命令响应VO")
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class DeviceCommandResponseAttributeDataVO {
|
public class DeviceCommandResponseAttributeDataVO implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Schema(description = "设备ID")
|
@Schema(description = "设备ID")
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ package net.maku.iot.vo;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备指令
|
* 设备指令
|
||||||
*
|
*
|
||||||
|
|
@ -10,7 +12,7 @@ import lombok.Data;
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "设备指令VO")
|
@Schema(description = "设备指令VO")
|
||||||
public class DeviceCommandVO {
|
public class DeviceCommandVO implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Schema(description = "设备ID")
|
@Schema(description = "设备ID")
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ package net.maku.iot.vo;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备上报属性数据
|
* 设备上报属性数据
|
||||||
*
|
*
|
||||||
|
|
@ -10,7 +12,7 @@ import lombok.Data;
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "设备上报属性数据VO")
|
@Schema(description = "设备上报属性数据VO")
|
||||||
public class DeviceReportAttributeDataVO {
|
public class DeviceReportAttributeDataVO implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Schema(description = "设备ID")
|
@Schema(description = "设备ID")
|
||||||
|
|
|
||||||
|
|
@ -76,5 +76,4 @@ public class IotDeviceVO implements Serializable {
|
||||||
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
|
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -3,25 +3,4 @@
|
||||||
|
|
||||||
<mapper namespace="net.maku.iot.dao.IotDeviceDao">
|
<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>
|
</mapper>
|
||||||
|
|
@ -3,20 +3,4 @@
|
||||||
|
|
||||||
<mapper namespace="net.maku.iot.dao.IotDeviceEventLogDao">
|
<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>
|
</mapper>
|
||||||
|
|
@ -3,20 +3,4 @@
|
||||||
|
|
||||||
<mapper namespace="net.maku.iot.dao.IotDeviceServiceLogDao">
|
<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>
|
</mapper>
|
||||||
Loading…
Reference in New Issue
Block a user