package com.its.op.dto.its.facility;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.facility.TbFcltFail;
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;

/**
 * 시설물 장애 발생 정보 DTO Class
 */
@Data
@Builder
@ApiModel("TbFcltFailDto(시설물 장애 발생 정보)")
public class TbFcltFailDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("장애발생번호(YYYYMMNNNN)")  // N VARCHAR2(10)
    @JsonProperty("fail_no")
    private String failNo;

    @ApiModelProperty("등록일시")  // N VARCHAR2(14)
    @JsonProperty("reg_dt")
    private String regDt;

    @ApiModelProperty("시설물 관리 번호")  // N NUMBER(10)
    @JsonProperty("fclt_nmbr")
    private Long fcltNmbr;

    @ApiModelProperty("장애 발생 구분코드")  // Y VARCHAR2(7)
    @JsonProperty("fail_ocrr_cd")
    private String failOcrrCd;

    @ApiModelProperty("장애품목 관리번호")  // Y NUMBER(10)
    @JsonProperty("subj_nmbr")
    private Long subjNmbr;

    @ApiModelProperty("장애발견자명")  // Y VARCHAR2(30)
    @JsonProperty("find_man")
    private String findMan;

    @ApiModelProperty("장애발생시각")  // Y VARCHAR2(14)
    @JsonProperty("str_dt")
    private String strDt;

    @ApiModelProperty("장애종료시각")  // Y VARCHAR2(14)
    @JsonProperty("end_dt")
    private String endDt;

    @ApiModelProperty("진행상태-장애조치('FSTEP')")  // Y VARCHAR2(7)
    @JsonProperty("step_cd")
    private String stepCd;

    @ApiModelProperty("장애명")  // Y VARCHAR2(100)
    @JsonProperty("fail_nm")
    private String failNm;

    @ApiModelProperty("장애등록구분('FREG')")  // Y VARCHAR2(7)
    @JsonProperty("fail_reg_cd")
    private String failRegCd;

    @ApiModelProperty("장애등급구분('FLVL')")  // Y VARCHAR2(7)
    @JsonProperty("fail_levl_cd")
    private String failLevlCd;

    @ApiModelProperty("날씨('FWTHR')")  // Y VARCHAR2(7)
    @JsonProperty("wthr_cd")
    private String wthrCd;

    @ApiModelProperty("장애내용")  // Y VARCHAR2(256)
    @JsonProperty("fail_desc")
    private String failDesc;

    @ApiModelProperty("선조치내용")  // Y VARCHAR2(256)
    @JsonProperty("bef_act_desc")
    private String befActDesc;

    @ApiModelProperty("기타비고")  // Y VARCHAR2(256)
    @JsonProperty("etc_rmk")
    private String etcRmk;

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

    // Code Description Field
    @ApiModelProperty("시설물 대분류")
    @JsonProperty("fclt_group")
    private String fcltGroup;

    @ApiModelProperty("시설물 위치")  // Y VARCHAR2(100)
    @JsonProperty("fclt_lctn")
    private String fcltLctn;

    @ApiModelProperty("장애 발생 구분코드 설명")
    @JsonProperty("fail_ocrr_desc")    // FAIL_OCRR_CD
    private String failOcrrDesc;

    @ApiModelProperty("진행상태-장애조치('FSTEP') 설명")
    @JsonProperty("step_desc")    // STEP_CD
    private String stepDesc;

    @ApiModelProperty("장애등록구분('FREG') 설명")
    @JsonProperty("fail_reg_desc")    // FAIL_REG_CD
    private String failRegDesc;

    @ApiModelProperty("장애등급구분('FLVL') 설명")
    @JsonProperty("fail_levl_desc")    // FAIL_LEVL_CD
    private String failLevlDesc;

    @ApiModelProperty("날씨('FWTHR') 설명")
    @JsonProperty("wthr_desc")    // WTHR_CD
    private String wthrDesc;

    @ApiModelProperty("사용여부 설명")
    @JsonProperty("use_desc")    // USE_YN
    private String useDesc;

    @ApiModel("TbFcltFailUpdReq(시설물 장애 발생 정보 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbFcltFailUpdReq {

        @ApiModelProperty("장애발생번호(YYYYMMNNNN), Nullable = N, VARCHAR2(10)")  // N VARCHAR2(10)
        @JsonProperty("fail_no")
        @Size(min=1, max=10)
        private String failNo;

        @ApiModelProperty("등록일시, Nullable = N, VARCHAR2(14)")  // N VARCHAR2(14)
        @JsonProperty("reg_dt")
        @Size(min=1, max=14)
        private String regDt;

        @ApiModelProperty("시설물 관리 번호, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("fclt_nmbr")
        @PositiveOrZero
        private Long fcltNmbr;

        @ApiModelProperty("장애 발생 구분코드, Nullable = Y, VARCHAR2(7)")  // Y VARCHAR2(7)
        @JsonProperty("fail_ocrr_cd")
        @Size(min=1, max=7)
        private String failOcrrCd;

        @ApiModelProperty("장애품목 관리번호, Nullable = Y, NUMBER(10)")  // Y NUMBER(10)
        @JsonProperty("subj_nmbr")
        @PositiveOrZero
        private Long subjNmbr;

        @ApiModelProperty("장애발견자명, Nullable = Y, VARCHAR2(30)")  // Y VARCHAR2(30)
        @JsonProperty("find_man")
        @Size(min=1, max=30)
        private String findMan;

        @ApiModelProperty("장애발생시각, Nullable = Y, VARCHAR2(14)")  // Y VARCHAR2(14)
        @JsonProperty("str_dt")
        @Size(min=1, max=14)
        private String strDt;

        @ApiModelProperty("장애종료시각, Nullable = Y, VARCHAR2(14)")  // Y VARCHAR2(14)
        @JsonProperty("end_dt")
        @Size(min=1, max=14)
        private String endDt;

        @ApiModelProperty("진행상태-장애조치('FSTEP'), Nullable = Y, VARCHAR2(7)")  // Y VARCHAR2(7)
        @JsonProperty("step_cd")
        @Size(min=1, max=7)
        private String stepCd;

        @ApiModelProperty("장애명, Nullable = Y, VARCHAR2(100)")  // Y VARCHAR2(100)
        @JsonProperty("fail_nm")
        @Size(min=1, max=100)
        private String failNm;

        @ApiModelProperty("장애등록구분('FREG'), Nullable = Y, VARCHAR2(7)")  // Y VARCHAR2(7)
        @JsonProperty("fail_reg_cd")
        @Size(min=1, max=7)
        private String failRegCd;

        @ApiModelProperty("장애등급구분('FLVL'), Nullable = Y, VARCHAR2(7)")  // Y VARCHAR2(7)
        @JsonProperty("fail_levl_cd")
        @Size(min=1, max=7)
        private String failLevlCd;

        @ApiModelProperty("날씨('FWTHR'), Nullable = Y, VARCHAR2(7)")  // Y VARCHAR2(7)
        @JsonProperty("wthr_cd")
        @Size(min=1, max=7)
        private String wthrCd;

        @ApiModelProperty("장애내용, Nullable = Y, VARCHAR2(256)")  // Y VARCHAR2(256)
        @JsonProperty("fail_desc")
        @Size(min=1, max=256)
        private String failDesc;

        @ApiModelProperty("선조치내용, Nullable = Y, VARCHAR2(256)")  // Y VARCHAR2(256)
        @JsonProperty("bef_act_desc")
        @Size(min=1, max=256)
        private String befActDesc;

        @ApiModelProperty("기타비고, Nullable = Y, VARCHAR2(256)")  // Y VARCHAR2(256)
        @JsonProperty("etc_rmk")
        @Size(min=1, max=256)
        private String etcRmk;

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

        @Builder
        public TbFcltFailUpdReq(String fail_no, String reg_dt, Long fclt_nmbr, String fail_ocrr_cd, Long subj_nmbr, String find_man, String str_dt, String end_dt, String step_cd, String fail_nm, String fail_reg_cd, String fail_levl_cd, String wthr_cd, String fail_desc, String bef_act_desc, String etc_rmk, String use_yn) {
            this.failNo = fail_no;
            this.regDt = reg_dt;
            this.fcltNmbr = fclt_nmbr;
            this.failOcrrCd = fail_ocrr_cd;
            this.subjNmbr = subj_nmbr;
            this.findMan = find_man;
            this.strDt = str_dt;
            this.endDt = end_dt;
            this.stepCd = step_cd;
            this.failNm = fail_nm;
            this.failRegCd = fail_reg_cd;
            this.failLevlCd = fail_levl_cd;
            this.wthrCd = wthr_cd;
            this.failDesc = fail_desc;
            this.befActDesc = bef_act_desc;
            this.etcRmk = etc_rmk;
            this.useYn = use_yn;
        }

        public TbFcltFail toEntity() {
            return TbFcltFail.builder()
                    .failNo(this.failNo)
                    .regDt(this.regDt)
                    .fcltNmbr(this.fcltNmbr)
                    .failOcrrCd(this.failOcrrCd)
                    .subjNmbr(this.subjNmbr)
                    .findMan(this.findMan)
                    .strDt(this.strDt)
                    .endDt(this.endDt)
                    .stepCd(this.stepCd)
                    .failNm(this.failNm)
                    .failRegCd(this.failRegCd)
                    .failLevlCd(this.failLevlCd)
                    .wthrCd(this.wthrCd)
                    .failDesc(this.failDesc)
                    .befActDesc(this.befActDesc)
                    .etcRmk(this.etcRmk)
                    .useYn(this.useYn)
                    .build();
        }

    }

}
