package com.ruoyi.ss.device.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonView;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.domain.JsonViewProfile;
import com.ruoyi.common.core.domain.ValidGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * 设备对象 ss_device
 *
 * @author 邱贞招
 * @date 2024-02-21
 */
@Data
public class Device extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 设备id */
    @ApiModelProperty("设备ID")
    @NotNull(message = "设备id不允许为空", groups = {ValidGroup.Update.class})
    @JsonView({DeviceView.SuitList.class, JsonViewProfile.App.class})
    private Long deviceId;

    @ApiModelProperty("设备编号（SN）")
    @JsonView({DeviceView.SuitList.class, JsonViewProfile.App.class})
    private String sn;

    /** 店铺id */
    @Excel(name = "店铺id")
    @ApiModelProperty("店铺id")
    @JsonView(JsonViewProfile.App.class)
    private Long storeId;

    /** 设备名称 */
    @Excel(name = "设备名称")
    @ApiModelProperty("设备名称")
    @JsonView({DeviceView.SuitList.class, JsonViewProfile.App.class})
    private String deviceName;

    /** 型号id */
    @Excel(name = "型号id")
    @ApiModelProperty("型号id")
    @NotNull(message = "型号不允许为空", groups = {ValidGroup.Create.class, ValidGroup.Update.class})
    private Long modelId;


    /** 设备Mac号 */
    @Excel(name = "设备Mac号")
    @ApiModelProperty("设备Mac号")
    @JsonView(JsonViewProfile.App.class)
    private String mac;

    @Excel(name = "设备Mac号2")
    @ApiModelProperty("设备Mac号2")
    @JsonView(JsonViewProfile.App.class)
    private String mac2;

    /** 激活时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("激活时间")
    @Excel(name = "激活时间", width = 30, dateFormat = "yyyy-MM-dd")
    @Past(message = "激活时间必须是过去的某个时间", groups = {ValidGroup.Create.class, ValidGroup.Update.class})
    private Date activationTime;

    @Excel(name = "总用电量")
    @ApiModelProperty("总用电量（KWH）")
    @JsonView(JsonViewProfile.App.class)
    private BigDecimal totalElectriQuantity;

    /** 在线状态 */
    @Excel(name = "在线状态")
    @ApiModelProperty("在线状态")
    @JsonView(JsonViewProfile.App.class)
    private String onlineStatus;

    @Excel(name = "在线状态1：0-不在线；1-在线")
    @ApiModelProperty("在线状态1：0-不在线；1-在线")
    @JsonView(JsonViewProfile.App.class)
    private String onlineStatus1;

    @Excel(name = "在线状态2：0-不在线；1-在线")
    @ApiModelProperty("在线状态2：0-不在线；1-在线")
    @JsonView(JsonViewProfile.App.class)
    private String onlineStatus2;

    /** 状态 */
    @Excel(name = "状态")
    @ApiModelProperty("状态")
    @JsonView(JsonViewProfile.App.class)
    private String status;

    /** 实时功率（千瓦） */
    @Excel(name = "实时功率", readConverterExp = "千=瓦")
    @ApiModelProperty("实时功率")
    @JsonView(JsonViewProfile.App.class)
    private BigDecimal realTimePower;

    /** 电流（A） */
    @Excel(name = "电流", readConverterExp = "A=")
    @ApiModelProperty("电流（A）")
    @Min(value = 0, message = "电流不允许小于0", groups = {ValidGroup.Create.class, ValidGroup.Update.class})
    @JsonView(JsonViewProfile.App.class)
    private BigDecimal electricity;

    /** 电压（V） */
    @Excel(name = "电压", readConverterExp = "V=")
    @ApiModelProperty("电压（V）")
    @Min(value = 0, message = "电压不允许小于0", groups = {ValidGroup.Create.class, ValidGroup.Update.class})
    @JsonView(JsonViewProfile.App.class)
    private BigDecimal voltage;

    /** 用户昵称 */
    @Excel(name = "用户昵称")
    @ApiModelProperty("用户昵称")
    private String nickName;

    @Excel(name = "开关设置方式")
    @ApiModelProperty("开关设置方式")
    private String outageWay;

    @Excel(name = "wifi名称")
    @ApiModelProperty("wifi名称")
    private String wifi;

    @ApiModelProperty("上次拉取设备信息的时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastPullTime;

    @ApiModelProperty("总电量初始读数")
    private BigDecimal initReading;

    @ApiModelProperty("开关状态,0断电，1通电")
    @JsonView(JsonViewProfile.App.class)
    private String powerStatus;

    @ApiModelProperty("设备到期时间")
    @JsonView(DeviceView.SuitList.class)
    private LocalDateTime expireTime;

    @ApiModelProperty("用户自定义图片")
    @JsonView(JsonViewProfile.App.class)
    private String customPicture;

    @ApiModelProperty("服务费")
    @Range(min = 0, message = "服务费不允许小于0")
    private BigDecimal serviceRate;

    @ApiModelProperty("服务费类型")
//    @NotBlank(message = "服务费类型不允许为空", groups = {ValidGroup.Create.class})
//    @DictValid(type = DictTypeConstants.SERVICE_TYPE, message = "非法的服务费类型")
    private String serviceType;

    @ApiModelProperty("剩余时长（秒）")
    private BigDecimal remainTime;

    @ApiModelProperty("所属用户ID")
    @JsonView(DeviceView.SuitList.class)
    private Long userId;

    @Excel(name = "起步时长")
    @ApiModelProperty("起步时长")
    private Integer startTime;

    @Excel(name = "起步时长单位")
    @ApiModelProperty("起步时长单位")
    private String startUnit;

    @Excel(name = "起步价格", readConverterExp = "元=")
    @ApiModelProperty("起步价格")
    private BigDecimal startPrice;

    @Excel(name = "超出起步时长")
    @ApiModelProperty("超出起步时长")
    private Integer overTime;

    @Excel(name = "超出起步时长单位")
    @ApiModelProperty("超出起步时长单位")
    private String overUnit;

    @Excel(name = "超出起步时长价格", readConverterExp = "元=")
    @ApiModelProperty("超出起步时长价格")
    private BigDecimal overPrice;

    @ApiModelProperty("设备租期到期时间")
    @JsonView(JsonViewProfile.AppMch.class)
    private LocalDateTime rentTime;

    @ApiModelProperty("设备锁定的用户ID")
    private Long lockUserId;

    @ApiModelProperty("剩余电量（度）")
    @JsonView(JsonViewProfile.App.class)
    private BigDecimal surplusEle;

    @Excel(name = "限制充值时间", readConverterExp = "到=期之前不允许充值")
    @ApiModelProperty("限制充值时间")
    private LocalDateTime limitRechargeTime;

    @Excel(name = "限制充值原因")
    @ApiModelProperty("限制充值原因")
    @Size(max = 200, message = "限制充值原因长度不能超过200个字符")
    private String limitRechargeReason;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "最后在线时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("最后在线时间")
    @JsonView(JsonViewProfile.App.class)
    private LocalDateTime lastOnlineTime;

    @ApiModelProperty("上次恢复余额的时间戳")
    private Long lastRecoverTime;

    @Excel(name = "代理商收取服务费费率")
    @ApiModelProperty("代理商收取服务费费率")
    private BigDecimal agentServiceRate;

    @Excel(name = "代理商ID")
    @ApiModelProperty("代理商ID")
    private Long agentId;

    @Excel(name = "服务模式：1-直营模式，2-代理模式")
    @ApiModelProperty("服务模式")
    private String serviceMode;

    @Excel(name = "月费", readConverterExp = "元=")
    @ApiModelProperty("月费")
    @Min(value = 0, message = "月费不允许小于0")
    private BigDecimal monthFee;

    @Excel(name = "设备版本号")
    @ApiModelProperty("设备版本号")
    private String version;

    @Excel(name = "投放状态")
    @ApiModelProperty("投放状态：0-未投放；1-已投放")
    private String placementStatus;

    @ApiModelProperty("投放类型：1-房间门；2-麻将桌；3-台球桌；4-房间灯；5-卫生间门；6-大门")
    private String placementType;

    @ApiModelProperty("电压系数")
    private BigDecimal vxs;
}
