| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | //优云对接数据任务 |
| | |
| | | } |
| | | // 先查出设备IP集合,剔除掉在线情况是未知的,并且只检测正在考核的设备避免多余工单 |
| | | List<TMonitorResult> monitorList = monitorMapper.getDistinctIP(); |
| | | //补充错误时间点 |
| | | Query onlineQuery = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | Map<String, TMonitorResult> mongoMap = mongoTemplate.find(onlineQuery, TMonitorResult.class).stream().collect(Collectors.toMap(TMonitorResult::getNo, Function.identity())); |
| | | for (TMonitorResult result : monitorList) { |
| | | TMonitorResult mongoData = mongoMap.get(result.getNo()); |
| | | if(mongoData!=null){ |
| | | result.setOffLineTime(mongoData.getOffLineTime()); |
| | | } |
| | | } |
| | | List<TMonitorResult> dataList = new ArrayList<>(48); |
| | | Integer time = times; |
| | | List<CompletableFuture<TMonitorResult>> futureList = monitorList.stream() |
| | |
| | | monitor.setPingOnline(Boolean.FALSE); |
| | | monitor.setCheckCount(checkTimes); |
| | | monitor.setOffLineCount(offLineTimes); |
| | | List<Date> offLineTime = monitor.getOffLineTime(); |
| | | if(CollectionUtils.isEmpty(offLineTime)) offLineTime = new ArrayList<>(); |
| | | offLineTime.add(new Date()); |
| | | monitor.setOffLineTime(offLineTime); |
| | | if (monitor.getOffLineCount() >= time) { |
| | | WorkOrder workOrder = new WorkOrder(); |
| | | workOrder.setSerialNumber(monitor.getNo()); |
| | |
| | | //存放在mongo中 |
| | | mongoTemplate.insertAll(dataList); |
| | | } |
| | | //工单 |
| | | //工单(同一IP只生成一个工单) |
| | | List<WorkOrder> workOrderList = dataList.stream() |
| | | .filter(item -> Objects.nonNull(item.getWorkOrder())) |
| | | .collect(Collectors.toMap( |
| | | TMonitorResult::getIp, |
| | | Function.identity(), |
| | | (existing, replacement) -> existing // 如果遇到相同的 IP,保留第一个 TMonitorResult 对象 |
| | | )) |
| | | .values() |
| | | .stream() |
| | | .map(TMonitorResult::getWorkOrder) |
| | | .collect(Collectors.toList()); |
| | | if (!CollectionUtils.isEmpty(workOrderList)) { |
| | |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | | monitorMapper.updateOnline(willUpdateList); |
| | | //离线生成工单 |
| | | List<VideoOnlineResult> workOrders = records.stream().filter(item -> ApiConstants.UY_OnlineSite_Offline.equals(item.getStatus())).collect(Collectors.toList()); |
| | | //离线生成工单,一个ip只生成一个工单 |
| | | List<VideoOnlineResult> workOrders = new ArrayList<>(records.stream() |
| | | .filter(item -> ApiConstants.UY_OnlineSite_Offline.equals(item.getStatus())) |
| | | .collect(Collectors.toMap( |
| | | VideoOnlineResult::getIpAddr, |
| | | Function.identity(), |
| | | (existing, replacement) -> existing // 如果遇到相同的 IP,保留第一个(existing) |
| | | )).values()); |
| | | uyErrorTypeCheckService.videoOnlineCheck(workOrders); |
| | | } else { |
| | | log.error("点位在线结果数据为空{}", data); |
| | |
| | | pointService.setDeviceTagByGB(records); |
| | | //存放在mongo中 |
| | | mongoTemplate.insertAll(records); |
| | | // 工单生成 |
| | | uyErrorTypeCheckService.recordMetaDSumCheck(records); |
| | | // // 工单生成 |
| | | // uyErrorTypeCheckService.recordMetaDSumCheck(records); |
| | | } |
| | | } else { |
| | | log.error("录像可用数据为空{}", jsonObject); |