package com.njcn.harmonic.pojo.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDate;

@Data
public class LimitExtentVO {

    @ApiModelProperty("指标编码")
    private String code;
    @ApiModelProperty("指标名称")
    private String name;

    @ApiModelProperty("越限最大值")
    private float maxValue;

    @ApiModelProperty("国际限值")
    private float internationalValue;

    @ApiModelProperty("越限程度")
    private float extent;

    @ApiModelProperty("发生日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private LocalDate time;

    @ApiModelProperty(value = "监测点ID合格率的变电站/装置/母线/线路序号")
    private String lineId;
    @ApiModelProperty("监测点名称")
    private String lineName;


    public float getExtent() {
        if (internationalValue == 0) {
            return 0.00F;
        }
        if (maxValue == 0) {
            return 0.00F;
        }
        if (maxValue < internationalValue) {
            return 0.00F;
        }
        return (maxValue - internationalValue) / internationalValue * 100;
    }

}
