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

import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import com.fasterxml.jackson.annotation.JsonFormat;
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 : silliter.yuan
 * @CreateDate : 2019-05-10 17:16
 * @Modify:
 **/
@Data
@Entity
@Table(name="ANDON_MANAGE_RECORD", indexes = {
        @Index(columnList = "WORK_CENTER_CODE", name = "ANDON_INDEX_WORK_CENTER_CODE"),
        @Index(columnList = "WORK_CELL_CODE", name = "ANDON_INDEX_WORK_CELL_CODE"),
        @Index(columnList = "ORGANIZE_CODE", name = "ANDON_INDEX_ORGANIZE_CODE"),
        @Index(columnList = "ANDON_ORDER_NO", name = "ANDON_INDEX_ANDON_ORDER_NO"),
        @Index(columnList = "ALARM_CODE", name = "ANDON_INDEX_ALARM_CODE"),
        @Index(columnList = "STATUS_CODE", name = "ANDON_INDEX_STATUS_CODE"),
        @Index(columnList = "ACTION_CODE", name = "ANDON_INDEX_ACTION_CODE"),
        @Index(columnList = "EQUIPMENT_CODE", name = "ANDON_INDEX_EQUIPMENT_CODE")
})
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Api("安灯记录")
public class AndonManageRecord extends BaseBean {

    @Column(name = "ANDON_ORDER_NO")
    @ApiParam(value = "安灯队列编号")
    private String andonOrderNo;

    @Column(name = "ALARM_CODE")
    @ApiParam(value = "安灯类型")
    private String alarmCode;

    @Column(name = "ACTION_CODE")
    @ApiParam(value = "安灯动作代码")
    private String actionCode;

    @Column(name = "WORK_CENTER_CODE")
    @ApiParam(value = "工作中心代码")
    private String workCenterCode;

    @Column(name = "WORK_CENTER_NAME_RDD")
    @ApiParam(value = "工作中心名称")
    private String workCenterNameRdd;

    @Column(name = "WORK_CELL_NAME_RDD")
    @ApiParam(value = "工作单元名称")
    private String workCellNameRdd;

    @Column(name = "WORK_CELL_CODE")
    @ApiParam(value = "工作单元代码")
    private String workCellCode;

    @Column(name = "EQUIPMENT_CODE")
    @ApiParam(value = "设备代码")
    private String equipmentCode;

    @Column(name = "EQUIPMENT_NAME_RDD")
    @ApiParam(value = "设备名称")
    private String equipmentNameRdd;

    @Column(name = "SHIFT_CODE")
    @ApiParam(value = "班次代码")
    private String shiftCode;

    @Column(name = "SHIFT_NAME_RDD")
    @ApiParam(value = "班次名称")
    private String shiftNameRdd;

    @Column(name = "STATUS_CODE")
    @ApiParam(value = "安灯状态代码")
    private String statusCode;

    @Column(name = "SEQ")
    @ApiParam(value = "序号", example = "1")
    private Double seq;

    @Column(name = "PRIORITY_LEVEL")
    @ApiParam(value = "优先级别", example = "1")
    private Integer priorityLevel;

    @Column(name="CALL_TIME",updatable = false)
    @ApiParam(value = "呼叫时间")
    @AnnoOutputColumn(hidden = true)
    public String callTime;

    @Transient
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiParam(value="呼叫时间",example = "2018-01-01 01:00:00")
    @AnnoOutputColumn(hidden = true)
    public String callTimeStr;

    @Column(name="CONFIRM_TIME",updatable = false)
    @ApiParam(value = "响应时间")
    @AnnoOutputColumn(hidden = true)
    public String confirmTime;

    @Transient
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiParam(value="响应时间",example = "2018-01-01 01:00:00")
    @AnnoOutputColumn(hidden = true)
    public String confirmTimeStr;

    @Column(name="RESET_TIME",updatable = false)
    @ApiParam(value = "解决时间")
    @AnnoOutputColumn(hidden = true)
    public String resetTime;

    @Transient
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiParam(value="解决时间",example = "2018-01-01 01:00:00")
    @AnnoOutputColumn(hidden = true)
    public String resetTimeStr;

    @Column(name = "CALL_USER")
    @ApiParam(value = "呼叫人")
    private String callUser;

    @Transient
    @ApiParam(value = "呼叫人名字")
    private String callUserName;

    @Column(name = "CONFIRM_USER")
    @ApiParam(value = "响应人")
    private String confirmUser;

