package com.its.vms.domain;

import com.its.vms.dto.TbVmsIncdDto;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 *  DTO Class
 */
@Data
public class VmsEvehicle implements Serializable {
    private static final long serialVersionUID = 1L;

    private boolean ocrr;
    private boolean end;
    private boolean first;
    private Long    dtOcrr;
    private boolean download;
    private Long    dtDownload;

    private List<TbVmsIncdDto> units;

    public VmsEvehicle() {
        this.units = new ArrayList<>();
    }

    public int size() {
        return this.units.size();
    }

    public void add(TbVmsIncdDto data) {
        for (TbVmsIncdDto obj : this.units) {
            if (obj.getIncdOcrrId().equals(data.getIncdOcrrId())) {
                // 이미 존재하면 추가하지 않는다.
                return;
            }
        }

        if (data.getStrtLctnNm() == null || "".equals(data.getStrtLctnNm().trim())) {
            data.setStrtLctnNm(data.getDsplStrtNodeNm());
        }
        if (data.getEndLctnNm() == null || "".equals(data.getEndLctnNm().trim())) {
            data.setEndLctnNm(data.getDsplEndNodeNm());
        }
        data.setVmsIncdDetlTypeCd("X");
        data.setVmsIncdRstrTypeNm("주의요망");
        this.units.add(data);
    }

}
