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.apache.commons.lang3.StringUtils;
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;
import java.util.Map;

/**
 * @Description : 悬挂链库存同步数据
 * @Reference :
 * @Author : jimmy.zeng
 * @CreateDate : 2020-07-14 9:53
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "WMS_SUSPEN_STOCK_SYNC", indexes = {
        @Index(columnList = "ORGANIZE_CODE")
})
@Api("悬挂链库存同步数据")
public class WmsSuspenStockSync extends BaseBean {

    @Column(name = "SRC")
    @ApiParam(value = "数据来源")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String src;

    @Column(name = "SERVER_URL")
    @ApiParam(value = "服务地址")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String serverUrl;

    @Column(name = "LOCATE_NO")
    @ApiParam(value = "库位号")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String locateNo;

    @Column(name = "PART_NO_A")
    @ApiParam(value = "物料号A")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String partNoA;

    @Column(name = "PART_NO_B")
    @ApiParam(value = "物料号B")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String partNoB;

    @Column(name = "QTY_A")
    @ApiParam(value = "数量A")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private Double qtyA;

    @Column(name = "QTY_B")
    @ApiParam(value = "数量B")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private Double qtyB;

    @Column(name = "LOT_NO_A")
    @ApiParam(value = "批次A")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String lotNoA;

    @Column(name = "LOT_NO_B")
    @ApiParam(value = "批次B")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String lotNoB;

    @Column(name = "STATUS")
    @ApiParam(value = "状态")
    @AnnoOutputColumn(refClass = WmsEnumUtil.SUSPEN_STOCK_SYNC_STATUS.class)
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER)
    private Integer status;

    @Column(name = "ERROR_MSG")
    @ApiParam(value = "错误信息")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String errorMsg;

    @Transient
    @ApiParam(value = "物料数组集")
    private String[] partNos;

    @Transient
    @ApiParam(value = "数量数组集")
    private Double[] qtys;

    @Transient
    @ApiParam(value = "批次数组集")
    private String[] lotNos;

    @Transient
    @ApiParam(value = "物料数据List")
    private List<WmsPart> partList;

    @Transient
    @ApiParam(value = "物料数据Map")
    private Map<String, WmsPart> partNameMap;

    public String getLocateNoVal() {
        return this.locateNo == null ? StringUtils.EMPTY : this.locateNo;
    }

    public String getPartNoAVal() {
        return this.partNoA == null ? StringUtils.EMPTY : this.partNoA;
    }

    public String getPartNoBVal() {
        return this.partNoB == null ? StringUtils.EMPTY : this.partNoB;
    }

    public Double getQtyAVal() {
        return this.qtyA == null ? 0 : this.qtyA;
    }

    public Double getQtyBVal() {
        return this.qtyB == null ? 0 : this.qtyB;
    }

    public String getLotNoAVal() {
        return this.lotNoA == null ? StringUtils.EMPTY : this.lotNoA;
    }

    public String getLotNoBVal() {
        return this.lotNoB == null ? StringUtils.EMPTY : this.lotNoB;
    }
}
