package com.its.op.dto.its.analysis;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;

/**
 * 교통 가공 통계 DTO Class
 */
@Data
@Builder
@ApiModel("TbTrfcPrcnStatDto(교통 가공 통계)")
public class TbTrfcPrcnStatDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("제공시각")  // N VARCHAR(14)
    @JsonProperty("prcn_dt")
    private String prcnDt;

    @ApiModelProperty("총링크수")
    @JsonProperty("tot_cnt")
    private int    totCnt;         // 총링크수
    @ApiModelProperty("생성수(제공건수)")
    @JsonProperty("offr_cnt")
    private int    offrCnt;        // 생성수(제공건수)
    @ApiModelProperty("원활")
    @JsonProperty("ltc1_cnt")
    private int    ltc1Cnt;        // 원활
    @ApiModelProperty("지체")
    @JsonProperty("ltc2_cnt")
    private int    ltc2Cnt;        // 지체
    @ApiModelProperty("정체")
    @JsonProperty("ltc3_cnt")
    private int    ltc3Cnt;        // 정체
    @ApiModelProperty("정보없음")
    @JsonProperty("ltc0_cnt")
    private int    ltc0Cnt;        // 정보없음

    public void makeOffrCnt() {
        if (this.ltc1Cnt > this.totCnt) {
            this.ltc1Cnt = this.totCnt;
        }
        if (this.ltc2Cnt > this.totCnt) {
            this.ltc2Cnt = this.totCnt;
        }
        if (this.ltc3Cnt > this.totCnt) {
            this.ltc3Cnt = this.totCnt;
        }

        this.offrCnt = this.ltc1Cnt + this.ltc2Cnt + this.ltc3Cnt;
        if (this.offrCnt > this.totCnt) {
            this.offrCnt = this.totCnt;
        }

        this.ltc0Cnt = this.totCnt - this.offrCnt;
    }
}
