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.base.enumutil.ApsEnumUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
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;

/**
 * @Description :采购订单
 * @Reference :
 * @Author : jason.niu
 * @CreateDate : 2019-09-17
 * @Modify:
 **/
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "APS_PURCHASE_ORDER")
@Api("采购订单")
public class PurchaseOrder extends BaseOrder {
    private static final long serialVersionUID = 4699381603433121631L;
    @Column(name="SPECIFY_TOP_ORDER")
    @ApiParam(value ="指定顶层订单")
    private String specifyTopOrder;

    @Column(name="SPECIFY_UP_ORDER")
    @ApiParam(value ="指定上层订单")
    private String specifyUpOrder;

    @Column(name="ASSIGN_COUNT", columnDefinition = "decimal(18,8)")
    @ApiParam(value ="已分配数量")
    private Double assignCount;

    @Column(name="SPECIFY_LEAD_TIME")
    @ApiParam(value ="指定提前期")
    @FieldAnnotation(editType = ApsEnumUtil.EDIT_TYPE.DURATION)
    private String specifyLeadTime;

    @Column(name="CALC_LEAD_TIME")
    @ApiParam(value ="提前期计算值")
    @FieldAnnotation(modify = false)
    private String calcLeadTime;

    @Column(name="EXCESS_COUNT", columnDefinition = "decimal(18,8)")
    @ApiParam(value ="多余量")
    @FieldAnnotation(modify = false)
    private Double excessCount;

    @Column(name="AUTO_SUPPLY")
    @ApiParam(value ="物料计算时自动补充")
    @FieldAnnotation(defaultValue = "true")
    private Boolean autoSupply;

    @JsonIgnore
    public Work getWork() {
        return BeanRelation.get(this, EBaseOrder.Works);
    }
}
