-- BMS设备管理表测试数据
-- 清空现有数据（可选）
-- TRUNCATE TABLE bms_devices;

-- 插入测试数据
INSERT INTO `bms_devices` (
    `id`, 
    `device_id`, 
    `device_name`, 
    `device_type`, 
    `status`, 
    `ip_address`, 
    `firmware_version`, 
    `last_online`, 
    `create_by`, 
    `create_time`, 
    `update_time`, 
    `update_by`
) VALUES 
-- 在线设备
('550e8400-e29b-41d4-a716-446655440001', 'BBOX-001', '1号充电桩BBox', 'BBox', 'online', '192.168.1.101', 'v2.1.3', '2024-01-15 14:30:25', 'admin', '2024-01-10 09:00:00', '2024-01-15 14:30:25', '2024-01-15 14:30:25'),
('550e8400-e29b-41d4-a716-446655440002', 'BBOX-002', '2号充电桩BBox', 'BBox', 'online', '192.168.1.102', 'v2.1.3', '2024-01-15 14:28:15', 'admin', '2024-01-10 09:15:00', '2024-01-15 14:28:15', '2024-01-15 14:28:15'),
('550e8400-e29b-41d4-a716-446655440003', 'BBOX-003', '3号充电桩BBox', 'BBox', 'online', '192.168.1.103', 'v2.1.2', '2024-01-15 14:25:40', 'admin', '2024-01-10 09:30:00', '2024-01-15 14:25:40', '2024-01-15 14:25:40'),
('550e8400-e29b-41d4-a716-446655440004', 'BBOX-004', '4号充电桩BBox', 'BBox', 'online', '192.168.1.104', 'v2.1.3', '2024-01-15 14:32:10', 'admin', '2024-01-10 10:00:00', '2024-01-15 14:32:10', '2024-01-15 14:32:10'),
('550e8400-e29b-41d4-a716-446655440005', 'BBOX-005', '5号充电桩BBox', 'BBox', 'online', '192.168.1.105', 'v2.1.3', '2024-01-15 14:29:55', 'admin', '2024-01-10 10:15:00', '2024-01-15 14:29:55', '2024-01-15 14:29:55'),

-- 离线设备
('550e8400-e29b-41d4-a716-446655440006', 'BBOX-006', '6号充电桩BBox', 'BBox', 'offline', '192.168.1.106', 'v2.1.1', '2024-01-14 18:45:30', 'admin', '2024-01-10 10:30:00', '2024-01-14 18:45:30', '2024-01-14 18:45:30'),
('550e8400-e29b-41d4-a716-446655440007', 'BBOX-007', '7号充电桩BBox', 'BBox', 'offline', '192.168.1.107', 'v2.0.8', '2024-01-13 22:15:20', 'admin', '2024-01-10 11:00:00', '2024-01-13 22:15:20', '2024-01-13 22:15:20'),
('550e8400-e29b-41d4-a716-446655440008', 'BBOX-008', '8号充电桩BBox', 'BBox', 'offline', '192.168.1.108', 'v2.1.0', '2024-01-12 16:30:45', 'admin', '2024-01-10 11:15:00', '2024-01-12 16:30:45', '2024-01-12 16:30:45'),

-- 维护中设备
('550e8400-e29b-41d4-a716-446655440009', 'BBOX-009', '9号充电桩BBox', 'BBox', 'maintenance', '192.168.1.109', 'v2.1.2', '2024-01-15 08:00:00', 'admin', '2024-01-10 11:30:00', '2024-01-15 08:00:00', '2024-01-15 08:00:00'),
('550e8400-e29b-41d4-a716-446655440010', 'BBOX-010', '10号充电桩BBox', 'BBox', 'maintenance', '192.168.1.110', 'v2.1.1', '2024-01-15 07:30:00', 'admin', '2024-01-10 12:00:00', '2024-01-15 07:30:00', '2024-01-15 07:30:00'),

