package com.fuyuanshen.equipment.domain.bo;

import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.core.validate.EditGroup;
import com.fuyuanshen.equipment.domain.DeviceChargeDischarge;
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import cn.hutool.core.date.DateUtil;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * 设备充放电记录业务对象 device_charge_discharge
 *
 * @author Lion Li
 * @date 2025-08-30
 */
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = DeviceChargeDischarge.class, reverseConvertGenerate = false)
public class DeviceChargeDischargeBo extends BaseEntity {

    /**
     * 记录唯一标识
     */
    @NotNull(message = "记录唯一标识不能为空", groups = { EditGroup.class })
    private Long id;

    /**
     * 设备唯一标识
     */
    @NotBlank(message = "设备唯一标识不能为空", groups = { AddGroup.class, EditGroup.class })
    private String deviceId;

    /**
     * 操作类型: 0 charge-充电, 1 discharge-放电
     */
    @NotNull(message = "操作类型: 0 charge-充电, 1 discharge-放电不能为空", groups = { AddGroup.class, EditGroup.class })
    private Long operationType;

    /**
     * 开始时间
     */
    @NotNull(message = "开始时间不能为空", groups = { AddGroup.class, EditGroup.class })
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date startTime;

    // 添加字符串类型的setter方法来处理前端传递的字符串日期
    public void setStartTime(String startTime) {
        this.startTime = DateUtil.parseDate(startTime);
    }

    /**
     * 结束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date endTime;

    // 添加字符串类型的setter方法来处理前端传递的字符串日期
    public void setEndTime(String endTime) {
        this.endTime = DateUtil.parseDate(endTime);
    }

    /**
     * 起始电量百分比(0-100)
     */
    private Long initialSoc;

    /**
     * 结束电量百分比(0-100)
     */
    private Long finalSoc;

    /**
     * 充放电量(kWh)
     */
    private Long energyKwh;

    /**
     * 设备额定功率(kW)
     */
    private Long powerRating;

    /**
     * 电压(V)
     */
    private Long voltage;

    /**
     * 电流(A)
     */
    private Long current;

    /**
     * 温度(℃)
     */
    private Long temperature;

    /**
     * 当前状态
     */
    private Long status;

    /**
     * 错误代码
     */
    private String errorCode;

    /**
     * 记录创建时间
     */
    private Date createdAt;

    /**
     * 记录更新时间
     */
    private Date updatedAt;


}
