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

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

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

/**
 * 신호 제어기 DTO Class
 */
@Data
@Builder
@ApiModel("TbScSgnlCtlrDto(신호 제어기)")
public class TbScSgnlCtlrDto implements Serializable {
    private static final long serialVersionUID = 1L;

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

    @ApiModelProperty("X 좌표")  // Y NUMBER(10)
    @JsonProperty("x_crdn")
    private Double xCrdn;

    @ApiModelProperty("Y 좌표")  // Y NUMBER(10)
    @JsonProperty("y_crdn")
    private Double yCrdn;

    @ApiModelProperty("A링 1현시 코드")  // Y NUMBER(7)
    @JsonProperty("aring_1phas_cd")
    private Integer aring1phasCd;

    @ApiModelProperty("A링 2현시 코드")  // Y NUMBER(7)
    @JsonProperty("aring_2phas_cd")
    private Integer aring2phasCd;

    @ApiModelProperty("A링 3현시 코드")  // Y NUMBER(7)
    @JsonProperty("aring_3phas_cd")
    private Integer aring3phasCd;

    @ApiModelProperty("A링 4현시 코드")  // Y NUMBER(7)
    @JsonProperty("aring_4phas_cd")
    private Integer aring4phasCd;

    @ApiModelProperty("A링 5현시 코드")  // Y NUMBER(7)
    @JsonProperty("aring_5phas_cd")
    private Integer aring5phasCd;

    @ApiModelProperty("A링 6현시 코드")  // Y NUMBER(7)
    @JsonProperty("aring_6phas_cd")
    private Integer aring6phasCd;

    @ApiModelProperty("A링 7현시 코드")  // Y NUMBER(7)
    @JsonProperty("aring_7phas_cd")
    private Integer aring7phasCd;

    @ApiModelProperty("A링 8현시 코드")  // Y NUMBER(7)
    @JsonProperty("aring_8phas_cd")
    private Integer aring8phasCd;

    @ApiModelProperty("B링 1현시 코드")  // Y NUMBER(7)
    @JsonProperty("bring_1phas_cd")
    private Integer bring1phasCd;

    @ApiModelProperty("B링 2현시 코드")  // Y NUMBER(7)
    @JsonProperty("bring_2phas_cd")
    private Integer bring2phasCd;

    @ApiModelProperty("B링 3현시 코드")  // Y NUMBER(7)
    @JsonProperty("bring_3phas_cd")
    private Integer bring3phasCd;

    @ApiModelProperty("B링 4현시 코드")  // Y NUMBER(7)
    @JsonProperty("bring_4phas_cd")
    private Integer bring4phasCd;

    @ApiModelProperty("B링 5현시 코드")  // Y NUMBER(7)
    @JsonProperty("bring_5phas_cd")
    private Integer bring5phasCd;

    @ApiModelProperty("B링 6현시 코드")  // Y NUMBER(7)
    @JsonProperty("bring_6phas_cd")
    private Integer bring6phasCd;

    @ApiModelProperty("B링 7현시 코드")  // Y NUMBER(7)
    @JsonProperty("bring_7phas_cd")
    private Integer bring7phasCd;

    @ApiModelProperty("B링 8현시 코드")  // Y NUMBER(7)
    @JsonProperty("bring_8phas_cd")
    private Integer bring8phasCd;

