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

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 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 : hansen.ke
 * @CreateDate : 2018-11-06 11:50
 * @Modify:
 **/
@Data
@Entity
@Table(name = "WMS_ZONES")
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Api(value = "存储区信息表", description = "存储区信息表")
public class WmsZones extends BaseBean {

    private static final long serialVersionUID = 7759454799191378612L;
    @Column(name = "WH_NO")
    @ApiParam(value = "仓库代码")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String whNo;

    @Column(name = "AREA_NO")
    @ApiParam(value = "库存地代码")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String areaNo;

    @Column(name = "ZONE_NO")
    @ApiParam(value = "存储区代码")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String zoneNo;

    @Column(name = "ZONE_NAME")
    @ApiParam(value = "存储区名称")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String zoneName;

    @Column(name = "PARENT_ZONE_NO")
    @ApiParam(value = "父级存储区", example = "-1")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String parentZoneNo;

    @Column(name = "IS_SON_NODE")
    @ApiParam(value = "是否子节点")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER, dataSrc = "TRUE_OR_FALSE")
    private Integer isSonNode;

    @Column(name = "IS_PM")
    @ApiParam(value = "零件级管控", example = "2")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER, isRequire = 2, dataSrc = "TRUE_OR_FALSE")
    private Integer isPm;

    @Column(name = "IS_LM")
    @ApiParam(value = "批次级管控", example = "2")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER, isRequire = 2, dataSrc = "TRUE_OR_FALSE")
    private Integer isLm;

    @Column(name = "IS_SN")
    @ApiParam(value = "条码级管控", example = "1")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER, isRequire = 2, dataSrc = "TRUE_OR_FALSE")
    private Integer isSn;

    @Column(name = "IS_MIX")
    @ApiParam(value = "允许混淆", example = "1")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER, isRequire = 2, dataSrc = "TRUE_OR_FALSE")
    private Integer isMix;

    @Column(name = "IS_SC")
    @ApiParam(value = "库容检查", example = "1")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER, isRequire = 2, dataSrc = "TRUE_OR_FALSE")
    private Integer isSc;

    @Column(name = "STRATEGY")
    @ApiParam(value = "堆放策略")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT, isRequire = 2)
    private String strategy;

    @Column(name = "IS_NEGATIVE")
    @ApiParam(value = "允许负库存", example = "1")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER, isRequire = 2, dataSrc = "TRUE_OR_FALSE")
    private Integer isNegative;

    @Column(name = "CHECK_FIFO")
    @ApiParam(value = "校验先进先出", example = "1")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER, isRequire = 2, dataSrc = "TRUE_OR_FALSE")
    private Integer checkFifo;

    @Column(name = "ZONE_LENGTH")
    @ApiParam(value = "长")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER)
    private Integer zoneLength;

    @Column(name = "ZONE_WIDTH")
    @ApiParam(value = "宽")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER)
    private Integer zoneWidth;

    @Column(name = "POSITION")
    @ApiParam(value = "三维位置")
    private String position;

    @Column(name = "ZONE_PULL_WAY")
    @ApiParam(value = "补货方式", example = "10")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.SELECT, isRequire = 2, dataSrc = "ZONE_PULL_WAY")
    private Integer zonePullWay;

    @Column(name = "PULL_CYCLE")
    @ApiParam(value = "固定拉动周期", example = "0")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER, isRequire = 2)
    private Integer pullCycle;

    @Column(name = "LAST_PULL_TIME")
    @ApiParam(value = "上次拉动时间")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.DATETIME, isRequire = 2)
    private String lastPullTime;

    @Transient
    @ApiParam(value = "子存储区列表")
    private List<WmsZones> childList;

    @Transient
    @ApiParam(value = "库位利用率百分比")
    private String Location;

    public WmsZones(String zoneNo) {
        this.zoneNo = zoneNo;
    }

    public WmsZones(String zoneNo, String areaNo) {
        this.zoneNo = zoneNo;
        this.areaNo = areaNo;
    }

    public WmsZones() {
    }

    public Integer getZoneLengthVal() {
        return this.zoneLength == null ? 0 : this.zoneLength.intValue();
    }
    public Integer getZoneWidthVal() {
        return this.zoneWidth == null ? 0 : this.zoneWidth.intValue();
    }
}
