package com.its.op.dto.its.link;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.link.TbLinkParaDetl;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.Pattern;
import javax.validation.constraints.Positive;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * 링크 파라미터 상세 DTO Class
 */
@Data
@Builder
@ApiModel("TbLinkParaDetlDto(링크 파라미터 상세)")
public class TbLinkParaDetlDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("파라미터 ID")  // N NUMBER(10)
    @JsonProperty("para_id")
    private Long paraId;

    @ApiModelProperty("필터링 최소 교통량")  // Y NUMBER(6)
    @JsonProperty("fltr_min_tfvl")
    private Integer fltrMinTfvl;

    @ApiModelProperty("필터링 최대 교통량")  // Y NUMBER(6)
    @JsonProperty("fltr_max_tfvl")
    private Integer fltrMaxTfvl;

    @ApiModelProperty("필터링 최저 속도")  // Y NUMBER(3)
    @JsonProperty("fltr_lwst_sped")
    private Integer fltrLwstSped;

    @ApiModelProperty("필터링 최고 속도")  // Y NUMBER(3)
    @JsonProperty("fltr_hghs_sped")
    private Integer fltrHghsSped;

    @ApiModelProperty("보정 가중치 평균 이전 1주기")  // Y NUMBER(5,2)
    @JsonProperty("adjs_wght_avrg_pre_1cycl")
    private Double adjsWghtAvrgPre1cycl;

    @ApiModelProperty("보정 가중치 평균 이전 2주기")  // Y NUMBER(5,2)
    @JsonProperty("adjs_wght_avrg_pre_2cycl")
    private Double adjsWghtAvrgPre2cycl;

    @ApiModelProperty("보정 가중치 평균 이전 3주기")  // Y NUMBER(5,2)
    @JsonProperty("adjs_wght_avrg_pre_3cycl")
    private Double adjsWghtAvrgPre3cycl;

    @ApiModelProperty("보정 15분 패턴 적용 여부")  // Y CHAR(1)
    @JsonProperty("adjs_ptrn_15m_aply_yn")
    private String adjsPtrn15mAplyYn;

    @ApiModelProperty("보정 단기 결측 판단 주기")  // Y NUMBER(2)
    @JsonProperty("adjs_shtr_miss_decs_cycl")
    private Integer adjsShtrMissDecsCycl;

    @ApiModelProperty("평활화 최저 속도 계수")  // Y NUMBER(3,2)
    @JsonProperty("smth_lwst_sped_fctr")
    private Double smthLwstSpedFctr;

    @ApiModelProperty("평활화 최고 속도 계수")  // Y NUMBER(3,2)
    @JsonProperty("smth_hghs_sped_fctr")
    private Double smthHghsSpedFctr;

    @ApiModelProperty("평활화 가중치 평균 현재")  // Y NUMBER(5,2)
    @JsonProperty("smth_wght_avrg_prst")
    private Double smthWghtAvrgPrst;

    @ApiModelProperty("평활화 가중치 평균 이전 1주기")  // Y NUMBER(5,2)
    @JsonProperty("smth_wght_avrg_pre_1cycl")
    private Double smthWghtAvrgPre1cycl;

    @ApiModelProperty("평활화 가중치 평균 이전 2주기")  // Y NUMBER(5,2)
    @JsonProperty("smth_wght_avrg_pre_2cycl")
    private Double smthWghtAvrgPre2cycl;

    @ApiModelProperty("패턴업데이트계수")  // Y NUMBER(5,2)
    @JsonProperty("ptrn_r")
    private Double ptrnR;

    // Code Description Field
    @ApiModelProperty("보정 15분 패턴 적용 여부 설명")
    @JsonProperty("adjs_ptrn_15m_aply_desc")    // ADJS_PTRN_15M_APLY_YN
    private String adjsPtrn15mAplyDesc;

    @ApiModel("TbLinkParaDetlUpdReq(링크 파라미터 상세 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbLinkParaDetlUpdReq {

        @ApiModelProperty("파라미터 ID, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("para_id")
        @Positive
        private Long paraId;

        @ApiModelProperty("필터링 최소 교통량, Nullable = Y, NUMBER(6)")  // Y NUMBER(6)
        @JsonProperty("fltr_min_tfvl")
        @Positive
        private Integer fltrMinTfvl;

        @ApiModelProperty("필터링 최대 교통량, Nullable = Y, NUMBER(6)")  // Y NUMBER(6)
        @JsonProperty("fltr_max_tfvl")
        @Positive
        private Integer fltrMaxTfvl;

        @ApiModelProperty("필터링 최저 속도, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("fltr_lwst_sped")
        @Positive
        private Integer fltrLwstSped;

        @ApiModelProperty("필터링 최고 속도, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("fltr_hghs_sped")
        @Positive
        private Integer fltrHghsSped;

        @ApiModelProperty("보정 가중치 평균 이전 1주기, , NUMBER(5,2)")  // Y NUMBER(5,2)
        @JsonProperty("adjs_wght_avrg_pre_1cycl")
        private Double adjsWghtAvrgPre1cycl;

        @ApiModelProperty("보정 가중치 평균 이전 2주기, , NUMBER(5,2)")  // Y NUMBER(5,2)
        @JsonProperty("adjs_wght_avrg_pre_2cycl")
        private Double adjsWghtAvrgPre2cycl;

        @ApiModelProperty("보정 가중치 평균 이전 3주기, , NUMBER(5,2)")  // Y NUMBER(5,2)
        @JsonProperty("adjs_wght_avrg_pre_3cycl")
        private Double adjsWghtAvrgPre3cycl;

        @ApiModelProperty("보정 15분 패턴 적용 여부, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("adjs_ptrn_15m_aply_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String adjsPtrn15mAplyYn;

        @ApiModelProperty("보정 단기 결측 판단 주기, Nullable = Y, NUMBER(2)")  // Y NUMBER(2)
        @JsonProperty("adjs_shtr_miss_decs_cycl")
        @Positive
        private Integer adjsShtrMissDecsCycl;

        @ApiModelProperty("평활화 최저 속도 계수, , NUMBER(3,2)")  // Y NUMBER(3,2)
        @JsonProperty("smth_lwst_sped_fctr")
        private Double smthLwstSpedFctr;

        @ApiModelProperty("평활화 최고 속도 계수, , NUMBER(3,2)")  // Y NUMBER(3,2)
        @JsonProperty("smth_hghs_sped_fctr")
        private Double smthHghsSpedFctr;

        @ApiModelProperty("평활화 가중치 평균 현재, , NUMBER(5,2)")  // Y NUMBER(5,2)
        @JsonProperty("smth_wght_avrg_prst")
        private Double smthWghtAvrgPrst;

        @ApiModelProperty("평활화 가중치 평균 이전 1주기, , NUMBER(5,2)")  // Y NUMBER(5,2)
        @JsonProperty("smth_wght_avrg_pre_1cycl")
        private Double smthWghtAvrgPre1cycl;

        @ApiModelProperty("평활화 가중치 평균 이전 2주기, , NUMBER(5,2)")  // Y NUMBER(5,2)
        @JsonProperty("smth_wght_avrg_pre_2cycl")
        private Double smthWghtAvrgPre2cycl;

        @ApiModelProperty("패턴업데이트계수, , NUMBER(5,2)")  // Y NUMBER(5,2)
        @JsonProperty("ptrn_r")
        private Double ptrnR;

        @Builder
        public TbLinkParaDetlUpdReq(Long para_id, Integer fltr_min_tfvl, Integer fltr_max_tfvl, Integer fltr_lwst_sped, Integer fltr_hghs_sped, Double adjs_wght_avrg_pre_1cycl, Double adjs_wght_avrg_pre_2cycl, Double adjs_wght_avrg_pre_3cycl, String adjs_ptrn_15m_aply_yn, Integer adjs_shtr_miss_decs_cycl, Double smth_lwst_sped_fctr, Double smth_hghs_sped_fctr, Double smth_wght_avrg_prst, Double smth_wght_avrg_pre_1cycl, Double smth_wght_avrg_pre_2cycl, Double ptrn_r) {
            this.paraId = para_id;
            this.fltrMinTfvl = fltr_min_tfvl;
            this.fltrMaxTfvl = fltr_max_tfvl;
            this.fltrLwstSped = fltr_lwst_sped;
            this.fltrHghsSped = fltr_hghs_sped;
            this.adjsWghtAvrgPre1cycl = adjs_wght_avrg_pre_1cycl;
            this.adjsWghtAvrgPre2cycl = adjs_wght_avrg_pre_2cycl;
            this.adjsWghtAvrgPre3cycl = adjs_wght_avrg_pre_3cycl;
            this.adjsPtrn15mAplyYn = adjs_ptrn_15m_aply_yn;
            this.adjsShtrMissDecsCycl = adjs_shtr_miss_decs_cycl;
            this.smthLwstSpedFctr = smth_lwst_sped_fctr;
            this.smthHghsSpedFctr = smth_hghs_sped_fctr;
            this.smthWghtAvrgPrst = smth_wght_avrg_prst;
            this.smthWghtAvrgPre1cycl = smth_wght_avrg_pre_1cycl;
            this.smthWghtAvrgPre2cycl = smth_wght_avrg_pre_2cycl;
            this.ptrnR = ptrn_r;
        }

        public TbLinkParaDetl toEntity() {
            return TbLinkParaDetl.builder()
                    .paraId(this.paraId)
                    .fltrMinTfvl(this.fltrMinTfvl)
                    .fltrMaxTfvl(this.fltrMaxTfvl)
                    .fltrLwstSped(this.fltrLwstSped)
                    .fltrHghsSped(this.fltrHghsSped)
                    .adjsWghtAvrgPre1cycl(this.adjsWghtAvrgPre1cycl)
                    .adjsWghtAvrgPre2cycl(this.adjsWghtAvrgPre2cycl)
                    .adjsWghtAvrgPre3cycl(this.adjsWghtAvrgPre3cycl)
                    .adjsPtrn15mAplyYn(this.adjsPtrn15mAplyYn)
                    .adjsShtrMissDecsCycl(this.adjsShtrMissDecsCycl)
                    .smthLwstSpedFctr(this.smthLwstSpedFctr)
                    .smthHghsSpedFctr(this.smthHghsSpedFctr)
                    .smthWghtAvrgPrst(this.smthWghtAvrgPrst)
                    .smthWghtAvrgPre1cycl(this.smthWghtAvrgPre1cycl)
                    .smthWghtAvrgPre2cycl(this.smthWghtAvrgPre2cycl)
                    .ptrnR(this.ptrnR)
                    .build();
        }

    }

}
