package com.njcn.event.pojo.vo;

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

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * 电压容忍度曲线兼容性统计
 *
 * @author : zhaojun
 * @version : 1.0.0
 * @date : 2022年06月24日 11:02
 */
@Data
@Builder
public class VoltageToleranceCurveVO implements Serializable {
    private static final long serialVersionUID = -2659670722467310785L;

    @ApiModelProperty(name = "totalNumberOfEvents", value = "事件总数")
    private Integer totalNumberOfEvents;

    @ApiModelProperty(name = "VoltageToleranceCurveDataList", value = "图表数据")
    private List<VoltageToleranceCurveDataList> voltageToleranceCurveDataList;

    /**
     * 构建默认对象
     *
     * @return 默认对象
     */
    public static VoltageToleranceCurveVO empty() {
        return VoltageToleranceCurveVO.buildVO(0, Collections.emptyList());
    }

    /**
     * 构建默认对象
     *
     * @param numberEvents 事件总数
     * @param dataList     图表数据
     * @return 默认对象
     */
    public static VoltageToleranceCurveVO buildVO(int numberEvents, List<VoltageToleranceCurveDataList> dataList) {
        return VoltageToleranceCurveVO.builder().totalNumberOfEvents(numberEvents).voltageToleranceCurveDataList(dataList).build();

    }

    @Data
    public static class VoltageToleranceCurveDataList implements Serializable {
        private static final long serialVersionUID = 2693688079727369565L;

        @ApiModelProperty(name = "lineId", value = "LineId")
        private String lineId;

        @ApiModelProperty(name = "lineName", value = "监测点名称")
        private String lineName;

        @ApiModelProperty(name = "lineId",value ="暂态事件id")
        private String eventId;

        @ApiModelProperty(name = "persistTime", value = "持续时间（ms）")
        private Double persistTime;

        @ApiModelProperty(name = "eventValue", value = "特征幅值")
        private Double eventValue;

        @ApiModelProperty(name = "subName", value = "变电站名称")
        private String subName;

        @ApiModelProperty(name = "gdName", value = "供电公司名称")
        private String gdName;

        @ApiModelProperty(name = "time", value = "发生时刻")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS",timezone = "GMT+8")
        private LocalDateTime time;

        public static Comparator<VoltageToleranceCurveDataList> sortAscTime() {
            return Comparator.comparing(VoltageToleranceCurveDataList::getTime);
        }
    }
}
