package com.ningdatech.pmapi.projectdeclared.utils;

import com.google.common.collect.Maps;
import com.ningdatech.pmapi.projectdeclared.manage.ConstructionPlanManage;
import com.ningdatech.pmapi.projectdeclared.manage.DeclaredProjectManage;
import com.ningdatech.pmapi.projectdeclared.manage.PrequalificationDeclaredProjectManage;
import com.ningdatech.pmapi.projectdeclared.model.dto.DefaultDeclaredDTO;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.function.Function;

/**
 * @Classname ReSubmitProcessMap
 * @Description 项目调整 重新提交时的 事件函数MAP
 * @Date 2023/2/15 11:19
 * @Author PoffyZhang
 */
@Component
public class ReStartProcessMapUtil {
    @Autowired
    private DeclaredProjectManage declaredProjectManage;

    @Autowired
    private ConstructionPlanManage constructionPlanManage;

    @Autowired
    private PrequalificationDeclaredProjectManage prequalificationDeclaredProjectManage;
    public Map<Integer, Function<DefaultDeclaredDTO,String>> reStartProcessMap = Maps.newHashMap();
    /**
     *  初始化业务分派逻辑,代替了if-else部分
     *  key: 枚举 状态值
     *  value: lambda表达式,最终会获取发起实例的函数
     */
    public ReStartProcessMapUtil(){
        //重新项目申报
        reStartProcessMap.put(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode(),
                dto->declaredProjectManage.reStartTheProcess(dto));
        //预审方案
        reStartProcessMap.put(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode(),
                dto->constructionPlanManage.startTheProcess(dto));
        //预审方案
        reStartProcessMap.put(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode(),
                dto->prequalificationDeclaredProjectManage.startTheProcess(dto));
        //省级联审
        reStartProcessMap.put(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode(),
                dto->null);
    }
}
