package com.yuchen.saas.integration.feign.api.dto;

import com.yuchen.saas.integration.feign.api.entity.ActProcessApprover;
import com.yuchen.saas.integration.feign.api.entity.DataEntity;
import io.jsonwebtoken.lang.Collections;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * @Description 节点，主要记录流程审批过程中的类型，序号，名称，是否通过，审批人集合等主要信息
 * @Author 林立超
 * @Date 2022-10-18
 * @Version 1.0
 **/
@Data
public class ActRuProcessNodeDto extends DataEntity<ActRuProcessNodeDto> {
    //所属的任务id
    private String taskId;
    //节点序号
    private int nodeNo;
    //节点名称
    private String text;
    //
    private List<ActProcessApprover> approverList;
    //    审批节点类型
    private int approverType;
    //动作标识
    private int actionMark;
    //审批用户id逗号分隔
    private String approverIds;

    /**
     * 审核人类型 1：具体人，2 角色，3 菜单
     */
    @ApiModelProperty(value = "审核人类型 1：具体人，2 角色，3 菜单")
    private String approverUserType;

    //所属的流程分支id
    private String processId;
    //是否通过
   // private String pass = ActEnum.ActState.RUNNING.getFlag();
    private String pass ;
    //下一节点id
    private ActRuProcessNodeDto nextNode;

   // private List<OaActHiTask> hiTasks;
    //下一节点集合
    private List<ActRuProcessNodeDto> nextNodeList;
    //上一节点集合
    private List<ActRuProcessNodeDto> prevNodeList;


    public String getApproverIds() {
        if (approverIds != null) {
            return approverIds;
        }
        if (Collections.isEmpty(approverList)) {
            return null;
        }
        StringBuilder builder = new StringBuilder();

        for (ActProcessApprover p : approverList) {
            builder.append(p.getId()).append(",");
        }
        builder.setLength(builder.length() - 1);
        this.approverIds = builder.toString();
        return approverIds;
    }


    public ActRuProcessNodeDto(String id) {
        super(id);
    }

    public ActRuProcessNodeDto() {
    }
}
