-- ====================================
-- 简化测试：清空表并尝试插入
-- ====================================

-- 1. 清空xq_client_log表
TRUNCATE TABLE xq_client_log;

-- 2. 检查表是否已清空
SELECT COUNT(*) as '记录数量' FROM xq_client_log;

-- 3. 检查iot_device_data表中项圈设备的数据
SELECT 
    device_id,
    device_type,
    voltage,
    temperature,
    latitude,
    longitude,
    steps,
    same_day_steps,
    server_device_id,
    LENGTH(CAST(latitude AS CHAR)) as lat_length,
    LENGTH(CAST(longitude AS CHAR)) as lng_length,
    LENGTH(CAST(voltage AS CHAR)) as voltage_length,
    LENGTH(CAST(temperature AS CHAR)) as temp_length,
    LENGTH(server_device_id) as server_id_length
FROM iot_device_data 
WHERE device_type = 4 
ORDER BY update_time DESC
LIMIT 5;

-- 4. 尝试插入最简单的数据
INSERT INTO xq_client_log (
    device_id, 
    device_voltage, 
    device_temp, 
    server_device_id,
    latitude, 
    longitude, 
    walk_steps, 
    y_walk_steps,
    create_time, 
    create_by, 
    update_time, 
    update_by
) VALUES (
    '24075000139',
    '3.300',
    '25.80',
    'test_server',
    '30.481277875444164',
    '114.40076076679632',
    21,
    0,
    NOW(),
    'SIMPLE_TEST',
    NOW(),
    'SIMPLE_TEST'
);

-- 5. 检查插入结果
SELECT 
    device_id,
    device_voltage,
    device_temp,
    latitude,
    longitude,
    walk_steps,
    y_walk_steps,
    create_by,
    create_time
FROM xq_client_log 
WHERE create_by = 'SIMPLE_TEST';
