package org.jeecg.modules.database.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * @Description: 试验报告 @Author: jeecg-boot @Date: 2024-10-23 @Version: V1.0
 */
@Data
@TableName("experiment_report")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "试验报告")
public class ExperimentReport implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId(type = IdType.ASSIGN_ID)
    @Schema(description = "主键")
    private String id;

    /**
     * 创建人
     */
    @Schema(description = "创建人")
    private String createBy;

    /**
     * 创建日期
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "创建日期")
    private Date createTime;

    /**
     * 更新人
     */
    @Schema(description = "更新人")
    private String updateBy;

    /**
     * 更新日期
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @Schema(description = "更新日期")
    private Date updateTime;

    /**
     * 所属部门
     */
    @Schema(description = "所属部门")
    private String sysOrgCode;

    /**
     * 试验ID
     */
    @Excel(name = "试验ID", width = 15)
    @Schema(description = "试验ID")
    private String experimentId;

    /**
     * 样品信息
     */
    @Excel(name = "样品信息", width = 15)
    @Schema(description = "样品信息")
    private String sampleInfo;

    /**
     * 偏置原理图
     */
    @Excel(name = "偏置原理图", width = 15)
    @Schema(description = "偏置原理图")
    private String imgUrls;

    /**
     * 偏置原理说明
     */
    @Excel(name = "偏置原理说明", width = 15)
    @Schema(description = "偏置原理说明")
    private String description;

    /**
     * 审核员
     */
    @Excel(name = "审核员", width = 15)
    @Schema(description = "审核员")
    private String auditor;

    /**
     * 校对员
     */
    @Excel(name = "校对员", width = 15)
    @Schema(description = "校对员")
    private String proofreader;

    /**
     * 确认员
     */
    @Excel(name = "确认员", width = 15)
    @Schema(description = "确认员")
    private String confirmer;

    /**
     * 报告名称
     */
    @Excel(name = "报告名称", width = 15)
    @Schema(description = "报告名称")
    private String reportName;

    /**
     * 状态
     */
    @Excel(name = "状态", width = 15)
    @Schema(
            description =
                    "状态(申请中待校对:INIT,不合格:REJECT ,校对通过待审核：PROOFREAD_PASS,审核通过待批准：AUDIT_PASS，批准通过：PASSED)")
    private String status;

    @Excel(name = "上一个状态", width = 15)
    @Schema(description = "上一个状态")
    private String lastStatus;

    @Excel(name = "审批意见", width = 15)
    @Schema(description = "审批意见")
    private String auditorMemo;

    @Excel(name = "校对意见", width = 15)
    @Schema(description = "校对意见")
    private String proofreaderMemo;

    @Excel(name = "批准意见", width = 15)
    @Schema(description = "批准意见")
    private String confirmerMemo;

    @Excel(name = "审批时间", width = 15)
    @Schema(description = "审批时间")
    private String auditorTime;

    @Excel(name = "校对时间", width = 15)
    @Schema(description = "校对时间")
    private String proofreaderTime;

    @Excel(name = "批准时间", width = 15)
    @Schema(description = "批准时间")
    private String confirmerTime;

    @Schema(description = "生成的文件路径")
    private String fileUrl;

    @TableField(exist = false)
    private String memo;

    public String getMemo() {
        if (StringUtils.isNotBlank(proofreaderMemo)) {
            return proofreaderMemo;
        }
        if (StringUtils.isNotBlank(auditorMemo)) {
            return auditorMemo;
        }
        if (StringUtils.isNotBlank(confirmerMemo)) {
            return confirmerMemo;
        }
        return null;
    }
}
