package com.zcxk.rmcp.api.dto.readmeter;

import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zcxk.core.utils.NumberDistri;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author linqingwei
 * @date 2021-08-11 14:22
 */
@Data
public class WaterMeterDto implements Comparable<WaterMeterDto> {
    @ApiModelProperty(value="id")
    private Long id;

    @ApiModelProperty(value="租户")
    private String tenantId;

    @ApiModelProperty(value="分类")
    private Integer categoryId;

    @ApiModelProperty(value="公司")
    private Integer companyOrgId;

    @ApiModelProperty(value="部门")
    private Integer deptOrgId;

    @ApiModelProperty(value="产品")
    private Integer productId;

    @ApiModelProperty(value="设备编号")
    private String deviceNo;

    @ApiModelProperty(value="电子号")
    private String meterNo;

    @ApiModelProperty(value="档案号")
    private String fileNo;

    @ApiModelProperty(value="铅封号")
    private String sealNo;

    @ApiModelProperty(value="设备状态 1、正常 2、离线 3、报警 4、未启用")
    private Integer deviceStatus;

    @ApiModelProperty(value="地址")
    private String address;

    @ApiModelProperty(value="经度")
    private BigDecimal lng;

    @ApiModelProperty(value="维度")
    private BigDecimal lat;

    @ApiModelProperty(value="设备类型id")
    private Integer deviceTypeId;

    @ApiModelProperty(value="小区id")
    private Integer communityId;

    @ApiModelProperty(value="读数")
    private String readData;

    @ApiModelProperty(value="阀门状态 0:关,1:开,2:无阀")
    private Integer valveStatus;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value="最后上报时间")
    private LocalDateTime lastReceiveTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value="创建时间")
    private LocalDateTime createDate;

    @ApiModelProperty(value="更新人")
    private String updateBy;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value="更新时间")
    private LocalDateTime updateDate;

    @ApiModelProperty(value="产品名称")
    private String productName;

    @ApiModelProperty(value="产品型号")
    private String productModel;

    @ApiModelProperty(value="厂商名称")
    private String manufacturerName;

    @ApiModelProperty(value="公司名称")
    private String companyName;

    @ApiModelProperty(value="部门名称")
    private String deptName;

    @ApiModelProperty(value="小区名称")
    private String communityName;


    @Override
    public int compareTo(WaterMeterDto dto) {
        if(!StrUtil.equals(tenantId,dto.tenantId))return -1;
        if(!NumberDistri.integerEquals(categoryId,dto.categoryId))return -1;
        if(!NumberDistri.integerEquals(companyOrgId,dto.companyOrgId))return -1;
        if(!StrUtil.equals(companyName,dto.companyName))return -1;
        if(!NumberDistri.integerEquals(deptOrgId,dto.deptOrgId))return -1;
        if(!StrUtil.equals(deptName,dto.deptName))return -1;
        if(!NumberDistri.integerEquals(communityId,dto.communityId))return -1;
        if(!StrUtil.equals(communityName,dto.communityName))return -1;
        if(!StrUtil.equals(deviceNo,dto.deviceNo))return -1;
        if(!StrUtil.equals(meterNo,dto.meterNo))return -1;
        if(!StrUtil.equals(fileNo,dto.fileNo))return -1;
        if(!StrUtil.equals(address,dto.address))return -1;
        if(!NumberDistri.integerEquals(productId,dto.productId))return -1;
        if(!StrUtil.equals(productName,dto.productName))return -1;
        if(!StrUtil.equals(productModel,dto.productModel))return -1;
        if(!StrUtil.equals(manufacturerName,dto.manufacturerName))return -1;
        return 0;
    }
}
