package com.hz.pm.api.projectlib.model.enumeration;

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

import java.util.Objects;

/**
 *
 * 预警填报类型枚举
 * @author CMM
 * @since 2023/02/24 16:14
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum WarningFlowTypeEnum {
    /**
     * 预警填报类型枚举
     */
    UNIT_INNER_AUDIT(1, "预审申报",ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode(),"declareManage/planDeclaration/preExaminationDeclare"),
    PRELIMINARY_PREVIEW(2, "建设方案申报",ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode(),"declareManage/constructionPlanDeclare"),
    DEPT_UNITED_REVIEW(3,"采购结果备案",ProjectStatusEnum.TO_BE_PURCHASED.getCode(),"declareManage/procurementRecord/purchaseResults"),
    CONSTRUCTION_PLAN_REVIEW(4,"初验备案",ProjectStatusEnum.UNDER_CONSTRUCTION.getCode(),"declareManage/acceptanceApply/initialInspectionRecord"),
    PROJECT_FINAL_INSPECTION(5,"验收申报",ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode(),"declareManage/acceptanceApply/finalInspectionDeclare");

    private Integer code;
    private String desc;

    //对应的 待提交时的项目状态
    private Integer projectStutas;

    private String path;

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

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