/*
 * 文 件 名:  ChargingMeterH
 * 版    权:  华设设计集团股份有限公司
 * 描    述:  充电计量表-分时实体类
 * 修 改 人:  lvwenbin
 * 修改时间:  2026/01/08
 */
package com.ruoyi.ems.domain;

import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * 充电计量表-分时实体类
 * 对应表 adm_charging_meter_h
 * 结构对齐 adm_elec_meter_h，便于统计聚合
 *
 * @author lvwenbin
 * @version [版本号, 2026/01/08]
 */
@Data
public class ChargingMeterH implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 计量类型枚举
     */
    public static final int METER_TYPE_VALLEY = -1;  // 谷
    public static final int METER_TYPE_FLAT = 0;     // 平
    public static final int METER_TYPE_PEAK = 1;     // 峰
    public static final int METER_TYPE_SHARP = 2;    // 尖

    /**
     * 序号
     */
    private Long id;

    /**
     * 关联交易流水号
     */
    private String transactionNo;

    /**
     * 区域代码
     */
    private String areaCode;

    /**
     * 充电枪设备编码
     */
    private String deviceCode;

    /**
     * 记录时间(取交易结束时间)
     */
    private Date recordTime;

    /**
     * 日期
     */
    private Date date;

    /**
     * 时间
     */
    private Date time;

    /**
     * 电量(kWh)
     */
    private Double elecQuantity;

    /**
     * 计损电量(kWh)
     */
    private Double elecQuantityLoss;

    /**
     * 计量类型(-1:谷 0:平 1:峰 2:尖)
     */
    private Integer meterType;

    /**
     * 单位电价(元/kWh)
     */
    private Double meterUnitPrice;

    /**
     * 电费(元)
     */
    private Double useElecCost;

    /**
     * 创建时间
     */
    private Date createTime;

    // ==================== 构造函数 ====================

    public ChargingMeterH() {
    }

    /**
     * 便捷构造函数
     */
    public ChargingMeterH(String transactionNo, String areaCode, String deviceCode,
                          Date recordTime, int meterType, double elecQuantity,
                          double elecQuantityLoss, double meterUnitPrice, double useElecCost) {
        this.transactionNo = transactionNo;
        this.areaCode = areaCode;
        this.deviceCode = deviceCode;
        this.recordTime = recordTime;
        this.date = recordTime;
        this.time = recordTime;
        this.meterType = meterType;
        this.elecQuantity = elecQuantity;
        this.elecQuantityLoss = elecQuantityLoss;
        this.meterUnitPrice = meterUnitPrice;
        this.useElecCost = useElecCost;
    }

    // ==================== 辅助方法 ====================

    /**
     * 获取计量类型描述
     */
    public String getMeterTypeDesc() {
        if (meterType == null) {
            return "未知";
        }
        switch (meterType) {
            case METER_TYPE_SHARP:
                return "尖";
            case METER_TYPE_PEAK:
                return "峰";
            case METER_TYPE_FLAT:
                return "平";
            case METER_TYPE_VALLEY:
                return "谷";
            default:
                return "未知";
        }
    }

    @Override
    public String toString() {
        return "ChargingMeterH{" +
            "transactionNo='" + transactionNo + '\'' +
            ", deviceCode='" + deviceCode + '\'' +
            ", recordTime=" + recordTime +
            ", meterType=" + getMeterTypeDesc() +
            ", elecQuantity=" + elecQuantity +
            ", meterUnitPrice=" + meterUnitPrice +
            ", useElecCost=" + useElecCost +
            '}';
    }
}
