package com.its.bis.entity;

import com.its.bis.dto.TbVmsCtlrDto;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;

/**
 *  DTO Class
 */
@Data
@Builder
public class TbVmsCtlr implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long vmsCtlrNmbr;
    private Integer vmsCtlrLocalNo;
    private String vmsCtlrId;
    private String vmsNm;
    private String vmsCtlrIp;
    private String vmsUsagTypeCd;
    private String vmsFrmTypeCd;
    private String vmsTypeCd;
    private String vmsModlTypeCd;
    private String vmsCtlrPort;
    private String operMode;
    private Integer cmncFailRate;
    private Integer brghNghtStep;
    private Integer brghWeekStep;
    private Integer defPhseChngCycl;
    private Integer modlErrRate;
    private Integer cmncfailSlotNmbr;
    private Integer pwerFailSlotNmbr;
    private String cmtrinfrCnctYn;
    private String wthrinfrCnctYn;
    private String envrinfrCnctYn;
    private Integer vmsMaxPhseNum;
    private String panlOnTime;
    private String panlOffTime;
    private Integer panlPwerMode;
    private Integer brghMode;
    private String istlLctnNm;
    private String trfcStrgUseYn;
    private Long vmsLocIfscId;
    private Integer fanRunTmpr;
    private Integer hetrRunTmpr;
    private Integer fanMode;
    private Integer hetrMode;
    private Integer brghCurrStep;
    private String istlLctnAddr;
    private Integer protocolVer;
    private String delYn;

    private int vmsWidth;
    private int vmsHeight;
    private int modlRowNum;
    private int modlColNum;
    private int powrRowNum;
    private int powrColNum;

    public TbVmsCtlrDto toDto() {
        if (this.vmsCtlrIp == null) this.vmsCtlrIp = "";
        this.vmsCtlrIp = this.vmsCtlrIp.trim();

        if (this.cmncFailRate == null) this.cmncFailRate = 10;
        if (this.brghNghtStep == null) this.brghNghtStep = 0;
        if (this.brghWeekStep == null) this.brghWeekStep = 10;
        if (this.defPhseChngCycl == null) this.defPhseChngCycl = 10;
        if (this.modlErrRate == null) this.modlErrRate = 10;
        if (this.cmncfailSlotNmbr == null) this.cmncfailSlotNmbr = 0;
        if (this.pwerFailSlotNmbr == null) this.pwerFailSlotNmbr = 0;
        if (this.vmsMaxPhseNum == null) this.vmsMaxPhseNum = 10;
        if (this.vmsLocIfscId == null) this.vmsLocIfscId = 0L;
        if (this.fanRunTmpr == null) this.fanRunTmpr = 0;
        if (this.hetrRunTmpr == null) this.hetrRunTmpr = 0;
        if (this.fanMode == null) this.fanMode = 10;
        if (this.hetrMode == null) this.hetrMode = 10;
        if (this.brghCurrStep == null) this.brghCurrStep = 10;
        if (this.protocolVer == null) this.protocolVer = 0;
        if (!"A".equals(this.operMode) && !"F".equals(this.operMode) && !"B".equals(this.operMode)) {
            this.operMode = "A";
        }

        if (this.panlOnTime == null) this.panlOnTime = "9999";
        if (this.panlOffTime == null) this.panlOffTime = "9999";
        if ("9999".equals(this.panlOnTime) || this.panlOnTime.length()  != 4) {
            this.panlOnTime  = "0000";
        }
        if ("9999".equals(this.panlOffTime) || this.panlOffTime.length()  != 4) {
            this.panlOffTime  = "0000";
        }

        TbVmsCtlrDto obj = TbVmsCtlrDto.builder()
                .vmsCtlrNmbr(this.vmsCtlrNmbr)
                .ctlrLocalNo(this.vmsCtlrLocalNo)
                .ctlrId(this.vmsCtlrId)
                .name(this.vmsNm)
                .ctlrIp(this.vmsCtlrIp)
                .usagTypeCd(this.vmsUsagTypeCd)
                .frmTypeCd(this.vmsFrmTypeCd)
                .typeCd(this.vmsTypeCd)
                .modlTypeCd(this.vmsModlTypeCd)
                .ctlrPort(this.vmsCtlrPort)
                .operMode(this.operMode)
                .cmncFailRate(this.cmncFailRate)
                .brghNghtStep(this.brghNghtStep)
                .brghWeekStep(this.brghWeekStep)
                .defPhseChngCycl(this.defPhseChngCycl)
                .modlErrRate(this.modlErrRate)
                .cmncfailSlotNmbr(this.cmncfailSlotNmbr)
                .pwerFailSlotNmbr(this.pwerFailSlotNmbr)
                 .cmtrinfrCnctYn(this.cmtrinfrCnctYn)
                .wthrinfrCnctYn(this.wthrinfrCnctYn)
                .envrinfrCnctYn(this.envrinfrCnctYn)
                .maxPhaseNum(this.vmsMaxPhseNum)
                .panlOnTime(this.panlOnTime)
                .panlOffTime(this.panlOffTime)
                .panlPwerMode(this.panlPwerMode)
                .brghMode(this.brghMode)
                .istlLctnNm(this.istlLctnNm)
                .trfcStrgUseYn(this.trfcStrgUseYn)
                .locIfscId(this.vmsLocIfscId)
                .fanRunTmpr(this.fanRunTmpr)
                .hetrRunTmpr(this.hetrRunTmpr)
                .fanMode(this.fanMode)
                .hetrMode(this.hetrMode)
                .brghCurrStep(this.brghCurrStep)
                .istlLctnAddr(this.istlLctnAddr)
                .protocolVer(this.protocolVer)
                .delYn(this.delYn)
                .vmsWidth(this.vmsWidth)
                .vmsHeight(this.vmsHeight)
                .modlRowNum(this.modlRowNum)
                .modlColNum(this.modlColNum)
                .powrRowNum(this.powrRowNum)
                .powrColNum(this.powrColNum)
                .build();

//        obj.init();
        return obj;
    }

}
