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.EWorkResource;
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_RESOURCE")
@Api("工作资源")
public class WorkResource extends BaseAPS {

    private static final long serialVersionUID = 4791940404968841144L;
    @Column(name="WORK_ID")
    @ApiParam(value ="工作")
    @FieldAnnotation(relation = "Work")
    private Long workId;

    @Column(name="RESOURCE_ID")
    @ApiParam(value ="资源")
    @FieldAnnotation(relation = "Resource")
    private Long resourceId;

    @Column(name="USE_TYPE")
    @ApiParam(value ="使用类型")
    @FieldAnnotation(modify = false)
    private ApsEnumUtil.USE_TYPE useType;

    @Column(name="PREV_TIME")
    @ApiParam(value ="前设置时间")
    @FieldAnnotation(modify = false, editType = ApsEnumUtil.EDIT_TYPE.DURATION)
    private Integer prevTime;

    @Column(name="PRODUCE_TIME")
    @ApiParam(value ="制造时间")
    @FieldAnnotation(modify = false, editType = ApsEnumUtil.EDIT_TYPE.DURATION)
    private Integer produceTime;

    @Column(name="POST_TIME")
    @ApiParam(value ="后设置时间")
    @FieldAnnotation(modify = false, editType = ApsEnumUtil.EDIT_TYPE.DURATION)
    private Integer postTime;

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

    @Column(name="MAX_PREV_SD_TIME")
    @ApiParam(value ="最大前设置中断时间")
    @FieldAnnotation(modify = false)
    private String maxPrevSdTime;

    @Column(name="MAX_PRODUCE_SD_TIME")
    @ApiParam(value ="最大制造中断时间")
    @FieldAnnotation(modify = false)
    private String maxProduceSdTime;

    @Column(name="MAX_POST_SD_TIME")
    @ApiParam(value ="最大后设置中断时间")
    @FieldAnnotation(modify = false)
    private String maxPostSdTime;

    @Column(name="USER_MATCH_NUMBER")
    @ApiParam(value ="资源使用配套号")
    @FieldAnnotation(modify = false)
    private String userMatchNumber;

    @Column(name="OPER_RESOURCE_ID")
    @ApiParam(value ="工序资源")
    @FieldAnnotation(property = false)
    private Long operResourceId;

    public Work getWork() {
        return BeanRelation.get(this, EWorkResource.Work);
    }

    public void setWork(Work work) {
        this.workId = work != null ? work.getId() : 0l;
        BeanRelation.set(this, EWorkResource.Work, work);
    }

    public Resource getResource() {
        return BeanRelation.get(this, EWorkResource.Resource);
    }

    public void setResource(Resource res) {
        this.resourceId = res != null ? res.getId() : 0l;
        BeanRelation.set(this, EWorkResource.Resource, res);
    }

    public OperResource getOperResource() {
        return BeanRelation.get(this, EWorkResource.OperResource);
    }

    public void setOperResource(OperResource res) {
        this.operResourceId = res != null ? res.getId() : 0l;
        BeanRelation.set(this, EWorkResource.OperResource, res);
    }
}
