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

import cn.estsh.i3plus.pojo.andon.model.BaseManageQueue;
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.*;
import java.io.Serializable;

/**
 * @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 BaseManageQueue implements Serializable {

    private static final long serialVersionUID = 4667499369694353351L;

    @Column(name = "ROUTE_CODE")
    @ApiParam(value = "流程代码")
    private String routeCode;

    @Column(name = "ROUTE_STATUS_CODE")
    @ApiParam(value = "状态点代码")
    private String routeStatusCode;

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

    @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;

    @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;

    @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;

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

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


    @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 = "SEND_FLAG")
    @ApiParam(value = "发送标志")
    private String sendFlag;

    @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;

    // 安灯附属表
    @Transient
    @ApiParam(value ="临时/纠正措施")
    private String tempCorrectMethod;

    @Transient
    @ApiParam(value ="预防/纠正措施")
    private String preCorrectMethod;

    @Transient
    @ApiParam(value ="客户")
    private String customer;

    @Transient
    @ApiParam(value ="零件号")
    private String partNo;

    @Transient
    @ApiParam(value ="零件名称")
    private String partName;

    @Transient
    @ApiParam(value ="报废数量")
    private Double scrapNum;

    @Transient
    @ApiParam(value ="批次")
    private String lot;

    @Transient
    @ApiParam(value ="零件数量")
    private Double partNum;

    @Transient
    @ApiParam(value ="设备名称")
    private String deviceName;

    @Transient
    @ApiParam(value ="是否更换备件")
    private Integer isChangeBackup;

    @Transient
    @ApiParam(value ="备件名称")
    private String backupPartName;

    @Transient
    @ApiParam(value ="规格型号")
    private String scale;

    @Transient
    @ApiParam(value ="当前件数")
    private Integer currentProdNum;

    @Transient
    @ApiParam(value ="生产累计件数")
    private Integer totalProdNum;

    // 是否转呼
    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;
    }
}
