package com.njcn.gather.system.dictionary.pojo.param;

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

import javax.validation.constraints.*;
import java.math.BigDecimal;

@Data
public class DictPqParam {

    @ApiModelProperty("名称")
    @NotBlank(message = SystemValidMessage.NAME_NOT_BLANK)
    @Pattern(regexp = PatternRegex.DICT_NAME_REGEX, message = SystemValidMessage.DICT_TYPE_NAME_FORMAT_ERROR)
    private String name;

    @ApiModelProperty("相别")
    @NotBlank(message = SystemValidMessage.PHASE_NOT_BLANK)
    private String phase;

    @ApiModelProperty("数据模型")
    @NotBlank(message = SystemValidMessage.DATA_TYPE_NOT_BLANK)
    private String dataType;

    @ApiModelProperty("别名，默认与名称相同")
    @Pattern(regexp = PatternRegex.DICT_PQ_OTHER_NAME_REGEX, message = SystemValidMessage.DICT_PQ_OTHER_NAME_FORMAT_ERROR)
    private String otherName;

    @ApiModelProperty("显示名称")
    @Pattern(regexp = PatternRegex.DICT_PQ_OTHER_NAME_REGEX, message = SystemValidMessage.DICT_PQ_SHOW_NAME_FORMAT_ERROR)
    private String showName;

    @ApiModelProperty("排序")
    @NotNull(message = SystemValidMessage.SORT_NOT_NULL)
    @Min(value = 1, message = SystemValidMessage.SORT_FORMAT_ERROR)
    @Max(value = 999, message = SystemValidMessage.SORT_FORMAT_ERROR)
    private Integer sort;

    @ApiModelProperty("指标数据类型（整型、浮点型、枚举型）")
    private String type;

    @ApiModelProperty("单位")
    private String unit;

    @ApiModelProperty("起始次数")
    private Integer harmStart;

    @ApiModelProperty("结束次数")
    private Integer harmEnd;

    @ApiModelProperty("数据表表名")
    @NotBlank(message = SystemValidMessage.CLASS_ID_NOT_BLANK)
    private String classId;

    @ApiModelProperty("数据统计类型（最大、最小、平均、CP95）")
    private String statMethod;

    @ApiModelProperty("系统类别（区分用能/电能）")
    private String systemType;

    @ApiModelProperty("数据是否上送（0:不上送 1:上送）")
    private Integer tranFlag;

    @ApiModelProperty("上送规则 变化: \"change\" 周期: \"period\"")
    private String tranRule;

    @ApiModelProperty("evt的事件类别 \"1\"、\"2\"")
    private String eventType;

    @ApiModelProperty("sts、di的是否存储 1:存储 0:不存储")
    private Integer storeFlag;

    @ApiModelProperty("sts、do的当前值")
    private Integer curSts;

    @ApiModelProperty("do的是否可远程控制 1:是 0:否；")
    private Integer ctlSts;

    @ApiModelProperty("设置最大值")
    private Double maxNum;

    @ApiModelProperty("设置最小值")
    private Double minNum;

    @ApiModelProperty("参数为enum可设置的所有值序列")
    private String setValue;

    @ApiModelProperty("参数string可设置字符串的长度上限")
    private Integer strlen;

    @ApiModelProperty("参数缺省值、告警code值")
    private String defaultValue;

    @ApiModelProperty("报表数据来源(统计表表名)")
    private String resourcesId;

    @ApiModelProperty("限值字段名称")
    private String limitName;

    @ApiModelProperty("限值表名")
    private String limitTable;

    @ApiModelProperty("超标判断方式")
    private String formula;

    @ApiModelProperty("二次值转一次值公式")
    private String primaryFormula;

    /**
     * 更新操作实体
     */
    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class UpdateParam extends DictPqParam {

        @ApiModelProperty("id")
        @NotBlank(message = SystemValidMessage.ID_NOT_BLANK)
        @Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
        private String id;

    }

    /**
     * 分页查询实体
     */
    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class QueryParam extends BaseParam {

        @ApiModelProperty("名称")
        private String name;

        @ApiModelProperty("别名")
        private String otherName;

        @ApiModelProperty("显示名称")
        private String showName;

        @ApiModelProperty("数据模型")
        private String dataType;

        @ApiModelProperty("数据表表名")
        private String classId;

    }

}
