package com.gyee.runeconomy.dto.result;

import com.gyee.runeconomy.dto.speed.Desc;
import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;

/**
 * 数据准备的测点
 * remark  0：表示该字段不在前端显示  1：表示该字段在前端显示
 */
@Data
public class PowerPointData {

    public PowerPointData(){}

    public PowerPointData(String[] str, boolean isFilter){
        DecimalFormat df = new DecimalFormat("0.00");
            this.time = str[0];
            this.power = Double.valueOf(df.format(Double.valueOf(str[1])));
            this.speed = Double.valueOf(df.format(Double.valueOf(str[2])));
            this.rr = Double.valueOf(df.format(Double.valueOf(str[3])));
            this.mxzt = Double.valueOf(str[4]).intValue();
            this.dl = Double.valueOf(df.format(Double.valueOf(str[5])));
            this.qfzt = Double.valueOf(str[6]).intValue();
            this.fx = Double.valueOf(df.format(Double.valueOf(str[7])));
            this.dfwc = Double.valueOf(df.format(Double.valueOf(str[8])));
            this.angle = Double.valueOf(df.format(Double.valueOf(str[9])));
            this.hjwd = Double.valueOf(df.format(Double.valueOf(str[10])));
            this.yp1 = Double.valueOf(df.format(Double.valueOf(str[11])));
            this.yp2 = Double.valueOf(df.format(Double.valueOf(str[12])));
            this.yp3 = Double.valueOf(df.format(Double.valueOf(str[13])));
            if (isFilter){
                BigDecimal bd = new BigDecimal(str[str.length - 1]);
                bd = bd.setScale(2, RoundingMode.HALF_UP);
                this.filter =  bd.intValue();
            }


    }

    //时间
    @Desc(des = "时间", remark = "1")
    private String time = "1970-01-01 00:00:00";

    //功率 AI114
    @Desc(des = "功率", uniformCode = "AI114", remark = "1")
    private double power = 0;

    //风速 AI066
    @Desc(des = "风速", uniformCode = "AI066", remark = "1")
    private double speed = 0;

    //转速 AI060
    @Desc(des = "转速",  uniformCode = "AI060", remark = "1")
    private double rr = 0;

    //明细状态
    // 0-待机  1-手动停机  2-正常发电  3-缺陷降出力  4-限电降出力  5-限电停机  6-故障停机
    // 7-场内受累停机  8-检修停机  9-场内受累检修  10-电网受累  11-环境受累  12-风机离线 MXZT
    @Desc(des = "风机状态",  uniformCode = "MXZT", remark = "1")
    private int mxzt = 0;

    //电量 RFDL AI121
    @Desc(des = "电量",  uniformCode = "AI121", remark = "1")
    private double dl = 0;

    //欠发状态 SSQFZT
    @Desc(des = "欠发状态",  uniformCode = "SSQFZT", remark = "1")
    private int qfzt = 0;


    //风向 AI067
    @Desc(des = "风向",  uniformCode = "AI067", remark = "1")
    private double fx = 0;

    //对风误差
    @Desc(des = "对风误差",  uniformCode = "AI073", remark = "1")
    private double dfwc = 0;

    //偏航角度 AI073
    @Desc(des = "偏航角度",  uniformCode = "AI028", remark = "1")
    private double angle = 0;

    /**
     * AI072
     */
    @Desc(des = "环境温度",  uniformCode = "AI072", remark = "1")
    private double hjwd = 0;

    @Desc(des = "叶片1",  uniformCode = "AI082", remark = "1")
    private double yp1 = 0;

    @Desc(des = "叶片2",  uniformCode = "AI083", remark = "1")
    private double yp2 = 0;

    @Desc(des = "叶片3",  uniformCode = "AI084", remark = "1")
    private double yp3 = 0;

//    是否过滤  0:不过滤 1:过滤
    @Desc(des = "筛选", remark = "0")
    private int filter = 0;

    private String wtId;

    @Override
    public String toString() {
        return "PowerPointData{" +
                "time='" + time + '\'' +
                ", power=" + power +
                ", speed=" + speed +
                ", rr=" + rr +
                ", mxzt=" + mxzt +
                ", dl=" + dl +
                ", qfzt=" + qfzt +
                ", fx=" + fx +
                ", dfwc=" + dfwc +
                ", angle=" + angle +
                ", hjwd=" + hjwd +
//                ", filter=" + filter +
                ", wtId='" + wtId + '\'' +
                '}';
    }
}

