package com.its.api.its.model.dto.vds;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.api.its.model.entity.vds.TbVdsDtct;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

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

/**
 * VDS 검지기 마스터 DTO Class
 */
@Data
@Builder
@ApiModel("TbVdsDtctMstrDto(VDS 검지기 마스터)")
public class TbVdsDtctDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("검지기 번호")  // N VARCHAR(8)
    @JsonProperty("dtct_nmbr")
    private String dtctNmbr;

    @ApiModelProperty("검지기 유형 코드")  // Y VARCHAR(7)
    @JsonProperty("dtct_type_cd")
    private String dtctTypeCd;

    @ApiModelProperty("정지선 거리")  // Y NUMBER(7)
    @JsonProperty("stln_dstc")
    private Integer stlnDstc;

    @ApiModelProperty("설치 차로")  // Y NUMBER(2)
    @JsonProperty("istl_lane")
    private Integer istlLane;

    @ApiModelProperty("DET 번호")  // Y VARCHAR(1)
    @JsonProperty("det_nmbr")
    private String detNmbr;

    @ApiModelProperty("감도")  // Y NUMBER(3)
    @JsonProperty("snst")
    private Integer snst;

    @ApiModelProperty("검지기 유효 거리")  // Y NUMBER(7)
    @JsonProperty("dtct_vald_dstc")
    private Integer dtctValdDstc;

    @ApiModelProperty("중형차 상한 길이")  // Y NUMBER(7)
    @JsonProperty("mdvh_uplm_lngt")
    private Integer mdvhUplmLngt;

    @ApiModelProperty("중형차 하한 길이")  // Y NUMBER(7)
    @JsonProperty("mdvh_lwlm_lngt")
    private Integer mdvhLwlmLngt;

    @ApiModelProperty("사용 여부")  // Y CHAR(1)
    @JsonProperty("use_yn")
    private String useYn;

    @ApiModelProperty("채널 번호")  // Y VARCHAR(4)
    @JsonProperty("chnl_nmbr")
    private String chnlNmbr;

    @ApiModelProperty("삭제자 번호")  // Y VARCHAR(20)
    @JsonProperty("dltr_nmbr")
    private String dltrNmbr;

    @ApiModelProperty("삭제 일시")  // Y VARCHAR(14)
    @JsonProperty("del_dt")
    private String delDt;

    @ApiModelProperty("삭제 여부")  // Y CHAR(1)
    @JsonProperty("del_yn")
    private String delYn;

    //@ApiModelProperty("최초 등록자 번호")  // Y VARCHAR(20)
    //@JsonProperty("frst_regr_nmbr")
    @JsonIgnore
    private String frstRegrNmbr;

    //@ApiModelProperty("최초 등록 일시")  // Y VARCHAR(14)
    //@JsonProperty("frst_rgst_dt")
    @JsonIgnore
    private String frstRgstDt;

    //@ApiModelProperty("최종 수정자 번호")  // Y VARCHAR(20)
    //@JsonProperty("last_crpr_nmbr")
    @JsonIgnore
    private String lastCrprNmbr;

    //@ApiModelProperty("최종 수정 일시")  // Y VARCHAR(14)
    //@JsonProperty("last_crct_dt")
    @JsonIgnore
    private String lastCrctDt;

    @ApiModelProperty("제어기 관리 번호")  // Y VARCHAR(20)
    @JsonProperty("ctlr_mngm_nmbr")
    private String ctlrMngmNmbr;

    @ApiModelProperty("VDS 검지기 명")  // Y VARCHAR(40)
    @JsonProperty("vds_dtct_nm")
    private String vdsDtctNm;

    @ApiModelProperty("최대 교통량")  // Y NUMBER(6)
    @JsonProperty("max_tfvl")
    private Integer maxTfvl;

    @ApiModelProperty("최소 교통량")  // Y NUMBER(6)
    @JsonProperty("min_tfvl")
    private Integer minTfvl;

    @ApiModelProperty("최대 점유 율")  // Y NUMBER(6,2)
    @JsonProperty("max_ocpy_rate")
    private Double maxOcpyRate;

    @ApiModelProperty("최소 점유 율")  // Y NUMBER(6,2)
    @JsonProperty("min_ocpy_rate")
    private Double minOcpyRate;

    @ApiModelProperty("최대 속도")  // Y NUMBER(3)
    @JsonProperty("max_sped")
    private Integer maxSped;

    @ApiModelProperty("최소 속도")  // Y NUMBER(3)
    @JsonProperty("min_sped")
    private Integer minSped;

    // Code Description Field
    @ApiModelProperty("검지기 유형 코드 설명")
    @JsonProperty("dtct_type_desc")    // DTCT_TYPE_CD
    private String dtctTypeDesc;

    @ApiModelProperty("링크ID")  // N NUMBER(10)
    @JsonProperty("link_id")
    private Long linkId;

    @ApiModel("TbVdsDtctMstrUpdReq(VDS 검지기 마스터 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor(access = AccessLevel.PROTECTED)
    public static class TbVdsDtctMstrUpdReq {

        @ApiModelProperty("검지기 번호, Nullable = N, VARCHAR(8)")  // N VARCHAR(8)
        @JsonProperty("dtct_nmbr")
        @Size(min=1, max=8)
        private String dtctNmbr;

        @ApiModelProperty("검지기 유형 코드, Nullable = Y, VARCHAR(7)")  // Y VARCHAR(7)
        @JsonProperty("dtct_type_cd")
        @Size(min=1, max=7)
        private String dtctTypeCd;

        @ApiModelProperty("정지선 거리, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("stln_dstc")
        @PositiveOrZero
        private Integer stlnDstc;

        @ApiModelProperty("설치 차로, Nullable = Y, NUMBER(2)")  // Y NUMBER(2)
        @JsonProperty("istl_lane")
        @PositiveOrZero
        private Integer istlLane;

        @ApiModelProperty("DET 번호, Nullable = Y, VARCHAR(1)")  // Y VARCHAR(1)
        @JsonProperty("det_nmbr")
        @Size(min=1, max=1)
        private String detNmbr;

        @ApiModelProperty("감도, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("snst")
        @PositiveOrZero
        private Integer snst;

        @ApiModelProperty("검지기 유효 거리, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("dtct_vald_dstc")
        @PositiveOrZero
        private Integer dtctValdDstc;

        @ApiModelProperty("중형차 상한 길이, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("mdvh_uplm_lngt")
        @PositiveOrZero
        private Integer mdvhUplmLngt;

        @ApiModelProperty("중형차 하한 길이, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("mdvh_lwlm_lngt")
        @PositiveOrZero
        private Integer mdvhLwlmLngt;

        @ApiModelProperty("사용 여부, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("use_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String useYn;

        @ApiModelProperty("채널 번호, Nullable = Y, VARCHAR(4)")  // Y VARCHAR(4)
        @JsonProperty("chnl_nmbr")
        @Size(min=1, max=4)
        private String chnlNmbr;

        @ApiModelProperty("삭제 여부, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("del_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String delYn;

        @ApiModelProperty("제어기 관리 번호, Nullable = Y, VARCHAR(20)")  // Y VARCHAR(20)
        @JsonProperty("ctlr_mngm_nmbr")
        @Size(min=1, max=20)
        private String ctlrMngmNmbr;

        @ApiModelProperty("VDS 검지기 명, Nullable = Y, VARCHAR(40)")  // Y VARCHAR(40)
        @JsonProperty("vds_dtct_nm")
        @Size(min=1, max=40)
        private String vdsDtctNm;

        @ApiModelProperty("최대 교통량, Nullable = Y, NUMBER(6)")  // Y NUMBER(6)
        @JsonProperty("max_tfvl")
        private Integer maxTfvl;

        @ApiModelProperty("최소 교통량, Nullable = Y, NUMBER(6)")  // Y NUMBER(6)
        @JsonProperty("min_tfvl")
        private Integer minTfvl;

        @ApiModelProperty("최대 점유 율, , NUMBER(6,2)")  // Y NUMBER(6,2)
        @JsonProperty("max_ocpy_rate")
        private Double maxOcpyRate;

        @ApiModelProperty("최소 점유 율, , NUMBER(6,2)")  // Y NUMBER(6,2)
        @JsonProperty("min_ocpy_rate")
        private Double minOcpyRate;

        @ApiModelProperty("최대 속도, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("max_sped")
        private Integer maxSped;

        @ApiModelProperty("최소 속도, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("min_sped")
        private Integer minSped;

        @ApiModelProperty("링크ID")  // N NUMBER(10)
        @JsonProperty("link_id")
        @PositiveOrZero
        private Long linkId;

        @Builder
        public TbVdsDtctMstrUpdReq(String dtct_nmbr, String dtct_type_cd, Integer stln_dstc, Integer istl_lane, String det_nmbr, Integer snst, Integer dtct_vald_dstc, Integer mdvh_uplm_lngt, Integer mdvh_lwlm_lngt, String use_yn, String chnl_nmbr, String dltr_nmbr, String del_dt, String del_yn, String ctlr_mngm_nmbr, String vds_dtct_nm, Integer max_tfvl, Integer min_tfvl, Double max_ocpy_rate, Double min_ocpy_rate, Integer max_sped, Integer min_sped, Long linkId) {
            this.dtctNmbr = dtct_nmbr;
            this.dtctTypeCd = dtct_type_cd;
            this.stlnDstc = stln_dstc;
            this.istlLane = istl_lane;
            this.detNmbr = det_nmbr;
            this.snst = snst;
            this.dtctValdDstc = dtct_vald_dstc;
            this.mdvhUplmLngt = mdvh_uplm_lngt;
            this.mdvhLwlmLngt = mdvh_lwlm_lngt;
            this.useYn = use_yn;
            this.chnlNmbr = chnl_nmbr;
            this.delYn = del_yn;
            this.ctlrMngmNmbr = ctlr_mngm_nmbr;
            this.vdsDtctNm = vds_dtct_nm;
            this.maxTfvl = max_tfvl;
            this.minTfvl = min_tfvl;
            this.maxOcpyRate = max_ocpy_rate;
            this.minOcpyRate = min_ocpy_rate;
            this.maxSped = max_sped;
            this.minSped = min_sped;
            this.linkId = linkId;
        }

        public TbVdsDtct toEntity() {
            return TbVdsDtct.builder()
                    .dtctNmbr(this.dtctNmbr)
                    .dtctTypeCd(this.dtctTypeCd)
                    .stlnDstc(this.stlnDstc)
                    .istlLane(this.istlLane)
                    .detNmbr(this.detNmbr)
                    .snst(this.snst)
                    .dtctValdDstc(this.dtctValdDstc)
                    .mdvhUplmLngt(this.mdvhUplmLngt)
                    .mdvhLwlmLngt(this.mdvhLwlmLngt)
                    .useYn(this.useYn)
                    .chnlNmbr(this.chnlNmbr)
                    .delYn(this.delYn)
                    .ctlrMngmNmbr(this.ctlrMngmNmbr)
                    .vdsDtctNm(this.vdsDtctNm)
                    .maxTfvl(this.maxTfvl)
                    .minTfvl(this.minTfvl)
                    .maxOcpyRate(this.maxOcpyRate)
                    .minOcpyRate(this.minOcpyRate)
                    .maxSped(this.maxSped)
                    .minSped(this.minSped)
                    .build();
        }

    }

}
