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.EInsertedOrder;
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 : 2021-03-02
 * @Modify:
 **/
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "APS_INSERTED_ORDER")
@Api("插单管理")
public class InsertedOrder extends BaseOrder  {
    private static final long serialVersionUID = -5036380772996107234L;

    @Column(name="ORDER_STATUS")
    @ApiParam(value ="订单状态")
    @FieldAnnotation(defaultValue = "UNCOMMIT")
    private ApsEnumUtil.INSERTED_ORDER_STATUS orderStatus = ApsEnumUtil.INSERTED_ORDER_STATUS.UNCOMMIT;

    @Column(name="STAND_OPERATIONS")
    @ApiParam("工序")
    private String standOperations;

    @Column(name="PRODUCT_ROUTING_ID")
    @ApiParam(value ="工艺路线")
    @FieldAnnotation(property = false)
    private Long productRoutingId;

    @Column(name="FINISH_COUNT")
    @ApiParam(value ="完工数")
    private Double finishCount;

    @Column(name="REMARK")
    @ApiParam(value ="备注")
    private String remark;

    public ProductRouting getProductRouting() {
        return BeanRelation.get(this, EInsertedOrder.ProductRouting);
    }

    public void setProductRouting(ProductRouting routing) {
        this.productRoutingId = routing != null ? routing.getId() : 0l;
        BeanRelation.set(this, EInsertedOrder.ProductRouting, routing);
    }

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