package com.its.op.dto.its.scrs;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.scrs.TbScTodCnfg;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.PositiveOrZero;
import java.io.Serializable;

/**
 * TOD 구성 DTO Class
 */
@Data
@Builder
@ApiModel("TbScTodCnfgDto(TOD 구성)")
public class TbScTodCnfgDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("신호 교차로 번호")  // N NUMBER(4)
    @JsonProperty("sgnl_ixr_nmbr")
    private Integer sgnlIxrNmbr;

    @ApiModelProperty("일반 제어용 플랜: 1~5, 시차 제어용 플랜: 6~10")  // N NUMBER(2)
    @JsonProperty("ixr_oper_mode")
    private Integer ixrOperMode;

    @ApiModelProperty("시간별운영계획번호(1~16번까지있음)")  // N NUMBER(2)
    @JsonProperty("ixr_phas_oper_plan_nmbr")
    private Integer ixrPhasOperPlanNmbr;

    @ApiModelProperty("시간")  // Y NUMBER(2)
    @JsonProperty("hh")
    private Integer hh;

    @ApiModelProperty("분")  // Y NUMBER(2)
    @JsonProperty("mm")
    private Integer mm;

    @ApiModelProperty("주기")  // Y NUMBER(3)
    @JsonProperty("cycl")
    private Integer cycl;

    @ApiModelProperty("옵셋")  // Y NUMBER(3)
    @JsonProperty("ofst")
    private Integer ofst;

    @ApiModelProperty("A링 1현시")  // Y NUMBER(3)
    @JsonProperty("aring_1phas")
    private Integer aring1phas;

    @ApiModelProperty("A링 2현시")  // Y NUMBER(3)
    @JsonProperty("aring_2phas")
    private Integer aring2phas;

    @ApiModelProperty("A링 3현시")  // Y NUMBER(3)
    @JsonProperty("aring_3phas")
    private Integer aring3phas;

    @ApiModelProperty("A링 4현시")  // Y NUMBER(3)
    @JsonProperty("aring_4phas")
    private Integer aring4phas;

    @ApiModelProperty("A링 5현시")  // Y NUMBER(3)
    @JsonProperty("aring_5phas")
    private Integer aring5phas;

    @ApiModelProperty("A링 6현시")  // Y NUMBER(3)
    @JsonProperty("aring_6phas")
    private Integer aring6phas;

    @ApiModelProperty("A링 7현시")  // Y NUMBER(3)
    @JsonProperty("aring_7phas")
    private Integer aring7phas;

    @ApiModelProperty("A링 8현시")  // Y NUMBER(3)
    @JsonProperty("aring_8phas")
    private Integer aring8phas;

    @ApiModelProperty("B링 1현시")  // Y NUMBER(3)
    @JsonProperty("bring_1phas")
    private Integer bring1phas;

    @ApiModelProperty("B링 2현시")  // Y NUMBER(3)
    @JsonProperty("bring_2phas")
    private Integer bring2phas;

    @ApiModelProperty("B링 3현시")  // Y NUMBER(3)
    @JsonProperty("bring_3phas")
    private Integer bring3phas;

    @ApiModelProperty("B링 4현시")  // Y NUMBER(3)
    @JsonProperty("bring_4phas")
    private Integer bring4phas;

    @ApiModelProperty("B링 5현시")  // Y NUMBER(3)
    @JsonProperty("bring_5phas")
    private Integer bring5phas;

    @ApiModelProperty("B링 6현시")  // Y NUMBER(3)
    @JsonProperty("bring_6phas")
    private Integer bring6phas;

    @ApiModelProperty("B링 7현시")  // Y NUMBER(3)
    @JsonProperty("bring_7phas")
    private Integer bring7phas;

    @ApiModelProperty("B링 8현시")  // Y NUMBER(3)
    @JsonProperty("bring_8phas")
    private Integer bring8phas;

    // Code Description Field
    @ApiModel("TbScTodCnfgUpdReq(TOD 구성 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbScTodCnfgUpdReq {

        @ApiModelProperty("신호 교차로 번호, Nullable = N, NUMBER(4)")  // N NUMBER(4)
        @JsonProperty("sgnl_ixr_nmbr")
        @PositiveOrZero
        private Integer sgnlIxrNmbr;

        @ApiModelProperty("일반 제어용 플랜: 1~5, 시차 제어용 플랜: 6~10, Nullable = N, NUMBER(2)")  // N NUMBER(2)
        @JsonProperty("ixr_oper_mode")
        @PositiveOrZero
        private Integer ixrOperMode;

        @ApiModelProperty("시간별운영계획번호(1~16번까지있음), Nullable = N, NUMBER(2)")  // N NUMBER(2)
        @JsonProperty("ixr_phas_oper_plan_nmbr")
        @PositiveOrZero
        private Integer ixrPhasOperPlanNmbr;

        @ApiModelProperty("시간, Nullable = Y, NUMBER(2)")  // Y NUMBER(2)
        @JsonProperty("hh")
        @PositiveOrZero
        private Integer hh;

        @ApiModelProperty("분, Nullable = Y, NUMBER(2)")  // Y NUMBER(2)
        @JsonProperty("mm")
        @PositiveOrZero
        private Integer mm;

        @ApiModelProperty("주기, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("cycl")
        @PositiveOrZero
        private Integer cycl;

        @ApiModelProperty("옵셋, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("ofst")
        @PositiveOrZero
        private Integer ofst;

        @ApiModelProperty("A링 1현시, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("aring_1phas")
        @PositiveOrZero
        private Integer aring1phas;

        @ApiModelProperty("A링 2현시, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("aring_2phas")
        @PositiveOrZero
        private Integer aring2phas;

        @ApiModelProperty("A링 3현시, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("aring_3phas")
        @PositiveOrZero
        private Integer aring3phas;

        @ApiModelProperty("A링 4현시, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("aring_4phas")
        @PositiveOrZero
        private Integer aring4phas;

        @ApiModelProperty("A링 5현시, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("aring_5phas")
        @PositiveOrZero
        private Integer aring5phas;

        @ApiModelProperty("A링 6현시, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("aring_6phas")
        @PositiveOrZero
        private Integer aring6phas;

        @ApiModelProperty("A링 7현시, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("aring_7phas")
        @PositiveOrZero
        private Integer aring7phas;

        @ApiModelProperty("A링 8현시, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("aring_8phas")
        @PositiveOrZero
        private Integer aring8phas;

        @ApiModelProperty("B링 1현시, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("bring_1phas")
        @PositiveOrZero
        private Integer bring1phas;

        @ApiModelProperty("B링 2현시, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("bring_2phas")
        @PositiveOrZero
        private Integer bring2phas;

        @ApiModelProperty("B링 3현시, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("bring_3phas")
        @PositiveOrZero
        private Integer bring3phas;

        @ApiModelProperty("B링 4현시, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("bring_4phas")
        @PositiveOrZero
        private Integer bring4phas;

        @ApiModelProperty("B링 5현시, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("bring_5phas")
        @PositiveOrZero
        private Integer bring5phas;

        @ApiModelProperty("B링 6현시, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("bring_6phas")
        @PositiveOrZero
        private Integer bring6phas;

        @ApiModelProperty("B링 7현시, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("bring_7phas")
        @PositiveOrZero
        private Integer bring7phas;

        @ApiModelProperty("B링 8현시, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("bring_8phas")
        @PositiveOrZero
        private Integer bring8phas;

        @Builder
        public TbScTodCnfgUpdReq(Integer sgnl_ixr_nmbr, Integer ixr_oper_mode, Integer ixr_phas_oper_plan_nmbr, Integer hh, Integer mm, Integer cycl, Integer ofst, Integer aring_1phas, Integer aring_2phas, Integer aring_3phas, Integer aring_4phas, Integer aring_5phas, Integer aring_6phas, Integer aring_7phas, Integer aring_8phas, Integer bring_1phas, Integer bring_2phas, Integer bring_3phas, Integer bring_4phas, Integer bring_5phas, Integer bring_6phas, Integer bring_7phas, Integer bring_8phas) {
            this.sgnlIxrNmbr = sgnl_ixr_nmbr;
            this.ixrOperMode = ixr_oper_mode;
            this.ixrPhasOperPlanNmbr = ixr_phas_oper_plan_nmbr;
            this.hh = hh;
            this.mm = mm;
            this.cycl = cycl;
            this.ofst = ofst;
            this.aring1phas = aring_1phas;
            this.aring2phas = aring_2phas;
            this.aring3phas = aring_3phas;
            this.aring4phas = aring_4phas;
            this.aring5phas = aring_5phas;
            this.aring6phas = aring_6phas;
            this.aring7phas = aring_7phas;
            this.aring8phas = aring_8phas;
            this.bring1phas = bring_1phas;
            this.bring2phas = bring_2phas;
            this.bring3phas = bring_3phas;
            this.bring4phas = bring_4phas;
            this.bring5phas = bring_5phas;
            this.bring6phas = bring_6phas;
            this.bring7phas = bring_7phas;
            this.bring8phas = bring_8phas;
        }

        public TbScTodCnfg toEntity() {
            return TbScTodCnfg.builder()
                    .sgnlIxrNmbr(this.sgnlIxrNmbr)
                    .ixrOperMode(this.ixrOperMode)
                    .ixrPhasOperPlanNmbr(this.ixrPhasOperPlanNmbr)
                    .hh(this.hh)
                    .mm(this.mm)
                    .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)
                    .build();
        }

    }

}
