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

import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
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 java.io.Serializable;

/**
 * @Description:
 * @Reference:
 * @Author: yiming.gu
 * @CreateDate:2019-04-22-17:32
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "MES_PCN_SYNC_CFG")
@Api("MES_PCN_同步配置")
public class MesPcnSyncCfg extends BaseBean implements Serializable {
    private static final long serialVersionUID = -6869288362923390521L;
    @Column(name = "PCN_CODE")
    @ApiParam("PCN代码")
    private String pcnCode;

    @Column(name = "OBJECT_CODE")
    @ApiParam("对象代码")
    private String objectCode;

    @Column(name = "OBJECT_NAME")
    @ApiParam("对象名称")
    private String objectName;

    @Column(name = "OBJECT_KEY")
    @ApiParam("对象主键")
    private String objectKey;

    @Column(name = "SYNC_FREQUENCY")
    @ApiParam("同步频率")
    private Integer syncFrequency;

    @Column(name = "SYNC_TIME")
    @ApiParam(value = "同步时间")
    private String syncTime;

    @Column(name = "SYNC_PATTERN")
    @ApiParam("同步方式 2.新增  1.修改")
    private Integer syncPattern;

    @Column(name = "SYNC_TYPE")
    @ApiParam("同步类型 1.pcn获取mes数据   2.pcn推送数据至mes")
    private Integer syncType;

    @Column(name = "LAST_SYNC_TIME")
    @ApiParam(value = "上一同步时间")
    private String lastSyncTime;

    @Column(name = "EXTRACT_GAP")
    @ApiParam(value = "从数据库抽取的最大值 目前为分钟为限制")
    private Integer extractGap;

    @Column(name = "EXTRACT_CONDITION")
    @ApiParam(value = "从数据库抽取的条件限制")
    private String extractCondition;

    @Column(name = "IS_IGNORE_ORG")
    @ApiParam(value = "同步的时候是否区分工厂")
    private Integer isIgnoreOrg = CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue();

    public int getSyncFrequencyVal() {
        return this.syncFrequency == null ? 0 : this.syncFrequency;
    }

    public int getSyncTypeVal() {
        return this.syncType == null ? 0 : this.syncType;
    }

    public int getSyncPatternVal() {
        return this.syncPattern == null ? 0 : this.syncPattern;
    }
}
