| | |
| | | DataSourceContextHolder.setDataSourceKey("default"); |
| | | List<DictHosp> list = dictHospService.list(); |
| | | List<Map<String, Object>> resultList = new ArrayList<>(); |
| | | boolean flag = false; |
| | | for (DictHosp dictHosp : list) { |
| | | String dbName = dictHosp.getDbname(); |
| | | Map<String, Object> dbResult = new HashMap<>(); |
| | |
| | | jdbcTemplate.execute(sql); |
| | | successList.add(sql); |
| | | } catch (Exception e) { |
| | | errorList.add(sql + " -> ERROR: " + e.getMessage()); |
| | | errorList.add(sql + "\nERROR: " + e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | dbResult.put("successSQL", successList); |
| | | dbResult.put("failedSQL", errorList); |
| | | resultList.add(dbResult); |
| | | if (!errorList.isEmpty()) |
| | | flag = true; |
| | | } |
| | | DataSourceContextHolder.clear(); |
| | | if (flag) |
| | | return AjaxResult.error("执行sql中存在失败",resultList); |
| | | return AjaxResult.success(resultList); |
| | | } |
| | | |