package com.gyee.wisdom.dao.sql.point.entity;

import com.gyee.wisdom.common.data.ToData;
import com.gyee.wisdom.common.data.point.ElectricalTestingPoint;
import com.gyee.wisdom.common.data.point.LevelTypeTestingPoint;
import com.gyee.wisdom.dao.sql.ModelConstants;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal;

/**
 *Author:Wanghs
 */

@Data
@NoArgsConstructor
@ToString
@EqualsAndHashCode()
@Entity
@Table(name = ModelConstants.LEVEL_TYPE_TESTING_POINT)
public class LevelTypeTestingPointEntity implements ToData<LevelTypeTestingPoint> {

    //编号(主键)
    @Id
    @Column(name = ModelConstants.ID_)
    private String id;

    //编码
    @Column(name = ModelConstants.CODE_)
    private String code;

    //名称
    @Column(name = ModelConstants.NAME_)
    private String name;

    //型号
    @Column(name = ModelConstants.MODEL_)
    private String model;

    //单位
    @Column(name = ModelConstants.VALUE_UNIT)
    private String valueUnit;

    //英文名称
    @Column(name = ModelConstants.ENGLISH_NAME)
    private String englishName;

    //最大值
    @Column(name = ModelConstants.MAX_VAL)
    private double maxVal;

    //最小值
    @Column(name = ModelConstants.MIN_VAL)
    private double minVal;

    //合理最大值
    @Column(name = ModelConstants.REASONABLE_MAX_VAL)
    private double reasonableMaxVal;

    //合理最小值
    @Column(name = ModelConstants.REASONABLE_MIN_VAL)
    private double reasonableMinVal;

    //统一编码
    @Column(name = ModelConstants.UNIFORM_CODE)
    private String uniformCode;

    //数据类型
    @Column(name = ModelConstants.DATA_TYPE)
    private String dataType;

    public LevelTypeTestingPointEntity(LevelTypeTestingPoint point){
        this.id = point.getId();
        this.code = point.getCode();
        this.name = point.getName();
        this.model = point.getModel();
        this.valueUnit = point.getValueUnit();
        this.englishName = point.getEnglishName();
        this.maxVal = point.getMaxVal();
        this.minVal = point.getMinVal();
        this.reasonableMaxVal = point.getReasonableMaxVal();
        this.reasonableMinVal = point.getReasonableMinVal();
        this.uniformCode = point.getUniformCode();
        this.dataType = point.getDataType();

    }

    @Override
    public LevelTypeTestingPoint toData() {

        LevelTypeTestingPoint data = new LevelTypeTestingPoint();
        data.setId(this.id);
        data.setCode(this.code);
        data.setName(this.name);
        data.setModel(this.model);
        data.setValueUnit(this.valueUnit);
        data.setEnglishName(this.englishName);
        data.setMaxVal(this.maxVal);
        data.setMinVal(this.minVal);
        data.setReasonableMaxVal(this.reasonableMaxVal);
        data.setReasonableMinVal(this.reasonableMinVal);
        data.setUniformCode(this.uniformCode);
        data.setDataType(this.dataType);
        return data;

    }
}
