物联网问题解决,只差最后测试完善
This commit is contained in:
51
tradeCattle/add_iot_device_table_simple.sql
Normal file
51
tradeCattle/add_iot_device_table_simple.sql
Normal file
@@ -0,0 +1,51 @@
|
||||
-- 简化版IoT设备数据表结构
|
||||
-- 适用于各种MySQL版本
|
||||
|
||||
-- 删除表(如果存在)
|
||||
DROP TABLE IF EXISTS `iot_sync_log`;
|
||||
DROP TABLE IF EXISTS `iot_device_data`;
|
||||
|
||||
-- 创建IoT设备数据表
|
||||
CREATE TABLE `iot_device_data` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`device_id` varchar(50) NOT NULL,
|
||||
`device_type` int(11) NOT NULL,
|
||||
`device_name` varchar(50) NOT NULL,
|
||||
`voltage` decimal(5,3) DEFAULT NULL,
|
||||
`battery_percentage` int(11) DEFAULT NULL,
|
||||
`temperature` decimal(5,2) DEFAULT NULL,
|
||||
`steps` bigint(20) DEFAULT NULL,
|
||||
`signal_strength` varchar(20) DEFAULT NULL,
|
||||
`rsrp` varchar(20) DEFAULT NULL,
|
||||
`gps_state` varchar(20) DEFAULT NULL,
|
||||
`latitude` varchar(20) DEFAULT NULL,
|
||||
`longitude` varchar(20) DEFAULT NULL,
|
||||
`altitude` varchar(20) DEFAULT NULL,
|
||||
`same_day_steps` int(11) DEFAULT NULL,
|
||||
`status` int(11) DEFAULT NULL,
|
||||
`version` varchar(20) DEFAULT NULL,
|
||||
`uptime` datetime DEFAULT NULL,
|
||||
`organ_id` varchar(20) DEFAULT NULL,
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_device_id` (`device_id`),
|
||||
KEY `idx_device_type` (`device_type`),
|
||||
KEY `idx_organ_id` (`organ_id`),
|
||||
KEY `idx_uptime` (`uptime`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- 创建数据同步日志表
|
||||
CREATE TABLE `iot_sync_log` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`sync_type` varchar(20) NOT NULL,
|
||||
`sync_status` varchar(20) NOT NULL,
|
||||
`total_count` int(11) DEFAULT 0,
|
||||
`success_count` int(11) DEFAULT 0,
|
||||
`failed_count` int(11) DEFAULT 0,
|
||||
`error_message` text,
|
||||
`sync_time` datetime DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_sync_time` (`sync_time`),
|
||||
KEY `idx_sync_status` (`sync_status`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
Reference in New Issue
Block a user