| | |
| | | import enumeration.general.WorkOrderStatusEnum; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | |
| | | item.setNo(item.getSerialNumber().getShowValue()); |
| | | } |
| | | }); |
| | | //TODO:优云的一机一档包含了视频、车辆、人脸 是有一种是省厅就算省厅吗 |
| | | pointService.setDeviceTagByGB(records,CheckConstants.Rule_Category_Video); |
| | | pointService.setDeviceTagByGB(records,CheckConstants.Rule_Category_Or); |
| | | pointService.setNew(records); |
| | | //存放在mongo中 |
| | | mongoTemplate.insertAll(records); |
| | |
| | | } |
| | | // 先查出设备IP集合,剔除掉在线情况是未知的,并且只检测正在考核的设备避免多余工单 |
| | | //TODO:需要把海康和优云的任务的时间调到ping之前 |
| | | //TODO:这里需要存三个标签吗 |
| | | List<TMonitorResult> monitorList = monitorMapper.getDistinctIP(); |
| | | //补充错误时间点 |
| | | Query onlineQuery = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | |
| | | ex.printStackTrace(); |
| | | } |
| | | return null; |
| | | // int checkTimes = 1; |
| | | // int offLineTimes = 1; |
| | | // Map<String, Object> map = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstant.ONLINE_KEY, monitor.getNo()); |
| | | // if (!CollectionUtils.isEmpty(map)) { |
| | | // checkTimes = (Integer) map.get("checkTimes") + 1; |
| | | // offLineTimes = (Integer) map.get("offLineTimes"); |
| | | // }else { |
| | | // map = new HashMap<>(); |
| | | // } |
| | | // 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()); |
| | | // List<String> errList = new ArrayList<>(); |
| | | // errList.add(ErrorType.DEVICE_OFFLINE.getValue()); |
| | | // workOrder.setErrorTypeList(errList); |
| | | // workOrder.setStatus(WorkOrderStatusEnum.DISTRIBUTED); |
| | | // monitor.setWorkOrder(workOrder); |
| | | // } |
| | | // map.put("checkTimes", checkTimes); |
| | | // map.put("offLineTimes", offLineTimes); |
| | | // redisTemplate.opsForHash().put(RedisConstant.ONLINE_KEY, monitor.getNo(), map); |
| | | // return monitor; // 返回失败的结果 |
| | | |
| | | })) |
| | | .collect(Collectors.toList()); |
| | | |
| | |
| | | } |
| | | //存放到mongo |
| | | if (!CollectionUtils.isEmpty(dataList)) { |
| | | List<TMonitorResult> mongoList = new ArrayList<>(); |
| | | dataList.forEach(item->{ |
| | | String monitorType = item.getMonitorType(); |
| | | //同一个设备多个类型每个类型存一条数据,以此在保留数据的情况下区分省厅标签 |
| | | if(StringUtils.isNotEmpty(monitorType)){ |
| | | String[] monitors = monitorType.split("/"); |
| | | for (String type : monitors) { |
| | | TMonitorResult mongoData = new TMonitorResult(); |
| | | BeanUtils.copyProperties(item,mongoData); |
| | | mongoData.setMonitorType(type); |
| | | if("1".equals(type)){ |
| | | mongoData.setProvinceTag(mongoData.getProvinceTagVideo()); |
| | | }else if("2".equals(type)){ |
| | | mongoData.setProvinceTag(mongoData.getProvinceTagCar()); |
| | | }else if("3".equals(type)){ |
| | | mongoData.setProvinceTag(mongoData.getProvinceTagFace()); |
| | | } |
| | | mongoList.add(mongoData); |
| | | } |
| | | } |
| | | }); |
| | | //如果存在之前的数据先删除 |
| | | Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, TMonitorResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insertAll(dataList); |
| | | mongoTemplate.insertAll(mongoList); |
| | | } |
| | | //工单(同一IP只生成一个工单) |
| | | List<WorkOrder> workOrderList = dataList.stream() |
| | |
| | | item.setNo(item.getDeviceId()); |
| | | } |
| | | }); |
| | | //貌似这里可以忽略省厅标签因为项目展示的后面ping的时候存的数据 |
| | | pointService.setDeviceTagByGB(records,CheckConstants.Rule_Category_Video); |
| | | //存放在mongo中 |
| | | mongoTemplate.insertAll(records); |