| | |
| | | @Autowired |
| | | private CollectController collectController; |
| | | |
| | | @Scheduled(fixedRate = 5000) // 每5秒执行一次 |
| | | @Scheduled(fixedRate = 10000) // 每5秒执行一次 |
| | | public void scheduleFixedRateTask() { |
| | | // 查询所有状态为pending的任务 |
| | | LambdaQueryWrapper<KeywordTask> queryWrapper = new LambdaQueryWrapper<>(); |
| | |
| | | && !"Error".equalsIgnoreCase(statusResponse.getStatus())) { |
| | | task.setStatus("false"); |
| | | return Mono.just(task); |
| | | } else { |
| | | }else if("ERROR".equalsIgnoreCase(statusResponse.getStatus())&&"任务不存在".equalsIgnoreCase(statusResponse.getMessage())){ |
| | | task.setStatus("false"); |
| | | return Mono.just(task); |
| | | } |
| | | else { |
| | | // 任务仍在进行中,不更新状态 |
| | | return Mono.empty(); |
| | | } |
| | |
| | | .switchIfEmpty(Mono.just(task)) // 如果状态检查返回empty,保持原有任务 |
| | | .flatMap(t -> { |
| | | if (!"pending".equalsIgnoreCase(t.getStatus())) { |
| | | |
| | | |
| | | // 修改这里:将updateById的结果包装成Mono |
| | | return Mono.fromSupplier(() -> keywordTaskService.updateById(t)) |