package com.hz.pm.sync.open.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * GovProjectStatusEnum
 *
 * @return
 * @author ZPF
 * @since 2023/10/24 16:27
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum GovProjectStatusEnum {
    /**
     * 项目归集 状态
     */
    APPROVAL("01", "评审中"),
    PENDING("02", "待立项"),
    REJECTED("03","已驳回"),
    APPROVED("04","已立项"),
    PURCHASED("05","已采购"),
    HAS_PRE_INS("06","已初验"),
    HAS_FINAL_INS("07","已终验"),
    TERMINATED("00","已终止");

    private String code;
    private String desc;

    public static String getDescByCode(Integer code) {
        if (Objects.isNull(code)) {
            return StringUtils.EMPTY;
        }
        for (GovProjectStatusEnum t : GovProjectStatusEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.desc;
            }
        }
        return StringUtils.EMPTY;
    }

    public static GovProjectStatusEnum match(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        for (GovProjectStatusEnum t : GovProjectStatusEnum.values()) {
            if (code.equals(t.getCode())) {
                return t;
            }
        }
        return null;
    }
}
