package com.xy.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.xy.utils.PageBean;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Data
@Accessors(chain = true)
public class DeviceRegisterDto {

    @Data
    @Accessors(chain = true)
    public static class Save {

        @NotNull(message = "deviceId不能为空")
        @ApiModelProperty(value = "设备ID", required = true)
        private Long deviceId;

        @NotBlank(message = "deviceSn不能为空")
        @ApiModelProperty(value = "设备sn", required = true)
        private String deviceSn;

        @NotBlank(message = "devicePc不能为空")
        @ApiModelProperty(value = "设备批次号", required = true)
        private String devicePc;

        @NotBlank(message = "assetNo不能为空")
        @ApiModelProperty(value = "资产编号", required = true)
        private String assetNo;


        @ApiModelProperty(value = "设备类型", hidden = true)
        private Integer deviceType;

    }

    @Data
    @Accessors(chain = true)
    public static class UpdateSn {

        @NotNull(message = "deviceId不能为空")
        @ApiModelProperty("设备ID")
        private Long deviceId;

        @ApiModelProperty("设备sn")
        private String deviceSn;
    }

    @Data
    @Accessors(chain = true)
    public static class Page extends Vo {

        @ApiModelProperty("分页对象")
        private PageBean page;

        @JsonFormat(pattern = "yyyy-MM-dd")
        @ApiModelProperty(value = "创建时间-起")
        private LocalDate beginCreateTime;

        @JsonFormat(pattern = "yyyy-MM-dd")
        @ApiModelProperty(value = "创建时间-始")
        private LocalDate endCreateTime;

        @ApiModelProperty("是否已绑定")
        private Boolean isBind;

        public LocalDateTime getBeginCreateTime() {
            return beginCreateTime == null ? null : beginCreateTime.atTime(0, 0, 0);
        }

        public LocalDateTime getEndCreateTime() {
            return endCreateTime == null ? null : endCreateTime.atTime(23, 59, 59);
        }
    }

    @Data
    @Accessors(chain = true)
    public static class SelectList extends Vo {

        @ApiModelProperty("设备ID")
        private List<Long> deviceIds;

        @ApiModelProperty("设备sn")
        private List<String> deviceSns;

        @ApiModelProperty("设备类型")
        private List<Integer> deviceTypes;

        @ApiModelProperty("设备批次号")
        private List<String> devicePcs;

        @ApiModelProperty("资产编号")
        private List<String> assetNos;
    }

    @Data
    @Accessors(chain = true)
    public static class Vo {

        @ApiModelProperty("设备ID")
        private Long deviceId;

        @ApiModelProperty("货道数量")
        private Integer aisleNum;

        @ApiModelProperty("注册序号")
        private Integer registerNum;

        @ApiModelProperty("设备sn")
        private String deviceSn;

        @ApiModelProperty("设备类型")
        private Integer deviceType;

        @ApiModelProperty("设备批次号")
        private String devicePc;

        @ApiModelProperty("资产编号")
        private String assetNo;

        @ApiModelProperty("创建时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime createTime;

        @ApiModelProperty("创建人")
        private Long createUser;

        @ApiModelProperty("出厂状态")
        private Integer factoryState;

        @ApiModelProperty("合格状态")
        private Integer qualityState;

        @ApiModelProperty("设备二维码商户id")
        private Long deviceQrMercId;

        @ApiModelProperty("设备二维码商户名称")
        private String deviceQrMercName;
    }

}
