package com.ningdatech.pmapi.projectlib.enumeration;

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

import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * <p>
 * ProjectStatusEnum
 * </p>
 *
 * @author Poffy
 * @since 16:54 2023/2/11
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum ProjectStatusEnum {
    /**
     * 项目阶段：未立项
     */
    NOT_APPROVED(10000, "未立项"),
    UNDER_INTERNAL_AUDIT(10001, "单位内部审核中"),
    UNDER_INTERNAL_AUDIT_NOT_PASS(10002, "单位内部审核不通过"),
    PENDING_PREQUALIFICATION(10003, "待预审"),
    JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS(10004, "省级部门联审中"),
    THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED(10005, "省级部门联审不通过"),
    PRE_APPLYING(10006, "预审中"),
    PREQUALIFICATION_FAILED(10007, "预审不通过"),
    DEPARTMENT_JOINT_REVIEW(10008, "部门联审中"),
    DEPARTMENT_JOINT_REVIEW_FAILED(10009, "部门联审不通过"),
    IN_THE_ANNUAL_PLAN(10010, "年度计划中"),
    BE_SUSPENDED(10011, "被暂缓"),
    SCHEME_UNDER_REVIEW(10012, "方案评审中"),
    SCHEME_REVIEW_FAILED(10013, "方案评审不通过"),
    TO_BE_APPROVED(10014, "待立项批复"),
    TO_BE_DECLARED(10015, "待申报"),
    PLAN_TO_BE_DECLARED(10016, "方案待申报"),
    PENDING_PREQUALIFICATION_CHOICE(10017, "待预审选择态"),
    /**
     * 项目阶段：已立项
     */
    PROJECT_APPROVED(20000, "已立项"),
    TO_BE_PURCHASED(20001, "待采购"),
    UNDER_CONSTRUCTION(20002, "建设中"),
    TO_BE_FINALLY_INSPECTED(20003, "待终验"),
    FINAL_ACCEPTANCE_IS_UNDER_REVIEW(20004, "终验审核中"),
    FINAL_ACCEPTANCE_REVIEW_FAILED(20005, "终验审核不通过"),
    /**
     * 项目阶段：已归档
     */
    ARCHIVED(30000, "已归档"),
    ACCEPTED(30001, "已验收");

    private Integer code;
    private String desc;

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

    public static ProjectStatusEnum getValue(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }
        for (ProjectStatusEnum t : ProjectStatusEnum.values()) {
            if (code.equals(t.getCode())) {
                return t;
            }
        }
        return null;
    }

    public boolean eq(int code) {
        return this.getCode().equals(code);
    }

}
