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

import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.WmsEnumUtil;
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.Index;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

/**
 * @Description : PO订单主表
 * @Reference :
 * @Author : silliter.yuan
 * @CreateDate : 2018-11-06 15:58
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "WMS_DOC_PO_MASTER", indexes = {
        @Index(columnList = "ORDER_NO"),
        @Index(columnList = "ORGANIZE_CODE")
})
@Api("PO主表信息")
public class WmsPOMaster extends BaseBean {

    private static final long serialVersionUID = -5439534283717671648L;
    @Column(name = "ORDER_NO")
    @ApiParam("订单号")
    public String orderNo;

    /**
     * 单据类型:
     * 1 REG=原物料采购,10 SUB=委外采购,20 TAR=多角贸易采购,30 TAP=多角代采购
     */
    @Column(name = "PO_TYPE")
    @ApiParam("单据类型")
    public String poType;

    /**
     * 状态:1=新建,10=收货中,20=收货完成,
     * 30=入库中,40=入库完成,90=已关闭,91=已取消
     */
    @Column(name = "PO_STATUS")
    @ApiParam(value = "状态", example = "1")
    @AnnoOutputColumn(refClass = WmsEnumUtil.MASTER_ORDER_STATUS.class, refForeignKey = "value", value = "description")
    public Integer poStatus;

    @Column(name = "VENDOR_NO")
    @ApiParam("供应商编号")
    public String vendorNo;

    @Column(name = "VERSION")
    @ApiParam("版本")
    public String version;

    /**
     * 单据来源：1 MNU=手工,2 ERP=ERP接口
     */
    @Column(name = "SRC")
    @ApiParam("单据来源")
    public String src;

    @Column(name = "IS_ASN")
    @ApiParam("是否有ASN")
    public String isAsn;

    /**
     * 供应商名称
     */
    @Transient
    @ApiParam("供应商名称")
    private String vendorName;

    @Column(name = "IS_TASK")
    @ApiParam(value = "是否生成任务", example = "1")
    public Integer isTask;

    @Column(name = "IS_PART")
    @ApiParam(value = "是否散件", example = "1")
    public Integer isPart;

    @ApiParam("PO明细列表信息")
    @Transient
    public List<WmsPOMasterDetails> poDetailList;

    @Transient
    @ApiParam(value = "发运单号")
    private String shipOrderNo;

    @Transient
    @ApiParam(value = "打印时间")
    private String printDate;

    @Transient
    @ApiParam(value = "发货人")
    private String sendUser;

    @Transient
    @ApiParam(value = "发货日期")
    private String sendDate;

    @Column(name = "IS_SN")
    @ApiParam(value = "是否生成条码", example = "1")
    public Integer isSn;

    @Column(name = "CONTAINER_NO")
    @ApiParam("集装箱号")
    public String containerNo;

    @Column(name = "PRIOR_RC",columnDefinition = "int default 2")
    @ApiParam("预收货")
    public Integer priorRC;

    @Transient
    @ApiParam(value = "工厂名称")
    public String organizeName;

    @Transient
    @ApiParam("联系人")
    private String vendorOwner;

    @Transient
    @ApiParam("邮箱")
    private String vendorEmail;

    @Transient
    @ApiParam("供应商电话")
    private String vendorCall;

    @Transient
    @ApiParam("传真")
    private String vendorFax;

    @Transient
    @ApiParam("手机")
    private String vendorPhone;

    @Transient
    @ApiParam("前端信息")
    private String message;

    @Transient
    @ApiParam("计划日期开始")
    private String planDateStart;

    @Transient
    @ApiParam("计划日期结束")
    private String planDateEnd;

    @Transient
    private List<String> orderNoList;

    @Column(name = "DOCK", columnDefinition = "varchar(50) default ''")
    @ApiParam("道口")
    public String dock;

    @ApiParam("泊位")
    @Column(name = "ZDOC", columnDefinition = "varchar(50) default ''")
    public String zdoc;

    public WmsPOMaster() {

    }

    public WmsPOMaster(String orderNo, Integer poStatus, String organizeCode, String vendorNo, String dockCode, String zdoc, String createDateTime, String receiveDateTime) {
        this.orderNo = orderNo;
        this.poStatus = poStatus;
        this.organizeCode = organizeCode;
        this.vendorNo = vendorNo;
        this.dock = dockCode;
        this.zdoc = zdoc;
        this.createDatetime = createDateTime;
        this.createDateTimeStart = receiveDateTime;
    }

    public int getPoStatusVal() {
        return this.poStatus == null ? 0 : this.poStatus;
    }
}
