package com.qmth.sop.common.enums;

import java.util.Objects;

/**
 * @Description: 广东医科大学流程审批步骤 enum
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2021/8/2
 */
public enum FlowApproveSetupEnum {

    START("开始", "start", 1, "开始节点"),

    END("已终止", null, -1, "终止"),

    FINISH("已结束", null, 0, "结束节点"),

    APPROVE("审批中", null, null, "审批节点");

    private String title;

    private String id;

    private Integer setup;

    private String remark;

    private FlowApproveSetupEnum(String title, String id, Integer setup, String remark) {
        this.title = title;
        this.id = id;
        this.setup = setup;
        this.remark = remark;
    }

    public String getTitle() {
        return title;
    }

    public String getId() {
        return id;
    }

    public Integer getSetup() {
        return setup;
    }

    public String getRemark() {
        return remark;
    }

    /**
     * 状态转换 toName
     *
     * @param title
     * @return
     */
    public static String convertToName(String title) {
        for (FlowApproveSetupEnum e : FlowApproveSetupEnum.values()) {
            if (Objects.equals(title, e.getTitle())) {
                return e.name();
            }
        }
        return null;
    }

    /**
     * 状态转换 ToInstance
     *
     * @param id
     * @return
     */
    public static FlowApproveSetupEnum convertToInstance(String id) {
        for (FlowApproveSetupEnum e : FlowApproveSetupEnum.values()) {
            if (Objects.equals(id, e.getId())) {
                return e;
            }
        }
        return null;
    }

    /**
     * 状态转换 ToRemark
     *
     * @param setup
     * @return
     */
    public static String convertToRemark(int setup) {
        for (FlowApproveSetupEnum e : FlowApproveSetupEnum.values()) {
            if (e.getSetup() == setup) {
                return e.getRemark();
            }
        }
        return null;
    }
}
