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 : jack.jia
 * @CreateDate : 2019-04-02
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "MES_STATION_BOM")
@Api("工位物料清单")
public class MesStationBom extends BaseBean implements Serializable {
    private static final long serialVersionUID = 1817387724628691734L;

    @Column(name = "PART_NO")
    @ApiParam("零件号")
    private String partNo;

    @Column(name = "PART_NAME")
    @ApiParam("产品物料名称")
    private String partName;

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

    @Column(name = "WORK_CELL_CODE")
    @ApiParam("工作单元")
    private String workCellCode;

    @Column(name = "ITEM_PART_NO")
    @ApiParam("子零件")
    private String itemPartNo;

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

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

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

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

    @Column(name = "IS_FEED")
    @ApiParam(value = "是否投料配置")
    private Integer isFeed;

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

    @Column(name = "MATCH_RULE")
    @ApiParam(value = "匹配规则")
    private Integer matchRule;

    @Column(name = "BIND_PART_TYPE")
    @ApiParam(value = "绑定物料类型")
    private Integer bindPartType = 20;

    @Column(name = "FEED_WARNING_QTY", columnDefinition = "decimal(18,8)")
    @ColumnDefault("0")
    @ApiParam(value = "投料预警值")
    private Double feedWarningQty;

    @Transient
    @ApiParam("标准包规数量")
    private Double partSpecQty = 0d;

    @Transient
    @ApiParam("是否已绑定")
    private Boolean isBind;

    @Transient
    @ApiParam("显示颜色")
    private String color;

    @Transient
    @ApiParam(value = "绑定数量")
    private Double boundQty;

    @Transient
    @ApiParam("关键件代码")
    private String keyBarCode;

    @Transient
    @ApiParam("产品条码")
    private String serialNumber;

    @Transient
    @ApiParam(value = "是否可重复名称")
    private String isRepeatName;

    @Transient
    @ApiParam(value = "是否检查名称")
    private String isCheckName;

    @Transient
    @ApiParam(value = "是否投料配置名称")
    private String isFeedName;

    @Transient
    @ApiParam(value = "是否绑定关键件名称")
    private String isBindKeyName;

    @Transient
    @ApiParam("是否扫描")
    private Boolean isScan = false;

    @Transient
    @ApiParam("半成品条码")
    private String halfProductSn;

    @Transient
    @ApiParam("主任务编号")
    private String orderNo;

    @Transient
    @ApiParam("产品类型代码")
    private String produceCategoryCode;

    @Transient
    @ApiParam("产品类型名称")
    private String produceCategoryName;

    @Transient
    @ApiParam("字符长度")
    private Integer length;

    @Transient
    @ApiParam("缺陷代码")
    private String defectCode;

    @Transient
    @ApiParam("校验内容")
    private String checkContent;

    @Transient
    @ApiParam("客户零件号")
    private String custPartNo;

    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 int getIsFeedVal() {
        return this.isFeed == null ? 0 : this.isFeed;
    }

    public boolean getIsBindVal() {
        return this.isBind == null ? false : this.isBind;
    }

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

    @Override
    public String toString() {
        return "MesStationBom{" +
                "partNo='" + partNo + '\'' +
                ", itemPartNo='" + itemPartNo + '\'' +
                ", qty=" + qty +
                ", isRepeat=" + isRepeat +
                ", isCheck=" + isCheck +
                ", isFeed=" + isFeed +
                ", isBind=" + isBind +
                ", color='" + color + '\'' +
                ", id=" + id +
                ", organizeCode='" + organizeCode + '\'' +
                ", isValid=" + isValid +
                ", isDeleted=" + isDeleted +
                ", createUser='" + createUser + '\'' +
                ", createDatetime='" + createDatetime + '\'' +
                ", modifyUser='" + modifyUser + '\'' +
                ", modifyDatetime='" + modifyDatetime + '\'' +
                ", createDateTimeStart='" + createDateTimeStart + '\'' +
                ", createDateTimeEnd='" + createDateTimeEnd + '\'' +
                ", modifyDateTimeStart='" + modifyDateTimeStart + '\'' +
                ", modifyDateTimeEnd='" + modifyDateTimeEnd + '\'' +
                ", orderByParam='" + orderByParam + '\'' +
                ", ascOrDesc=" + ascOrDesc +
                '}';
    }
}
