package com.utic.center.utic.traf.server.dto;

import lombok.*;

import java.io.Serializable;

@Data
public class LinkTrafVal implements Serializable {
    private static final long serialVersionUID = 1L;

    private LinkTrafState state;     // 값의 상태

    private String centerId;        // 센터 ID
    private Integer speed;          // 통행속도
    private Integer travelTime;     // 통행시간

    public LinkTrafVal() {
        this.state = new LinkTrafState();
        init();
    }

    public void init() {
        this.state.init();
        //this.centerId = "C00";
        this.speed = 0;
        this.travelTime = 0;
    }

//    public LinkTrafCenterDto toDto(String linkId, int linkLevel, String regDate, LinkTrafMiss missPsd) {
//        LinkTrafCenterDto dto = new LinkTrafCenterDto(linkId, linkLevel);
//        dto.setMissValueYn(this.getState().getMissValueYn());
//        dto.setRegDate(regDate);
//        dto.setSpeed(this.speed);
//        dto.setTravelTime(this.travelTime);
//        dto.setTrafficGrade("0" + this.getState().getTrafficGrade());
//        dto.setIncidentId("");
//        dto.setDataResType(this.getState().getDataResType());
//        dto.setCenterId(this.centerId);
//        dto.setPsdMissValueYn(missPsd.getMissValueYn());
//        dto.setPsdSpeed(missPsd.getSpeed());
//        dto.setKnnSpeed(0);
//        dto.setKnnCnt(0);
//        return dto;
//    }

    public void setTraffic(LinkTrafState.TRAFFIC_CRT_DATA_TYPE crtDataType, LinkCollectDto traffic) {
        setTraffic(crtDataType, traffic.getCenterId(), traffic.getSpeed(), traffic.getMissValueYn(), traffic.getDataResType());
    }
    public void setTraffic(LinkTrafState.TRAFFIC_CRT_DATA_TYPE crtDataType, String centerId, Integer speed, String missValueYn, String dataResType) {
        this.centerId = centerId;
        this.speed = speed;
        this.travelTime = 0;

        this.state.setState(true);
        this.state.setCrtDataType(crtDataType);
        this.state.setMissValueYn(missValueYn);
        this.state.setDataResType(dataResType);
        this.state.setTrafficGrade(0);
    }

}
