from lib.db import execute_query

# 查询开启特来电合并的配置的历史记录
h = execute_query("""
    SELECT id, config_name, report_date, start_time, end_time, total_orders, status, create_time 
    FROM t_daily_report_history 
    WHERE config_name IN ('华辉121路', '华辉188路', '248路', '华辉251路')
    AND report_date >= '2026-07-22' 
    ORDER BY create_time DESC
""")

print("===== 特来电合并配置的历史记录 =====")
for h_ in h:
    print(f"{h_['config_name']} | {h_['report_date']} | {h_['start_time']} ~ {h_['end_time']} | {h_['total_orders']}条 | status={h_['status']} | {h_['create_time']}")

print("\n===== 检查配置的selected_fields是否包含车牌号和VIN =====")
configs = execute_query("""
    SELECT id, config_name, selected_fields 
    FROM t_daily_report_config 
    WHERE config_name IN ('华辉121路', '华辉188路', '248路', '华辉251路')
""")

import json
for c in configs:
    fields = json.loads(c['selected_fields'])
    has_plate = 'charge_plate_no' in fields
    has_vin = 'charge_vin' in fields
    print(f"{c['config_name']}: 车牌号={has_plate}, VIN码={has_vin}")
    print(f"  字段列表: {fields}")
