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

import com.njcn.bpm.pojo.vo.instance.BpmProcessInstanceVO;
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 BpmTaskVO {

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

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

    @ApiModelProperty("创建时间")
    private LocalDateTime createTime;

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

    @Schema(description = "持续时间", example = "1000")
    @ApiModelProperty("持续时间")
    private Long durationInMillis;

    @ApiModelProperty("任务状态")
    private Integer status; // 参见 BpmTaskStatusEnum 枚举

    @ApiModelProperty("审批理由")
    private String reason;

    /**
     * 负责人的用户信息
     */
    private BpmProcessInstanceVO.User ownerUser;

    /**
     * 审核的用户信息
     */
    private BpmProcessInstanceVO.User assigneeUser;


    @ApiModelProperty("任务定义的标识")
    private String taskDefinitionKey;

    @ApiModelProperty("所属流程实例编号")
    private String processInstanceId;
    /**
     * 所属流程实例
     */
    private ProcessInstance processInstance;

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

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


    @ApiModelProperty("父任务编号")
    private String parentTaskId;


    @ApiModelProperty("子任务列表（由加签生成）")
    private List<BpmTaskVO> children;

    @ApiModelProperty("表单编号")
    private String formId;


    @ApiModelProperty("表单名字")
    private String formName;


    @ApiModelProperty("表单的配置-JSON 字符串")
    private String formConf;

    @ApiModelProperty("表单项的数组")
    private List<String> formFields;

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

    @Data
    @Schema(description = "流程实例")
    public static class ProcessInstance {

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

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

        @ApiModelProperty("提交时间")
        private LocalDateTime createTime;

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

        /**
         * 发起人的用户信息
         */
        private BpmProcessInstanceVO.User startUser;

    }
}
