| | |
| | | if (params.getOption() != null) { |
| | | query.addCriteria(Criteria.where("online").is(params.getOption())); |
| | | } |
| | | Sort sort = Sort.by( |
| | | Sort.Order.asc("pingOnline") // 首先按照 pingOnline 升序排序 |
| | | ); |
| | | // 通过pingOnline字段排序,为false的排在前面 |
| | | query.with(Sort.by(Sort.Order.asc("pingOnline"))); |
| | | query.with(sort); |
| | | //分页数量 |
| | | long total = mongoTemplate.count(query, TMonitorResult.class); |
| | | MongoUtil.setPage(query, params, TIME_FIELD); |
| | |
| | | } else { |
| | | item.setOnlineStr("未知"); |
| | | } |
| | | List<Date> offLineTime = item.getOffLineTime(); |
| | | List<String> offLineTime = item.getOffLineTimeStr(); |
| | | if(!CollectionUtils.isEmpty(offLineTime)) { |
| | | //后续可以改成配置的离线次数(提取前n次,n为配置的离线次数) |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | if (offLineTime.size() > 1) { |
| | | offLineTime = offLineTime.subList(0, 2); |
| | | } |
| | | List<String> dateStr = new ArrayList<>(); |
| | | for (Date date : offLineTime) { |
| | | String formatDate = format.format(date); |
| | | dateStr.add(formatDate); |
| | | } |
| | | item.setOffLineTimeStr(dateStr); |
| | | item.setOffLineTimeStr(offLineTime); |
| | | } |
| | | }); |
| | | params.setDeptTag(-1); |