-- 更新旧工单的 batch_name（如果为空）
-- 使用 batch_id 生成默认的 batch_name

UPDATE test_work_order
SET batch_name = CONCAT('批次-', FROM_UNIXTIME(batch_id/1000, '%Y%m%d%H%i%s'))
WHERE batch_name IS NULL 
  AND batch_id IS NOT NULL;

-- 验证更新
SELECT 
    id,
    batch_id,
    batch_name,
    name,
    create_time
FROM test_work_order
WHERE order_id IS NULL
ORDER BY id DESC
LIMIT 20;
