package com.casic.PgInterface.devTable.dto;

import com.casic.PgInterface.devTable.domain.PgPartition;
import com.casic.PgInterface.devTable.manager.PgRoadManager;

import java.text.SimpleDateFormat;

/**
 * Created by yxw on 2017/11/2.
 */
public class PgPartitionDto{

    private String id;
    private String parName;//分区名称
    private String road;//所属道路
    private  String pgPosition;//仓段位置
    private String pgNum;//仓位数量
    private String pgType;//仓位类型
    private String pgLength;//分区长度
    private String buildDate;//建设年代
    private String material;//建设材质
    private String active;//状态位

    public String getId() {
        return id;
    }

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

    public String getParName() {
        return parName;
    }

    public void setParName(String parName) {
        this.parName = parName;
    }

    public String getActive() {
        return active;
    }

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

    public String getRoad() {
        return road;
    }

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

    public String getPgPosition() {
        return pgPosition;
    }

    public void setPgPosition(String pgPosition) {
        this.pgPosition = pgPosition;
    }

    public String getPgNum() {
        return pgNum;
    }

    public void setPgNum(String pgNum) {
        this.pgNum = pgNum;
    }

    public String getPgType() {
        return pgType;
    }

    public void setPgType(String pgType) {
        this.pgType = pgType;
    }

    public String getPgLength() {
        return pgLength;
    }

    public void setPgLength(String pgLength) {
        this.pgLength = pgLength;
    }

    public String getBuildDate() {
        return buildDate;
    }

    public void setBuildDate(String buildDate) {
        this.buildDate = buildDate;
    }

    public String getMaterial() {
        return material;
    }

    public void setMaterial(String material) {
        this.material = material;
    }

    public PgPartitionDto(PgPartition pgPartition,PgRoadManager pgRoadManager)
    {
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");

        this.setId(String.valueOf(pgPartition.getId()));
        this.setParName(pgPartition.getParName());
        if(Long.valueOf(pgPartition.getPgRoadId())==null||pgRoadManager.get(pgPartition.getPgRoadId())==null)
            this.setRoad("");
        else
            this.setRoad(pgRoadManager.get(pgPartition.getPgRoadId()).getRoadName());
        this.setPgPosition(pgPartition.getPgPosition());
        this.setPgNum(pgPartition.getPgNum());
        this.setPgType(pgPartition.getPgType());
        this.setPgLength(pgPartition.getPgLength());
        this.setBuildDate(sdf.format(pgPartition.getBuildDate()));
        this.setMaterial(pgPartition.getMaterial());
        this.setActive(String.valueOf(pgPartition.getActive()));
    }

}