package cn.estsh.i3plus.pojo.mes.bean;

import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;

/**
 * @Description :物料关键数据
 * @Reference :
 * @Author : crish
 * @CreateDate : 2019-05-15
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "MES_KP_DATA")
@Api("物料关键数据关系")
public class MesKpData extends BaseBean implements Serializable {
    private static final long serialVersionUID = 8243089140216459544L;

    @Column(name = "PART_NO")
    @ApiParam("物料号")
    private String partNo;

    @Column(name = "KEY_DATA_CODE")
    @ApiParam("关键数据代码")
    private String keyDataCode;

    @Column(name = "KEY_DATA_NAME")
    @ApiParam("关键数据名称")
    private String keyDataName;

    @Column(name = "KEY_DATA_COUNT")
    @ApiParam("关键数据数量")
    private Integer keyDataCount;

    @Column(name = "UPPER_LIMIT", columnDefinition = "decimal(18,8)")
    @ColumnDefault("0")
    @ApiParam("数据上限")
    private Double upperLimit;

    @Column(name = "LOWER_LIMIT", columnDefinition = "decimal(18,8)")
    @ColumnDefault("0")
    @ApiParam("数据下限")
    private Double lowerLimit;

    @Column(name = "WORK_CENTER_CODE")
    @ApiParam("工作中心代码")
    private String workCenterCode;

    @Column(name = "WORK_CELL_CODE")
    @ApiParam("工位")
    private String workCellCode;

    @Column(name = "TORQUE_GROUP")
    @ApiParam("扭矩组")
    private String torqueGroup;

    @Column(name = "TORQUE_GROUP_SEQ")
    @ApiParam("扭矩组顺序")
    private Integer torqueGroupSeq;

    @Column(name = "TORQUE")
    @ApiParam("扭矩项")
    private String torque;

    @Column(name = "TORQUE_SEQ")
    @ApiParam("扭矩项顺序")
    private Integer torqueSeq;

    @Column(name = "JOB_ID")
    @ApiParam("JOB_ID")
    private Integer jobId;

    @Column(name = "LAST_TIGHTENING_ID")
    @ApiParam("最后一次扭矩id")
    private Long lastTighteningId;

    @Transient
    @ApiParam("扭矩值")
    private Double torqueValue;

    @Transient
    @ApiParam("是否在范围之内")
    private Boolean ok;

    @Transient
    @ApiParam("应采个数")
    private Integer shouldNum;

    @Transient
    @ApiParam("实采个数")
    private Integer actualNum;

    @Transient
    @ApiParam("记录颜色")
    private String color;


    public double getKeyDataCountVal() {
        return this.keyDataCount == null ? 0 : this.keyDataCount;
    }

    public double getUpperLimitVal() {
        return this.upperLimit == null ? 0.0d : this.upperLimit;
    }

    public double getLowerLimitVal() {
        return this.lowerLimit == null ? 0.0d : this.lowerLimit;
    }
}
