package cn.estsh.i3plus.pojo.mes.pcn.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 org.springframework.format.annotation.DateTimeFormat;

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

/**
 * @Description :BOM清单
 * @Reference :
 * @Author : jack.jia
 * @CreateDate : 2019-04-02
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "MES_BOM")
@Api("BOM清单")
public class MesBom extends BaseBean implements Serializable {
    private static final long serialVersionUID = -1772273641263268564L;
    @Column(name = "PART_NO")
    @ApiParam("父零件号")
    private String partNo;

    @Column(name = "PART_NAME")
    @ApiParam("父零件名称")
    private String partName;

    @Column(name = "UNIT")
    @ApiParam(value = "单位")
    private String unit;

    @Column(name = "QTY")
    @ColumnDefault("0")
    @ApiParam(value = "数量", example = "0")
    private Double qty;

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

    @Column(name = "ITEM_PART_NAME")
    @ApiParam("子零件名称")
    private String itemPartName;

    @Column(name = "ITEM_UNIT")
    @ApiParam(value = "子零件单位")
    private String itemUnit;

    @Column(name = "ITEM_QTY")
    @ColumnDefault("0")
    @ApiParam(value = "子零件数量", example = "0")
    private Double itemQty;

    @Column(name = "BOM_VERSION")
    @ApiParam(value = "BOM版本")
    private String bomVersion;

    @Column(name = "EFF_START_TIME")
    @ApiParam(value = "生效时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private String effStartTime;

    @Column(name = "EFF_END_TIME")
    @ApiParam(value = "失效时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private String effEndTime;

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

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