package cn.estsh.i3plus.ext.mes.pojo.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.*;
import java.io.Serializable;

/**
 * @Author: xiangming.liao
 * @CreateDate: 2021/01/17 17:35 下午
 * @Description:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "MES_PROCESS_BOM", indexes = {
        @Index(columnList = "ORGANIZE_CODE,PART_NO,PROCESS_CODE")
})
@Api("工序BOM")
public class MesProcessBom extends BaseBean implements Serializable {

    private static final long serialVersionUID = -49978884836794657L;

    @Column(name = "PART_NO")
    @ApiParam("成品物料编码")
    private String partNo;

    @Column(name = "PART_NAME_RDD")
    @ApiParam("成品物料名称")
    private String partNameRdd;

    @Column(name = "ITEM_PART_NO")
    @ApiParam("原材料物料编码")
    private String itemPartNo;

    @Column(name = "ITEM_PART_NAME")
    @ApiParam("原材料物料名称")
    private String itemPartName;

    @Column(name = "PROCESS_CODE")
    @ApiParam("工序代码")
    private String processCode;

    @Column(name = "PROCESS_NAME")
    @ApiParam("工序名称")
    private String processName;

    @Column(name = "QTY", columnDefinition = "decimal(18,8)")
    @ColumnDefault("0")
    @ApiParam(value = "子零件数量", example = "0")
    private Double qty;

    /**
     *匹配规则：10=条码规则匹配、20=箱条码匹配、30=过程条码匹配、40=物料编码匹配。
     */
    @Column(name = "MATCH_RULE")
    @ApiParam(value = "匹配规则")
    private Integer matchRule;

    @Column(name = "IS_BIND_KEY")
    @ApiParam("是否绑定关键件")
    private Integer isBindKey;

    @Column(name = "IS_REPEAT")
    @ApiParam("是否可重复")
    private Integer isRepeat;

    @Column(name = "IS_CHECK")
    @ApiParam("是否检查")
    private Integer isCheck;

    @Column(name = "SEQ")
    @ApiParam("关键件序号")
    private Double seq;

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

    public int getIsRepeatVal() {
        return this.isRepeat == null ? 0 : this.isRepeat;
    }

    public int getIsCheckVal() {
        return this.isCheck == null ? 0 : this.isCheck;
    }

    public double getSeqVal() {
        return this.seq == null ? 0.0 : this.seq;
    }

}
