| | |
| | | if (uuid.equals(id)) { |
| | | if (i == uuids.size() - 1) { |
| | | log.info("最后一个任务,没有下一个要执行的了"); |
| | | redisUtil.del(key); |
| | | } else { |
| | | nextUuid = uuids.getStr(i + 1); |
| | | break; |
| | |
| | | Task task = this.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskId, jobExecLog.getTaskId())); |
| | | if (null != task) { |
| | | Task selectOne = baseMapper.selectOne(new LambdaQueryWrapper<Task>().eq(Task::getRequireId, task.getRequireId()).in(Task::getPyScript, Constant.douyin_search_spider, Constant.kuaishou_search_spider, Constant.xhs_search_spider).last("limit 1")); |
| | | String s = execPyJob(task, uuid, selectOne, secId); |
| | | String s = execPyJob(task, nextUuid, selectOne, secId); |
| | | CommonRes bean = JSONUtil.toBean(s, CommonRes.class); |
| | | log.info("回调接口:任务启动成功: {}", bean.getJobid()); |
| | | int stepSet = stepSet(task); |
| | | boolean update = demandService.update(null, new LambdaUpdateWrapper<Demand>().set(Demand::getStatus, stepSet).eq(Demand::getId, task.getRequireId())); |
| | | log.info("callback ==》任务开始执行"); |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | return step; |
| | | } |
| | | |
| | | private int stepSet(Task task) { |
| | | int step = 0; |
| | | // 调用成功,根据不同脚本更新需求状态 |
| | | if (Constant.douyin_search_spider.equals(task.getPyScript()) |
| | | || Constant.kuaishou_search_spider.equals(task.getPyScript()) |
| | | || Constant.xhs_search_spider.equals(task.getPyScript())) { |
| | | step = DemandStatusEnum.DATA_COLLECT.getValue(); |
| | | } else if (Constant.douyin_comment_spider.equals(task.getPyScript()) |
| | | || Constant.kuaishou_comment_spider.equals(task.getPyScript()) |
| | | || Constant.xhs_comment_spider.equals(task.getPyScript())) { |
| | | step = DemandStatusEnum.COMMENT_COLLECT.getValue(); |
| | | } else if (Constant.douyin_user_profile_spider.equals(task.getPyScript()) |
| | | || Constant.kuaishou_user_profile_spider.equals(task.getPyScript()) |
| | | || Constant.xhs_user_profile_spider.equals(task.getPyScript())) { |
| | | step = DemandStatusEnum.IMPROVE_USER_INFO.getValue(); |
| | | } else if (Constant.douyin_hot_post_comment_spider.equals(task.getPyScript()) |
| | | || Constant.kuaishou_hot_post_comment_spider.equals(task.getPyScript()) |
| | | || Constant.xhs_hot_post_comment_spider.equals(task.getPyScript())) { |
| | | step = DemandStatusEnum.HOT_COMMENT_COLLECT.getValue(); |
| | | } else if (Constant.douyin_v_user_spider.equals(task.getPyScript()) |
| | | || Constant.kuaishou_v_user_spider.equals(task.getPyScript()) |
| | | || Constant.xhs_v_user_spider.equals(task.getPyScript())) { |
| | | step = DemandStatusEnum.V_DATA_COLLECT.getValue(); |
| | | } |
| | | return step; |
| | | } |
| | | |
| | | /** |
| | | * 任务执行完成状态 |
| | | * @param first |