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

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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;

/**
 * WMS - SAP 中间数据库接口映射关系
 *
 * @author Rock.Yu
 * @since 2019-06-09 20:08
 */
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Table(name = "WMS_INTERFACE_DATA_RECORD", indexes = {
        @Index(columnList = "ORGANIZE_CODE"),
        @Index(columnList = "SRC_TABLE_NAME"),
        @Index(columnList = "DEST_BEAN_NAME"),
        @Index(columnList = "SOFT_ADAPTOR_CODE"),
        @Index(columnList = "SID"),
        @Index(columnList = "MOVE_TO_ERP_ID"),
        @Index(columnList = "ERP_DOC_NO")
})
@Api("接口数据收发记录")
public class WmsInterfaceDataRecord extends BaseBean {
    private static final long serialVersionUID = 4139055040492108499L;

    @ApiParam("来源表名")
    @Column(name = "SRC_TABLE_NAME", length = 50)
    private String srcTableName;

    @ApiParam("目标实体对象的名字，多个字段用半角逗号分隔")
    @Column(name = "DEST_BEAN_NAME", length = 500)
    private String destBeanName;

    @ApiParam("软适配编号")
    @Column(name = "SOFT_ADAPTOR_CODE")
    private String softAdaptorCode;

    @ApiParam("接口名称")
    @Column(name = "INTERFACE_NAME")
    private String interfaceName;

    @ApiParam("报文唯一编号")
    @Column(name = "SID")
    private Long sid;

    @ApiParam("MOVE_TO_ERP表的ID")
    @Column(name = "MOVE_TO_ERP_ID")
    private Long moveToErpID;

    @ApiParam("报文校验状态")
    @Column(name = "VERIFY_STATUS")
    @ColumnDefault("10")
    @AnnoOutputColumn(refClass = WmsEnumUtil.INTERFACE_DATA_VERIFY_STATUS.class, refForeignKey = "value", value = "description", required = false)
    private int verifyStatus;

    @ApiParam("备注信息")
    @Column(name = "REMARK")
    private String remark;

    @ApiParam("ERP文档编号")
    @Column(name = "ERP_DOC_NO")
    private String erpDocNo;

    // 必须有默认值
    @ApiParam("ERP状态代码")
    @Column(name = "ERP_STATUS_CODE", columnDefinition = "varchar(225) default ''")
    private String erpStatusCode;

    @ApiParam("ERP状态描述")
    @Column(name = "ERP_STATUS_DESC")
    private String erpStatusDesc;

    @ApiParam("ERP最后更新时间")
    @Column(name = "ERP_LAST_MODIFY_TIME")
    private String erpLastModifyTime;

}
