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.Index;
import javax.persistence.Table;

/**
 * @Description : 单位换算
 * @Reference :
 * @Author : amy
 * @CreateDate : 2019-06-11 14:18
 * @Modify:
 **/
@Data
@Entity
@Table(name="WMS_UNIT_CONVERT", indexes = {
        @Index(columnList = "UNIT_CODE"),
        @Index(columnList = "DEST_UNIT_CODE"),
        @Index(columnList = "ORGANIZE_CODE")
})
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Api(value="单位换算",description = "单位换算")
public class WmsUnitConvert extends BaseBean {

    private static final long serialVersionUID = -466720560879335877L;
    @Column(name = "UNIT_CODE")
    @ApiParam(value = "单位代码")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String unitCode;

    @Column(name = "DEST_UNIT_CODE")
    @ApiParam(value = "目标单位")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String destUnitCode;

    @Column(name = "UNIT_COEFFICIENT", columnDefinition = "decimal(18,8)")
    @ApiParam(value = "换算率")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER)
    private Double unitCoefficient;

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