package com.njcn.event.pojo.vo;

import io.swagger.annotations.ApiModel;
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 yzh
 * @date 2022/10/24
 */
@Data
@Builder
@ApiModel("获取暂态指标分布统计曲线图实体类")
public class EventFeatureAmplitudeCurveVO implements Serializable {

    private static final long serialVersionUID = 1L;

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

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

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

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

    }

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

        @ApiModelProperty(name = "measurementPointId", value = "监测点id")
        private String measurementPointId;

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

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

        @ApiModelProperty(name = "startTime", value = "开始时间")
        private LocalDateTime startTime;

        public static Comparator<EventFeatureAmplitudeCurveDataList> sortAscTime() {
            return Comparator.comparing(EventFeatureAmplitudeCurveDataList::getStartTime);
        }
    }
}
