package com.sifang.modules.customer.constant;

import java.util.Optional;
import java.util.stream.Stream;

/**
 * 首次进件状态映射
 */
public enum GFFirstStateKM {

    Pending("待进件", "10", 4, 10),
    PreAudit("待审核", "20", 5, 20),
    Auditing("审核中", "25", 5, 25),
    Success("成功", "30", 6, 30),
    Fail("失败", "40", 7, 40),
    AuditFailed("审核不通过", "50", 7, 50),
    InProgress("进行中", "60", 5, 60);

    private String name;//状态名称
    private Integer internalCode;//内部编码
    private Integer externalCode;//外部编码
    private String code;

    public String getName() {
        return name;
    }

    public Integer getInternalCode() {
        return internalCode;
    }

    public Integer getExternalCode() {
        return externalCode;
    }

    public String getCode(){
        return code;
    }

    private GFFirstStateKM(String name, String code, Integer internalCode, Integer externalCode){
        this.name = name;
        this.code = code;
        this.internalCode = internalCode;
        this.externalCode = externalCode;
    }

    public static GFFirstStateKM externalOf(Integer externalCode){
        return Optional.ofNullable(externalCode)
                .map(v -> Stream.of(values())
                        .filter(s -> s.externalCode == v)
                        .findFirst()
                        .orElse(null))
                .orElse(null);
    }
}