    @ApiModel("TbScSgnlCtlrUpdReq(신호 제어기 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbScSgnlCtlrUpdReq {

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

        @ApiModelProperty("X 좌표, Nullable = Y, NUMBER(10)")  // Y NUMBER(10)
        @JsonProperty("x_crdn")
        @Positive
        private Double xCrdn;

        @ApiModelProperty("Y 좌표, Nullable = Y, NUMBER(10)")  // Y NUMBER(10)
        @JsonProperty("y_crdn")
        @Positive
        private Double yCrdn;

        @ApiModelProperty("A링 1현시 코드, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("aring_1phas_cd")
        @PositiveOrZero
        private Integer aring1phasCd;

        @ApiModelProperty("A링 2현시 코드, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("aring_2phas_cd")
        @PositiveOrZero
        private Integer aring2phasCd;

        @ApiModelProperty("A링 3현시 코드, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("aring_3phas_cd")
        @PositiveOrZero
        private Integer aring3phasCd;

        @ApiModelProperty("A링 4현시 코드, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("aring_4phas_cd")
        @PositiveOrZero
        private Integer aring4phasCd;

        @ApiModelProperty("A링 5현시 코드, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("aring_5phas_cd")
        @PositiveOrZero
        private Integer aring5phasCd;

        @ApiModelProperty("A링 6현시 코드, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("aring_6phas_cd")
        @PositiveOrZero
        private Integer aring6phasCd;

        @ApiModelProperty("A링 7현시 코드, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("aring_7phas_cd")
        @PositiveOrZero
        private Integer aring7phasCd;

        @ApiModelProperty("A링 8현시 코드, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("aring_8phas_cd")
        @PositiveOrZero
        private Integer aring8phasCd;

        @ApiModelProperty("B링 1현시 코드, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("bring_1phas_cd")
        @PositiveOrZero
        private Integer bring1phasCd;

        @ApiModelProperty("B링 2현시 코드, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("bring_2phas_cd")
        @PositiveOrZero
        private Integer bring2phasCd;

        @ApiModelProperty("B링 3현시 코드, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("bring_3phas_cd")
        @PositiveOrZero
        private Integer bring3phasCd;

        @ApiModelProperty("B링 4현시 코드, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("bring_4phas_cd")
        @PositiveOrZero
        private Integer bring4phasCd;

        @ApiModelProperty("B링 5현시 코드, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("bring_5phas_cd")
        @PositiveOrZero
        private Integer bring5phasCd;

        @ApiModelProperty("B링 6현시 코드, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("bring_6phas_cd")
        @PositiveOrZero
        private Integer bring6phasCd;

        @ApiModelProperty("B링 7현시 코드, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("bring_7phas_cd")
        @PositiveOrZero
        private Integer bring7phasCd;

        @ApiModelProperty("B링 8현시 코드, Nullable = Y, NUMBER(7)")  // Y NUMBER(7)
        @JsonProperty("bring_8phas_cd")
        @PositiveOrZero
        private Integer bring8phasCd;

        @Builder
        public TbScSgnlCtlrUpdReq(Integer sgnl_ixr_nmbr, Double x_crdn, Double y_crdn, Integer aring_1phas_cd, Integer aring_2phas_cd, Integer aring_3phas_cd, Integer aring_4phas_cd, Integer aring_5phas_cd, Integer aring_6phas_cd, Integer aring_7phas_cd, Integer aring_8phas_cd, Integer bring_1phas_cd, Integer bring_2phas_cd, Integer bring_3phas_cd, Integer bring_4phas_cd, Integer bring_5phas_cd, Integer bring_6phas_cd, Integer bring_7phas_cd, Integer bring_8phas_cd) {
            this.sgnlIxrNmbr = sgnl_ixr_nmbr;
            this.xCrdn = x_crdn;
            this.yCrdn = y_crdn;
            this.aring1phasCd = aring_1phas_cd;
            this.aring2phasCd = aring_2phas_cd;
            this.aring3phasCd = aring_3phas_cd;
            this.aring4phasCd = aring_4phas_cd;
            this.aring5phasCd = aring_5phas_cd;
            this.aring6phasCd = aring_6phas_cd;
            this.aring7phasCd = aring_7phas_cd;
            this.aring8phasCd = aring_8phas_cd;
            this.bring1phasCd = bring_1phas_cd;
            this.bring2phasCd = bring_2phas_cd;
            this.bring3phasCd = bring_3phas_cd;
            this.bring4phasCd = bring_4phas_cd;
            this.bring5phasCd = bring_5phas_cd;
            this.bring6phasCd = bring_6phas_cd;
            this.bring7phasCd = bring_7phas_cd;
            this.bring8phasCd = bring_8phas_cd;
        }

        public TbScSgnlCtlr toEntity() {
            return TbScSgnlCtlr.builder()
                    .sgnlIxrNmbr(this.sgnlIxrNmbr)
                    .xCrdn((long) (this.xCrdn * 1000000))
                    .yCrdn((long) (this.yCrdn * 1000000))
                    .aring1phasCd(this.aring1phasCd)
                    .aring2phasCd(this.aring2phasCd)
                    .aring3phasCd(this.aring3phasCd)
                    .aring4phasCd(this.aring4phasCd)
                    .aring5phasCd(this.aring5phasCd)
                    .aring6phasCd(this.aring6phasCd)
                    .aring7phasCd(this.aring7phasCd)
                    .aring8phasCd(this.aring8phasCd)
                    .bring1phasCd(this.bring1phasCd)
                    .bring2phasCd(this.bring2phasCd)
                    .bring3phasCd(this.bring3phasCd)
                    .bring4phasCd(this.bring4phasCd)
                    .bring5phasCd(this.bring5phasCd)
                    .bring6phasCd(this.bring6phasCd)
                    .bring7phasCd(this.bring7phasCd)
                    .bring8phasCd(this.bring8phasCd)
                    .build();
        }

    }

}
