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

import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
import cn.estsh.i3plus.pojo.base.annotation.DynamicField;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;

/**
 * @Description : QAD_BOP信息
 * @Reference :
 * @Author : jimmy.zeng
 * @CreateDate : 2020-01-09 14:40
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name="QAD_BOP")
@Api("QAD_BOP信息")
public class QadBop  implements Serializable {

    private static final long serialVersionUID = 4673217061075875734L;

    @Id
    @GeneratedValue(generator = "IDGenerator")
    @GenericGenerator(name = "IDGenerator", strategy = "assigned")
    @Column(name="ID")
    @ApiParam(value = "主键",example = "0")
    @JsonSerialize(using = ToStringSerializer.class)
    @AnnoOutputColumn(hidden = true)
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER)
    public Long id;

    //get单独处理
    public Long getId() {
        if(id != null) {
            return id.longValue();
        }else{
            return id;
        }
    }

    /**
     * MonogoDB _id映射
     * @param id
     */
    @JSONField(name="_id")
    public void setId(Long id) {
        this.id = id;
    }

    @Column(name="BOP_CODE")
    @ApiParam("BOP编号")
    public String bopCode;

    @Column(name="BOP_DESC")
    @ApiParam("BOP描述")
    public String bopDesc;

    @Column(name="BOP_DOMAIN")
    @ApiParam("BOP所属Domain")
    public String bopDomain;

    @Column(name="PARENT_PART")
    @ApiParam("父层级packcode对应的qad零件号")
    public String parentPart;

    @Column(name="PARENT_RETURN_PART")
    @ApiParam("父层级packcode对应的可回用零件号")
    public String parentReturnPart;

    @Column(name="BOPDW_QTY")
    @ApiParam("默认1 不考虑")
    public String bopdwQty;

    @Column(name="SUB_BOP_CODE")
    @ApiParam("子层级packcode代码或者是物料零件号")
    public String subBopCode;

    @Column(name="SUB_BOP_PART")
    @ApiParam("子层级packcode对应的qad零件号，如果是物料零件这里为空")
    public String subBopPart;

    @Column(name="SUB_ITEM_PART")
    @ApiParam("子层级packcode对应的可回用零件号，如果是物料零件这里为空")
    public String subItemPart;

    @Column(name="SUB_QTY", columnDefinition = "decimal(18,8)")
    @ColumnDefault("0")
    @ApiParam(value = "该层级在父层级中的个数", example = "0")
    public String subQty;

    @Column(name="SUB_UNIT")
    @ApiParam("单位")
    public String subUnit;

    @Column(name="CREATE_DATE_TIME")
    @ApiParam("创建时间")
    public String createDateTime;

    @Transient
    @ApiParam("收货时是供应商编号，发运时是客户发往地")
    public String inAddr;

    @Transient
    @ApiParam("工厂代码")
    public String inSite;

    @ApiParam("父层级packcode代码")
    @Column(name="BOPDW_PARENT")
    public String bopdwParent;

    public QadBop(){

    }

    public QadBop(String bopCode, String bopDesc, String bopDomain, String parentPart, String parentReturnPart, String bopdwQty, String subBopCode, String subBopPart, String subItemPart, String subQty, String subUnit, String createDateTime, String inAddr, String inSite) {
        this.bopCode = bopCode;
        this.bopDesc = bopDesc;
        this.bopDomain = bopDomain;
        this.parentPart = parentPart;
        this.parentReturnPart = parentReturnPart;
        this.bopdwQty = bopdwQty;
        this.subBopCode = subBopCode;
        this.subBopPart = subBopPart;
        this.subItemPart = subItemPart;
        this.subQty = subQty;
        this.subUnit = subUnit;
        this.createDateTime = createDateTime;
        this.inAddr = inAddr;
        this.inSite = inSite;
    }
}
