|
@@ -44,10 +44,14 @@ public class PipelineServiceImpl implements PipelineService {
|
|
|
@Autowired
|
|
|
private MongoTemplate mongoTemplate;
|
|
|
|
|
|
+ private static final String COLLECTION_NAME = "content_understanding_info";
|
|
|
+
|
|
|
@Override
|
|
|
public void execute(ContentAnalyseParam param) {
|
|
|
// 1.获取pipeline配置
|
|
|
Long pipelineId = param.getPipelineId();
|
|
|
+ String content = param.getContent();
|
|
|
+ Long videoId = param.getVideoId();
|
|
|
CuPipelineStepExample example = new CuPipelineStepExample();
|
|
|
example.createCriteria().andPipelineIdEqualTo(pipelineId);
|
|
|
List<CuPipelineStep> stepList = cuPipelineStepMapper.selectByExample(example);
|
|
@@ -56,8 +60,9 @@ public class PipelineServiceImpl implements PipelineService {
|
|
|
}
|
|
|
// 2.构建tree结构
|
|
|
PipelineTreeNode root = buildTree(stepList);
|
|
|
+ root.setInput(content);
|
|
|
// 3.按照步骤执行pipeline每一步动作
|
|
|
- executeTreeNodeBFS(root);
|
|
|
+ executeTreeNodeBFS(root, videoId);
|
|
|
}
|
|
|
|
|
|
public PipelineTreeNode buildTree(List<CuPipelineStep> stepList) {
|
|
@@ -90,7 +95,7 @@ public class PipelineServiceImpl implements PipelineService {
|
|
|
return root;
|
|
|
}
|
|
|
|
|
|
- public void executeTreeNodeBFS(PipelineTreeNode root) {
|
|
|
+ public void executeTreeNodeBFS(PipelineTreeNode root, Long videoId) {
|
|
|
if (root == null) {
|
|
|
return;
|
|
|
}
|
|
@@ -108,7 +113,8 @@ public class PipelineServiceImpl implements PipelineService {
|
|
|
//异常不阻塞其他分支执行
|
|
|
try {
|
|
|
Map<String, Object> resultMap = JSON.parseObject(result,new TypeReference<Map<String, Object>>() {});
|
|
|
- mongoTemplate.insert(resultMap);
|
|
|
+ resultMap.put("video_id", videoId);
|
|
|
+ mongoTemplate.insert(resultMap, COLLECTION_NAME);
|
|
|
} catch (Exception e) {
|
|
|
log.error("step execute error step = {}, result = {}", e, JSON.toJSONString(step), result);
|
|
|
}
|