package com.njcn.bpm.pojo.vo.instance;

import com.njcn.bpm.pojo.vo.BpmProcessDefinitionInfoVO;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Schema(description = "管理后台 - 流程实例的VO")
@Data
public class BpmProcessInstanceVO {

    @ApiModelProperty("流程实例的编号")
    private String id;

    @ApiModelProperty("流程名称")
    private String name;

    @ApiModelProperty("流程分类")
    private String category;

    @ApiModelProperty("流程分类名称")
    private String categoryName;

    @ApiModelProperty("流程实例的状态")
    private Integer status; // 参见 BpmProcessInstanceStatusEnum 枚举

    @ApiModelProperty("发起时间")
    private LocalDateTime startTime;

    @ApiModelProperty("结束时间")
    private LocalDateTime endTime;

    @ApiModelProperty("持续时间")
    private Long durationInMillis;

    @ApiModelProperty("提交的表单值")
    private Map<String, Object> formVariables;

    @ApiModelProperty("业务的唯一标识")
    private String businessKey;

    /**
     * 历史流程实例编号
     */
    private String historyInstanceId;

    /**
     * 业务流程重要信息
     */
    private String instanceSign;

    /**
     * 发起流程的用户
     */
    private User startUser;

    @ApiModelProperty("流程定义的编号")
    private String processDefinitionId;
    /**
     * 流程定义
     */
    private BpmProcessDefinitionInfoVO processDefinition;

    /**
     * 当前审批中的任务
     */
    private List<Task> tasks; // 仅在流程实例分页才返回

    @Schema(description = "用户信息")
    @Data
    public static class User {

        @ApiModelProperty("用户编号")
        private String id;

        @ApiModelProperty("用户昵称")
        private String name;

        @ApiModelProperty("部门编号")
        private String deptId;

        @ApiModelProperty("部门名称")
        private String deptName;

    }

    @Schema(description = "流程任务")
    @Data
    public static class Task {

        @ApiModelProperty("流程任务的编号")
        private String id;

        @ApiModelProperty("任务名称")
        private String name;

    }

}
