package com.casic.PgInterface.intelPlan.dto;

import com.casic.PgInterface.devTable.manager.PgRoadManager;
import com.casic.PgInterface.intelPlan.domain.PgLineHole;
import com.casic.PgInterface.intelPlan.manager.PgPileAcuManager;

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

public class PgLineHoleDTO {

    private Long id;
    private String lineName;//管线
    private String road;
    private String pileAcuCode;//桩分区ID
    private Long secRow;//行号
    private Long secColumn;//列号
    private boolean active;//状态位

    public Long getId() {
        return id;
    }

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

    public String getLineName() {
        return lineName;
    }

    public void setLineName(String lineName) {
        this.lineName = lineName;
    }

    public String getRoad() {
        return road;
    }

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

    public String getPileAcuCode() {
        return pileAcuCode;
    }

    public void setPileAcuCode(String pileAcuCode) {
        this.pileAcuCode = pileAcuCode;
    }

    public Long getSecRow() {
        return secRow;
    }

    public void setSecRow(Long secRow) {
        this.secRow = secRow;
    }

    public Long getSecColumn() {
        return secColumn;
    }

    public void setSecColumn(Long secColumn) {
        this.secColumn = secColumn;
    }

    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public static PgLineHoleDTO ConvertToDTO(PgLineHole pgLineHole, PgPileAcuManager pgPileAcuManager, PgRoadManager pgRoadManager){

        PgLineHoleDTO pgLineHoleDTO=new PgLineHoleDTO();
        pgLineHoleDTO.setId(pgLineHole.getId());
        pgLineHoleDTO.setLineName(pgLineHole.getLineName());
        pgLineHoleDTO.setSecColumn(pgLineHole.getSecColumn());
        pgLineHoleDTO.setSecRow(pgLineHole.getSecRow());
        if(pgLineHole.getPileAcuId()==null||pgPileAcuManager.get(pgLineHole.getPileAcuId())==null)
            pgLineHoleDTO.setPileAcuCode("");
        else
        {
            pgLineHoleDTO.setPileAcuCode(pgPileAcuManager.get(pgLineHole.getPileAcuId()).getAcuCode());

            if(pgRoadManager.get(pgPileAcuManager.get(pgLineHole.getPileAcuId()).getRoadId())==null)
                pgLineHoleDTO.setRoad("");
            else
                pgLineHoleDTO.setRoad(pgRoadManager.get(pgPileAcuManager.get(pgLineHole.getPileAcuId()).getRoadId()).getRoadName());
        }

        return pgLineHoleDTO;

    }

    public static List<PgLineHoleDTO> ConvertToDTOList(List<PgLineHole> pgLineHoleList,
                                                       PgPileAcuManager pgPileAcuManager,PgRoadManager pgRoadManager){
        List<PgLineHoleDTO> pgLineHoleDTOList=new ArrayList<>();

        for(PgLineHole pgLineHole:pgLineHoleList){
            pgLineHoleDTOList.add(ConvertToDTO(pgLineHole,pgPileAcuManager,pgRoadManager));
        }

        return pgLineHoleDTOList;
    }
}
