package com.njcn.csharmonic.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;

    @ApiModelProperty("工程名称")
    private String engineeringName;

    @ApiModelProperty("项目名称")
    private String projectName;

    @ApiModelProperty("设备id")
    private String devId;

    @ApiModelProperty("设备名称")
    private String devName;


    public Float getExtent() {
        if (internationalValue == null || maxValue == null) {
            return null;
        }

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

}
