ALTER TABLE hot_vehicle_three_inspect
    ADD COLUMN inspect_no varchar(32) NULL COMMENT '三检记录编号',
    ADD COLUMN inspect_location varchar(255) NULL COMMENT '检查地点';

UPDATE hot_vehicle_three_inspect t
LEFT JOIN hot_vehicle v ON v.id = t.vehicle_id
SET t.inspect_no = CONCAT(
        'SJ',
        DATE_FORMAT(COALESCE(t.inspect_time, t.create_time), '%Y%m%d'),
        RIGHT(COALESCE(v.plate_number, '000'), 3),
        LPAD(MOD(COALESCE(t.inspect_id, t.id), 10000), 4, '0')
    )
WHERE (t.inspect_no IS NULL OR t.inspect_no = '')
  AND t.is_deleted = 0;
