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

import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.WmsEnumUtil;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
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.*;

/**
 * @Description : 作业流程
 * @Reference :
 * @Author : amy
 * @CreateDate : 2018-11-23 13:13
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "WMS_ACTION_GROUP")
@Api("作业流程")
public class WmsActionGroup extends BaseBean {

    private static final long serialVersionUID = -4169996695337717755L;
    @Column(name = "AG_NAME_E", columnDefinition = "varchar(225) default ''")
    @ApiParam("英文流程名称")
    private String agNameE;

    @Column(name = "AG_DESC_E", columnDefinition = "varchar(225) default ''")
    @ApiParam("英文流程描述")
    private String agDescE;

    @Column(name = "AG_NAME_C", nullable = false)
    @ApiParam("中文流程名称")
    @AnnoOutputColumn
    private String agNameC;

    @Column(name = "AG_DESC_C", nullable = false)
    @ApiParam("中文流程描述")
    @AnnoOutputColumn
    private String agDescC;

    @Column(name = "INIT_AM_ID", columnDefinition = "bigint default 0")
    @ApiParam(value = "初始化组件编号", example = "0")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long initAmId;

    @Column(name = "DETAILS_AM_ID", columnDefinition = "bigint default 0")
    @ApiParam(value = "明细处理组件编号", example = "0")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long detailsAmId;

    @Column(name = "END_AM_ID", columnDefinition = "bigint default 0")
    @ApiParam(value = "结束组件编号", example = "0")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long endAmId;

    // 1=true, 2 = false
    @Column(name = "AUTO_INIT", nullable = false)
    @ApiParam(value = "任务自动初始化", example = "0")
    @AnnoOutputColumn
    private Integer autoInit;

    @Column(name = "COMMIT_MODE", nullable = false)
    @ApiParam(value = "提交移动单模式")
    @AnnoOutputColumn(refClass = WmsEnumUtil.GROUP_COMMIT_MODE.class)
    private Integer commitMode;

    // 1=true, 2 = false
    @Column(name = "IS_AUTO_COMMIT", nullable = false)
    @ApiParam(value = "是否自动提交")
    @AnnoOutputColumn
    private Integer isAutoCommit;

    // 1=true, 2 = false
    @Column(name = "IS_RESET_ABLE", columnDefinition = "int default 1", nullable = false)
    @ApiParam(value = "是否允许重置")
    @AnnoOutputColumn
    private Integer isResetAble;

    @Lob
    @Column(name = "POSITION", columnDefinition = "TEXT")
    @ApiParam(value = "GOJS位置")
    private String position;

    @Transient
    @ApiParam(value = "提交步骤序号")
    private Integer submitStepSeq;

    public long getInitAmIdVal() {
        return this.initAmId == null ? 0 : this.initAmId.longValue();
    }

    public long getDetailsAmIdVal() {
        return this.detailsAmId == null ? 0 : this.detailsAmId.longValue();
    }

    public long getEndAmIdVal() {
        return this.endAmId == null ? 0 : this.endAmId.longValue();
    }

    public int getCommitModeVal() {
        return this.commitMode == null ? 0 : this.commitMode.intValue();
    }

    public int getIsAutoCommitVal() {
        return this.isAutoCommit == null ? 0 : this.isAutoCommit.intValue();
    }

    public int getAutoInitVal() {
        return this.autoInit == null ? 0 : this.autoInit.intValue();
    }

    public int getSubmitStepSeqVal() {
        return this.submitStepSeq == null ? 0 : this.submitStepSeq.intValue();
    }

    public int getIsResetAbleVal() {
        return this.isResetAble == null ? 0 : this.isResetAble.intValue();
    }
}
