package com.njcn.event.pojo.vo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Comparator;

/**
 * 暂降电压等级统计
 *
 * @author : zhaojun
 * @version : 1.0.0
 * @date : 2022年06月24日 11:02
 */
@Data
public class VoltageLevelCalculationVO implements Serializable {
    private static final long serialVersionUID = 3801801245395998386L;

    @ApiModelProperty(name = "voltageLevel", value = "电压等级")
    private String voltageLevel;

    @ApiModelProperty(name = "monitoringPoints", value = "监测点数")
    private Integer monitoringPoints;

    @ApiModelProperty(name = "frequency", value = "暂降次数")
    private Long frequency;

    /**
     * 电压等级升序排序,取KV单位前的数值
     *
     * @return 排序结果
     */
    public static Comparator<VoltageLevelCalculationVO> sortAscVoltageLevel() {
        return (o1, o2) -> {
            String l1 = o1.getVoltageLevel();
            String l2 = o2.getVoltageLevel();

            String sub1 = l1.substring(0, l1.length() - 2);
            String sub2 = l2.substring(0, l2.length() - 2);
            return Double.valueOf(sub1).compareTo(Double.valueOf(sub2));
        };
    }
}