    @Transient
    @ApiParam(value = "响应人名字")
    private String confirmUserName;

    @Column(name = "RESET_USER")
    @ApiParam(value = "解决人")
    private String resetUser;

    @Transient
    @ApiParam(value = "解决人名字")
    private String resetUserName;

    @Column(name = "IS_SHIFT_CALL")
    @ApiParam(value = "是否转呼", example = "1")
    private Integer isShiftCall;

    @Column(name="SHIFT_CALL_TIME",updatable = false)
    @ApiParam(value = "转呼时间")
    @AnnoOutputColumn(hidden = true)
    public String shiftCallTime;

    @Transient
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiParam(value="转呼时间",example = "2018-01-01 01:00:00")
    @AnnoOutputColumn(hidden = true)
    public String shiftCallTimeStr;

    @Column(name = "RP_OBJECT_CODE")
    @ApiParam(value = "转呼对象代码")
    private String rpObjectCode;

    @Column(name = "SC_RESPONSE_CODE")
    @ApiParam(value = "转呼响应方式")
    private String scResponseCode;

    @Column(name = "SC_RP_LEVEL")
    @ApiParam(value = "转呼通知等级")
    private String scRpLevel;

    @Column(name = "AC_CODE")
    @ApiParam(value = "呼叫原因代码")
    private String acCode;

    @Column(name = "AC_NAME_RDD")
    @ApiParam(value = "呼叫原因描述")
    private String acNameRdd;

    @Column(name = "AC_DESC")
    @ApiParam(value = "呼叫具体原因")
    private String acDesc;

    @Column(name = "EC_CODE")
    @ApiParam(value = "事件原因代码")
    private String ecCode;

    @Column(name = "EC_NAME_RDD")
    @ApiParam(value = "事件原因描述")
    private String ecNameRdd;

    @Column(name = "EC_DESC")
    @ApiParam(value = "事件具体原因")
    private String ecDesc;

    @Column(name = "EM_CODE")
    @ApiParam(value = "事件方法代码")
    private String emCode;

    @Column(name = "EM_NAME_RDD")
    @ApiParam(value = "事件方法描述")
    private String emNameRdd;

    @Column(name = "EM_DESC")
    @ApiParam(value = "事件具体方法")
    private String emDesc;

    @Column(name = "IS_HALT")
    @ApiParam(value = "是否停机", example = "1")
    private Integer isHalt;

    @Column(name = "HALT_CODE")
    @ApiParam(value = "停机类型")
    private String haltCode;

    @Column(name = "HALT_DESC")
    @ApiParam(value = "停机具体原因")
    private String haltDesc;

    @Column(name = "SEND_FLAG")
    @ApiParam(value = "发送标志")
    private String sendFlag;

    /**
     * 处理类型：10=标准处理，20=自处理
     */
    @Column(name = "DISPOSAL_TYPE")
    @ApiParam(value = "处理类型")
    private String disposalType;

    @Column(name = "ALARM_DETAIL_CODE")
    @ApiParam(value = "安灯子类型代码")
    private String alarmDetailCode;

    @Column(name = "EPM_CODE")
    @ApiParam(value = "事件现象代码")
    private String epmCode;

    @Column(name = "EPM_NAME_RDD")
    @ApiParam(value = "事件现象描述")
    private String epmNameRdd;

    @Column(name = "IMPORTANCE_CODE")
    @ApiParam(value = "重要等级代码")
    private String importanceCode;

    @Column(name = "IMPORTANCE_NAME_RDD")
    @ApiParam(value = "重要等级名称")
    private String importanceNameRdd;

    @Column(name = "ORGANIZE_NAME_RDD")
    @ApiParam(value = "组织名称")
    private String organizeNameRdd;

    @Column(name = "REJECT_OPINION")
    @ApiParam(value = "驳回意见")
    private String rejectOpinion;

    @Column(name = "OPEN_INFO")
    @ApiParam(value = "放行说明")
    private String openInfo;

    @Column(name = "SIGN_SEND_FLAG")
    @ApiParam(value = "响应已通知标识")
    private String signSendFlag;

    // 是否转呼
    public Integer getIsShiftCall() {
        return this.isShiftCall == null ? 0 : this.isShiftCall;
    }

    // 获取优先级别
    public Integer getPriorityLevel() {
        return this.priorityLevel == null ? 0 : this.priorityLevel;
    }

    public AndonManageRecord() {
    }

    public AndonManageRecord(String andonOrderNo) {
        this.andonOrderNo = andonOrderNo;
    }
}
