package com.casic.PgInterface.intelPlan.dto;

import com.casic.PgInterface.devTable.manager.PgRoadManager;
import com.casic.PgInterface.intelPlan.domain.PgPileAcu;

import java.util.ArrayList;
import java.util.List;

public class PgPileAcuDTO {

    private Long id;
    private String acuCode;//编号
    private Long length;//长度
    private String road;//界面类型

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAcuCode() {
        return acuCode;
    }

    public void setAcuCode(String acuCode) {
        this.acuCode = acuCode;
    }

    public Long getLength() {
        return length;
    }

    public void setLength(Long length) {
        this.length = length;
    }

    public String getRoad() {
        return road;
    }

    public void setRoad(String road) {
        this.road = road;
    }

    public static PgPileAcuDTO ConvertToDTO(PgPileAcu pgPileAcu, PgRoadManager pgRoadManager){
        PgPileAcuDTO pgPileAcuDTO=new PgPileAcuDTO();

        pgPileAcuDTO.setId(pgPileAcu.getId());
        pgPileAcuDTO.setAcuCode(pgPileAcu.getAcuCode());
        pgPileAcuDTO.setLength(pgPileAcu.getLength());

        if(pgPileAcu.getRoadId()==null||pgRoadManager.get(pgPileAcu.getRoadId())==null)
            pgPileAcuDTO.setRoad("");
        else
            pgPileAcuDTO.setRoad(pgRoadManager.get(pgPileAcu.getRoadId()).getRoadName());

        return pgPileAcuDTO;
    }

    public static List<PgPileAcuDTO> ConvertToDTOList(List<PgPileAcu> pgPileAcuList,PgRoadManager pgRoadManager){

        List<PgPileAcuDTO> pgPileAcuDTOList=new ArrayList<>();
        for(PgPileAcu pgPileAcu:pgPileAcuList){
            pgPileAcuDTOList.add(ConvertToDTO(pgPileAcu,pgRoadManager));
        }

        return pgPileAcuDTOList;
    }

}
