package com.casic.PgInterface.devData.dto;

import com.casic.PgInterface.devData.domain.PgTempHum;

import java.text.SimpleDateFormat;

/**
 * Created by yxw on 2017/11/28.
 */
public class PgTempHumDto{

    private String id;
    private String valueTemp;
    private String valueHum;
    private String upTime;
    private String logTime;
    private String devCode;
    private String devName;

    public String getId() {
        return id;
    }

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

    public String getValueTemp() {
        return valueTemp;
    }

    public void setValueTemp(String valueTemp) {
        this.valueTemp = valueTemp;
    }

    public String getValueHum() {
        return valueHum;
    }

    public void setValueHum(String valueHum) {
        this.valueHum = valueHum;
    }

    public String getUpTime() {
        return upTime;
    }

    public void setUpTime(String upTime) {
        this.upTime = upTime;
    }

    public String getLogTime() {
        return logTime;
    }

    public void setLogTime(String logTime) {
        this.logTime = logTime;
    }

    public String getDevCode() {
        return devCode;
    }

    public void setDevCode(String devCode) {
        this.devCode = devCode;
    }

    public String getDevName() {
        return devName;
    }

    public void setDevName(String devName) {
        this.devName = devName;
    }

    public PgTempHumDto(PgTempHum pgTempHum) {

        if(pgTempHum==null)
            return;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        this.setId(String.valueOf(pgTempHum.getId()));
        this.setValueHum(pgTempHum.getHum());
        this.setValueTemp(pgTempHum.getTemp());
        if (pgTempHum.getLogTime() != null)
            this.setLogTime(sdf.format(pgTempHum.getLogTime()));
        else
            this.setLogTime("");
        if (pgTempHum.getUpTime() != null)
            this.setUpTime(sdf.format(pgTempHum.getUpTime()));
        else
            this.setUpTime("");
        this.setDevCode(pgTempHum.getPgDeviceId().getDevCode());
        this.setDevName(pgTempHum.getPgDeviceId().getAssetName());
    }
}
