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 lombok.ToString;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.List;

/**
 * @Description :移库单实体(用于转储类业务)
 * @Reference :
 * @Author : dragon.xu
 * @CreateDate : 2018-11-13 16:06
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "WMS_DOC_MOVEMENT_MASTER", indexes = {
        @Index(columnList = "ORDER_NO"),
        @Index(columnList = "REF_NO"),
        @Index(columnList = "ERP_SRC_NO"),
        @Index(columnList = "BUSI_TYPE"),
        @Index(columnList = "ORGANIZE_CODE")
})
@Api("移库单表")
@ToString
public class WmsDocMovementMaster extends BaseBean {
    private static final long serialVersionUID = -4459803926536024325L;
    @Column(name = "ORDER_NO")
    @ApiParam(value = "移库单单号")
    private String orderNo;
    /**
     * 移动类型:IN=入库,OUT=出库,MOVE=移库
     */
    @Column(name = "MOVE_TYPE")
    @ApiParam("移动类型")
    @AnnoOutputColumn(refClass = WmsEnumUtil.OUT_MOVEMENT_MOVE_TYPE.class, refForeignKey = "value", value = "description")
    public Integer moveType;
    /**
     * 业务类型:RC=收货,QC=质检,IN=入库,ZI=杂收,ZO=杂发,
     * VJ=供应商退货,CJ=客户退货,WP=工单领料,WJ=工单退料,
     * MI=移库入库,MO=移库出库,SO=发运
     */
    @Column(name = "BUSI_TYPE")
    @ApiParam("业务类型")
    @AnnoOutputColumn(refClass = WmsEnumUtil.OUT_MOVEMENT_BUSI_TYPE.class, refForeignKey = "value", value = "description")
    public Integer busiType;

    /**
     * 状态:0=新建,10=处理中
     * ,20=已完成,90=已关闭,91=已取消
     */
    @Column(name = "ORDER_STATUS")
    @ApiParam(value = "状态", example = "1")
    @AnnoOutputColumn(refClass = WmsEnumUtil.MASTER_ORDER_STATUS.class, refForeignKey = "value", value = "description")
    public Integer orderStatus;

    @Column(name = "CUST_NO")
    @ApiParam(value = "客户编号")
    private String custNo;

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

    @Column(name = "VERSION")
    @ApiParam(value = "版本", example = "1")
    private Integer version;

    /**
     * 关联单据类型:1=ASN,10=PO,20=SO
     */
    @Column(name = "REF_TYPE")
    @ApiParam(value = "关联单据类型")
    private String refType;

    @Column(name = "REF_NO")
    @ApiParam(value = "关联单据")
    private String refNo;

    @Column(name = "ERP_SRC_NO")
    @ApiParam(value = "ERP单号")
    private String erpSrcNo;

    @Column(name = "IS_TASK")
    @ApiParam(value = "是否生产任务", example = "1")
    @AnnoOutputColumn(refClass = WmsEnumUtil.IS_GENERAL_TASK.class, refForeignKey = "value", value = "description")
    public Integer isTask;

    @Column(name = "PRIORITY")
    @AnnoOutputColumn(refClass = WmsEnumUtil.PRIORITY.class, refForeignKey = "value", value = "description")
    @ApiParam(value = "优先级", example = "1")
    public Integer priority;

    @Column(name = "CAR_NO")
    @ApiParam(value = "车牌号")
    private String carNo;

    @Column(name = "CUST_ORDER_NO")
    @ApiParam(value = "客户单号")
    private String custOrderNo;

    @Transient
    private List<WmsDocMovementDetails> movementDetailsList;

    @Transient
    @ApiParam(value = "源库存地代码")
    private String srcAreaNo;

    @Transient
    @ApiParam(value = "目的库存地代码")
    private String desrAreaNo;

    @Column(name = "IS_PART")
    @ApiParam(value = "是否散件", example = "1")
    @AnnoOutputColumn(refClass = WmsEnumUtil.TRUE_OR_FALSE.class, refForeignKey = "value", value = "description")
    private Integer isPart;

    @Column(name = "PRINT_STATUS")
    @ApiParam("打印状态")
    @AnnoOutputColumn(refClass = WmsEnumUtil.PRINT_STATUS.class, refForeignKey = "value", value = "description")
    private Integer printStatus;

    @Column(name = "SRC_WH_NO")
    @ApiParam("源仓库代码")
    public String assignSrcWhNo;

    @Column(name = "SRC_ZONE_NO")
    @ApiParam("源存储区代码")
    public String assignSrcZoneNo;

    @Column(name = "DEST_WH_NO")
    @ApiParam("目标仓库代码")
    public String assignDestWhNo;

    @Column(name = "DEST_ZONE_NO")
    @ApiParam("目标存储区代码")
    public String assignDestZoneNo;

    @Column(name = "PLAN_DATE")
    @ApiParam(value = "计划日期")
    private String assignPlanDate;

    @Column(name = "FLAG_NO")
    @ApiParam(value = "客户发往地编号")
    private String flagNo;

    @Column(name = "PLAN_TIME")
    @ApiParam(value = "计划时间")
    private String assignPlanTime;

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

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

    @Transient
    @ApiParam("类型名称")
    public String busiTypeName;

    @Transient
    @ApiParam("物料编号")
    public String partNo;

    @ApiParam(value = "标题")
    @Transient
    public String title;

    @Column(name = "TAG")
    @ApiParam(value = "标签")
    private String tag;

    public int getOrderStatusVal() {
        return this.orderStatus == null ? 0 : this.orderStatus;
    }
}
