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

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

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

    @ApiModelProperty("시설물 유형")  // N VARCHAR2(7)
    @JsonProperty("fclt_type")
    private String fcltType;

    @ApiModelProperty("시설물 ID")  // N VARCHAR2(30)
    @JsonProperty("fclt_id")
    private String fcltId;

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

    @ApiModelProperty("설치 위치 주소")  // Y VARCHAR2(200)
    @JsonProperty("istl_lctn_addr")
    private String istlLctnAddr;

    @ApiModelProperty("모델 명")  // Y VARCHAR2(50)
    @JsonProperty("mdl_nm")
    private String mdlNm;

    @ApiModelProperty("사용 년수")  // Y NUMBER(3)
    @JsonProperty("use_year")
    private Integer useYear;

    @ApiModelProperty("설치일")  // Y VARCHAR2(8)
    @JsonProperty("istl_dt")
    private String istlDt;

    @ApiModelProperty("제조업체 ID")  // Y VARCHAR2(30)
    @JsonProperty("mnfc_cmpy_id")
    private String mnfcCmpyId;

    @ApiModelProperty("설치업체 ID")  // Y VARCHAR2(30)
    @JsonProperty("istl_cmpy_id")
    private String istlCmpyId;

    @ApiModelProperty("유지보수업체 ID")  // Y VARCHAR2(30)
    @JsonProperty("maint_cmpy_id")
    private String maintCmpyId;

    @ApiModelProperty("RFID ID")  // Y VARCHAR2(30)
    @JsonProperty("rfid_id")
    private String rfidId;

    @ApiModelProperty("관리책임자-정 사원번호(ID)")  // Y VARCHAR2(20)
    @JsonProperty("main_user_id")
    private String mainUserId;

    @ApiModelProperty("관리책임자-부 사원번호(ID)")  // Y VARCHAR2(20)
    @JsonProperty("sub_user_id")
    private String subUserId;

    @ApiModelProperty("유효기간")  // Y VARCHAR2(8)
    @JsonProperty("valid_ymd")
    private String validYmd;

    @ApiModelProperty("사업단계")  // Y VARCHAR2(7)
    @JsonProperty("work_step")
    private String workStep;

    @ApiModelProperty("폐기 일시")  // Y VARCHAR2(14)
    @JsonProperty("abdn_dt")
    private String abdnDt;

    @ApiModelProperty("금액")  // Y NUMBER(15)
    @JsonProperty("amt")
    private Long amt;

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

    // Code Description Field
    @ApiModelProperty("사업단계")  // Y VARCHAR2(7)
    @JsonProperty("work_step_desc")
    private String workStepDesc;

    @ApiModelProperty("제조업체 명")  // Y VARCHAR2(30)
    @JsonProperty("mnfc_cmpy_nm")
    private String mnfcCmpyNm;

    @ApiModelProperty("설치업체 명")  // Y VARCHAR2(30)
    @JsonProperty("istl_cmpy_nm")
    private String istlCmpyNm;

    @ApiModelProperty("유지보수업체 명")  // Y VARCHAR2(30)
    @JsonProperty("maint_cmpy_nm")
    private String maintCmpyNm;

    @ApiModelProperty("관리책임자-정 사원번호(ID)")  // Y VARCHAR2(20)
    @JsonProperty("main_user_nm")
    private String mainUserNm;

    @ApiModelProperty("관리책임자-부 사원번호(ID)")  // Y VARCHAR2(20)
    @JsonProperty("sub_user_nm")
    private String subUserNm;

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

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

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

        @ApiModelProperty("시설물 유형, Nullable = N, VARCHAR2(7)")  // N VARCHAR2(7)
        @JsonProperty("fclt_type")
        @Size(min=1, max=7)
        private String fcltType;

        @ApiModelProperty("시설물 ID, Nullable = N, VARCHAR2(30)")  // N VARCHAR2(30)
        @JsonProperty("fclt_id")
        @Size(min=1, max=30)
        private String fcltId;

        @ApiModelProperty("시설물 위치, Nullable = Y, VARCHAR2(100)")  // Y VARCHAR2(100)
        @JsonProperty("fclt_lctn")
        @Size(min=1, max=100)
        private String fcltLctn;

        @ApiModelProperty("설치 위치 주소, Nullable = Y, VARCHAR2(200)")  // Y VARCHAR2(200)
        @JsonProperty("istl_lctn_addr")
        @Size(max=200)
        private String istlLctnAddr;

        @ApiModelProperty("모델 명, Nullable = Y, VARCHAR2(50)")  // Y VARCHAR2(50)
        @JsonProperty("mdl_nm")
        @Size(max=50)
        private String mdlNm;

        @ApiModelProperty("사용 년수, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("use_year")
        @PositiveOrZero
        private Integer useYear;

        @ApiModelProperty("설치일, Nullable = Y, VARCHAR2(8)")  // Y VARCHAR2(8)
        @JsonProperty("istl_dt")
        @Size(max=8)
        private String istlDt;

        @ApiModelProperty("제조업체 ID, Nullable = Y, VARCHAR2(30)")  // Y VARCHAR2(30)
        @JsonProperty("mnfc_cmpy_id")
        @Size(max=30)
        private String mnfcCmpyId;

        @ApiModelProperty("설치업체 ID, Nullable = Y, VARCHAR2(30)")  // Y VARCHAR2(30)
        @JsonProperty("istl_cmpy_id")
        @Size(max=30)
        private String istlCmpyId;

        @ApiModelProperty("유지보수업체 ID, Nullable = Y, VARCHAR2(30)")  // Y VARCHAR2(30)
        @JsonProperty("maint_cmpy_id")
        @Size(max=30)
        private String maintCmpyId;

        @ApiModelProperty("RFID ID, Nullable = Y, VARCHAR2(30)")  // Y VARCHAR2(30)
        @JsonProperty("rfid_id")
        @Size(max=30)
        private String rfidId;

        @ApiModelProperty("관리책임자-정 사원번호(ID), Nullable = Y, VARCHAR2(20)")  // Y VARCHAR2(20)
        @JsonProperty("main_user_id")
        @Size(max=20)
        private String mainUserId;

        @ApiModelProperty("관리책임자-부 사원번호(ID), Nullable = Y, VARCHAR2(20)")  // Y VARCHAR2(20)
        @JsonProperty("sub_user_id")
        @Size(max=20)
        private String subUserId;

        @ApiModelProperty("유효기간, Nullable = Y, VARCHAR2(8)")  // Y VARCHAR2(8)
        @JsonProperty("valid_ymd")
        @Size(max=8)
        private String validYmd;

        @ApiModelProperty("사업단계, Nullable = Y, VARCHAR2(7)")  // Y VARCHAR2(7)
        @JsonProperty("work_step")
        @Size(max=7)
        private String workStep;

        @ApiModelProperty("폐기 일시, Nullable = Y, VARCHAR2(14)")  // Y VARCHAR2(14)
        @JsonProperty("abdn_dt")
        @Size(max=14)
        private String abdnDt;

        @ApiModelProperty("금액, Nullable = Y, NUMBER(15)")  // Y NUMBER(15)
        @JsonProperty("amt")
        @PositiveOrZero
        private Long amt;

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

        @Builder
        public TbFcltInfrUpdReq(Long fclt_nmbr, String fclt_type, String fclt_id, String fclt_lctn, String istl_lctn_addr,
                                String mdl_nm, Integer use_year, String istl_dt, String mnfc_cmpy_id, String istl_cmpy_id, String maint_cmpy_id,
                                String rfid_id, String main_user_id, String sub_user_id, String valid_ymd, String work_step, String abdn_dt, Long amt, String del_yn) {
            this.fcltNmbr = fclt_nmbr;
            this.fcltType = fclt_type;
            this.fcltId = fclt_id;
            this.fcltLctn = fclt_lctn;
            this.istlLctnAddr = istl_lctn_addr;
            this.mdlNm = mdl_nm;
            this.useYear = use_year;
            this.istlDt = istl_dt;
            this.mnfcCmpyId = mnfc_cmpy_id;
            this.istlCmpyId = istl_cmpy_id;
            this.maintCmpyId = maint_cmpy_id;
            this.rfidId = rfid_id;
            this.mainUserId = main_user_id;
            this.subUserId = sub_user_id;
            this.validYmd = valid_ymd;
            this.workStep = work_step;
            this.abdnDt = abdn_dt;
            this.amt = amt;
            this.delYn = del_yn;
        }

        public TbFcltInfr toEntity() {
            return TbFcltInfr.builder()
                    .fcltNmbr(this.fcltNmbr)
                    .fcltType(this.fcltType)
                    .fcltId(this.fcltId)
                    .fcltLctn(this.fcltLctn)
                    .istlLctnAddr(this.istlLctnAddr)
                    .mdlNm(this.mdlNm)
                    .useYear(this.useYear)
                    .istlDt(this.istlDt)
                    .mnfcCmpyId(this.mnfcCmpyId)
                    .istlCmpyId(this.istlCmpyId)
                    .maintCmpyId(this.maintCmpyId)
                    .rfidId(this.rfidId)
                    .mainUserId(this.mainUserId)
                    .subUserId(this.subUserId)
                    .validYmd(this.validYmd)
                    .workStep(this.workStep)
                    .abdnDt(this.abdnDt)
                    .amt(this.amt)
                    .delYn(this.delYn)
                    .build();
        }

    }

}
