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

/**
 * @Description :  产品条码事务表
 * @Reference :
 * @Author : jimmy.zeng
 * @CreateDate : 2020-05-22 9:42
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="WMS_SERIAL_SN_TRANS")
@Api("产品条码事务表")
public class WmsSerialSnTrans extends BaseBean {

    @Column(name = "BATCH_NO")
    @ApiParam(value = "BATCH号")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT, isRequire = 2)
    private String batchNo;

    @Column(name="SERIAL_SN")
    @ApiParam("产品条码")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String serialSn;

    @Column(name="BH_TYPE")
    @ApiParam("BH类型")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.SELECT, isRequire = 2, dataSrc = "FG_INSTOCK_SN_TYPE")
    @AnnoOutputColumn(refClass = WmsEnumUtil.FG_INSTOCK_SN_TYPE.class)
    private Integer bhType;

    @Column(name = "PART_NO")
    @ApiParam(value = "物料编号")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.LIST, isRequire = 2, getValWay = CommonEnumUtil.DYNAMIC_FIELD_GET_WAY.OBJ,
            dataSrc = "cn.estsh.i3plus.pojo.wms.bean.WmsPart",
            searchColumnName = "partNo,partName", listColumnName = "partNo,partName", explicitColumnName = "partNo")
    private String partNo;

    @Column(name = "PART_NAME_RDD")
    @ApiParam(value = "物料名称")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.LIST, isRequire = 2, getValWay = CommonEnumUtil.DYNAMIC_FIELD_GET_WAY.OBJ,
            dataSrc = "cn.estsh.i3plus.pojo.wms.bean.WmsPart",
            searchColumnName = "partNo,partName", listColumnName = "partNo,partName", explicitColumnName = "partName")
    private String partNameRdd;

    @Column(name="SRC_STOCK_SN")
    @ApiParam("源库存条码")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String srcStockSn;

    @Column(name="DEST_STOCK_SN")
    @ApiParam("目标库存条码")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String destStockSn;

    @Column(name="TRANS_TYPE")
    @ApiParam("操作类型")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.SELECT, isRequire = 1, dataSrc = "BACTH_TRANS_TYPE")
    @AnnoOutputColumn(refClass = WmsEnumUtil.BACTH_TRANS_TYPE.class)
    private Integer transType;

    @Column(name = "IS_OK")
    @ApiParam(value = "是否合格")
    @AnnoOutputColumn(refClass = WmsEnumUtil.TRUE_OR_FALSE.class)
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.SELECT, dataSrc = "TRUE_OR_FALSE", isRequire = 2)
    private Integer isOk;

    @Column(name = "LOT_NO")
    @ApiParam("生产批次")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String lotNo;

    @Column(name = "STATUS")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.SELECT, dataSrc = "MOVE_ORDER_DETAILS_STATUS")
    @AnnoOutputColumn(refClass = WmsEnumUtil.MOVE_ORDER_DETAILS_STATUS.class)
    @ApiParam("状态")
    private Integer status;

    @Transient
    @ApiParam("操作类型")
    private List<Integer> transTypeLst;

    public WmsSerialSnTrans(WmsSerialSn wmsSerialSn, Integer transType) {
        this.organizeCode = wmsSerialSn.getOrganizeCode();
        this.batchNo = wmsSerialSn.getBatchNo();
        this.serialSn = wmsSerialSn.getSerialSn();
        this.bhType = wmsSerialSn.getBhType();
        this.partNo = wmsSerialSn.getPartNo();
        this.partNameRdd = wmsSerialSn.getPartNameRdd();
        this.destStockSn = wmsSerialSn.getStockSn();
        this.transType = transType;
    }

    public WmsSerialSnTrans() {
    }
}
