| | |
| | | * @return |
| | | */ |
| | | public List<ResEntity> selectResStatus() { |
| | | List<ResEntity> list = new ArrayList<ResEntity>(); |
| | | |
| | | List<ResEntity> resList = resService.selectResAll(); |
| | | |
| | | return testResStatus(resList); |
| | | } |
| | | |
| | | private List<ResEntity> testResStatus(List<ResEntity> resList) { |
| | | List<ResEntity> list = new ArrayList<ResEntity>(); |
| | | for (ResEntity re : resList) { |
| | | Socket socket = new Socket(); |
| | | try { |
| | | if (StringHelper.isEmpty(re.getServer())){ |
| | | if (StringHelper.isEmpty(re.getServer())) { |
| | | list.add(re); |
| | | continue; |
| | | } |
| | |
| | | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 统计服务资源状态 |
| | | * |
| | | * @return |
| | | */ |
| | | public JSONObject countResStatus() { |
| | | List<ResEntity> resList = resService.selectResAll(); |
| | | List<ResEntity> unableList = testResStatus(resList); |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | |
| | | // 资源可用 |
| | | jsonObject.put("resAbleCount", resList.size() - unableList.size()); |
| | | // 资源不可用 |
| | | jsonObject.put("resUnableCount", unableList.size()); |
| | | |
| | | return jsonObject; |
| | | } |
| | | } |