package com.jeeplus.centerservice.enums;

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

/**
 * 流程枚举
 */
public enum TaskAliasEnum {

    REIMBURSEMENT ("108,109", "Process_1665383385070");

    /**
     *  ccpm
     */
    private String ccpmTaskAlias;

    /**
     *  cpa
     */
    private String cpaTaskAlias;

    TaskAliasEnum(String ccpmTaskAlias, String cpaTaskAlias) {
        this.ccpmTaskAlias = ccpmTaskAlias;
        this.cpaTaskAlias = cpaTaskAlias;
    }

    public String getCcpmTaskAlias() {
        return ccpmTaskAlias;
    }

    public String getCpaTaskAlias() {
        return cpaTaskAlias;
    }

    /**
     * 根据ccpm流程key查询枚举
     * @param value
     * @return
     */
    public static TaskAliasEnum getByCcpmContains(String value) {
        TaskAliasEnum result = null;
        for (TaskAliasEnum s : values()) {
            List<String> stringList = Arrays.asList(s.getCcpmTaskAlias().split(","));
            if (stringList.contains(value)) {
                result = s;
            }
        }
        return result;
    }

    /**
     * 根据cpa流程key查询枚举
     * @param value
     * @return
     */
    public static TaskAliasEnum getByCpa(String value) {
        TaskAliasEnum result = null;
        for (TaskAliasEnum s : values()) {
            if (s.getCpaTaskAlias().equals(value)) {
                result = s;
                break;
            }
        }
        return result;
    }

    @Override
    public String toString() {
        return "ccpm:" + this.ccpmTaskAlias + ", cpa:" + this.cpaTaskAlias;
    }
}
