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.EShippingTime;
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_SHIPPING_TIME")
@Api("运输时间")
public class ShippingTime extends BaseAPS {

    private static final long serialVersionUID = -8698904420363808737L;
    @Column(name="PREV_RES_CODE")
    @ApiParam(value ="前资源编码")
    @FieldAnnotation(relation = "PrevRes")
    private Long prevResId;

    @Column(name="POST_RES_CODE")
    @ApiParam(value ="后资源编码")
    @FieldAnnotation(relation = "PostRes")
    private Long postResId;

    @Column(name="PREV_STAND_CODE")
    @ApiParam(value ="前标准工序编码")
    @FieldAnnotation(relation = "PrevStand")
    private Long prevStandId;

    @Column(name="POST_STAND_CODE")
    @ApiParam(value ="后标准工序编码")
    @FieldAnnotation(relation = "PostStand")
    private Long postStandId;

    @Column(name="TIME")
    @ApiParam(value ="运输时间")
    @FieldAnnotation(notEmpty = true)
    private String time;

    @Column(name="PRIORITY")
    @ApiParam(value ="优先级")
    @FieldAnnotation(defaultValue = "10")
    private Integer priority;

    public Resource getPrevRes() {return BeanRelation.get(this, EShippingTime.PrevRes); }

    public  void setPrevRes(Resource res) {
        this.prevResId = res != null ? res.getId() : 0l;
        BeanRelation.set(this, EShippingTime.PrevRes, res);
    }

    public Resource getPostRes() { return BeanRelation.get(this, EShippingTime.PostRes); }

    public void setPostRes(Resource res) {
        this.postResId = res != null ? res.getId() : 0l;
        BeanRelation.set(this, EShippingTime.PostRes, res);
    }

    public StandOperation getPrevStand() { return BeanRelation.get(this, EShippingTime.PrevStand);}

    public void setPrevStand(StandOperation stand) {
        this.prevStandId = stand != null ? stand.getId() : 0l;
        BeanRelation.set(this, EShippingTime.PrevStand, stand);
    }

    public StandOperation getPostStand() { return BeanRelation.get(this, EShippingTime.PostStand); }

    public void setPostStand(StandOperation stand) {
        this.postStandId = stand != null ? stand.getId() : 0l;
        BeanRelation.set(this, EShippingTime.PostStand, stand);
    }
}
