package com.pqs9300.pojo.report;

import com.njcn.utils.PubUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.util.Date;

/**
 * @Author: Sunwei 【sunW2016@163.com】
 * @Description:
 * @Date: Create in 10:54 2018/6/7
 * @Modified By:
 */
public class ReportValue implements Serializable {
    private static final Logger logger = LoggerFactory.getLogger(ReportValue.class);
    private static final long serialVersionUID = 1120649990440477224L;
    private String phaseType; //A(AB)相，B(BC)相，C(CA)相，T总功
    private Float fmaxValue; //最大值
    private Float minValue; //最小值
    private Float meanValue; //平均值
    private Float cp95Value; //CP95值
    transient private Date timeid;//发生的时间
    transient private String strTime; //一天一条数据

    public String getStrTime() {
        return strTime;
    }

    public void setStrTime(String strTime) {
        this.strTime = strTime;
    }

    public Date getTimeid() {
        return timeid;
    }

    public void setTimeid(Date timeid) {
        try {
            this.strTime = PubUtils.date2String(timeid, "yyyy-MM-dd");
        } catch (Exception e) {
            logger.error("时间转换发生异常，异常是"+e.getMessage());
        }
    }

    public ReportValue() {
        super();
    }

    public ReportValue(String phaseType, Float maxValue, Float minValue, Float meanValue, Float cp95Value) {
        this.phaseType = phaseType;
        this.fmaxValue = transData(maxValue);
        this.minValue = transData(minValue);
        this.meanValue = transData(meanValue);
        this.cp95Value = transData(cp95Value);
    }

    @Override
    public String toString() {
        return "ReportValue{" +
                "phaseType='" + phaseType + '\'' +
                ", fmaxValue=" + fmaxValue +
                ", minValue=" + minValue +
                ", meanValue=" + meanValue +
                ", cp95Value=" + cp95Value +
                ", timeid=" + timeid +
                ", strTime='" + strTime + '\'' +
                '}';
    }

    public String getPhaseType() {
        return phaseType;
    }

    public void setPhaseType(String phaseType) {
        this.phaseType = phaseType;
    }

    public Float getFmaxValue() {
        return fmaxValue;
    }

    public void setFmaxValue(Float maxValue) {
        this.fmaxValue = transData(maxValue);
    }

    public Float getMinValue() {
        return minValue;
    }

    public void setMinValue(Float minValue) {
        this.minValue = transData(minValue);
    }

    public Float getMeanValue() {
        return meanValue;
    }

    public void setMeanValue(Float meanValue) {
        this.meanValue = transData(meanValue);
    }

    public Float getCp95Value() {
        return cp95Value;
    }

    public void setCp95Value(Float cp95Value) {
        this.cp95Value = transData(cp95Value);
    }

    private Float transData(Float f) {
        if (f == null) {
            return f;
        }

        float f1 = (float) (Math.round(f.floatValue() * 100)) / 100;
        return new Float(f1);
    }

}
