| | |
| | | import com.mongodb.client.AggregateIterable; |
| | | import com.mongodb.client.MongoCollection; |
| | | import com.mongodb.client.MongoDatabase; |
| | | import com.ycl.platform.domain.entity.MonitorConstruction; |
| | | import com.ycl.platform.domain.entity.TMonitor; |
| | | import com.ycl.platform.domain.excel.*; |
| | | import com.ycl.platform.domain.form.VideoExportForm; |
| | |
| | | import com.ycl.platform.mapper.TMonitorMapper; |
| | | import com.ycl.platform.mapper.WorkOrderMapper; |
| | | import com.ycl.platform.mapper.YwPointMapper; |
| | | import com.ycl.platform.service.IMonitorConstructionService; |
| | | import com.ycl.platform.service.ITMonitorService; |
| | | import com.ycl.system.Result; |
| | | import com.ycl.system.entity.SysDictData; |
| | |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ycl.utils.PageUtils.startPage; |
| | | |
| | | /** |
| | | * 设备资产Service业务层处理 |
| | | * |
| | |
| | | private DynamicColumnMapper dynamicColumnMapper; |
| | | @Autowired |
| | | private ThreadPoolTaskExecutor threadPoolTaskExecutor; |
| | | |
| | | @Autowired |
| | | private IMonitorConstructionService monitorConstructionService; |
| | | /** |
| | | * 查询设备资产 |
| | | * |
| | |
| | | } |
| | | tMonitor.setTime(time); |
| | | } |
| | | List<TMonitorVO> monitors = tMonitorMapper.selectTMonitorList(tMonitor); |
| | | List<TMonitorVO> monitors = new ArrayList<>(); |
| | | if (StringUtils.isNotBlank(tMonitor.getConstructionType())){ |
| | | List<MonitorConstruction> list = |
| | | monitorConstructionService.getSerialNumberListByConstructionType(tMonitor.getConstructionType()); |
| | | log.info("打印查询设备标签数:{},建设类型标签:{}",list.size(), tMonitor.getConstructionType() ); |
| | | //获得设备编号集合 通过建设类型标签 |
| | | if(!CollectionUtils.isEmpty(list)){ |
| | | tMonitor.setIds( |
| | | list.stream().map(MonitorConstruction::getSerialNumber).collect(Collectors.toList())); |
| | | |
| | | startPage(); |
| | | monitors = tMonitorMapper.selectTMonitorListAndIds(tMonitor); |
| | | } |
| | | |
| | | }else{ |
| | | startPage(); |
| | | monitors = tMonitorMapper.selectTMonitorList(tMonitor); |
| | | } |
| | | // 异常恢复监控 |
| | | if (Objects.equals(tMonitor.getRecovery(), 1L)) { |
| | | //工单号 |
| | |
| | | @Override |
| | | @DataScope(deptAlias = "d", userAlias = "u") |
| | | public Map<String, String> getVideoCount(TMonitorVO tMonitor) { |
| | | |
| | | List<MonitorConstruction> list = |
| | | monitorConstructionService.getSerialNumberListByConstructionType(tMonitor.getConstructionType()); |
| | | //获得设备编号集合 通过建设类型标签 |
| | | tMonitor.setIds( |
| | | list.stream().map(MonitorConstruction::getSerialNumber).collect(Collectors.toList())); |
| | | |
| | | return tMonitorMapper.getVideoCount(tMonitor); |
| | | } |
| | | |
| | |
| | | ExcelUtilManySheet<List<ExcelExp>> util = new ExcelUtilManySheet<>(mysheet); |
| | | util.exportExcelManySheet(response, mysheet); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出每日在线数据 |
| | | */ |
| | |
| | | // 使用线程安全的List,预先指定容量 |
| | | List<ExcelExp> mysheet = Collections.synchronizedList(new ArrayList<>()); |
| | | VideoExportForm.convertTags(exportForm); |
| | | Query query = getQuery(exportForm); |
| | | Query query = getQuery(exportForm);//装配条件 |
| | | // 月份每日在线数据 |
| | | |
| | | List<TMonitorResult> onlineResult = mongoTemplate.find(query, TMonitorResult.class); |
| | | log.info("大小:{}",onlineResult.size()); |
| | | //此处需要过滤掉设备全景在线 细节不在线的情况 可以按 point分组 分我许多组之后再做处理 |
| | | Map<String, List<TMonitorResult>> ipToDevices = onlineResult.stream() |
| | | .collect(Collectors.groupingBy(TMonitorResult::getIp)); |
| | | |
| | | // onlineResult = ipToDevices.values().stream() |
| | | // .map(devices -> { |
| | | // // 检查分组中是否有 online = true 的设备 |
| | | // List<TMonitorResult> onlineDevices = devices.stream() |
| | | // .filter(monitor -> monitor.getOnline() == 1) // 假设online字段的getter是isOnline() |
| | | // .collect(Collectors.toList()); |
| | | // |
| | | // if (!onlineDevices.isEmpty()) { |
| | | // // 若存在online=true的设备,只保留第一个(或取任意一个,按需调整) |
| | | // return onlineDevices.get(0); |
| | | // } else { |
| | | // // 若全为online=false,只保留第一个 |
| | | // return devices.get(0); |
| | | // } |
| | | // }) |
| | | // .collect(Collectors.toList()); |
| | | |
| | | |
| | | |
| | | log.info("月份在线数据:{}条数", onlineResult.size()); |
| | | // 使用Collectors.toMap去重,保留每个No的第一个遇到的元素 |
| | | Map<String, TMonitorResult> uniqueResultsMap = onlineResult.stream() |
| | |
| | | Function.identity(), // valueMapper,直接使用对象本身 |
| | | (existing, replacement) -> existing // mergeFunction,如果有重复,保留第一个 |
| | | )); |
| | | |
| | | |
| | | // 将 Map 转换为 List |
| | | List<TMonitorResult> tMonitorResults = new ArrayList<>(uniqueResultsMap.values()); |
| | | log.info("去重后大小:{}", tMonitorResults.size()); |
| | | |
| | | |
| | | |
| | | // 获取动态列数据并构建缓存Map |
| | | Map<Integer, List<DynamicColumnVO>> dynamicColumnMap = new HashMap<>(); |
| | | if (!tMonitorResults.isEmpty()) { |
| | |
| | | .map(TMonitorResult::getPointId) |
| | | .distinct() // 去重,减少数据库查询 |
| | | .collect(Collectors.toList()); |
| | | |
| | | |
| | | //获取集合点位的补充列信息 |
| | | List<DynamicColumnVO> dynamics = dynamicColumnMapper.getDynamicsByIds("t_yw_point", pointIds); |
| | | if (!CollectionUtils.isEmpty(dynamics)) { |
| | |
| | | CompletableFuture<ExcelExp> future = CompletableFuture.supplyAsync(() -> { |
| | | // 直接从预分组的Map中获取,避免每次过滤 |
| | | List<TMonitorResult> monitors = deptMonitorMap.getOrDefault(currentDeptId, Collections.emptyList()); |
| | | |
| | | |
| | | |
| | | if (monitors.isEmpty()) { |
| | | return null; |
| | | } |
| | |
| | | @Override |
| | | public void export(HttpServletResponse response, TMonitorVO tMonitor) { |
| | | List<TMonitorExp> monitors = tMonitorMapper.exportTMonitorList(tMonitor); |
| | | //过滤出设备建设类型 |
| | | if (StringUtils.isNotBlank(tMonitor.getConstructionType())){ |
| | | List<MonitorConstruction> list = |
| | | monitorConstructionService.getSerialNumberListByConstructionType(tMonitor.getConstructionType()); |
| | | //获得设备编号集合 通过建设类型标签 |
| | | List<String> serialNumberList = list.stream().map(MonitorConstruction::getSerialNumber).collect(Collectors.toList()); |
| | | monitors = monitors.stream() |
| | | .filter(result -> { |
| | | String sn = result.getSerialNumber(); |
| | | // 任一字段非空且在集合中即可 |
| | | return (sn != null && serialNumberList.contains(sn)); |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | //获取动态列数据 |
| | | List<Integer> pointIds = monitors.stream().map(TMonitorExp::getPointId).collect(Collectors.toList()); |
| | | List<DynamicColumnVO> dynamics = dynamicColumnMapper.getDynamicsByIds("t_yw_point", pointIds); |