package com.its.op.entity.its.scrs;

import com.its.op.dto.its.scrs.TbScSgnlIxrSttsDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;

/**
 * 신호 교차로 상태 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("신호 교차로 상태")
@Entity
@Table(name = "TB_SC_SGNL_IXR_STTS")
public class TbScSgnlIxrStts implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("신호 교차로 번호")  // N NUMBER(4)
    @Id
    @Column(name = "SGNL_IXR_NMBR", nullable = false, columnDefinition = "NUMBER", length = 4)
    private Integer sgnlIxrNmbr;

    @ApiModelProperty("LC 카운트")  // Y NUMBER(3)
    @Column(name = "LC_CNT", columnDefinition = "NUMBER", length = 3)
    private Integer lcCnt;

    @ApiModelProperty("제어모드(0: TRC, 1: TOD, 2: MAN)")  // Y NUMBER(1)
    @Column(name = "CNTL_MODE", columnDefinition = "NUMBER", length = 1)
    private Integer cntlMode;

    @ApiModelProperty("제어상태(0: 온라인, 1: 오프라인, 2: 트랜스, 3: 통신장애)")  // Y NUMBER(1)
    @Column(name = "CNTL_STTS", columnDefinition = "NUMBER", length = 1)
    private Integer cntlStts;

    @ApiModelProperty("특수제어(0: 없음, 1: 점멸, 2: 소등, 3: 수동, 4: 감응)")  // Y NUMBER(2)
    @Column(name = "SPCL_CNTL", columnDefinition = "NUMBER", length = 2)
    private Integer spclCntl;

    @ApiModelProperty("주기")  // Y NUMBER(3)
    @Column(name = "CYCL", columnDefinition = "NUMBER", length = 3)
    private Integer cycl;

    @ApiModelProperty("옵셋")  // Y NUMBER(3)
    @Column(name = "OFST", columnDefinition = "NUMBER", length = 3)
    private Integer ofst;

    @ApiModelProperty("A링 1현시")  // Y NUMBER(3)
    @Column(name = "ARING_1PHAS", columnDefinition = "NUMBER", length = 3)
    private Integer aring1phas;

    @ApiModelProperty("A링 2현시")  // Y NUMBER(3)
    @Column(name = "ARING_2PHAS", columnDefinition = "NUMBER", length = 3)
    private Integer aring2phas;

    @ApiModelProperty("A링 3현시")  // Y NUMBER(3)
    @Column(name = "ARING_3PHAS", columnDefinition = "NUMBER", length = 3)
    private Integer aring3phas;

    @ApiModelProperty("A링 4현시")  // Y NUMBER(3)
    @Column(name = "ARING_4PHAS", columnDefinition = "NUMBER", length = 3)
    private Integer aring4phas;

    @ApiModelProperty("A링 5현시")  // Y NUMBER(3)
    @Column(name = "ARING_5PHAS", columnDefinition = "NUMBER", length = 3)
    private Integer aring5phas;

    @ApiModelProperty("A링 6현시")  // Y NUMBER(3)
    @Column(name = "ARING_6PHAS", columnDefinition = "NUMBER", length = 3)
    private Integer aring6phas;

    @ApiModelProperty("A링 7현시")  // Y NUMBER(3)
    @Column(name = "ARING_7PHAS", columnDefinition = "NUMBER", length = 3)
    private Integer aring7phas;

    @ApiModelProperty("A링 8현시")  // Y NUMBER(3)
    @Column(name = "ARING_8PHAS", columnDefinition = "NUMBER", length = 3)
    private Integer aring8phas;

    @ApiModelProperty("B링 1현시")  // Y NUMBER(3)
    @Column(name = "BRING_1PHAS", columnDefinition = "NUMBER", length = 3)
    private Integer bring1phas;

    @ApiModelProperty("B링 2현시")  // Y NUMBER(3)
    @Column(name = "BRING_2PHAS", columnDefinition = "NUMBER", length = 3)
    private Integer bring2phas;

    @ApiModelProperty("B링 3현시")  // Y NUMBER(3)
    @Column(name = "BRING_3PHAS", columnDefinition = "NUMBER", length = 3)
    private Integer bring3phas;

    @ApiModelProperty("B링 4현시")  // Y NUMBER(3)
    @Column(name = "BRING_4PHAS", columnDefinition = "NUMBER", length = 3)
    private Integer bring4phas;

    @ApiModelProperty("B링 5현시")  // Y NUMBER(3)
    @Column(name = "BRING_5PHAS", columnDefinition = "NUMBER", length = 3)
    private Integer bring5phas;

    @ApiModelProperty("B링 6현시")  // Y NUMBER(3)
    @Column(name = "BRING_6PHAS", columnDefinition = "NUMBER", length = 3)
    private Integer bring6phas;

    @ApiModelProperty("B링 7현시")  // Y NUMBER(3)
    @Column(name = "BRING_7PHAS", columnDefinition = "NUMBER", length = 3)
    private Integer bring7phas;

    @ApiModelProperty("B링 8현시")  // Y NUMBER(3)
    @Column(name = "BRING_8PHAS", columnDefinition = "NUMBER", length = 3)
    private Integer bring8phas;

    @ApiModelProperty("현재 A링 현시")  // Y NUMBER(1)
    @Column(name = "PRST_ARING_PHAS", columnDefinition = "NUMBER", length = 1)
    private Integer prstAringPhas;

    @ApiModelProperty("현재 B링 현시")  // Y NUMBER(1)
    @Column(name = "PRST_BRING_PHAS", columnDefinition = "NUMBER", length = 1)
    private Integer prstBringPhas;

    @ApiModelProperty("함체 상태")  // Y NUMBER(1)
    @Column(name = "CBOX_STTS", columnDefinition = "NUMBER", length = 1)
    private Integer cboxStts;

    public TbScSgnlIxrSttsDto toDto() {
        return TbScSgnlIxrSttsDto.builder()
                .sgnlIxrNmbr(this.sgnlIxrNmbr)
                .lcCnt(this.lcCnt)
                .cntlMode(this.cntlMode)
                .cntlStts(this.cntlStts)
                .spclCntl(this.spclCntl)
                .cycl(this.cycl)
                .ofst(this.ofst)
                .aring1phas(this.aring1phas)
                .aring2phas(this.aring2phas)
                .aring3phas(this.aring3phas)
                .aring4phas(this.aring4phas)
                .aring5phas(this.aring5phas)
                .aring6phas(this.aring6phas)
                .aring7phas(this.aring7phas)
                .aring8phas(this.aring8phas)
                .bring1phas(this.bring1phas)
                .bring2phas(this.bring2phas)
                .bring3phas(this.bring3phas)
                .bring4phas(this.bring4phas)
                .bring5phas(this.bring5phas)
                .bring6phas(this.bring6phas)
                .bring7phas(this.bring7phas)
                .bring8phas(this.bring8phas)
                .prstAringPhas(this.prstAringPhas)
                .prstBringPhas(this.prstBringPhas)
                .cboxStts(this.cboxStts)
                .build();
    }

    public TbScSgnlIxrStts(Integer sgnlIxrNmbr) {
        this.sgnlIxrNmbr = sgnlIxrNmbr;
    }

    public void updateInfo(TbScSgnlIxrSttsDto.TbScSgnlIxrSttsUpdReq req) {
        this.lcCnt = req.getLcCnt();
        this.cntlMode = req.getCntlMode();
        this.cntlStts = req.getCntlStts();
        this.spclCntl = req.getSpclCntl();
        this.cycl = req.getCycl();
        this.ofst = req.getOfst();
        this.aring1phas = req.getAring1phas();
        this.aring2phas = req.getAring2phas();
        this.aring3phas = req.getAring3phas();
        this.aring4phas = req.getAring4phas();
        this.aring5phas = req.getAring5phas();
        this.aring6phas = req.getAring6phas();
        this.aring7phas = req.getAring7phas();
        this.aring8phas = req.getAring8phas();
        this.bring1phas = req.getBring1phas();
        this.bring2phas = req.getBring2phas();
        this.bring3phas = req.getBring3phas();
        this.bring4phas = req.getBring4phas();
        this.bring5phas = req.getBring5phas();
        this.bring6phas = req.getBring6phas();
        this.bring7phas = req.getBring7phas();
        this.bring8phas = req.getBring8phas();
        this.prstAringPhas = req.getPrstAringPhas();
        this.prstBringPhas = req.getPrstBringPhas();
        this.cboxStts = req.getCboxStts();
    }

}
