package com.sundot.airport.system.domain.approval;

import java.util.Date;
import java.util.List;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.sundot.airport.common.annotation.Excel;
import com.sundot.airport.common.core.domain.BaseEntity;

/**
 * 审批实例对象 approval_instance
 *
 * @author simon lin
 * @date 2025-09-06
 */
@TableName("approval_instance")
public class ApprovalInstance extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 实例编号
     */
    @Excel(name = "实例编号")
    @NotBlank(message = "实例编号不能为空")
    @Size(min = 0, max = 50, message = "实例编号长度不能超过50个字符")
    private String instanceNo;

    /**
     * 流程定义ID
     */
    @Excel(name = "流程定义ID")
    @NotNull(message = "流程定义ID不能为空")
    private Long workflowId;

    /**
     * 审批标题
     */
    @Excel(name = "审批标题")
    @NotBlank(message = "审批标题不能为空")
    @Size(min = 0, max = 200, message = "审批标题长度不能超过200个字符")
    private String title;

    /**
     * 业务类型
     */
    @Excel(name = "业务类型")
    @NotBlank(message = "业务类型不能为空")
    @Size(min = 0, max = 50, message = "业务类型长度不能超过50个字符")
    private String businessType;

    /**
     * 业务ID
     */
    @Excel(name = "业务ID")
    @NotNull(message = "业务ID不能为空")
    private Long businessId;

    /**
     * 业务数据(JSON格式)
     */
    @Excel(name = "业务数据")
    private String businessData;

    /**
     * 提交人ID
     */
    @Excel(name = "提交人ID")
    @NotNull(message = "提交人ID不能为空")
    private Long submitterId;

    /**
     * 提交人姓名
     */
    @Excel(name = "提交人姓名")
    @NotBlank(message = "提交人姓名不能为空")
    @Size(min = 0, max = 50, message = "提交人姓名长度不能超过50个字符")
    private String submitterName;

    /**
     * 提交时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "提交时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date submitTime;

    /**
     * 当前节点ID
     */
    @Excel(name = "当前节点ID")
    private Long currentNodeId;

    /**
     * 实例状态(RUNNING:运行中,COMPLETED:已完成,REJECTED:已驳回,CANCELLED:已取消)
     */
    @Excel(name = "实例状态")
    @Size(min = 0, max = 20, message = "实例状态长度不能超过20个字符")
    private String status;

    /**
     * 完成时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "完成时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date completionTime;

    /**
     * 紧急程度(LOW:低,NORMAL:普通,HIGH:高,URGENT:紧急)
     */
    @Excel(name = "紧急程度")
    @Size(min = 0, max = 20, message = "紧急程度长度不能超过20个字符")
    private String urgentLevel;

    /**
     * 表单数据
     */
    @Excel(name = "表单数据")
    private String formData;

    /**
     * 任务列表
     */
    @TableField(exist = false)
    private List<ApprovalTask> tasks;

    /**
     * 历史记录
     */
    @TableField(exist = false)
    private List<ApprovalHistory> histories;

    /**
     * 流程定义
     */
    @TableField(exist = false)
    private ApprovalWorkflowDefinition workflowDefinition;

    /**
     * 当前节点定义
     */
    @TableField(exist = false)
    private ApprovalNodeDefinition currentNode;

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setInstanceNo(String instanceNo) {
        this.instanceNo = instanceNo;
    }

    public String getInstanceNo() {
        return instanceNo;
    }

    public void setWorkflowId(Long workflowId) {
        this.workflowId = workflowId;
    }

    public Long getWorkflowId() {
        return workflowId;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setBusinessType(String businessType) {
        this.businessType = businessType;
    }

    public String getBusinessType() {
        return businessType;
    }

    public void setBusinessId(Long businessId) {
        this.businessId = businessId;
    }

    public Long getBusinessId() {
        return businessId;
    }

    public void setBusinessData(String businessData) {
        this.businessData = businessData;
    }

    public String getBusinessData() {
        return businessData;
    }

    public void setSubmitterId(Long submitterId) {
        this.submitterId = submitterId;
    }

    public Long getSubmitterId() {
        return submitterId;
    }

    public void setSubmitterName(String submitterName) {
        this.submitterName = submitterName;
    }

    public String getSubmitterName() {
        return submitterName;
    }

    public void setSubmitTime(Date submitTime) {
        this.submitTime = submitTime;
    }

    public Date getSubmitTime() {
        return submitTime;
    }

    public void setCurrentNodeId(Long currentNodeId) {
        this.currentNodeId = currentNodeId;
    }

    public Long getCurrentNodeId() {
        return currentNodeId;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getStatus() {
        return status;
    }

    public void setCompletionTime(Date completionTime) {
        this.completionTime = completionTime;
    }

    public Date getCompletionTime() {
        return completionTime;
    }

    public void setUrgentLevel(String urgentLevel) {
        this.urgentLevel = urgentLevel;
    }

    public String getUrgentLevel() {
        return urgentLevel;
    }

    public void setFormData(String formData) {
        this.formData = formData;
    }

    public String getFormData() {
        return formData;
    }

    public List<ApprovalTask> getTasks() {
        return tasks;
    }

    public void setTasks(List<ApprovalTask> tasks) {
        this.tasks = tasks;
    }

    public List<ApprovalHistory> getHistories() {
        return histories;
    }

    public void setHistories(List<ApprovalHistory> histories) {
        this.histories = histories;
    }

    public ApprovalWorkflowDefinition getWorkflowDefinition() {
        return workflowDefinition;
    }

    public void setWorkflowDefinition(ApprovalWorkflowDefinition workflowDefinition) {
        this.workflowDefinition = workflowDefinition;
    }

    public ApprovalNodeDefinition getCurrentNode() {
        return currentNode;
    }

    public void setCurrentNode(ApprovalNodeDefinition currentNode) {
        this.currentNode = currentNode;
    }

    @Override
    public String toString() {
        return "ApprovalInstance{" +
                "id=" + id +
                ", instanceNo='" + instanceNo + '\'' +
                ", workflowId=" + workflowId +
                ", title='" + title + '\'' +
                ", businessType='" + businessType + '\'' +
                ", businessId=" + businessId +
                ", submitterId=" + submitterId +
                ", submitterName='" + submitterName + '\'' +
                ", submitTime=" + submitTime +
                ", currentNodeId=" + currentNodeId +
                ", status='" + status + '\'' +
                ", completionTime=" + completionTime +
                ", urgentLevel='" + urgentLevel + '\'' +
                '}';
    }
}