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

import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
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;

/**
 * @Description :
 * @Reference :
 * @Author : amy
 * @CreateDate : 2019-06-11 15:03
 * @Modify:
 **/
@Data
@Entity
@Table(name = "WMS_BOM")
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Api(value = "物料清单", description = "物料清单")
public class WmsBom extends BaseBean {

    private static final long serialVersionUID = 5555657644784074446L;
    @Column(name = "PART_NO")
    @ApiParam(value = "父物料号")
    private String partNo;

    @Column(name = "PART_NAME")
    @ApiParam(value = "父物料描述")
    private String partName;

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

    @Column(name = "QTY", columnDefinition = "decimal(18,8)")
    @ApiParam(value = "数量")
    private Double qty;

    @Column(name = "ITEM_PART_NO")
    @ApiParam(value = "子物料号")
    private String itemPartNo;

    @Column(name = "ITEM_PART_NAM")
    @ApiParam(value = "子料物料描述")
    private String itemPartNam;

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

    @Column(name = "ITEM_QTY", columnDefinition = "decimal(18,8)")
    @ApiParam(value = "子用量")
    private Double itemQty;

    @Column(name = "BOM_NUM")
    @ApiParam(value = "BOM编号")
    private String bomNum;

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

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiParam(value = "有效起始日期", example = "2018-12-31 23:59:59")
    @AnnoOutputColumn(hidden = true)
    @Column(name = "EFF_START_TIME")
    private String effStartTime;


    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiParam(value = "有效截止日期", example = "2018-12-31 23:59:59")
    @AnnoOutputColumn(hidden = true)
    @Column(name = "EFF_END_TIME")
    private String effEndTime;

    @ApiParam(value = "目标存储区")
    @Transient
    public String destZoneNo;

    @ApiParam(value = "交易类型")
    @Transient
    public String transTypeCode;

    @ApiParam(value = "线路代码")
    @Transient
    public String routingCode;

    public Double getQty() {
        return this.qty == null ? 0 : this.qty.doubleValue();
    }

    public Double getItemQty() {
        return this.itemQty == null ? 0 : this.itemQty.doubleValue();
    }

    public WmsBom() {
    }

    public WmsBom(String itemPartNo, String itemPartNam, String itemUnit, String bomNum, Double itemQty) {
        this.itemPartNo = itemPartNo;
        this.itemPartNam = itemPartNam;
        this.itemUnit = itemUnit;
        this.bomNum = bomNum;
        this.itemQty = itemQty;
    }
}
