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


import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;

/**
 * @Description :MES_设备工装关系
 * @Reference :
 * @Author : jessica.chen
 * @CreateDate : 2020-03-19
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "MES_EQUIPMENT_TOOLING")
@Api("MES_设备工装关系")
public class MesEquipmentTooling extends BaseBean implements Serializable {
    private static final long serialVersionUID = 1947971369479107711L;
    @Column(name = "EQUIPMENT_CODE")
    @ApiParam("设备代码")
    private String equipmentCode;

    @Column(name = "TOOLING_NO")
    @ApiParam("工装编号")
    private String toolingNo;

    @Column(name = "TOOLING_CODE")
    @ApiParam("工装代码")
    private String toolingCode ;

    @Column(name = "TOOLING_NAME")
    @ApiParam("工装名称")
    private String toolingName;

    @Column(name = "TOOLING_TYPE")
    @ApiParam("工装类型")
    private Integer toolingType;

    @Column(name = "USE_COUNT")
    @ApiParam("使用次数")
    private Integer useCount;

    @Column(name = "START_TIME")
    @ApiParam("更换开始时间")
    private String startTime;

    @Column(name = "END_TIME")
    @ApiParam("更换结束时间")
    private String endTime;

    @Column(name = "USE_COUNT_MAX")
    @ApiParam("最大使用次数")
    private Integer useCountMax;

    @Column(name = "REMIND_COUNT")
    @ApiParam("提醒次数")
    private Integer remindCount;

    @Transient
    @ApiParam("按钮名称")
    private String btnName;

    @Transient
    @ApiParam("按钮颜色")
    private String btnColor;

    @Transient
    @ApiParam("按钮类别")
    private String btnType;

    public Integer getToolingType() {
        return this.toolingType == null ? 0 : this.toolingType;
    }

    public Integer getUseCount() {
        return this.useCount == null ? 0 : this.useCount;
    }

    public MesEquipmentTooling(){

    }

    public MesEquipmentTooling(MesTooling tooling, Integer useCount) {
        this.toolingCode = tooling.getToolingCode();
        this.toolingName = tooling.getToolingName();
        this.useCount = useCount;
        this.useCountMax = tooling.getUseCountMax();
    }
}
