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

import java.util.Date;

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_task
 *
 * @author simon lin
 * @date 2025-09-06
 */
@TableName("approval_task")
public class ApprovalTask 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 taskNo;

    /**
     * 实例ID
     */
    @Excel(name = "实例ID")
    @NotNull(message = "实例ID不能为空")
    private Long instanceId;

    /**
     * 节点ID
     */
    @Excel(name = "节点ID")
    @NotNull(message = "节点ID不能为空")
    private Long nodeId;

    /**
     * 任务名称
     */
    @Excel(name = "任务名称")
    @NotBlank(message = "任务名称不能为空")
    @Size(min = 0, max = 100, message = "任务名称长度不能超过100个字符")
    private String taskName;

    /**
     * 处理人ID
     */
    @Excel(name = "处理人ID")
    @NotNull(message = "处理人ID不能为空")
    private Long assigneeId;

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

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

    /**
     * 任务状态(PENDING:待处理,APPROVED:已同意,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 completeTime;

    /**
     * 审批意见
     */
    @Excel(name = "审批意见")
    private String comment;

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

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

    /**
     * 是否超时(0否 1是)
     */
    @Excel(name = "是否超时", readConverterExp = "0=否,1=是")
    private String isTimeout;

    /**
     * 审批实例
     */
    @TableField(exist = false)
    private ApprovalInstance instance;

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

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

    public Long getId() {
        return id;
    }

    public void setTaskNo(String taskNo) {
        this.taskNo = taskNo;
    }

    public String getTaskNo() {
        return taskNo;
    }

    public void setInstanceId(Long instanceId) {
        this.instanceId = instanceId;
    }

    public Long getInstanceId() {
        return instanceId;
    }

    public void setNodeId(Long nodeId) {
        this.nodeId = nodeId;
    }

    public Long getNodeId() {
        return nodeId;
    }

    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }

    public String getTaskName() {
        return taskName;
    }

    public void setAssigneeId(Long assigneeId) {
        this.assigneeId = assigneeId;
    }

    public Long getAssigneeId() {
        return assigneeId;
    }

    public void setAssigneeName(String assigneeName) {
        this.assigneeName = assigneeName;
    }

    public String getAssigneeName() {
        return assigneeName;
    }

    public void setAssignTime(Date assignTime) {
        this.assignTime = assignTime;
    }

    public Date getAssignTime() {
        return assignTime;
    }

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

    public String getStatus() {
        return status;
    }

    public void setCompleteTime(Date completeTime) {
        this.completeTime = completeTime;
    }

    public Date getCompleteTime() {
        return completeTime;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getComment() {
        return comment;
    }

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

    public String getFormData() {
        return formData;
    }

    public void setTimeoutTime(Date timeoutTime) {
        this.timeoutTime = timeoutTime;
    }

    public Date getTimeoutTime() {
        return timeoutTime;
    }

    public void setIsTimeout(String isTimeout) {
        this.isTimeout = isTimeout;
    }

    public String getIsTimeout() {
        return isTimeout;
    }

    public ApprovalInstance getInstance() {
        return instance;
    }

    public void setInstance(ApprovalInstance instance) {
        this.instance = instance;
    }

    public ApprovalNodeDefinition getNodeDefinition() {
        return nodeDefinition;
    }

    public void setNodeDefinition(ApprovalNodeDefinition nodeDefinition) {
        this.nodeDefinition = nodeDefinition;
    }

    @Override
    public String toString() {
        return "ApprovalTask{" +
                "id=" + id +
                ", taskNo='" + taskNo + '\'' +
                ", instanceId=" + instanceId +
                ", nodeId=" + nodeId +
                ", taskName='" + taskName + '\'' +
                ", assigneeId=" + assigneeId +
                ", assigneeName='" + assigneeName + '\'' +
                ", assignTime=" + assignTime +
                ", status='" + status + '\'' +
                ", completeTime=" + completeTime +
                ", timeoutTime=" + timeoutTime +
                ", isTimeout='" + isTimeout + '\'' +
                '}';
    }
}