package com.ruoyi.hywz.common.enums;

import com.ruoyi.hywz.entity.vo.NodeVo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author: jxh
 * @description: 开票申请流程节点
 * @create: 2023/10/24
 */
public enum InvoiceNodeEnum {

    /**开票申请流程节点*/
    NODE_0(0, 0,0,"开票申请"),
    NODE_2(2, 1,1,"业务审核"),
    NODE_4(4, 2,1,"财务审批"),
    NODE_6(6, 3,1,"财务开票"),
    NODE_8(8, 4,2,"发票上传"),
    NODE_10(10, 5,3,"发起报账"),
    NODE_12(12, 6,3,"财务入账及凭证生成"),
    END(14, 7,4,"已完成");

    private final int node;
    private final int index;
    private final int status;
    private final String desc;

    InvoiceNodeEnum(int node, int index, int status, String desc) {
        this.node = node;
        this.index = index;
        this.status = status;
        this.desc = desc;
    }

    public int getNode() {
        return node;
    }

    public int getIndex() {
        return index;
    }

    public int getStatus() {
        return status;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDesc(int node){
        return Arrays.stream(InvoiceNodeEnum.values()).filter(o -> o.getNode() == node).findFirst().get().getDesc();
    }

    public static int getIndex(int node) {
        return Arrays.stream(InvoiceNodeEnum.values()).filter(o -> o.getNode() == node).findFirst().get().getIndex();
    }

    public static List<NodeVo> getNodeList() {
        List<NodeVo> nodeList = new ArrayList<>();
        nodeList.add(new NodeVo(InvoiceNodeEnum.NODE_0.getDesc()));
        nodeList.add(new NodeVo(InvoiceNodeEnum.NODE_2.getDesc()));
        nodeList.add(new NodeVo(InvoiceNodeEnum.NODE_4.getDesc()));
        nodeList.add(new NodeVo(InvoiceNodeEnum.NODE_6.getDesc()));
        nodeList.add(new NodeVo(InvoiceNodeEnum.NODE_8.getDesc()));
        nodeList.add(new NodeVo(InvoiceNodeEnum.NODE_10.getDesc()));
        nodeList.add(new NodeVo(InvoiceNodeEnum.NODE_12.getDesc()));
        return nodeList;
    }

}
