@Slf4j
@Component
public class SpringUtil implements ApplicationContextAware {
private static ApplicationContext applicationContext;
// 获取applicationContext
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if (SpringUtil.applicationContext == null) {
SpringUtil.applicationContext = applicationContext;
}
log.debug("获取ApplicationContext");
}
// 通过name获取Bean
public static Object getBean(String name) {
return getApplicationContext().getBean(name);
}
// 通过class获取Bean
public static <T> T getBean(Class<T> clazz) {
return getApplicationContext().getBean(clazz);
}
// 通过name,以及Clazz返回指定的Bean
public static <T> T getBean(String name, Class<T> clazz) {
return getApplicationContext().getBean(name, clazz);
}
}
private WorkSignBusinessService initWorkFlowBusinessService(String tableName) {
WorkSignBusinessService workSignBusinessService = null;
switch (tableName) {
case "t_agent_info":
workSignBusinessService = workSignBusinessServiceAgentInfo == null ? SpringUtil.getBean(WorkSignBusinessServiceAgentInfo.class) : workSignBusinessServiceAgentInfo;
break;
case "t_applicant_info":
workSignBusinessService = workSignBusinessServiceApplicantInfo== null ? SpringUtil.getBean(WorkSignBusinessServiceApplicantInfo.class) : workSignBusinessServiceApplicantInfo;
break;
case "t_case_handle":
workSignBusinessService = workSignBusinessServiceCaseHandle== null ? SpringUtil.getBean(WorkSignBusinessServiceCaseHandle.class) : workSignBusinessServiceCaseHandle;
break;
case "t_case_handle_record":
workSignBusinessService = workSignBusinessServiceCaseHandleRecord== null ? SpringUtil.getBean(WorkSignBusinessServiceCaseHandleRecord.class) : workSignBusinessServiceCaseHandleRecord;
break;
case "t_case_handle_user":
workSignBusinessService = workSignBusinessServiceCaseHandleUser== null ? SpringUtil.getBean(WorkSignBusinessServiceCaseHandleUser.class) : workSignBusinessServiceCaseHandleUser;
break;
case "t_case_info":
workSignBusinessService = workSignBusinessServiceCaseInfo== null ? SpringUtil.getBean(WorkSignBusinessServiceCaseInfo.class) : workSignBusinessServiceCaseInfo;
break;
case "t_case_modify_record":
workSignBusinessService = workSignBusinessServiceCaseModifyRecord== null ? SpringUtil.getBean(WorkSignBusinessServiceCaseModifyRecord.class) : workSignBusinessServiceCaseModifyRecord;
break;
case "t_case_threerule":
workSignBusinessService = workSignBusinessServiceCaseThreeRule== null ? SpringUtil.getBean(WorkSignBusinessServiceCaseThreeRule.class) : workSignBusinessServiceCaseThreeRule;
break;
case "t_case_work_extend":
workSignBusinessService = workSignBusinessServiceCaseWorkExtend== null ? SpringUtil.getBean(WorkSignBusinessServiceCaseWorkExtend.class) : workSignBusinessServiceCaseWorkExtend;
break;
case "t_case_work_rl":
workSignBusinessService = workSignBusinessServiceCaseWorkRl== null ? SpringUtil.getBean(WorkSignBusinessServiceCaseWorkRl.class) : workSignBusinessServiceCaseWorkRl;
break;
case "t_deliver_receiver":
workSignBusinessService = workSignBusinessServiceDeliverReceiver== null ? SpringUtil.getBean(WorkSignBusinessServiceDeliverReceiver.class) : workSignBusinessServiceDeliverReceiver;
break;
case "t_handle_user_record":
workSignBusinessService = workSignBusinessServiceHandleUserRecord== null ? SpringUtil.getBean(WorkSignBusinessServiceHandleUserRecord.class) : workSignBusinessServiceHandleUserRecord;
break;
case "t_overview_back_record":
workSignBusinessService = workSignBusinessServiceOverViewBackRecord== null ? SpringUtil.getBean(WorkSignBusinessServiceOverViewBackRecord.class) : workSignBusinessServiceOverViewBackRecord;
break;
case "t_proxy_info":
workSignBusinessService = workSignBusinessServiceProxyInfo== null ? SpringUtil.getBean(WorkSignBusinessServiceProxyInfo.class) : workSignBusinessServiceProxyInfo;
break;
case "t_respondent_info":
workSignBusinessService = workSignBusinessServiceRespondentInfo== null ? SpringUtil.getBean(WorkSignBusinessServiceRespondentInfo.class) : workSignBusinessServiceRespondentInfo;
break;
case "t_sms_record":
workSignBusinessService = workSignBusinessServiceSmsRecord== null ? SpringUtil.getBean(WorkSignBusinessServiceSmsRecord.class) : workSignBusinessServiceSmsRecord;
break;
case "t_sys_config":
workSignBusinessService = workSignBusinessServiceSysConfig== null ? SpringUtil.getBean(WorkSignBusinessServiceSysConfig.class) : workSignBusinessServiceSysConfig;
break;
case "t_third_person_info":
workSignBusinessService = workSignBusinessServiceThirdPersonInfo== null ? SpringUtil.getBean(WorkSignBusinessServiceThirdPersonInfo.class) : workSignBusinessServiceThirdPersonInfo;
break;
case "t_ws_result":
workSignBusinessService = workSignBusinessServiceWsResult== null ? SpringUtil.getBean(WorkSignBusinessServiceWsResult.class) : workSignBusinessServiceWsResult;
break;
case "t_ws_temp":
workSignBusinessService = workSignBusinessServiceWsTemp== null ? SpringUtil.getBean(WorkSignBusinessServiceWsTemp.class) : workSignBusinessServiceWsTemp;
break;
case "t_uap_app":
workSignBusinessService = workSignBusinessServiceUapApp== null ? SpringUtil.getBean(WorkSignBusinessServiceUapApp.class) : workSignBusinessServiceUapApp;
break;
case "t_uap_group":
workSignBusinessService = workSignBusinessServiceUapGroup== null ? SpringUtil.getBean(WorkSignBusinessServiceUapGroup.class) : workSignBusinessServiceUapGroup;
break;
case "t_uap_user":
workSignBusinessService = workSignBusinessServiceUapUser== null ? SpringUtil.getBean(WorkSignBusinessServiceUapUser.class) : workSignBusinessServiceUapUser;
break;
case "t_entrusting_depart":
workSignBusinessService = workSignBusinessServiceEntrustingDepart== null ? SpringUtil.getBean(WorkSignBusinessServiceEntrustingDepart.class) : workSignBusinessServiceEntrustingDepart;
break;
case "t_wssq_applicant_info":
workSignBusinessService = workSignBusinessServiceWssqApplicantInfo== null ? SpringUtil.getBean(WorkSignBusinessServiceWssqApplicantInfo.class) : workSignBusinessServiceWssqApplicantInfo;
break;
case "t_wssq_evidence":
workSignBusinessService = workSignBusinessServiceWssqEvidence== null ? SpringUtil.getBean(WorkSignBusinessServiceWssqEvidence.class) : workSignBusinessServiceWssqEvidence;
break;
case "t_wssq_inquire":
workSignBusinessService = workSignBusinessServiceWssqInquire== null ? SpringUtil.getBean(WorkSignBusinessServiceWssqInquire.class) : workSignBusinessServiceWssqInquire;
break;
case "t_wssq_login":
workSignBusinessService = workSignBusinessServiceWssqLogin== null ? SpringUtil.getBean(WorkSignBusinessServiceWssqLogin.class) : workSignBusinessServiceWssqLogin;
break;
case "t_wssq_overt":
workSignBusinessService = workSignBusinessServiceWssqOvert== null ? SpringUtil.getBean(WorkSignBusinessServiceWssqOvert.class) : workSignBusinessServiceWssqOvert;
break;
case "t_wssq_respondent_info":
workSignBusinessService = workSignBusinessServiceWssqRespondentInfo== null ? SpringUtil.getBean(WorkSignBusinessServiceWssqRespondentInfo.class) : workSignBusinessServiceWssqRespondentInfo;
break;
case "t_person_info":
workSignBusinessService = workSignBusinessServicePersonInfo== null ? SpringUtil.getBean(WorkSignBusinessServicePersonInfo.class) : workSignBusinessServicePersonInfo;
break;
case "xssht_respondent_info":
workSignBusinessService = workSignBusinessServiceXsshRespondentInfo== null ? SpringUtil.getBean(WorkSignBusinessServiceXsshRespondentInfo.class) : workSignBusinessServiceXsshRespondentInfo;
break;
case "ed_user":
workSignBusinessService = workSignBusinessServiceEdUser== null ? SpringUtil.getBean(WorkSignBusinessServiceEdUser.class) : workSignBusinessServiceEdUser;
break;
}
return workSignBusinessService;
}