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

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.api.its.model.entity.incident.TbIncdOcrrVms;
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;

/**
 * 돌발상황 발생 VMS DTO Class
 */
@Data
@Builder
@ApiModel("TbIncdOcrrVmsDto(돌발상황 발생 VMS)")
public class TbIncdOcrrVmsDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("돌발상황 발생 ID")  // N VARCHAR(12)
    @JsonProperty("incd_ocrr_id")
    private String incdOcrrId;

    @ApiModelProperty("시작 위치 명")  // Y VARCHAR(10)
    @JsonProperty("strt_lctn_nm")
    private String strtLctnNm;

    @ApiModelProperty("종료 위치 명")  // Y VARCHAR(10)
    @JsonProperty("end_lctn_nm")
    private String endLctnNm;

    @ApiModelProperty("발생 위치 명")  // Y VARCHAR(100)
    @JsonProperty("ocrr_lctn_nm")
    private String ocrrLctnNm;

    @ApiModelProperty("VMS 돌발상황 유형 코드")  // Y VARCHAR(7)
    @JsonProperty("vms_incd_type_cd")
    private String vmsIncdTypeCd;

    @ApiModelProperty("VMS 돌발상황 상세 유형 코드")  // Y VARCHAR(7)
    @JsonProperty("vms_incd_detl_type_cd")
    private String vmsIncdDetlTypeCd;

    @ApiModelProperty("소통 등급 코드")  // Y VARCHAR(7)
    @JsonProperty("cmtr_grad_cd")
    private String cmtrGradCd;

    @ApiModelProperty("돌발상황 차단 차로")  // Y VARCHAR(6)
    @JsonProperty("incd_clsr_lane")
    private String incdClsrLane;

    @ApiModelProperty("VMS 표출 여부")  // Y CHAR(1)
    @JsonProperty("vms_dspl_yn")
    private String vmsDsplYn;

    @ApiModelProperty("돌발상황 진행 단계 코드")  // Y VARCHAR(7)
    @JsonProperty("incd_prgr_step_cd")
    private String incdPrgrStepCd;

    @ApiModelProperty("돌발상황 시작 일시")  // Y VARCHAR(14)
    @JsonProperty("incd_strt_dt")
    private String incdStrtDt;

    @ApiModelProperty("돌발상황 종료 예정 일시")  // Y VARCHAR(14)
    @JsonProperty("incd_end_prar_dt")
    private String incdEndPrarDt;

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

    // Code Description Field
    @ApiModelProperty("VMS 돌발상황 유형 코드 설명")
    @JsonProperty("vms_incd_type_desc")    // VMS_INCD_TYPE_CD
    private String vmsIncdTypeDesc;

    @ApiModelProperty("VMS 돌발상황 상세 유형 코드 설명")
    @JsonProperty("vms_incd_detl_type_desc")    // VMS_INCD_DETL_TYPE_CD
    private String vmsIncdDetlTypeDesc;

    @ApiModelProperty("소통 등급 코드 설명")
    @JsonProperty("cmtr_grad_desc")    // CMTR_GRAD_CD
    private String cmtrGradDesc;

    @ApiModelProperty("VMS 표출 여부 설명")
    @JsonProperty("vms_dspl_desc")    // VMS_DSPL_YN
    private String vmsDsplDesc;

    @ApiModelProperty("돌발상황 진행 단계 코드 설명")
    @JsonProperty("incd_prgr_step_desc")    // INCD_PRGR_STEP_CD
    private String incdPrgrStepDesc;

    @ApiModel("TbIncdOcrrVmsUpdReq(돌발상황 발생 VMS 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor(access = AccessLevel.PROTECTED)
    public static class TbIncdOcrrVmsUpdReq {

        @ApiModelProperty("돌발상황 발생 ID, Nullable = N, VARCHAR(12)")  // N VARCHAR(12)
        @JsonProperty("incd_ocrr_id")
        @Size(min=1, max=12)
        private String incdOcrrId;

        @ApiModelProperty("시작 위치 명, Nullable = Y, VARCHAR(10)")  // Y VARCHAR(10)
        @JsonProperty("strt_lctn_nm")
        @Size(min=1, max=10)
        private String strtLctnNm;

        @ApiModelProperty("종료 위치 명, Nullable = Y, VARCHAR(10)")  // Y VARCHAR(10)
        @JsonProperty("end_lctn_nm")
        @Size(min=1, max=10)
        private String endLctnNm;

        @ApiModelProperty("발생 위치 명, Nullable = Y, VARCHAR(100)")  // Y VARCHAR(100)
        @JsonProperty("ocrr_lctn_nm")
        @Size(min=1, max=100)
        private String ocrrLctnNm;

        @ApiModelProperty("VMS 돌발상황 유형 코드, Nullable = Y, VARCHAR(7)")  // Y VARCHAR(7)
        @JsonProperty("vms_incd_type_cd")
        @Size(min=1, max=7)
        private String vmsIncdTypeCd;

        @ApiModelProperty("VMS 돌발상황 상세 유형 코드, Nullable = Y, VARCHAR(7)")  // Y VARCHAR(7)
        @JsonProperty("vms_incd_detl_type_cd")
        @Size(min=1, max=7)
        private String vmsIncdDetlTypeCd;

        @ApiModelProperty("소통 등급 코드, Nullable = Y, VARCHAR(7)")  // Y VARCHAR(7)
        @JsonProperty("cmtr_grad_cd")
        @Size(min=1, max=7)
        private String cmtrGradCd;

        @ApiModelProperty("돌발상황 차단 차로, Nullable = Y, VARCHAR(6)")  // Y VARCHAR(6)
        @JsonProperty("incd_clsr_lane")
        @Size(min=1, max=6)
        private String incdClsrLane;

        @ApiModelProperty("VMS 표출 여부, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("vms_dspl_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String vmsDsplYn;

        @ApiModelProperty("돌발상황 진행 단계 코드, Nullable = Y, VARCHAR(7)")  // Y VARCHAR(7)
        @JsonProperty("incd_prgr_step_cd")
        @Size(min=1, max=7)
        private String incdPrgrStepCd;

        @ApiModelProperty("돌발상황 시작 일시, Nullable = Y, VARCHAR(14)")  // Y VARCHAR(14)
        @JsonProperty("incd_strt_dt")
        @Size(min=1, max=14)
        private String incdStrtDt;

        @ApiModelProperty("돌발상황 종료 예정 일시, Nullable = Y, VARCHAR(14)")  // Y VARCHAR(14)
        @JsonProperty("incd_end_prar_dt")
        @Size(min=1, max=14)
        private String incdEndPrarDt;

        @ApiModelProperty("링크ID, Nullable = Y, NUMBER(10)")  // Y NUMBER(10)
        @JsonProperty("link_id")
        @PositiveOrZero
        private Long linkId;

        @Builder
        public TbIncdOcrrVmsUpdReq(String incd_ocrr_id, String strt_lctn_nm, String end_lctn_nm, String ocrr_lctn_nm, String vms_incd_type_cd, String vms_incd_detl_type_cd, String cmtr_grad_cd, String incd_clsr_lane, String vms_dspl_yn, String incd_prgr_step_cd, String incd_strt_dt, String incd_end_prar_dt, Long link_id) {
            this.incdOcrrId = incd_ocrr_id;
            this.strtLctnNm = strt_lctn_nm;
            this.endLctnNm = end_lctn_nm;
            this.ocrrLctnNm = ocrr_lctn_nm;
            this.vmsIncdTypeCd = vms_incd_type_cd;
            this.vmsIncdDetlTypeCd = vms_incd_detl_type_cd;
            this.cmtrGradCd = cmtr_grad_cd;
            this.incdClsrLane = incd_clsr_lane;
            this.vmsDsplYn = vms_dspl_yn;
            this.incdPrgrStepCd = incd_prgr_step_cd;
            this.incdStrtDt = incd_strt_dt;
            this.incdEndPrarDt = incd_end_prar_dt;
            this.linkId = link_id;
        }

        public TbIncdOcrrVms toEntity() {
            return TbIncdOcrrVms.builder()
                    .incdOcrrId(this.incdOcrrId)
                    .strtLctnNm(this.strtLctnNm)
                    .endLctnNm(this.endLctnNm)
                    .ocrrLctnNm(this.ocrrLctnNm)
                    .vmsIncdTypeCd(this.vmsIncdTypeCd)
                    .vmsIncdDetlTypeCd(this.vmsIncdDetlTypeCd)
                    .cmtrGradCd(this.cmtrGradCd)
                    .incdClsrLane(this.incdClsrLane)
                    .vmsDsplYn(this.vmsDsplYn)
                    .incdPrgrStepCd(this.incdPrgrStepCd)
                    .incdStrtDt(this.incdStrtDt)
                    .incdEndPrarDt(this.incdEndPrarDt)
                    .linkId(this.linkId)
                    .build();
        }

    }

}
