package com.xy.dto;

import cn.hutool.json.JSONObject;
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.NotEmpty;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

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

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

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

        @JsonFormat(pattern = "yyyy-MM-dd")
        @ApiModelProperty(value = "更新时间-起")
        private LocalDate beginUpdateTime;

        @JsonFormat(pattern = "yyyy-MM-dd")
        @ApiModelProperty(value = "更新时间-始")
        private LocalDate endUpdateTime;

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

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

        @ApiModelProperty(value = "质检值对象", hidden = true)
        private DeviceQualityValueDto.Vo deviceQualityValue;
    }

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

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

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

        @ApiModelProperty("唯一标识")
        private List<Integer> qualityIds;

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

        @ApiModelProperty("显示状态")
        private Boolean showStatus;
    }

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

        @NotNull(message = "qualityId不能为空")
        @ApiModelProperty(value = "唯一标识", required = true)
        private Integer qualityId;

        @NotEmpty(message = "types不能为空")
        @ApiModelProperty(value = "质检类型", required = true)
        private List<String> types;
    }

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

        @ApiModelProperty(value = "设备ID", required = true)
        private Long deviceId;
    }

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

        @ApiModelProperty("唯一标识")
        private Integer qualityId;

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

        @ApiModelProperty("显示状态")
        private Boolean showStatus;

        @ApiModelProperty(value = "质检值对象", hidden = true)
        private DeviceQualityValueDto.Vo deviceQualityValue;
    }

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

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

        @NotBlank(message = "type不能为空")
        @ApiModelProperty("质检类型")
        private String type;

        @ApiModelProperty("通知数据")
        private JSONObject data;
    }

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

        @ApiModelProperty("唯一标识")
        private Integer qualityId;

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

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

        @ApiModelProperty("出厂审核人ID")
        private Long factoryAuditUserId;

        @ApiModelProperty("质检状态审核人ID")
        private Long qualityAuditUserId;

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

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

        @ApiModelProperty("交易测试状态")
        private Integer tradeState;

        @ApiModelProperty("交易测试状态开始时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime tradeStateBeginTime;

        @ApiModelProperty("交易测试状态结束时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime tradeStateEndTime;

        @ApiModelProperty("门锁状态")
        private Integer lockerState;

        @ApiModelProperty("门锁状态开始时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime lockerStateBeginTime;

        @ApiModelProperty("门锁状态结束时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime lockerStateEndTime;

        @ApiModelProperty("温度检测状态")
        private Integer temperatureState;

        @ApiModelProperty("温度检测状态开始时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime temperatureStateBeginTime;

        @ApiModelProperty("温度检测状态结束时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime temperatureStateEndTime;

        @ApiModelProperty("模拟批量测试状态")
        private Integer imitateTestState;

        @ApiModelProperty("模拟批量测试状态开始时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime imitateTestStateBeginTime;

        @ApiModelProperty("模拟批量测试状态结束时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime imitateTestStateEndTime;

        @ApiModelProperty("软件硬系统状态")
        private Integer systemState;

        @ApiModelProperty("软件硬系统状态开始时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime systemStateBeginTime;

        @ApiModelProperty("软件硬系统状态结束时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime systemStateEndTime;

        @ApiModelProperty("参数设置状态")
        private Integer settingState;

        @ApiModelProperty("参数设置状态开始时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime settingStateBeginTime;

        @ApiModelProperty("参数设置状态结束时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime settingStateEndTime;

        @ApiModelProperty("更新时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime updateTime;

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

        @ApiModelProperty("显示状态")
        private Boolean showStatus;

        @ApiModelProperty("质检值对象")
        private DeviceQualityValueDto.Vo deviceQualityValue;

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

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