|
|
@@ -1,20 +1,25 @@
|
|
|
package com.tzld.piaoquan.sde.service.impl;
|
|
|
|
|
|
+import com.aliyun.odps.data.Record;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.tzld.piaoquan.sde.common.enums.*;
|
|
|
import com.tzld.piaoquan.sde.mapper.ContentProfileMapper;
|
|
|
import com.tzld.piaoquan.sde.mapper.SdExecutionTaskContentMapper;
|
|
|
+import com.tzld.piaoquan.sde.model.dto.content.ContentDeconstructionResultQueryDTO;
|
|
|
import com.tzld.piaoquan.sde.model.dto.deconstruction.QueryResponseDataDTO;
|
|
|
import com.tzld.piaoquan.sde.model.entity.ContentProfile;
|
|
|
import com.tzld.piaoquan.sde.model.entity.SdExecutionTask;
|
|
|
import com.tzld.piaoquan.sde.model.entity.SdExecutionTaskContent;
|
|
|
+import com.tzld.piaoquan.sde.model.vo.ContentDescontructionResultVo;
|
|
|
import com.tzld.piaoquan.sde.service.ContentProfileService;
|
|
|
+import com.tzld.piaoquan.sde.util.OdpsManager;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
@@ -25,6 +30,9 @@ public class ContentProfileServiceImpl implements ContentProfileService {
|
|
|
@Autowired
|
|
|
private SdExecutionTaskContentMapper sdExecutionTaskContentMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private OdpsManager odpsManager;
|
|
|
+
|
|
|
@Override
|
|
|
public ContentProfile findContentProfileByIdAndStage(String contentId, TaskStageEnum stageEnum) {
|
|
|
if (StringUtils.isEmpty(contentId) || Objects.isNull(stageEnum)) {
|
|
|
@@ -125,6 +133,48 @@ public class ContentProfileServiceImpl implements ContentProfileService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, List<ContentDescontructionResultVo>> queryContentDeconstructionResultByKeywords(ContentDeconstructionResultQueryDTO queryDTO) {
|
|
|
+ if (CollectionUtils.isEmpty(queryDTO.getKeywords())) {
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+
|
|
|
+ String sqlFormat = "SELECT DISTINCT content_id\n" +
|
|
|
+ "FROM loghubods.content_deconstruction_result_structuring\n" +
|
|
|
+ "WHERE dt = (\n" +
|
|
|
+ " SELECT MAX(dt)\n" +
|
|
|
+ " FROM loghubods.content_deconstruction_result_structuring\n" +
|
|
|
+ " ) \n" +
|
|
|
+ "AND hh = (\n" +
|
|
|
+ " SELECT MAX(hh)\n" +
|
|
|
+ " FROM loghubods.content_deconstruction_result_structuring\n" +
|
|
|
+ " WHERE dt = (\n" +
|
|
|
+ " SELECT MAX(dt)\n" +
|
|
|
+ " FROM loghubods.content_deconstruction_result_structuring\n" +
|
|
|
+ " ) \n" +
|
|
|
+ " ) \n" +
|
|
|
+ "AND type_desc LIKE \"%%s%\"\n" +
|
|
|
+ ";";
|
|
|
+
|
|
|
+ Map<String, List<ContentDescontructionResultVo>> result = new HashMap<>(queryDTO.getKeywords().size());
|
|
|
+ for (String keyword : queryDTO.getKeywords()) {
|
|
|
+ String querySql = String.format(sqlFormat, keyword);
|
|
|
+ List<Record> records = odpsManager.query(querySql);
|
|
|
+ if (CollectionUtils.isEmpty(records)) {
|
|
|
+ result.put(keyword, Collections.emptyList());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<ContentDescontructionResultVo> contentDescontructionResultVos = new ArrayList<>(result.size());
|
|
|
+ for (Record record : records) {
|
|
|
+ ContentDescontructionResultVo contentDescontructionResultVo = new ContentDescontructionResultVo();
|
|
|
+ contentDescontructionResultVo.setContentId(record.getString("content_id"));
|
|
|
+ contentDescontructionResultVos.add(contentDescontructionResultVo);
|
|
|
+ }
|
|
|
+ result.put(keyword, contentDescontructionResultVos);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
private SdExecutionTaskContent findByExecutionTaskId(Long executionTaskId) {
|
|
|
if (Objects.isNull(executionTaskId)) {
|
|
|
return null;
|