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

import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.BlockSoftSwitchEnumUtil;
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.*;
import java.util.List;

/**
 * @Description : 适配报文详情
 * @Reference :
 * @Author : yunhao
 * @CreateDate : 2019-08-13 9:21
 * @Modify:
 */
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "BS_SUIT_DATA_DETAIL",indexes = {
        @Index(name="bs_suit_data_detail_suit_record_id_idx",columnList = "SUIT_RECORD_ID"),
        @Index(name="bs_suit_data_detail_suit_case_name_rdd_idx",columnList = "SUIT_CASE_NAME_RDD"),
        @Index(name="bs_suit_data_detail_suit_case_code_idx",columnList = "SUIT_CASE_CODE_RDD"),
        @Index(name="bs_suit_data_detail_create_date_time_idx",columnList = "CREATE_DATE_TIME")
})
@Api(value = "适配报文详情", description = "适配报文详情")
public class BsSuitDataDetail extends BaseBean {

    private static final long serialVersionUID = 4086839854444963656L;
    @Column(name = "SUIT_CASE_ID")
    @ApiParam(value = "适配套件id")
    private String suitCaseId;

    @Column(name = "SUIT_CASE_NAME_RDD")
    @ApiParam(value = "适配套件名称")
    private String suitCaseNameRdd;

    @Column(name = "SUIT_CASE_CODE_RDD")
    @ApiParam(value = "适配套件代码")
    private String suitCaseCodeRdd;

    @Column(name = "SUIT_TYPE_ID")
    @ApiParam(value = "适配类型id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long suitTypeId;

    @Column(name = "CASE_TYPE_ID")
    @ApiParam(value = "套件类型id(枚举)")
    @AnnoOutputColumn(refClass = BlockSoftSwitchEnumUtil.CASE_TYPE.class)
    private Integer caseTypeId;

    @Column(name = "SUIT_TYPE_NAME_RDD")
    @ApiParam(value = "适配类型名称")
    private String suitTypeNameRdd;

    @Column(name = "SUIT_RECORD_ID")
    @ApiParam(value = "适配记录id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long suitRecordId;

    @Column(name = "GET_DATE_TIME")
    @ApiParam(value = "获取报文时间")
    private String getDateTime;

    // 移动至记录数据表
    @Column(name = "ORGIN_DATA")
    @ApiParam(value = "原始报文数据")
    private String orginData;

    // 移动至记录数据表
    @Column(name = "TRANS_DATA")
    @ApiParam(value = "转换后的报文数据")
    private String transData;

    @Column(name = "PROCESS_STATE")
    @ApiParam(value = "处理状态")
    @AnnoOutputColumn(refClass = BlockSoftSwitchEnumUtil.SUIT_PROCESS_STATUS.class)
    private Integer processState;

    public String getProcessStateTxt() {
        return processState == null ? BlockSoftSwitchEnumUtil.SUIT_PROCESS_STATUS.UNPROCESSED.getDescription() :
                BlockSoftSwitchEnumUtil.SUIT_PROCESS_STATUS.valueOfDescription(processState);
    }

    @Column(name = "PROCESS_TIME")
    @ApiParam(value = "处理时间")
    private String processTime;

    @Transient
    @ApiParam(value = "适配请求文件列表")
    private List<BsSuitFile> bsSuitFileList;

    @Transient
    @ApiParam(value = "id-查询条件")
    private List<Long> searchIdList;
}

