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 : amy
 * @CreateDate : 2018-11-06 15:58
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "WMS_WAREHOUSE")
@Api("工厂仓库信息")
public class WareHouse extends BaseBean {

    private static final long serialVersionUID = 7914396535326597148L;
    @Column(name = "CODE")
    @ApiParam("仓库代码")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    public String code;

    @Column(name = "NAME")
    @ApiParam("仓库名称")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    public String name;

    @Column(name = "ADDRESS")
    @ApiParam("仓库地址")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT, isRequire = 2)
    public String address;

    @Column(name = "WH_LENGTH")
    @ApiParam(value = "长(单位：全局设置参数中的基本单元)")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER)
    private Integer whLength;

    @Column(name = "WH_WIDTH")
    @ApiParam(value = "宽(单位：全局设置参数中的基本单元)")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER)
    private Integer whWidth;

    @Column(name = "WH_HEIGHT")
    @ApiParam(value = "高(单位：全局设置参数中的基本单元)")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER)
    private Integer whHeight;

    @Column(name = "BASE_UNIT", columnDefinition = "decimal(18,8)")
    @ApiParam(value = "基本单元（米）")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER)
    private Double baseUnit;

    @Column(name = "MAP_LOCATION")
    @ApiParam("经纬度")
    private String mapLocation;

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

    public Integer getWhLengthVal() {
        return this.whLength == null ? 0 : this.whLength.intValue();
    }

    public Integer getWhWidthVal() {
        return this.whWidth == null ? 0 : this.whWidth.intValue();
    }

    public Integer getWhHeightVal() {
        return this.whHeight == null ? 0 : this.whHeight.intValue();
    }

    public Double getBaseUnitVal() {
        return this.baseUnit == null ? 0 : this.baseUnit.doubleValue();
    }
}
