package com.njcn.advance.pojo.bo.responsibility;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 提取用采数据或者将用采数据写进excel的实体类
 *
 * @author hongawen
 * @date 2019/4/11 10:43
 */
@Data
public class UserDataExcel implements Serializable, Comparable<UserDataExcel> {

    @Excel(name = "时间")
    private String time;

    @Excel(name = "瞬时功率")
    private BigDecimal work;

    @Excel(name = "户号")
    private String userId;

    @Excel(name = "测量点局号")
    private String line;

    @Excel(name = "户名")
    private String userName;


    @Override
    public int compareTo(UserDataExcel o) {

        if (DateUtil.parse(this.time, DatePattern.NORM_DATETIME_PATTERN).getTime() > DateUtil.parse(o.getTime(), DatePattern.NORM_DATETIME_PATTERN).getTime()) {
            return 1;
        } else if (DateUtil.parse(this.time, DatePattern.NORM_DATETIME_PATTERN).getTime() == DateUtil.parse(o.getTime(), DatePattern.NORM_DATETIME_PATTERN).getTime()) {
            return 0;
        }
        return -1;
    }
}
