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

import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.pojo.constant.DetectionValidMessage;
import com.njcn.gather.system.pojo.constant.SystemValidMessage;
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.constraints.*;

/**
 * @author caozehui
 * @data 2024/11/18
 */
@Data
public class PqScriptParam {

    @ApiModelProperty("名称")
    @NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
    @Pattern(regexp = PatternRegex.SCRIPT_NAME_REGEX, message = DetectionValidMessage.SCRIPT_NAME_FORMAT_ERROR)
    private String name;

    @ApiModelProperty("类型")
    @NotNull(message = DetectionValidMessage.SCRIPT_TYPE_NOT_BLANK)
    @Min(value = 0, message = DetectionValidMessage.SCRIPT_TYPE_FORMAT_ERROR)
    @Max(value = 1, message = DetectionValidMessage.SCRIPT_TYPE_FORMAT_ERROR)
    private Integer type;

    /**
     * 检测脚本模式，字典表（数字、模拟、比对）
     */
    @ApiModelProperty("模式")
    @NotBlank(message = DetectionValidMessage.PATTERN_NOT_BLANK)
    @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PATTERN_FORMAT_ERROR)
    private String pattern;

    /**
     * 检测脚本值类型（在非比对模式情况下，分为相对值检测脚本和绝对值检测脚本）
     */
    @ApiModelProperty("值类型")
    private String valueType;

    @ApiModelProperty("参照标准名称")
    @NotBlank(message = DetectionValidMessage.STANDARD_NAME_NOT_BLANK)
    private String standardName;


    @ApiModelProperty("标准推行时间")
    @NotBlank(message = DetectionValidMessage.STANDARD_TIME_NOT_BLANK)
    @DateTimeStrValid(format = "yyyy", message = DetectionValidMessage.STANDARD_TIME_FORMAT_ERROR)
    private String standardTime;


    /**
     * 额定电压
     */
    @ApiModelProperty("额定电压")
    @NotNull(message = DetectionValidMessage.SCRIPT_TYPE_NOT_BLANK)
    @Min(value = 0, message = DetectionValidMessage.SCRIPT_VOLT_FORMAT_ERROR)
    @Max(value = 380, message = DetectionValidMessage.SCRIPT_VOLT_FORMAT_ERROR)
    private Double ratedVolt;

    /**
     * 额定电流
     */
    @ApiModelProperty("额定电流")
    @NotNull(message = DetectionValidMessage.SCRIPT_TYPE_NOT_BLANK)
    @Min(value = 0, message = DetectionValidMessage.SCRIPT_CURR_FORMAT_ERROR)
    @Max(value = 20, message = DetectionValidMessage.SCRIPT_CURR_FORMAT_ERROR)
    private Double ratedCurr;

    @ApiModelProperty("是否为Fluke专用脚本")
    private Integer fluke;


    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class QueryParam extends BaseParam {
        @ApiModelProperty("名称")
        private String name;

        @ApiModelProperty("类型")
        private Integer type;

        @ApiModelProperty("值类型")
        private String valueType;

        @ApiModelProperty("模式")
        @NotBlank(message = DetectionValidMessage.PATTERN_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PATTERN_FORMAT_ERROR)
        private String pattern;
    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class UpdateParam extends PqScriptParam {
        @ApiModelProperty("检测脚本ID")
        @NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
        private String id;
    }
}
