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

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.facility.TbFcltFailAct;
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("TbFcltFailActDto(시설물 장애 발생 조치 정보)")
public class TbFcltFailActDto implements Serializable {
    private static final long serialVersionUID = 1L;

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

    @ApiModelProperty("조치차수")  // N NUMBER(3)
    @JsonProperty("act_seq")
    private Integer actSeq;

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

    @ApiModelProperty("장애조치자명")  // Y VARCHAR2(30)
    @JsonProperty("act_man")
    private String actMan;

    @ApiModelProperty("진행상태")  // Y VARCHAR2(7)
    @JsonProperty("step_cd")
    private String stepCd;

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

    @ApiModelProperty("장애유형")  // Y VARCHAR2(7)
    @JsonProperty("fail_cd")
    private String failCd;

    @ApiModelProperty("장애조치방법")  // Y VARCHAR2(7)
    @JsonProperty("fail_act_cd")
    private String failActCd;

    @ApiModelProperty("장애 부품 관리번호")  // Y NUMBER(10)
    @JsonProperty("part_nmbr")
    private Long partNmbr;

    @ApiModelProperty("장애조치일시")  // Y VARCHAR2(14)
    @JsonProperty("act_dt")
    private String actDt;

    @ApiModelProperty("서비스영향")  // Y CHAR(1)
    @JsonProperty("svc_yn")
    private String svcYn;

    @ApiModelProperty("서비스개시일시")  // Y VARCHAR2(14)
    @JsonProperty("svc_str_dt")
    private String svcStrDt;

    @ApiModelProperty("장애원인")  // Y VARCHAR2(256)
    @JsonProperty("fail_cause")
    private String failCause;

    @ApiModelProperty("조치내용")  // Y VARCHAR2(256)
    @JsonProperty("act_desc")
    private String actDesc;

    @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("step_desc")    // STEP_CD
    private String stepDesc;

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

    @ApiModelProperty("장애유형 설명")
    @JsonProperty("fail_desc")    // FAIL_CD
    private String failDesc;

    @ApiModelProperty("장애조치방법 설명")
    @JsonProperty("fail_act_desc")    // FAIL_ACT_CD
    private String failActDesc;

    @ApiModelProperty("서비스영향 설명")
    @JsonProperty("svc_desc")    // SVC_YN
    private String svcDesc;

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

    @ApiModelProperty("부품명")  // Y VARCHAR2(100)
    @JsonProperty("part_nm")
    private String partNm;

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

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

        @ApiModelProperty("조치차수, Nullable = N, NUMBER(3)")  // N NUMBER(3)
        @JsonProperty("act_seq")
        @PositiveOrZero
        private Integer actSeq;

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

        @ApiModelProperty("장애조치자명, Nullable = Y, VARCHAR2(30)")  // Y VARCHAR2(30)
        @JsonProperty("act_man")
        @Size(min=1, max=30)
        private String actMan;

        @ApiModelProperty("진행상태, Nullable = Y, VARCHAR2(7)")  // Y VARCHAR2(7)
        @JsonProperty("step_cd")
        @Size(min=1, max=7)
        private String stepCd;

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

        @ApiModelProperty("장애유형, Nullable = Y, VARCHAR2(7)")  // Y VARCHAR2(7)
        @JsonProperty("fail_cd")
        @Size(min=1, max=7)
        private String failCd;

        @ApiModelProperty("장애조치방법, Nullable = Y, VARCHAR2(7)")  // Y VARCHAR2(7)
        @JsonProperty("fail_act_cd")
        @Size(min=1, max=7)
        private String failActCd;

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

        @ApiModelProperty("장애조치일시, Nullable = Y, VARCHAR2(14)")  // Y VARCHAR2(14)
        @JsonProperty("act_dt")
        @Size(min=1, max=14)
        private String actDt;

        @ApiModelProperty("서비스영향, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("svc_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String svcYn;

        @ApiModelProperty("서비스개시일시, Nullable = Y, VARCHAR2(14)")  // Y VARCHAR2(14)
        @JsonProperty("svc_str_dt")
        @Size(min=1, max=14)
        private String svcStrDt;

        @ApiModelProperty("장애원인, Nullable = Y, VARCHAR2(256)")  // Y VARCHAR2(256)
        @JsonProperty("fail_cause")
        @Size(min=1, max=256)
        private String failCause;

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

        @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 TbFcltFailActUpdReq(String fail_no, Integer act_seq, String reg_dt, String act_man, String step_cd, String fail_ocrr_cd, String fail_cd, String fail_act_cd, Long part_nmbr, String act_dt, String svc_yn, String svc_str_dt, String fail_cause, String act_desc, String etc_rmk, String use_yn) {
            this.failNo = fail_no;
            this.actSeq = act_seq;
            this.regDt = reg_dt;
            this.actMan = act_man;
            this.stepCd = step_cd;
            this.failOcrrCd = fail_ocrr_cd;
            this.failCd = fail_cd;
            this.failActCd = fail_act_cd;
            this.partNmbr = part_nmbr;
            this.actDt = act_dt;
            this.svcYn = svc_yn;
            this.svcStrDt = svc_str_dt;
            this.failCause = fail_cause;
            this.actDesc = act_desc;
            this.etcRmk = etc_rmk;
            this.useYn = use_yn;
        }

        public TbFcltFailAct toEntity() {
            return TbFcltFailAct.builder()
                    .failNo(this.failNo)
                    .actSeq(this.actSeq)
                    .regDt(this.regDt)
                    .actMan(this.actMan)
                    .stepCd(this.stepCd)
                    .failOcrrCd(this.failOcrrCd)
                    .failCd(this.failCd)
                    .failActCd(this.failActCd)
                    .partNmbr(this.partNmbr)
                    .actDt(this.actDt)
                    .svcYn(this.svcYn)
                    .svcStrDt(this.svcStrDt)
                    .failCause(this.failCause)
                    .actDesc(this.actDesc)
                    .etcRmk(this.etcRmk)
                    .useYn(this.useYn)
                    .build();
        }

    }

}
