package com.shining.cloud.pojo.report;

import com.njcn.pojo.data.LimitRate;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Table(name = "APP_REPORT")
public class ReportData {
    @Id
    @Column(name = "REPORT_INDEX")
    private String reportIndex;

    @Column(name = "REPORT_NAME")
    private String reportName;

    @Column(name = "LINE_INDEX")
    private String lineIndex;

    @Column(name = "USER_INDEX")
    private String userIndex;

    @Column(name = "UPDATE_TIME")
    private Date updateTime;

    @Column(name = "START_TIME")
    private Date startTime;

    @Column(name = "END_TIME")
    private Date endTime;

    @Column(name = "SYSTEM_TYPE")
    private String sysType;

    @Column(name = "REPORT_TYPE")
    private String reportType;

    @Column(name = "REPORT_PATH")
    private String reportPath;

    @Column(name = "STATE")
    private Integer state;

    @Column(name = "ERROR_COUNT")
    private Integer errorCount;

    @Transient
    private LimitRate limitRate;

    @Transient
    private Integer total;

    @Transient
    private Integer tinterval;

    @Transient
    private List<String> listResult = new ArrayList<String>() {{
        add("该监测点暂无指标越限");
    }};

    @Transient
    private String name;

    public Integer getTinterval() {
        return tinterval;
    }

    public void setTinterval(Integer tinterval) {
        this.tinterval = tinterval;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
        listResult = new ArrayList<>();
        listResult.add("共发生" + total.toString() + "次暂降事件");
    }

    public List<String> getListResult() {
        return listResult;
    }

    public void setListResult(List<String> listResult) {
        this.listResult = listResult;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "ReportData{" +
                "reportIndex='" + reportIndex + '\'' +
                ", reportName='" + reportName + '\'' +
                ", lineIndex='" + lineIndex + '\'' +
                ", userIndex='" + userIndex + '\'' +
                ", updateTime=" + updateTime +
                ", startTime=" + startTime +
                ", endTime=" + endTime +
                ", sysType='" + sysType + '\'' +
                ", reportType='" + reportType + '\'' +
                ", reportPath='" + reportPath + '\'' +
                ", errorCount=" + errorCount +
                ", limitRate=" + limitRate +
                '}';
    }

    public LimitRate getLimitRate() {
        return limitRate;
    }

