package com.zcxk.charge.api.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @description
 * @author  wangli
 * @data 2020/12/7 10:21
 */
@Data
@ApiModel("数据内容")
public class MonitorDataChartReportValueDto implements  Comparable<MonitorDataChartReportValueDto>, Serializable {

    private static final long serialVersionUID = 6248751275101485917L;
    @ApiModelProperty("X轴数字")
    private Integer dateLabel;
    @ApiModelProperty("X轴时间")
    private String dateStringLabel;
    @ApiModelProperty("数据带单位")
    private String monitorData;
    @ApiModelProperty("数据值")
    private Double data;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
    @ApiModelProperty("日期时间")
    private LocalDateTime date;


    @Override
    public int compareTo(MonitorDataChartReportValueDto o) {
        return toInt(this.getDateStringLabel()) - toInt(o.getDateStringLabel());
    }

    private int toInt(String str ){
        if (StringUtils.isEmpty(str)){
            str = "0";
        }
        str = str.replaceAll("-", "");
        return Integer.parseInt(str);
    }
}
