package com.xzzn.ems.domain;

import com.xzzn.common.annotation.Excel;
import com.xzzn.common.core.domain.BaseEntity;

import java.math.BigDecimal;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * 点位匹配对象 ems_point_match
 *
 * @author xzzn
 * @date 2025-11-04
 */
public class EmsPointMatch extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 设备ID，主键自增长 */
    private Long id;

    /** 存储点位名称 */
    @Excel(name = "存储点位名称")
    private String pointName;

    /** 点位所在表 */
    @Excel(name = "点位所在表")
    private String matchTable;

    /** 点位匹配字段 */
    @Excel(name = "点位匹配字段")
    private String matchField;

    /** 站点id */
    @Excel(name = "站点id")
    private String siteId;

    /** 设备类别，例如“STACK/CLUSTER/PCS等” */
    @Excel(name = "设备类别，例如“STACK/CLUSTER/PCS等”")
    private String deviceCategory;

    /** 数据点位 */
    @Excel(name = "数据点位")
    private String dataPoint;

    /** 数据点位名称 */
    @Excel(name = "数据点位名称")
    private String dataPointName;

    /** 数据点位来源设备 */
    @Excel(name = "数据点位来源设备")
    private String dataDevice;

    /** 数据单位 */
    @Excel(name = "数据单位")
    private String dataUnit;

    /** 地址 */
    @Excel(name = "寄存器地址")
    private String ipAddress;

    /** 端口 */
    @Excel(name = "端口")
    private Integer ipPort;

    /** 数据类型：1-瞬时值 2-累计值 */
    @Excel(name = "数据类型：1-瞬时值 2-累计值")
    private Long dataType;

    /** 点位是否需要区分多设备：0-不需要 1-需要 */
    @Excel(name = "点位是否需要区分多设备：0-不需要 1-需要")
    private Long needDiffDeviceId;

    /** 是否告警点位 */
    @Excel(name = "是否告警点位", readConverterExp = "0=否,1=是")
    private Integer isAlarm;

    /** 设备唯一标识符 */
    @Excel(name = "设备唯一标识符")
    private String deviceId;

    /** 设备点位数据转换公式：二次函数（f(x) = Ax² + Kx + B）  */
    /** 二次项系数 */
    @Excel(name = "二次项系数")
    private BigDecimal a;

    /** 一次项系数 */
    @Excel(name = "一次项系数")
    private BigDecimal k;

    /** 常量 */
    @Excel(name = "常量")
    private BigDecimal b;


    public void setId(Long id)
    {
        this.id = id;
    }

    public Long getId()
    {
        return id;
    }

    public void setPointName(String pointName)
    {
        this.pointName = pointName;
    }

    public String getPointName()
    {
        return pointName;
    }

    public void setMatchTable(String matchTable)
    {
        this.matchTable = matchTable;
    }

    public String getMatchTable()
    {
        return matchTable;
    }

    public void setMatchField(String matchField)
    {
        this.matchField = matchField;
    }

    public String getMatchField()
    {
        return matchField;
    }

    public void setSiteId(String siteId)
    {
        this.siteId = siteId;
    }

    public String getSiteId()
    {
        return siteId;
    }

    public void setDeviceCategory(String deviceCategory)
    {
        this.deviceCategory = deviceCategory;
    }

    public String getDeviceCategory()
    {
        return deviceCategory;
    }

    public void setDataPoint(String dataPoint)
    {
        this.dataPoint = dataPoint;
    }

    public String getDataPoint()
    {
        return dataPoint;
    }

    public void setDataPointName(String dataPointName)
    {
        this.dataPointName = dataPointName;
    }

    public String getDataPointName()
    {
        return dataPointName;
    }

    public void setDataDevice(String dataDevice)
    {
        this.dataDevice = dataDevice;
    }

    public String getDataDevice()
    {
        return dataDevice;
    }

    public void setDataUnit(String dataUnit)
    {
        this.dataUnit = dataUnit;
    }

    public String getDataUnit()
    {
        return dataUnit;
    }

    public void setIpAddress(String ipAddress)
    {
        this.ipAddress = ipAddress;
    }

    public String getIpAddress()
    {
        return ipAddress;
    }

    public Integer getIpPort() {
        return ipPort;
    }

    public void setIpPort(Integer ipPort) {
        this.ipPort = ipPort;
    }

    public void setDataType(Long dataType)
    {
        this.dataType = dataType;
    }

    public Long getDataType()
    {
        return dataType;
    }

    public void setNeedDiffDeviceId(Long needDiffDeviceId)
    {
        this.needDiffDeviceId = needDiffDeviceId;
    }

    public Long getNeedDiffDeviceId()
    {
        return needDiffDeviceId;
    }

    public Integer getIsAlarm() {
        return isAlarm;
    }

    public void setIsAlarm(Integer isAlarm) {
        this.isAlarm = isAlarm;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public BigDecimal getA() {
        return a;
    }

    public void setA(BigDecimal a) {
        this.a = a;
    }

    public BigDecimal getK() {
        return k;
    }

    public void setK(BigDecimal k) {
        this.k = k;
    }

    public BigDecimal getB() {
        return b;
    }

    public void setB(BigDecimal b) {
        this.b = b;
    }

    /** 二次函数公式转换点位数据: A * value² + K * value + B */
    public int convert(BigDecimal value) {
        return a.multiply(value.pow(2)).add(k.multiply(value)).add(b).intValueExact();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("pointName", getPointName())
                .append("matchTable", getMatchTable())
                .append("matchField", getMatchField())
                .append("siteId", getSiteId())
                .append("deviceCategory", getDeviceCategory())
                .append("dataPoint", getDataPoint())
                .append("dataPointName", getDataPointName())
                .append("dataDevice", getDataDevice())
                .append("dataUnit", getDataUnit())
                .append("ipAddress", getIpAddress())
                .append("ipPort", getIpPort())
                .append("dataType", getDataType())
                .append("needDiffDeviceId", getNeedDiffDeviceId())
                .append("createBy", getCreateBy())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .append("remark", getRemark())
                .append("isAlarm", getIsAlarm())
                .append("deviceId", getDeviceId())
                .append("a", getA())
                .append("k", getK())
                .append("b", getB())
                .toString();
    }
}