    public void setLimitRate(LimitRate limitRate) {
        if (listResult == null) {
            listResult = new ArrayList<>();
        }

        if (limitRate != null) {
            if (listResult.size() == 1 && listResult.get(0).equals("该监测点暂无指标越限")) {
                listResult = new ArrayList<>();
            }

            //packageData(limitRate.getFlicketAllTime(), "闪变总计算次数");
            packageData(limitRate.getFreqDevOverTime(), "频率偏差越限");
            packageData(limitRate.getVoltageDevOvertime(), "电压偏差越限");
            packageData(limitRate.getUBalanceOverTime(), "电压不平衡越限");
            packageData(limitRate.getFlickerOverTime(), "闪变越限");
            packageData(limitRate.getUAberranceOverTime(), "电压谐波畸变率越限");
            packageData(limitRate.getUHarm2OverTime(), "2次电压谐波含有率越限");
            packageData(limitRate.getUHarm3OverTime(), "3次电压谐波含有率越限");
            packageData(limitRate.getUHarm4OverTime(), "4次电压谐波含有率越限");
            packageData(limitRate.getUHarm5OverTime(), "5次电压谐波含有率越限");
            packageData(limitRate.getUHarm6OverTime(), "6次电压谐波含有率越限");
            packageData(limitRate.getUHarm7OverTime(), "7次电压谐波含有率越限");
            packageData(limitRate.getUHarm8OverTime(), "8次电压谐波含有率越限");
            packageData(limitRate.getUHarm9OverTime(), "9次电压谐波含有率越限");
            packageData(limitRate.getUHarm10OverTime(), "10次电压谐波含有率越限");
            packageData(limitRate.getUHarm11OverTime(), "11次电压谐波含有率越限");
            packageData(limitRate.getUHarm12OverTime(), "12次电压谐波含有率越限");
            packageData(limitRate.getUHarm13OverTime(), "13次电压谐波含有率越限");
            packageData(limitRate.getUHarm14OverTime(), "14次电压谐波含有率越限");
            packageData(limitRate.getUHarm15OverTime(), "15次电压谐波含有率越限");
            packageData(limitRate.getUHarm16OverTime(), "16次电压谐波含有率越限");
            packageData(limitRate.getUHarm17OverTime(), "17次电压谐波含有率越限");
            packageData(limitRate.getUHarm18OverTime(), "18次电压谐波含有率越限");
            packageData(limitRate.getUHarm19OverTime(), "19次电压谐波含有率越限");
            packageData(limitRate.getUHarm20OverTime(), "20次电压谐波含有率越限");
            packageData(limitRate.getUHarm21OverTime(), "21次电压谐波含有率越限");
            packageData(limitRate.getUHarm22OverTime(), "22次电压谐波含有率越限");
            packageData(limitRate.getUHarm23OverTime(), "23次电压谐波含有率越限");
            packageData(limitRate.getUHarm24OverTime(), "24次电压谐波含有率越限");
            packageData(limitRate.getUHarm25OverTime(), "25次电压谐波含有率越限");
            packageData(limitRate.getIHarm2OverTime(), "2次电流谐波幅值越限");
            packageData(limitRate.getIHarm3OverTime(), "3次电流谐波幅值越限");
            packageData(limitRate.getIHarm4OverTime(), "4次电流谐波幅值越限");
            packageData(limitRate.getIHarm5OverTime(), "5次电流谐波幅值越限");
            packageData(limitRate.getIHarm6OverTime(), "6次电流谐波幅值越限");
            packageData(limitRate.getIHarm7OverTime(), "7次电流谐波幅值越限");
            packageData(limitRate.getIHarm8OverTime(), "8次电流谐波幅值越限");
            packageData(limitRate.getIHarm9OverTime(), "9次电流谐波幅值越限");
            packageData(limitRate.getIHarm10OverTime(), "10次电流谐波幅值越限");
            packageData(limitRate.getIHarm11OverTime(), "11次电流谐波幅值越限");
            packageData(limitRate.getIHarm12OverTime(), "12次电流谐波幅值越限");
            packageData(limitRate.getIHarm13OverTime(), "13次电流谐波幅值越限");
            packageData(limitRate.getIHarm14OverTime(), "14次电流谐波幅值越限");
            packageData(limitRate.getIHarm15OverTime(), "15次电流谐波幅值越限");
            packageData(limitRate.getIHarm16OverTime(), "16次电流谐波幅值越限");
            packageData(limitRate.getIHarm17OverTime(), "17次电流谐波幅值越限");
            packageData(limitRate.getIHarm18OverTime(), "18次电流谐波幅值越限");
            packageData(limitRate.getIHarm19OverTime(), "19次电流谐波幅值越限");
            packageData(limitRate.getIHarm20OverTime(), "20次电流谐波幅值越限");
            packageData(limitRate.getIHarm21OverTime(), "21次电流谐波幅值越限");
            packageData(limitRate.getIHarm22OverTime(), "22次电流谐波幅值越限");
            packageData(limitRate.getIHarm23OverTime(), "23次电流谐波幅值越限");
            packageData(limitRate.getIHarm24OverTime(), "24次电流谐波幅值越限");
            packageData(limitRate.getIHarm25OverTime(), "25次电流谐波幅值越限");
        }

        if (listResult.size() == 0) {
            this.listResult.add("该监测点暂无指标越限");
        }
    }

    private void packageData(Integer count, String des) {
        if (count.intValue() > 0) {
            if (des.equals("闪变越限")) {
                this.listResult.add(des + count * 120 + "分钟");
            } else {
                this.listResult.add(des + count * this.tinterval + "分钟");
            }
        }

    }

    public String getReportIndex() {
        return reportIndex;
    }

    public void setReportIndex(String reportIndex) {
        this.reportIndex = reportIndex;
    }

    public String getReportName() {
        return reportName;
    }

    public void setReportName(String reportName) {
        this.reportName = reportName;
    }

    public String getLineIndex() {
        return lineIndex;
    }

    public void setLineIndex(String lineIndex) {
        this.lineIndex = lineIndex;
    }

    public String getUserIndex() {
        return userIndex;
    }

    public void setUserIndex(String userIndex) {
        this.userIndex = userIndex;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getSysType() {
        return sysType;
    }

    public void setSysType(String sysType) {
        this.sysType = sysType;
    }

    public String getReportType() {
        return reportType;
    }

    public void setReportType(String reportType) {
        this.reportType = reportType;
    }

    public String getReportPath() {
        return reportPath;
    }

    public void setReportPath(String reportPath) {
        this.reportPath = reportPath;
    }

    public Integer getErrorCount() {
        return errorCount;
    }

    public void setErrorCount(Integer errorCount) {
        this.errorCount = errorCount;
    }

}
