#pragma once

#include "DataFields.h"

namespace DMStatSwap
{
    const string TABLENAME = "stat_swap";
    const string DT = "dt";		// 统计的日期（按天统计）
    const string T_TOTAL = "t_total";	// 总换电时长
    const string T_AVG = "t_avg";	// 平均换电时长
    const string T_MIN = "t_min";	// 最快换电时长
    const string T_MAX = "t_max";	// 最慢换电时长
    const string ELECTRIC = "electric";	// 总电量
    const string FEE_SERVICE = "fee_service";	// 服务费
    const string FEE_ELECTRIC = "fee_electric";	// 电费
    const string NUM = "num";	// 换电次数
    const string NUM_SUCCESS = "num_success";	// 换电成功次数
    const string NUM_FAILED = "num_failed";	// 换电失败次数
    const string NUM_DF = "num_brand_df";	// 品牌车辆换电次数(东风)
    const string NUM_WL = "num_brand_wl";	// 品牌车辆换电次数(蔚来)
    const string NUM_BQ = "num_brand_bq";	// 品牌车辆换电次数(北汽)
}

namespace DMStatCharge
{
    const string TABLENAME = "stat_charge";
    const string DT = "dt";
    const string T_TOTAL = "t_total";
    const string T_AVG = "t_avg";
    const string T_MIN = "t_min";
    const string T_MAX = "t_max";
    const string T_ONLINE = "t_online";
    const string ELECTRIC = "electric";
    const string ELECT_AVG = "elect_avg";
    const string FEE_ELECTRIC = "fee_electric";
    const string FEE_SERVICE = "fee_service";
    const string NUM = "num";	// 充电次数
    const string NUM_SUCCESS = "num_success";	// 充电成功次数
    const string NUM_FAILED = "num_failed";	// 充电失败次数
}

namespace DMStatChargerData
{
    const string TABLENAME = "stat_charger_data";
    const string TIME = "collect_time";
    const string CHARGER_ID = "charger_id";
    const string VOLTAGE = "voltage";
    const string CURRENT = "current";
    const string POWER = "power";
}


class DaoStat
{
public:
    // ************************************************************************************************
    static bool insert_charge_curve(DataFields& fields);
    static bool query_charge_curve_by_time(string start_time, string end_time, std::vector<DataFields>& result);
    static bool query_station_power_by_time(string start_time, string end_time, std::vector<DataFields>& result);


    static void insert_charger_data(int t_interval);

    /**
    * 查询当天的充电机电压、电流、功率历史数据
    */
    static bool query_charge_data(std::string dt, vector<DataFields>& result);

};