//依据不同的报表类型进行分别获取 dto.getReportTypes().stream().forEach( info->{ try { //反射获取下层方法,动态调用 String serviceName= FinancialReportEnum.getServiceNameByCode(info); String methName= FinancialReportEnum.getMethodNameByCode(info); Class<?> serviceClass = Class.forName(serviceName); Method method = serviceClass.getMethod(methName, FinancialReportDto.class); FinancialReportDto financialReportDto = new FinancialReportDto(); BeanUtils.copyProperties(dto,financialReportDto); List<String> report = Lists.newArrayList(); report.add(info); financialReportDto.setReportTypes(report); Object invoke = method.invoke(serviceClass, financialReportDto); }catch (Exception e){ log.error("导出财务报表接口-findAllFinancial异常参数:"+ JSON.toJSONString(e)); } } );
反射获取接口
最新推荐文章于 2021-07-20 09:41:46 发布