package com.hz.pm.api.projectdeclared.utils;

import com.google.common.collect.Maps;
import com.hz.pm.api.projectdeclared.manage.*;
import com.hz.pm.api.projectdeclared.model.dto.DefaultDeclaredDTO;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.function.Function;

/**
 * <p>
 * RestartProcessMapUtil - 项目调整 重新提交时的 事件函数MAP
 * </p>
 *
 * @author PoffyZhang
 * @since 2023/2/15 11:19
 */
@Component
public class RestartProcessMapUtil {

    private static final Map<Integer, Function<DefaultDeclaredDTO, String>> RESTART_PROCESS_MAP = Maps.newHashMap();

    public RestartProcessMapUtil(DeclaredProjectManage declaredProjectManage,
                                 ConstructionPlanManage constructionPlanManage,
                                 PrequalificationDeclaredProjectManage prequalificationDeclaredProjectManage,
                                 ReviewByProvincialDeptManage provincialDeptManage,
                                 FinalAcceptanceManage finalAcceptanceManage) {
        //重新项目申报
        RESTART_PROCESS_MAP.put(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode(),
                declaredProjectManage::reStartTheProcess);
        //建设方案
        RESTART_PROCESS_MAP.put(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode(),
                constructionPlanManage::restartTheProcess);
        //预审方案
        RESTART_PROCESS_MAP.put(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode(),
                prequalificationDeclaredProjectManage::restartTheProcess);
        //省级联审
        RESTART_PROCESS_MAP.put(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode(),
                provincialDeptManage::restartTheProcess);
        //终审
        RESTART_PROCESS_MAP.put(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED.getCode(),
                finalAcceptanceManage::restartProcess);
    }

    public static Function<DefaultDeclaredDTO, String> getRestartFunction(Integer status) {
        return RESTART_PROCESS_MAP.get(status);
    }

}
