package org.well.well.domain;

import org.well.well.core.util.DateUtils;

import javax.persistence.*;
import java.io.Serializable;
import java.text.ParseException;
import java.util.Date;
import java.util.Map;

/**
 * <p>
 * 水质监测仪上传数据表
 * </p>
 *
 * @author stylefeng123
 * @since 2019-10-28
 */
@Entity
@Table(name = "data_meter")
public class DataMeter implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID")
    private Long id;
    /**
     * 井编号
     */
    @Column(name ="WELL_CODE")
    private String wellCode;
    /**
     * 设备编号
     */
    @Column(name ="DEVCODE")
    private String devcode;
    /**
     * 温度
     */
    @Column(name ="temp")
    private String temp;
    /**
     * PH
     */
    @Column(name ="PH")
    private String ph;
    /**
     * 电导率
     */
    @Column(name ="conductivity")
    private String conductivity;
    /**
     * 溶解氧
     */
    @Column(name ="DO")
    private String do2;
    /**
     * 浊度
     */
    @Column(name ="turbidity")
    private String turbidity;
    /**
     * COD
     */
    @Column(name ="COD")
    private String cod;
    /**
     * 氨氮
     */
    @Column(name ="AN")
    private String an;
    /**
     * 总磷
     */
    @Column(name ="TP")
    private String tp;
    /**
     * 总氮
     */
    @Column(name ="TN")
    private String tn;
    /**
     * 状态描述
     */
    @Column(name ="DESCN")
    private String descn;
    /**
     * 采集时间
     */
    @Column(name ="UPTIME")
    private Date uptime;
    /**
     * 记录时间
     */
    @Column(name ="LOGTIME")
    private Date logtime;

    public Long getId() {
        return id;
    }

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

    public String getWellCode() {
        return wellCode;
    }

    public void setWellCode(String wellCode) {
        this.wellCode = wellCode;
    }

    public String getDevcode() {
        return devcode;
    }

    public void setDevcode(String devcode) {
        this.devcode = devcode;
    }

    public String getTemp() {
        return temp;
    }

    public void setTemp(String temp) {
        this.temp = temp;
    }

    public String getPh() {
        return ph;
    }

    public void setPh(String ph) {
        this.ph = ph;
    }

    public String getConductivity() {
        return conductivity;
    }

    public void setConductivity(String conductivity) {
        this.conductivity = conductivity;
    }

    public String getDo2() {
        return do2;
    }

    public void setDo2(String do2) {
        this.do2 = do2;
    }

    public String getTurbidity() {
        return turbidity;
    }

    public void setTurbidity(String turbidity) {
        this.turbidity = turbidity;
    }

    public String getCod() {
        return cod;
    }

    public void setCod(String cod) {
        this.cod = cod;
    }

    public String getAn() {
        return an;
    }

    public void setAn(String an) {
        this.an = an;
    }

    public String getTp() {
        return tp;
    }

    public void setTp(String tp) {
        this.tp = tp;
    }

    public String getTn() {
        return tn;
    }

    public void setTn(String tn) {
        this.tn = tn;
    }

    public String getDescn() {
        return descn;
    }

    public void setDescn(String descn) {
        this.descn = descn;
    }

    public Date getUptime() {
        return uptime;
    }

    public void setUptime(Date uptime) {
        this.uptime = uptime;
    }

    public Date getLogtime() {
        return logtime;
    }

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


    @Override
    public String toString() {
        return "DataMeter{" +
        "id=" + id +
        ", wellCode=" + wellCode +
        ", devcode=" + devcode +
        ", temp=" + temp +
        ", ph=" + ph +
        ", conductivity=" + conductivity +
        ", do=" + do2+
        ", turbidity=" + turbidity +
        ", cod=" + cod +
        ", an=" + an +
        ", tp=" + tp +
        ", tn=" + tn +
        ", descn=" + descn +
        ", uptime=" + uptime +
        ", logtime=" + logtime +
        "}";
    }

    public DataMeter(Map<String,String> meterMap,String wellCode) {
        this.devcode=(meterMap.get("devCode"));
        this.logtime=(new Date());
        try {
            this.uptime=(DateUtils.sdf4.parse(DateUtils.DateFormat(meterMap.get("DataTime"))));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        this.temp=(meterMap.get("temp"));
        this.ph=(meterMap.get("PH"));
        this.conductivity=(meterMap.get("conductivity"));
        this.do2=(meterMap.get("DO"));
        this.cod=(meterMap.get("COD"));
        this.turbidity=(meterMap.get("turbidity"));
        this.an=(meterMap.get("AN"));
        this.tp=(meterMap.get("TP"));
        this.tn=(meterMap.get("TN"));
        this.wellCode=wellCode;
    }
}
