package com.its.op.dto.its.statistics;

import com.its.utils.ItsUtils;
import io.swagger.annotations.ApiModel;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@ApiModel(description = "기간검색 파라미터")
public class TrafficTermParam extends QueryCondParam {
    private String ID;
    private String FROM_DT;
    private String TO_DT;

    public TrafficTermParam(String ID, String FROM_DT, String TO_DT) {
        this.ID = ID;

        int fromDateLength = FROM_DT.length();
        switch(fromDateLength) {
            case  4: // YYYY
                this.FROM_DT = FROM_DT + "0101000000";
                break;
            case  6: // YYYYMM
                this.FROM_DT = FROM_DT + "01000000";
                break;
            case  8: // YYYYMMDD
                this.FROM_DT = FROM_DT + "000000";
                break;
            case 10: // YYYYMMDDHH24
                this.FROM_DT = FROM_DT + "0000";
                break;
            case 12: // YYYYMMDDHH24MI
                this.FROM_DT = FROM_DT + "00";
                break;
            default:
                this.FROM_DT = FROM_DT;
                break;
        }

        int toDateLength = TO_DT.length();
        switch(toDateLength) {
            case  4: // YYYY
                this.TO_DT = TO_DT + "1231235959";
                break;
            case  6: // YYYYMM
                this.TO_DT = ItsUtils.getLastDayOfMonth(TO_DT) + "235959";
                break;
            case  8: // YYYYMMDD
                this.TO_DT = TO_DT + "235959";
                break;
            case 10: // YYYYMMDDHH24
                this.TO_DT = TO_DT + "5959";
                break;
            case 12: // YYYYMMDDHH24MI
                this.TO_DT = TO_DT + "59";
                break;
            default:
                this.TO_DT = TO_DT;
                break;
        }
    }
}
