package com.its.op.dto.its.scrs;

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

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

/**
 * 교통 조건 관리 DTO Class
 */
@Data
@Builder
@ApiModel("TbScTrfcCndtMngmDto(교통 조건 관리)")
public class TbScTrfcCndtMngmDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("교차로 ID")  // N VARCHAR2(10)
    @JsonProperty("ixr_id")
    private String ixrId;

    @ApiModelProperty("방향 구분(01:북, 02:동, 03:남, 04:서, 05:북동, 06:남동, 07:남서, 08:북서)")  // N NUMBER(1)
    @JsonProperty("drct_dvsn_cd")
    private Integer drctDvsnCd;

    @ApiModelProperty("버스 베이 유무")  // Y VARCHAR2(1)
    @JsonProperty("bus_bay_en")
    private String busBayEn;

    @ApiModelProperty("노상 주차 유무")  // Y VARCHAR2(1)
    @JsonProperty("stre_park_en")
    private String streParkEn;

    @ApiModelProperty("상류 링크 길이")  // Y NUMBER(3)
    @JsonProperty("upst_link_lngt")
    private Integer upstLinkLngt;

    @ApiModelProperty("경사")  // Y NUMBER(3)
    @JsonProperty("hpev")
    private Integer hpev;

    @ApiModelProperty("좌회전 곡선 반경")  // Y NUMBER(3)
    @JsonProperty("left_curv_rads")
    private Integer leftCurvRads;

    @ApiModelProperty("평균 차로폭")  // Y NUMBER(3,1)
    @JsonProperty("avrg_lawh")
    private Double avrgLawh;

    @ApiModelProperty("버스 정류장 거리")  // Y NUMBER(3)
    @JsonProperty("bus_sttn_dstc")
    private Integer busSttnDstc;

    @ApiModelProperty("첨두 시간 계수")  // Y NUMBER(2)
    @JsonProperty("peak_hh_fctr")
    private Integer peakHhFctr;

    @ApiModelProperty("U 턴 교통량")  // Y NUMBER(4)
    @JsonProperty("u_turn_tfvl")
    private Integer uTurnTfvl;

    @ApiModelProperty("진입 교통량")  // Y NUMBER(4)
    @JsonProperty("entr_tfvl")
    private Integer entrTfvl;

    @ApiModelProperty("진출 교통량")  // Y NUMBER(4)
    @JsonProperty("exit_tfvl")
    private Integer exitTfvl;

    @ApiModelProperty("주차 활동 대수")  // Y NUMBER(4)
    @JsonProperty("park_actn_unum")
    private Integer parkActnUnum;

    @ApiModelProperty("횡단 보행 수")  // Y NUMBER(4)
    @JsonProperty("cros_walk_cnt")
    private Integer crosWalkCnt;

    @ApiModelProperty("순행 속도")  // Y NUMBER(3)
    @JsonProperty("crus_sped")
    private Integer crusSped;

    @ApiModelProperty("초기 대기 차량 대수")  // Y NUMBER(4)
    @JsonProperty("intl_atmp_vhcl_unum")
    private Integer intlAtmpVhclUnum;

    @ApiModelProperty("보행 신호 시간")  // Y NUMBER(3)
    @JsonProperty("walk_sgnl_hh")
    private Integer walkSgnlHh;

    @ApiModelProperty("버스 정차 대수")  // Y NUMBER(4)
    @JsonProperty("bus_stop_unum")
    private Integer busStopUnum;

    @ApiModelProperty("상류 정류장 이격 거리")  // Y NUMBER(3)
    @JsonProperty("upst_sttn_dstc")
    private Integer upstSttnDstc;

    // Code Description Field
    @ApiModelProperty("방향 구분(01:북, 02:동, 03:남, 04:서, 05:북동, 06:남동, 07:남서, 08:북서) 설명")
    @JsonProperty("drct_dvsn_desc")    // DRCT_DVSN_CD
    private String drctDvsnDesc;

    @ApiModel("TbScTrfcCndtMngmUpdReq(교통 조건 관리 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbScTrfcCndtMngmUpdReq {

        @ApiModelProperty("교차로 ID, Nullable = N, VARCHAR2(10)")  // N VARCHAR2(10)
        @JsonProperty("ixr_id")
        @Size(min=1, max=10)
        private String ixrId;

        @ApiModelProperty("방향 구분(01:북, 02:동, 03:남, 04:서, 05:북동, 06:남동, 07:남서, 08:북서), Nullable = N, NUMBER(1)")  // N NUMBER(1)
        @JsonProperty("drct_dvsn_cd")
        @PositiveOrZero
        private Integer drctDvsnCd;

        @ApiModelProperty("버스 베이 유무, Nullable = Y, VARCHAR2(1)")  // Y VARCHAR2(1)
        @JsonProperty("bus_bay_en")
        @Size(min=1, max=1)
        private String busBayEn;

        @ApiModelProperty("노상 주차 유무, Nullable = Y, VARCHAR2(1)")  // Y VARCHAR2(1)
        @JsonProperty("stre_park_en")
        @Size(min=1, max=1)
        private String streParkEn;

        @ApiModelProperty("상류 링크 길이, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("upst_link_lngt")
        @PositiveOrZero
        private Integer upstLinkLngt;

        @ApiModelProperty("경사, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("hpev")
        @PositiveOrZero
        private Integer hpev;

        @ApiModelProperty("좌회전 곡선 반경, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("left_curv_rads")
        @PositiveOrZero
        private Integer leftCurvRads;

        @ApiModelProperty("평균 차로폭, , NUMBER(3,1)")  // Y NUMBER(3,1)
        @JsonProperty("avrg_lawh")
        private Double avrgLawh;

        @ApiModelProperty("버스 정류장 거리, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("bus_sttn_dstc")
        @PositiveOrZero
        private Integer busSttnDstc;

        @ApiModelProperty("첨두 시간 계수, Nullable = Y, NUMBER(2)")  // Y NUMBER(2)
        @JsonProperty("peak_hh_fctr")
        @PositiveOrZero
        private Integer peakHhFctr;

        @ApiModelProperty("U 턴 교통량, Nullable = Y, NUMBER(4)")  // Y NUMBER(4)
        @JsonProperty("u_turn_tfvl")
        @PositiveOrZero
        private Integer uTurnTfvl;

        @ApiModelProperty("진입 교통량, Nullable = Y, NUMBER(4)")  // Y NUMBER(4)
        @JsonProperty("entr_tfvl")
        @PositiveOrZero
        private Integer entrTfvl;

        @ApiModelProperty("진출 교통량, Nullable = Y, NUMBER(4)")  // Y NUMBER(4)
        @JsonProperty("exit_tfvl")
        @PositiveOrZero
        private Integer exitTfvl;

        @ApiModelProperty("주차 활동 대수, Nullable = Y, NUMBER(4)")  // Y NUMBER(4)
        @JsonProperty("park_actn_unum")
        @PositiveOrZero
        private Integer parkActnUnum;

        @ApiModelProperty("횡단 보행 수, Nullable = Y, NUMBER(4)")  // Y NUMBER(4)
        @JsonProperty("cros_walk_cnt")
        @PositiveOrZero
        private Integer crosWalkCnt;

        @ApiModelProperty("순행 속도, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("crus_sped")
        @PositiveOrZero
        private Integer crusSped;

        @ApiModelProperty("초기 대기 차량 대수, Nullable = Y, NUMBER(4)")  // Y NUMBER(4)
        @JsonProperty("intl_atmp_vhcl_unum")
        @PositiveOrZero
        private Integer intlAtmpVhclUnum;

        @ApiModelProperty("보행 신호 시간, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("walk_sgnl_hh")
        @PositiveOrZero
        private Integer walkSgnlHh;

        @ApiModelProperty("버스 정차 대수, Nullable = Y, NUMBER(4)")  // Y NUMBER(4)
        @JsonProperty("bus_stop_unum")
        @PositiveOrZero
        private Integer busStopUnum;

        @ApiModelProperty("상류 정류장 이격 거리, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("upst_sttn_dstc")
        @PositiveOrZero
        private Integer upstSttnDstc;

        @Builder
        public TbScTrfcCndtMngmUpdReq(String ixr_id, Integer drct_dvsn_cd, String bus_bay_en, String stre_park_en, Integer upst_link_lngt, Integer hpev, Integer left_curv_rads, Double avrg_lawh, Integer bus_sttn_dstc, Integer peak_hh_fctr, Integer u_turn_tfvl, Integer entr_tfvl, Integer exit_tfvl, Integer park_actn_unum, Integer cros_walk_cnt, Integer crus_sped, Integer intl_atmp_vhcl_unum, Integer walk_sgnl_hh, Integer bus_stop_unum, Integer upst_sttn_dstc) {
            this.ixrId = ixr_id;
            this.drctDvsnCd = drct_dvsn_cd;
            this.busBayEn = bus_bay_en;
            this.streParkEn = stre_park_en;
            this.upstLinkLngt = upst_link_lngt;
            this.hpev = hpev;
            this.leftCurvRads = left_curv_rads;
            this.avrgLawh = avrg_lawh;
            this.busSttnDstc = bus_sttn_dstc;
            this.peakHhFctr = peak_hh_fctr;
            this.uTurnTfvl = u_turn_tfvl;
            this.entrTfvl = entr_tfvl;
            this.exitTfvl = exit_tfvl;
            this.parkActnUnum = park_actn_unum;
            this.crosWalkCnt = cros_walk_cnt;
            this.crusSped = crus_sped;
            this.intlAtmpVhclUnum = intl_atmp_vhcl_unum;
            this.walkSgnlHh = walk_sgnl_hh;
            this.busStopUnum = bus_stop_unum;
            this.upstSttnDstc = upst_sttn_dstc;
        }

        public TbScTrfcCndtMngm toEntity() {
            return TbScTrfcCndtMngm.builder()
                    .ixrId(this.ixrId)
                    .drctDvsnCd(this.drctDvsnCd)
                    .busBayEn(this.busBayEn)
                    .streParkEn(this.streParkEn)
                    .upstLinkLngt(this.upstLinkLngt)
                    .hpev(this.hpev)
                    .leftCurvRads(this.leftCurvRads)
                    .avrgLawh(this.avrgLawh)
                    .busSttnDstc(this.busSttnDstc)
                    .peakHhFctr(this.peakHhFctr)
                    .uTurnTfvl(this.uTurnTfvl)
                    .entrTfvl(this.entrTfvl)
                    .exitTfvl(this.exitTfvl)
                    .parkActnUnum(this.parkActnUnum)
                    .crosWalkCnt(this.crosWalkCnt)
                    .crusSped(this.crusSped)
                    .intlAtmpVhclUnum(this.intlAtmpVhclUnum)
                    .walkSgnlHh(this.walkSgnlHh)
                    .busStopUnum(this.busStopUnum)
                    .upstSttnDstc(this.upstSttnDstc)
                    .build();
        }

    }

}