-- 不同区域的设备
('550e8400-e29b-41d4-a716-446655440011', 'BBOX-A01', 'A区1号BBox', 'BBox', 'online', '192.168.2.101', 'v2.1.3', '2024-01-15 14:31:20', 'admin', '2024-01-11 09:00:00', '2024-01-15 14:31:20', '2024-01-15 14:31:20'),
('550e8400-e29b-41d4-a716-446655440012', 'BBOX-A02', 'A区2号BBox', 'BBox', 'online', '192.168.2.102', 'v2.1.3', '2024-01-15 14:27:35', 'admin', '2024-01-11 09:30:00', '2024-01-15 14:27:35', '2024-01-15 14:27:35'),
('550e8400-e29b-41d4-a716-446655440013', 'BBOX-B01', 'B区1号BBox', 'BBox', 'offline', '192.168.3.101', 'v2.0.9', '2024-01-14 20:15:10', 'admin', '2024-01-11 10:00:00', '2024-01-14 20:15:10', '2024-01-14 20:15:10'),
('550e8400-e29b-41d4-a716-446655440014', 'BBOX-B02', 'B区2号BBox', 'BBox', 'online', '192.168.3.102', 'v2.1.2', '2024-01-15 14:26:50', 'admin', '2024-01-11 10:30:00', '2024-01-15 14:26:50', '2024-01-15 14:26:50'),
('550e8400-e29b-41d4-a716-446655440015', 'BBOX-C01', 'C区1号BBox', 'BBox', 'maintenance', '192.168.4.101', 'v2.1.1', '2024-01-15 06:00:00', 'admin', '2024-01-11 11:00:00', '2024-01-15 06:00:00', '2024-01-15 06:00:00'),

-- 测试设备（用于开发测试）
('550e8400-e29b-41d4-a716-446655440016', 'BBOX-TEST01', '测试设备01', 'BBox', 'online', '192.168.100.101', 'v2.2.0-beta', '2024-01-15 14:33:00', 'developer', '2024-01-12 14:00:00', '2024-01-15 14:33:00', '2024-01-15 14:33:00'),
('550e8400-e29b-41d4-a716-446655440017', 'BBOX-TEST02', '测试设备02', 'BBox', 'offline', '192.168.100.102', 'v2.2.0-alpha', '2024-01-14 16:20:30', 'developer', '2024-01-12 14:30:00', '2024-01-14 16:20:30', '2024-01-14 16:20:30'),

-- 老版本固件设备
('550e8400-e29b-41d4-a716-446655440018', 'BBOX-OLD01', '老版本设备01', 'BBox', 'offline', '192.168.1.201', 'v1.8.5', '2024-01-10 12:00:00', 'admin', '2023-12-15 10:00:00', '2024-01-10 12:00:00', '2024-01-10 12:00:00'),
('550e8400-e29b-41d4-a716-446655440019', 'BBOX-OLD02', '老版本设备02', 'BBox', 'maintenance', '192.168.1.202', 'v1.9.2', '2024-01-11 08:30:00', 'admin', '2023-12-20 11:00:00', '2024-01-11 08:30:00', '2024-01-11 08:30:00'),

-- 高负载区域设备
('550e8400-e29b-41d4-a716-446655440020', 'BBOX-HUB01', '枢纽站1号BBox', 'BBox', 'online', '192.168.5.101', 'v2.1.3', '2024-01-15 14:34:15', 'admin', '2024-01-08 08:00:00', '2024-01-15 14:34:15', '2024-01-15 14:34:15');

-- 查询验证数据
SELECT 
    COUNT(*) as total_devices,
    SUM(CASE WHEN status = 'online' THEN 1 ELSE 0 END) as online_count,
    SUM(CASE WHEN status = 'offline' THEN 1 ELSE 0 END) as offline_count,
    SUM(CASE WHEN status = 'maintenance' THEN 1 ELSE 0 END) as maintenance_count
FROM bms_devices;

-- 按固件版本统计
SELECT 
    firmware_version, 
    COUNT(*) as device_count,
    GROUP_CONCAT(device_name) as devices
FROM bms_devices 
GROUP BY firmware_version 
ORDER BY firmware_version DESC;

-- 按状态查看设备
SELECT device_id, device_name, status, ip_address, firmware_version, last_online 
FROM bms_devices 
ORDER BY status, last_online DESC;