#pragma once

#include "DataFields.h"

namespace DMBattery
{
    const string TABLENAME = "battery";
    const string ID = "id";
    const string CODE = "code";
    const string MODEL = "model";
    const string TYPE = "type";
    const string LOCK_TYPE = "lock_type";
    const string FACTOR = "factory";
    const string CAPACITY = "rated_capacity"; // 额定容量
    const string RATED_VOLTAGE = "rated_voltage"; // 额定电压
    const string TOTALENERGY = "rated_total_energy"; // 额定总能量
    const string VOLTAGE_MAX = "voltage_max"; // 最高充电电压
    const string BATTERY_NUM = "battery_num"; // 单体电池个数
}

namespace DMBatteryData
{
    const string TABLENAME = "battery_status";
    const string FID_ID = "id";
    const string FID_BATTERY_CODE = "battery_code";
    const string FID_POSID = "storehouse_id";
    const string FID_VOLTAGE = "voltage";
    const string FID_CURRENT = "current";
    const string FID_POWER = "power";
    const string FID_SOC = "soc";
    const string FID_SOH = "soh";
    const string FID_MAX_VOLTAGE = "max_voltage";
    const string FID_MAX_VOLTAGE_ID = "max_voltage_id";
    const string FID_MIN_VOLTAGE = "min_voltage";
    const string FID_MIN_VOLTAGE_ID = "min_voltage_id";
    const string FID_MAX_TEMP = "max_temp";
    const string FID_MAX_TEMP_ID = "max_temp_id";
    const string FID_MIN_TEMP = "min_temp";
    const string FID_MIN_TEMP_ID = "min_temp_id";
    const string FID_CREATE_TIME = "cteate_time";
}

class DaoBattery
{
public:

    static void insert_battery(DataFields& fields);
    static void query_battery(PageInfo& pageinfo, vector<DataFields>& result, string condition = "");
    static void query_battery(vector<DataFields>& result);
    static void query_battery_by_code(string code, vector<DataFields>& result);
    static bool query_battery_by_pos(string storage_id, vector<DataFields>& result);
    static int update_battery(DataFields& fields, string condition);
    static bool insert_battery_data(DataFields& fields);

    static bool update_battery_bms(std::string batt_code, DataFields& fields);

};
