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

import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
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;

/**
 * @Description : 作业步骤处理组件
 * @Reference :
 * @Author : dragon.xu
 * @CreateDate : 2018-11-22 16:53
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "WMS_ACTION_MODULE")
@Api("作业步骤处理组件")
public class WmsActionModule extends BaseBean {
    private static final long serialVersionUID = 9117362998863937579L;

    private static final int TRUE = 1;
    private static final int FALSE = 2;

    @Column(name = "AM_NAME",nullable = false)
    @ApiParam("组件名称")
    @AnnoOutputColumn
    public String amName;

    @Column(name = "AM_DESC",  nullable = false)
    @ApiParam("组件描述")
    @AnnoOutputColumn
    public String amDesc;

    @Column(name = "CALL_CLASS",nullable = false)
    @ApiParam("实现类")
    @AnnoOutputColumn
    public String callClass;

    @Column(name = "AM_TYPE",  nullable = false)
    @ApiParam(value = "组件类型")
    @AnnoOutputColumn
    public Integer amType;

    @Column(name = "OP_TYPE_CODE", columnDefinition = "varchar(225) default ''")
    @ApiParam(value = "作业类型")
    public String opTypeCode;

    @Column(name = "IS_SHOW_INFO", nullable = false)
    @ApiParam(value = "是否实现回显")
    @AnnoOutputColumn
    public Integer isShowInfo;

    @Column(name = "OP_TYPE_NAME", columnDefinition = "varchar(225) default ''")
    @ApiParam(value = "作业类型名称")
    public String opTypeName;

    @Column(name = "IS_SCRIPT_MODULE", columnDefinition = "int default 2")
    @ApiParam(value = "是否脚本组件")
    private Integer isScriptModule;

    /**
     * 是否脚本组件
     * @return
     */
    public boolean isScriptModule() {
        if (this.isScriptModule != null && this.isScriptModule.intValue() == TRUE) {
            return true;
        }

        return false;
    }

    public WmsActionModule() {
    }

    public WmsActionModule(Long id, String amName, String amDesc, String callClass,
                           Integer amType, String opTypeCode, Integer isShowInfo, String opTypeName) {
        this.id = id;
        this.amName = amName;
        this.amDesc = amDesc;
        this.callClass = callClass;
        this.amType = amType;
        this.opTypeCode = opTypeCode;
        this.isShowInfo = isShowInfo;
        this.opTypeName = opTypeName;
    }
}
