evo-BMS/sql/bms_device.sql
2025-11-09 19:21:01 +08:00

38 lines
2.3 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- ----------------------------
-- BMS设备表
-- ----------------------------
DROP TABLE IF EXISTS `bms_device`;
CREATE TABLE `bms_device` (
`device_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '设备ID',
`device_code` varchar(64) NOT NULL COMMENT '设备编号',
`device_name` varchar(100) NOT NULL COMMENT '设备名称',
`device_type` varchar(50) DEFAULT NULL COMMENT '设备类型',
`status` char(1) DEFAULT '0' COMMENT '设备状态0正常 1停用',
`battery_capacity` decimal(10,2) DEFAULT NULL COMMENT '电池容量(Ah)',
`rated_voltage` decimal(10,2) DEFAULT NULL COMMENT '额定电压(V)',
`current_voltage` decimal(10,2) DEFAULT NULL COMMENT '当前电压(V)',
`current_current` decimal(10,2) DEFAULT NULL COMMENT '当前电流(A)',
`remaining_capacity` decimal(5,2) DEFAULT NULL COMMENT '剩余电量(%)',
`temperature` decimal(5,2) DEFAULT NULL COMMENT '温度(℃)',
`last_comm_time` datetime DEFAULT NULL COMMENT '最后通信时间',
`del_flag` char(1) DEFAULT '0' COMMENT '删除标志0代表存在 2代表删除',
`version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`device_id`),
UNIQUE KEY `uk_device_code` (`device_code`),
KEY `idx_device_type` (`device_type`),
KEY `idx_status` (`status`),
KEY `idx_last_comm_time` (`last_comm_time`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='BMS设备表';
-- ----------------------------
-- 初始化BMS设备数据
-- ----------------------------
INSERT INTO `bms_device` VALUES
(1, 'BMS001', '1号电池管理系统', 'LiFePO4', '0', 100.00, 48.00, 48.50, 10.20, 85.50, 25.30, '2025-01-22 10:30:00', '0', 0, 'admin', '2025-01-22 10:00:00', '', NULL, '测试设备1'),
(2, 'BMS002', '2号电池管理系统', 'LiFePO4', '0', 200.00, 48.00, 47.80, -5.60, 72.30, 26.10, '2025-01-22 10:25:00', '0', 0, 'admin', '2025-01-22 10:00:00', '', NULL, '测试设备2'),
(3, 'BMS003', '3号电池管理系统', 'NCM', '1', 150.00, 52.00, 0.00, 0.00, 0.00, 0.00, NULL, '0', 0, 'admin', '2025-01-22 10:00:00', '', NULL, '停用设备');