package com.ruoyi.bst.device.domain;

import java.math.BigDecimal;
import java.time.LocalDateTime;

import javax.validation.constraints.NotBlank;

import org.springframework.format.annotation.DateTimeFormat;

import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.interfaces.LogBizParam;
import com.ruoyi.common.core.validate.ValidGroup;
import com.ruoyi.iot.interfaces.IotDevice;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 设备对象 bst_device
 *
 * @author ruoyi
 * @date 2025-03-20
 */
@Data
public class Device extends BaseEntity implements IotDevice, LogBizParam
{
    private static final long serialVersionUID = 1L;

    private Long id;

    @Excel(name = "型号id")
    @ApiModelProperty("型号id")
    private Long modelId;

    @Excel(name = "图片")
    @ApiModelProperty("图片")
    private String picture;

    @Excel(name = "设备Mac号")
    @ApiModelProperty("设备Mac号")
    @NotBlank(message = "设备Mac号不能为空", groups = {ValidGroup.Create.class})
    private String mac;

    @Excel(name = "设备SN号")
    @ApiModelProperty("设备SN号")
    @NotBlank(message = "设备SN号不能为空", groups = {ValidGroup.Create.class})
    private String sn;

    @Excel(name = "车牌号")
    @ApiModelProperty("车牌号")
    private String vehicleNum;

    @Excel(name = "运营区ID")
    @ApiModelProperty("运营区ID")
    private Long areaId;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "激活时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("激活时间")
    private LocalDateTime activationTime;

    @Excel(name = "在线状态：0-不在线；1-在线")
    @ApiModelProperty("在线状态：0-不在线；1-在线")
    private String onlineStatus;

    @Excel(name = "车辆状态:0-仓库中，1-待骑行，2-预约中，3-骑行中，4-临时锁车，6-调度中，8-下线", readConverterExp = "禁=用")
    @ApiModelProperty("车辆状态:0-仓库中，1-待骑行，2-预约中，3-骑行中，4-临时锁车，6-调度中，8-下线")
    private String status;

    @Excel(name = "锁状态: 1-开,0-关")
    @ApiModelProperty("锁状态: 1-开,0-关")
    private String lockStatus;

    @Excel(name = "定位地址")
    @ApiModelProperty("定位地址")
    private String location;

    @Excel(name = "电压：V")
    @ApiModelProperty("电压：V")
    private BigDecimal voltage;

    @Excel(name = "经度")
    @ApiModelProperty("经度")
    private BigDecimal longitude;

    @Excel(name = "纬度")
    @ApiModelProperty("纬度")
    private BigDecimal latitude;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "最近更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("最近更新时间")
    private LocalDateTime lastTime;

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

    @Excel(name = "信号强度")
    @ApiModelProperty("信号强度")
    private Integer signalStrength;

    @Excel(name = "电门状态")
    @ApiModelProperty("电门状态")
    private String quality;

    @Excel(name = "卫星数量")
    @ApiModelProperty("卫星数量")
    private Integer satellites;

    @Excel(name = "是否有GPS信号")
    @ApiModelProperty("是否有GPS信号")
    private Boolean gps;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "最后定位时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("最后定位时间")
    private LocalDateTime lastLocationTime;

    @Excel(name = "硬件版本id")
    @ApiModelProperty("硬件版本id")
    private Long hardwareVersionId;

    @Excel(name = "运营商ID")
    @ApiModelProperty("运营商ID")
    private Long mchId;

    @Excel(name = "物联网状态：0断电，1上电运行 2轮动抱死  3超出区域断电", readConverterExp = "远=程下发了qlose")
    @ApiModelProperty("物联网状态：0断电，1上电运行 2轮动抱死  3超出区域断电")
    private String iotStatus;

    @Excel(name = "声音设置")
    @ApiModelProperty("声音设置")
    private String music;

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

    @Excel(name = "当前订单设备ID")
    @ApiModelProperty("当前订单设备ID")
    private Long orderDeviceId;

    @Excel(name = "软件版本")
    @ApiModelProperty("软件版本") 
    private String softwareVersion;

    @Excel(name = "最近一次下单用户ID")
    @ApiModelProperty("最近一次下单用户ID")
    private Long lastUserId;

    @Excel(name = "定位类型")
    @ApiModelProperty("定位类型（1设备定位 2手机定位）")
    private String locationType;

    @Override
    public String mac() {
        return this.mac;
    }

    @Override
    public BigDecimal longitude() {
        return this.longitude;
    }

    @Override
    public BigDecimal latitude() {
        return this.latitude;
    }

    @Override
    public Object logBizId() {
        return id;
    }
}
