package com.its.api.its.model.entity.link;

import com.its.api.its.model.dto.link.LinkParaDetlDto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@DynamicInsert
@DynamicUpdate
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "TB_LINK_PARA_DETL")
public class TbLinkParaDetl {

    @Id
    @Column(nullable = false, unique = true, length = 7)
    private Long    LINK_ID;                    //	N	NUMBER(10)	N			링크ID
    @Column(length = 6)
    private Integer FLTR_MIN_TFVL;              //	N	NUMBER(6)	Y	0		필터링 최소 교통량
    @Column(length = 6)
    private Integer FLTR_MAX_TFVL;              //	N	NUMBER(6)	Y	0		필터링 최대 교통량
    @Column(length = 6)
    private Integer FLTR_LWST_SPED;             //	N	NUMBER(3)	Y	0		필터링 최저 속도
    @Column(length = 3)
    private Integer FLTR_HGHS_SPED;             //	N	NUMBER(3)	Y	0		필터링 최고 속도
    @Column(columnDefinition = "NUMBER", length = 5, precision = 2)
    private Double  ADJS_WGHT_AVRG_PRE_1CYCL;   //	N	NUMBER(5,2)	Y	0		보정 가중치 평균 이전 1주기
    @Column(columnDefinition = "NUMBER", length = 5, precision = 2)
    private Double  ADJS_WGHT_AVRG_PRE_2CYCL;   //	N	NUMBER(5,2)	Y	0		보정 가중치 평균 이전 2주기
    @Column(columnDefinition = "NUMBER", length = 5, precision = 2)
    private Double  ADJS_WGHT_AVRG_PRE_3CYCL;   //	N	NUMBER(5,2)	Y	0		보정 가중치 평균 이전 3주기
    @Column(columnDefinition = "CHAR", length = 1)
    @ColumnDefault(value = "N")
    private String  ADJS_15M_PTRN_APLY_YN;      //	N	CHAR(1)	    Y	'N'		보정 15분 패턴 적용 여부
    @Column(length = 2)
    private Integer ADJS_SHTR_MISS_DECS_CYCL;   //	N	NUMBER(2)	Y			보정 단기 결측 판단 주기
    @Column(columnDefinition = "NUMBER", length = 3, precision = 2)
    private Double  SMTH_LWST_SPED_FCTR;        //	N	NUMBER(3,2)	Y	0		평활화 최저 속도 계수
    @Column(columnDefinition = "NUMBER", length = 3, precision = 2)
    private Double  SMTH_HGHS_SPED_FCTR;        //	N	NUMBER(3,2)	Y	0		평활화 최고 속도 계수
    @Column(columnDefinition = "NUMBER", length = 5, precision = 2)
    private Double  SMTH_WGHT_AVRG_PRST;        //	N	NUMBER(5,2)	Y	0		평활화 가중치 평균 현재
    @Column(columnDefinition = "NUMBER", length = 5, precision = 2)
    private Double  SMTH_WGHT_AVRG_PRE_1CYCL;   //	N	NUMBER(5,2)	Y	0		평활화 가중치 평균 이전 1주기
    @Column(columnDefinition = "NUMBER", length = 5, precision = 2)
    private Double  SMTH_WGHT_AVRG_PRE_2CYCL;   //	N	NUMBER(5,2)	Y	0		평활화 가중치 평균 이전 2주기


    public TbLinkParaDetl(Long LINK_ID) {
        this.LINK_ID = LINK_ID;
    }

    public void updateInfo(LinkParaDetlDto.LinkParaDetlUpdateReq req) {
        this.FLTR_MIN_TFVL            = req.getFLTR_MIN_TFVL();
        this.FLTR_MAX_TFVL            = req.getFLTR_MAX_TFVL();
        this.FLTR_LWST_SPED           = req.getFLTR_LWST_SPED();
        this.FLTR_HGHS_SPED           = req.getFLTR_HGHS_SPED();
        this.ADJS_WGHT_AVRG_PRE_1CYCL = req.getADJS_WGHT_AVRG_PRE_1CYCL();
        this.ADJS_WGHT_AVRG_PRE_2CYCL = req.getADJS_WGHT_AVRG_PRE_2CYCL();
        this.ADJS_WGHT_AVRG_PRE_3CYCL = req.getADJS_WGHT_AVRG_PRE_3CYCL();
        this.ADJS_15M_PTRN_APLY_YN    = req.getADJS_15M_PTRN_APLY_YN();
        this.ADJS_SHTR_MISS_DECS_CYCL = req.getADJS_SHTR_MISS_DECS_CYCL();
        this.SMTH_LWST_SPED_FCTR      = req.getSMTH_LWST_SPED_FCTR();
        this.SMTH_HGHS_SPED_FCTR      = req.getSMTH_HGHS_SPED_FCTR();
        this.SMTH_WGHT_AVRG_PRST      = req.getSMTH_WGHT_AVRG_PRST();
        this.SMTH_WGHT_AVRG_PRE_1CYCL = req.getSMTH_WGHT_AVRG_PRE_1CYCL();
        this.SMTH_WGHT_AVRG_PRE_2CYCL = req.getSMTH_WGHT_AVRG_PRE_2CYCL();

    }
}
