leo.li
2024-09-10 436ec3a553ca18a3304bdf3568ca887b022c2e4d
update
1 files modified
34 ■■■■■ changed files
src/main/java/com/jw/ai/service/impl/TaskServiceImpl.java 34 ●●●●● patch | view | raw | blame | history
src/main/java/com/jw/ai/service/impl/TaskServiceImpl.java
@@ -547,6 +547,7 @@
                    if (uuid.equals(id)) {
                        if (i == uuids.size() - 1) {
                            log.info("最后一个任务,没有下一个要执行的了");
                            redisUtil.del(key);
                        } else {
                            nextUuid = uuids.getStr(i + 1);
                            break;
@@ -560,9 +561,13 @@
                    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 ==》任务开始执行");
                    }
                }
            }
@@ -843,6 +848,33 @@
        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