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

import cn.estsh.i3plus.pojo.aps.annotation.FieldAnnotation;
import cn.estsh.i3plus.pojo.aps.common.BeanRelation;
import cn.estsh.i3plus.pojo.aps.holders.EBaseOrder;
import cn.estsh.i3plus.pojo.aps.holders.EMaterialDeliveryPromise;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

/**
 * @Description :物料交期承诺
 * @Reference :
 * @Author : jason.niu
 * @CreateDate : 2020-06-11
 * @Modify:
 **/
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "APS_MATERIAL_DELIVERY_PROMISE")
@Api("物料")
public class MaterialDeliveryPromise extends BaseBean {
    @Column(name="QTY")
    @ApiParam(value ="到货数量")
    private Double count;

    @Column(name="DATE_TIME")
    @ApiParam(value ="到货日期")
    private Date dateTime;

    @Column(name="MATERIAL_ID")
    @ApiParam(value ="物料")
    @FieldAnnotation(relation = "Material", notEmpty = true)
    private Long materialId;

    public Material getMaterial() {
        return BeanRelation.get(this, EMaterialDeliveryPromise.Material);
    }

    public void setMaterial(Material material) {
        this.materialId = material != null ? material.getId() : 0l;
        BeanRelation.set(this, EMaterialDeliveryPromise.Material, material);
    }
}
