package com.szpg.db.data; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; import z.json.JSONException; import z.json.JSONObject; /** * 井盖状态数据表 * * @author admin * */ public class PgJgStat implements java.io.Serializable { /** * */ private static final long serialVersionUID = -3706226324665928352L; private Integer id; private Date logtime; private Date uptime; private Integer pgdeviceid; private String jgopen; private Boolean jglock; 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 String getJgopen() { return jgopen; } public void setJgopen(String jgopen) { this.jgopen = jgopen; } public Boolean getJglock() { return jglock; } public void setJglock(Boolean jglock) { this.jglock = jglock; } 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 "PgJgStat[open=" + jgopen + ", lock=" + jglock + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } public JSONObject toJson() { JSONObject json = new JSONObject(); try { json.put("time", this.getTmStr()); json.put("open", null != this.getJgopen() ? URLEncoder.encode(getJgopen(), "UTF-8") : ""); json.put("lock", null != this.getJglock() && this.getJglock() == true ? URLEncoder.encode("井盖锁定", "UTF-8") : URLEncoder.encode("井盖解锁", "UTF-8")); json.put("runStat", null != this.getJglock() && this.getJglock() == true ? "0" : "1"); } catch (JSONException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return json; } }