package com.njcn.gather.err.pojo.param;

import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.pojo.constant.DetectionValidMessage;
import com.njcn.web.pojo.annotation.DateTimeStrValid;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.List;

/**
 * @author caozehui
 * @data 2024-11-27
 */
@Data
public class PqErrSysParam {

    @ApiModelProperty(value = "参照标准名称", required = true)
    @NotBlank(message = DetectionValidMessage.STANDARD_NAME_NOT_BLANK)
    @Pattern(regexp = PatternRegex.ERR_SYS_NAME_REGEX, message = DetectionValidMessage.STANDARD_NAME_FORMAT_ERROR)
    private String standardName;

    @ApiModelProperty(value = "标准实施年份", required = true)
    @NotBlank(message = DetectionValidMessage.STANDARD_TIME_NOT_BLANK)
    @DateTimeStrValid(format = "yyyy", message = DetectionValidMessage.STANDARD_TIME_FORMAT_ERROR)
    private String standardTime;

    @ApiModelProperty(value = "设备等级", required = true)
    @NotBlank(message = DetectionValidMessage.DEV_LEVEL_NOT_BLANK)
    @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.DEV_LEVEL_FORMAT_ERROR)
    private String devLevel;

    @ApiModelProperty("状态")
    @NotNull(message = DetectionValidMessage.ENABLE_NOT_NULL)
    @Min(value = 0, message = DetectionValidMessage.ENABLE_FORMAT_ERROR)
    @Max(value = 1, message = DetectionValidMessage.ENABLE_FORMAT_ERROR)
    private Integer enable;

    @ApiModelProperty(value = "误差详情列表", required = true)
    private List<PqErrSysDtlsParam> pqErrSysDtlsList;

    @Data
    @EqualsAndHashCode(callSuper = false)
    public static class QueryParam extends BaseParam {
        @ApiModelProperty("标准实施年份")
        @DateTimeStrValid(format = "yyyy", message = DetectionValidMessage.STANDARD_TIME_FORMAT_ERROR)
        private String standardTime;

        @ApiModelProperty("设备等级")
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.DEV_LEVEL_FORMAT_ERROR)
        private String devLevel;
    }

    @Data
    @EqualsAndHashCode(callSuper = false)
    public static class UpdateParam extends PqErrSysParam {
        @ApiModelProperty("id")
        @NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
        private String id;
    }

    @Data
    @EqualsAndHashCode(callSuper = false)
    public static class DetectionParam {
        @ApiModelProperty("所属误差体系ID")
        private String errorSysId;

        @ApiModelProperty("总检测脚本中的测试项序号")
        private Integer index;

        @ApiModelProperty("所属检测脚本")
        private String scriptId;


        @ApiModelProperty("电压")
        private Double un;

        @ApiModelProperty("电流")
        private Double in;

    }

}
