package com.szpg.db.data;

import com.szpg.util.TimeFormat;
import z.json.JSONException;
import z.json.JSONObject;

import java.util.Date;

/**
 * 电力参数值监测数据表
 * 
 * @author admin
 *
 */
public class PgPower implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3227305968602654566L;
	
	private Integer id;
	private Date logtime;
	private Date uptime;
	private Integer pgdeviceid;
	private Float au;
	private Float bu;
	private Float cu;
	private Float ai;
	private Float bi;
	private Float ci;

	public Integer getId() {
		return id;
	}

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

	public Date getLogtime() {
		return logtime;
	}

	public void setLogtime(Date logtime) {
		this.logtime = logtime;
	}

	public Date getUptime() {
		return uptime;
	}

	public void setUptime(Date uptime) {
		this.uptime = uptime;
	}
	
	public Integer getPgdeviceid() {
		return pgdeviceid;
	}

	public void setPgdeviceid(Integer pgdeviceid) {
		this.pgdeviceid = pgdeviceid;
	}

	public Float getAu() {
		return au;
	}

	public void setAu(Float au) {
		this.au = au;
	}

	public Float getBu() {
		return bu;
	}

	public void setBu(Float bu) {
		this.bu = bu;
	}

	public Float getCu() {
		return cu;
	}

	public void setCu(Float cu) {
		this.cu = cu;
	}

	public Float getAi() {
		return ai;
	}

	public void setAi(Float ai) {
		this.ai = ai;
	}

	public Float getBi() {
		return bi;
	}

	public void setBi(Float bi) {
		this.bi = bi;
	}

	public Float getCi() {
		return ci;
	}

	public void setCi(Float ci) {
		this.ci = ci;
	}

	public void setTm(Date tm) {
		this.logtime = tm;
		this.uptime = tm;
	}
	
	public String getTmStr() {
		if (null != this.logtime) {
			return TimeFormat.formatTimestamp(logtime);
		} else {
			return "";
		}
	}
	
	public String getTmStrGB() {
		if (null != this.logtime) {
			return TimeFormat.format(logtime, "yyyyMMddHHmmss");
		} else {
			return "";
		}
	}

	@Override
	public String toString() {
		return "PgPower{" +
				"logtime=" + TimeFormat.formatTimestamp(logtime) +
				", au=" + au +
				", bu=" + bu +
				", cu=" + cu +
				", ai=" + ai +
				", bi=" + bi +
				", ci=" + ci +
				'}';
	}

	public JSONObject toJson() {
		JSONObject json = new JSONObject();
		try {
			json.put("time", this.getTmStr());
			json.put("au", this.getAu());
			json.put("bu", this.getBu());
			json.put("cu", this.getCu());
			json.put("ai", this.getAi());
			json.put("bi", this.getBi());
			json.put("ci", this.getCi());
		} catch (JSONException e) {
			e.printStackTrace();
		}

		return json;
	}
}
