Commit 2da615fd by shenjunjie

Merge branch 'feature' into 'release'

Feature

See merge request !462
parents f4f556f3 41c52dad
......@@ -3,6 +3,7 @@ package com.zhiwei.brandkbs2.service;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.base.entity.subclass.mark.MarkInfo;
import com.zhiwei.brandkbs2.pojo.MarkFlowEntity;
import com.zhiwei.brandkbs2.pojo.dto.TagFilterDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
......@@ -83,10 +84,13 @@ public interface MarkFlowService {
private String planId;
private Long gid;
public MarkInfoSource(JSONObject json, String projectId, String contendId) {
private List<TagFilterDTO> tagFilters;
public MarkInfoSource(JSONObject json, String projectId, String contendId, List<TagFilterDTO> tagFilters) {
this.json = json;
this.projectId = projectId;
this.contendId = contendId;
this.tagFilters = tagFilters;
}
public MarkInfoSource(JSONObject json, String linkedGroupId) {
......
......@@ -2748,9 +2748,6 @@ public class MarkDataServiceImpl implements MarkDataService {
CompletableFuture.allOf(markTopTitleList.stream().map(json -> CompletableFuture.supplyAsync(() -> {
try {
BaseMap firstArticle = getFirstArticle(startTime, endTime, json.getString("title"), projectId, Constant.PRIMARY_CONTEND_ID, planId, include);
if (Objects.isNull(firstArticle)){
return null;
}
json.put("content", firstArticle.getContent());
json.put("url", firstArticle.getUrl());
json.put("realSource", firstArticle.getRealSource());
......@@ -3296,6 +3293,7 @@ public class MarkDataServiceImpl implements MarkDataService {
private List<MarkFlowEntity> getMarkFlowEntity(MarkSearchDTO markSearchDTO, SearchHits searchHits) {
String projectId = markSearchDTO.getProjectId();
String contendId = markSearchDTO.getContendId();
List<TagFilterDTO> tagFilters = tagFilterService.getTagFilter();
// 重复消息折叠
if (markSearchDTO.isFold()) {
// 根据旧顺序排序
......@@ -3309,17 +3307,17 @@ public class MarkDataServiceImpl implements MarkDataService {
return sortList.stream().map(id -> {
List<Map<String, Object>> maps = collect.get(id);
if (null != maps) {
return MarkFlowEntity.getFoldInstance(maps.stream().map(map -> getMarkFlowEntity(map, projectId, contendId)).collect(Collectors.toList()));
return MarkFlowEntity.getFoldInstance(maps.stream().map(map -> getMarkFlowEntity(map, projectId, contendId, tagFilters)).collect(Collectors.toList()));
}
return null;
}).filter(Objects::nonNull).collect(Collectors.toList());
}
return Arrays.stream(searchHits.getHits()).map(hit -> getMarkFlowEntity(hit.getSourceAsMap(), projectId, contendId)).collect(Collectors.toList());
return Arrays.stream(searchHits.getHits()).map(hit -> getMarkFlowEntity(hit.getSourceAsMap(), projectId, contendId, tagFilters)).collect(Collectors.toList());
}
private MarkFlowEntity getMarkFlowEntity(Map<String, Object> map, String projectId, String contendId) {
private MarkFlowEntity getMarkFlowEntity(Map<String, Object> map, String projectId, String contendId, List<TagFilterDTO> tagFilters) {
MarkFlowEntity instance = new MarkFlowEntity(new JSONObject(map));
instance.setInfo(markFlowService.createMarkFlowInfo(new MarkFlowService.MarkInfoSource(new JSONObject(map), projectId, contendId)));
instance.setInfo(markFlowService.createMarkFlowInfo(new MarkFlowService.MarkInfoSource(new JSONObject(map), projectId, contendId, tagFilters)));
return instance;
}
......@@ -3389,6 +3387,7 @@ public class MarkDataServiceImpl implements MarkDataService {
if (null == dto.getAggreeId()) {
ExceptionCast.cast(CommonCodeEnum.INVALID_PARAM);
}
List<TagFilterDTO> tagFilter = tagFilterService.getTagFilter();
dto.setProjectId(UserThreadLocal.getProjectId());
Query query = assembleAggreeQuery(dto);
// 量查询
......@@ -3404,7 +3403,7 @@ public class MarkDataServiceImpl implements MarkDataService {
List<MarkFlowEntity> markFlowEntities = new ArrayList<>();
MarkFlowEntity instance = new MarkFlowEntity(aggreeResult.getData(), dto.getLinkedGroupId());
instance.setInfo(createMarkFlowInfo.create(new MarkFlowService.MarkInfoSource(aggreeResult.getData(), dto.getProjectId(), dto.getContendId(),
dto.getLinkedGroupId(), dto.getPlanId(), dto.getGid())));
dto.getLinkedGroupId(), dto.getPlanId(), dto.getGid(), tagFilter)));
markFlowEntities.add(instance);
// 添加父标题集下的子标题集
resList.add(MarkFlowEntity.getAggreeInstance(markFlowEntities, aggreeResult, sonDetails));
......
......@@ -15,7 +15,9 @@ import com.zhiwei.brandkbs2.enmus.ChannelEmotion;
import com.zhiwei.brandkbs2.exception.ExceptionCast;
import com.zhiwei.brandkbs2.model.CommonCodeEnum;
import com.zhiwei.brandkbs2.pojo.MarkFlowEntity;
import com.zhiwei.brandkbs2.pojo.dto.TagFilterDTO;
import com.zhiwei.brandkbs2.service.MarkFlowService;
import com.zhiwei.brandkbs2.service.TagFilterService;
import com.zhiwei.brandkbs2.util.RedisUtil;
import com.zhiwei.brandkbs2.util.Tools;
import com.zhiwei.middleware.automaticmark.vo.Keyword;
......@@ -24,6 +26,7 @@ import com.zhiwei.middleware.mark.service.MarkerClient;
import com.zhiwei.middleware.mark.vo.QueryResult;
import com.zhiwei.qbjc.bean.pojo.common.Tag;
import com.zhiwei.qbjc.bean.tools.BeanTools;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;
......@@ -59,13 +62,11 @@ public class MarkFlowServiceImpl implements MarkFlowService {
@Resource(name = "filterClient")
UnifiedFilterClient filterClient;
@Resource(name = "highlightWordDao")
HighlightWordDao highlightWordDao;
@Override
public JSONObject createMarkFlowInfo(MarkInfoSource markInfoSource) {
JSONObject resultInfo = createInfoWithEmotion(markInfoSource.getJson());
resultInfo.put("sourceDetails", getSourceDetails(markInfoSource));
resultInfo.put("customTags", getCustomTagsInfo(markInfoSource));
return resultInfo;
}
......@@ -196,6 +197,34 @@ public class MarkFlowServiceImpl implements MarkFlowService {
return JSON.parseObject(data, MarkFlowEntity.class);
}
/**
* 获取自定义标签
* @param markInfoSource
* @return
*/
private List<JSONObject> getCustomTagsInfo(MarkInfoSource markInfoSource){
List<JSONObject> res = new ArrayList<>();
JSONObject json = markInfoSource.getJson();
List<JSONObject> markCacheMaps = json.getJSONArray(GenericAttribute.ES_MARK_CACHE_MAPS).toJavaList(JSONObject.class);
if (CollectionUtils.isEmpty(markCacheMaps)){
return null;
}
// 已配置的标签筛选
List<TagFilterDTO> tagFilters = markInfoSource.getTagFilters();
List<String> groupNames = tagFilters.stream().map(TagFilterDTO::getGroupName).collect(Collectors.toList());
for (JSONObject markCacheMap : markCacheMaps) {
String groupName = markCacheMap.getString("group_name");
if (!groupNames.contains(groupName) || Objects.equals(Constant.EMOTION_LABEL_KEY, groupName)){
continue;
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("uniqueId", markCacheMap.getString("unique_id"));
jsonObject.put("name", markCacheMap.getString("name"));
res.add(jsonObject);
}
return res;
}
private JSONObject createInfoWithEmotion(JSONObject json) {
JSONObject info = new JSONObject();
String emotion = Tools.getEmotion(json);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment