| | |
| | | |
| | | @Override |
| | | public PaginationData<MediaFileEntity> MediaQuery(Integer page, Integer pageSize, Long updateStart, Long updateEnd, Long photoStart, Long photoEnd, String jobName, String workspaceId, String type) { |
| | | // 创建分页对象 |
| | | Page<MediaFileEntity> pageObj = new Page<>(page, pageSize); |
| | | |
| | | // 创建查询条件对象 |
| | | LambdaQueryWrapper<MediaFileEntity> queryWrapper = new LambdaQueryWrapper<>(); |
| | | |
| | |
| | | |
| | | if (jobName != null && !jobName.isEmpty()) { |
| | | List<String> jobIds = waylineJobService.getJobIds(jobName); |
| | | // 检查 jobIds 列表是否为空 |
| | | if (jobIds.isEmpty()) { |
| | | // 如果为空,则直接返回空的分页数据 |
| | | return new PaginationData<>(Collections.emptyList(), new Pagination(pageObj)); |
| | | return new PaginationData<>(Collections.emptyList(), new Pagination(new Page<>(page, pageSize))); |
| | | } |
| | | |
| | | queryWrapper.in(MediaFileEntity::getJobId, jobIds); |
| | | } |
| | | |
| | | if (type != null && !type.isEmpty()) { |
| | | if ("图片".equals(type)) { |
| | | queryWrapper.likeLeft(MediaFileEntity::getFileName, ".jpeg"); |
| | |
| | | queryWrapper.likeLeft(MediaFileEntity::getFileName, ".mp4"); |
| | | } |
| | | } |
| | | queryWrapper.last("ORDER BY JSON_EXTRACT(metadata, '$.createdTime') DESC"); |
| | | // 执行分页查询 |
| | | Page<MediaFileEntity> resultPage = mapper.selectPage(pageObj, queryWrapper); |
| | | |
| | | // 处理查询结果并去重 |
| | | queryWrapper.last("ORDER BY JSON_EXTRACT(metadata, '$.createdTime') DESC"); |
| | | |
| | | // 执行查询获取所有结果 |
| | | List<MediaFileEntity> allResults = mapper.selectList(queryWrapper); |
| | | |
| | | // 处理结果去重并设置任务名称 |
| | | Map<String, MediaFileEntity> uniqueFileMap = new LinkedHashMap<>(); |
| | | List<MediaFileEntity> records = resultPage.getRecords() |
| | | .stream() |
| | | List<MediaFileEntity> uniqueResults = allResults.stream() |
| | | .peek(mediaFile -> { |
| | | // 获取任务名称并设置到fileId |
| | | String taskNameResult = waylineJobService.getName(mediaFile.getJobId()); |
| | | mediaFile.setJobName(taskNameResult); |
| | | }) |
| | | .filter(mediaFile -> uniqueFileMap.putIfAbsent(mediaFile.getFileName(), mediaFile) == null) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 计算分页信息 |
| | | int total = uniqueResults.size(); |
| | | int start = (page - 1) * pageSize; |
| | | int end = Math.min(start + pageSize, total); |
| | | |
| | | // 获取当前页的结果 |
| | | List<MediaFileEntity> pageResults = uniqueResults.subList(start, end); |
| | | |
| | | // 创建临时的 Page 对象 |
| | | Page<MediaFileEntity> resultPage = new Page<>(page, pageSize); |
| | | resultPage.setRecords(pageResults); |
| | | resultPage.setTotal(total); |
| | | |
| | | // 返回分页数据 |
| | | return new PaginationData<>(records, new Pagination(resultPage)); |
| | | return new PaginationData<>(pageResults, new Pagination(resultPage)); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<MediaFileEntity> listMediaFileEntity(String workspaceId, String jobId) { |
| | | return mapper.selectList(new LambdaQueryWrapper<MediaFileEntity>() |