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

import cn.estsh.i3plus.pojo.aps.annotation.FieldAnnotation;
import cn.estsh.i3plus.pojo.aps.common.BaseAPS;
import cn.estsh.i3plus.pojo.aps.common.BeanRelation;
import cn.estsh.i3plus.pojo.aps.holders.EWorkRelation;
import cn.estsh.i3plus.pojo.base.enumutil.ApsEnumUtil;
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_Work_Relation")
@Api("工作关联")
public class WorkRelation extends BaseAPS {

    private static final long serialVersionUID = -5824884364328962956L;
    @Column(name="MATERIAL_ID")
    @ApiParam(value ="物料")
    @FieldAnnotation(relation = "Material", modify = false)
    private Long materialId;

    @Column(name="PREV_ORDER_ID")
    @ApiParam(value ="前订单")
    @FieldAnnotation(relation = "PrevOrder", modify = false)
    private Long prevOrderId;

    @Column(name="POST_ORDER_ID")
    @ApiParam(value ="后订单")
    @FieldAnnotation(relation = "PostOrder", modify = false)
    private Long postOrderId;

    @Column(name="PREV_WORK_ID")
    @ApiParam(value ="前工作")
    @FieldAnnotation(relation = "PrevWork", modify = false)
    private Long prevWorkId;

    @Column(name="POST_WORK_ID")
    @ApiParam(value ="后工作")
    @FieldAnnotation(relation = "PostWork", modify = false)
    private Long postWorkId;

    @Column(name="COUNT", columnDefinition = "decimal(18,8)")
    @ApiParam(value ="关联数量")
    @FieldAnnotation(modify = false)
    private Double count;

    @Column(name="TYPE")
    @ApiParam(value ="关联类型")
    @FieldAnnotation(modify = false)
    private ApsEnumUtil.WORK_RELATION_TYPE type;

    @Column(name="CONS_TYPE")
    @ApiParam(value ="接续方式")
    @FieldAnnotation(modify = false)
    private ApsEnumUtil.CONSTRAINT_TYPE consType;

    @Column(name="MAX_SPACE_TIME")
    @ApiParam(value ="最大间隔时间")
    @FieldAnnotation(modify = false)
    private String maxSpaceTime;

    @Column(name="MIN_SPACE_TIME")
    @ApiParam(value ="最小间隔时间")
    @FieldAnnotation(modify = false)
    private String minSpaceTime;

    @Column(name="FIX_RELATION")
    @ApiParam(value ="是否固定关联")
    private Boolean fixRelation;

    @Column(name="FIX_COUNT")
    @ApiParam(value ="是否固定数量")
    private Boolean fixCount;

    @Column(name="WORK_INPUT_ID")
    @ApiParam(value ="工作输入")
    @FieldAnnotation(property = false)
    private Long workInputId;

    @Column(name="WORK_OUTPUT_ID")
    @ApiParam(value ="工作输出")
    @FieldAnnotation(property = false)
    private Long workOutputId;

    public WorkInput getWorkInput() {
        return BeanRelation.get(this, EWorkRelation.WorkInput);
    }

    public void setWorkInput(WorkInput input) {
        this.workInputId = input != null ? input.getId() : 0l;
        BeanRelation.set(this, EWorkRelation.WorkInput, input);
    }

    public WorkOutput getWorkOutput() {
        return BeanRelation.get(this, EWorkRelation.WorkOutput);
    }

    public void setWorkOutput(WorkOutput output) {
        this.workOutputId = output != null ? output.getId() : 0l;
        BeanRelation.set(this, EWorkRelation.WorkOutput, output);
    }

    public Work getPrevWork() {
        return BeanRelation.get(this, EWorkRelation.PrevWork);
    }

    public void setPrevWork(Work work) {
        this.prevWorkId = work != null ? work.getId() : 0l;
        BeanRelation.set(this, EWorkRelation.PrevWork, work);
    }

    public Work getPostWork() {
        return BeanRelation.get(this, EWorkRelation.PostWork);
    }

    public void setPostWork(Work work) {
        this.postWorkId = work != null ? work.getId() : 0l;
        BeanRelation.set(this, EWorkRelation.PostWork, work);
    }

    public BaseOrder getPrevOrder() {
        return BeanRelation.get(this, EWorkRelation.PrevOrder);
    }

    public void setPrevOrder(BaseOrder order) {
        this.prevOrderId = order != null ? order.getId() : 0l;
        BeanRelation.set(this, EWorkRelation.PrevOrder, order);
    }

    public BaseOrder getPostOrder() {
        return BeanRelation.get(this, EWorkRelation.PostOrder);
    }

    public void setPostOrder(BaseOrder order) {
        this.postOrderId = order != null ? order.getId() : 0l;
        BeanRelation.set(this, EWorkRelation.PostOrder, order);
    }

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

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