提交 6d525246 作者: 王峰

Merge remote-tracking branch 'origin/master' into yjzx

package com.zzsn.event.constant; package com.zzsn.event.constant;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
public class Constants { public class Constants {
...@@ -78,4 +76,23 @@ public class Constants { ...@@ -78,4 +76,23 @@ public class Constants {
//关键词采集通道 //关键词采集通道
public static final String KEY_WORDS_COLLECT_TOPIC = "eventKeyWordsInfo"; public static final String KEY_WORDS_COLLECT_TOPIC = "eventKeyWordsInfo";
public static final String EVENT_SUBJECT_MODEL = "eventSubjectModel"; public static final String EVENT_SUBJECT_MODEL = "eventSubjectModel";
/**获取真正的来源*/
public static String getRealOrigin(String origin){
String[] splitArr = new String[]{"-","-"};
String split = null;
boolean contain = false;
for (String s : splitArr) {
if (origin.contains(s)) {
contain = true;
split = s;
break;
}
}
if (contain) {
int index = origin.indexOf(split);
origin = origin.substring(0, index);
}
return origin;
}
} }
...@@ -162,8 +162,9 @@ public class EventAnalysisController { ...@@ -162,8 +162,9 @@ public class EventAnalysisController {
pageList.forEach(e -> idList.add(e.getId())); pageList.forEach(e -> idList.add(e.getId()));
Map<String, Integer> similarNumber = esService.getSimilarNumber(subjectId, idList); Map<String, Integer> similarNumber = esService.getSimilarNumber(subjectId, idList);
for (SubjectDataVo subjectDataVo : pageList) { for (SubjectDataVo subjectDataVo : pageList) {
String dataId = subjectDataVo.getId(); subjectDataVo.setOrigin(Constants.getRealOrigin(subjectDataVo.getOrigin()));
Integer count = similarNumber.get(dataId); //相似数
Integer count = similarNumber.get(subjectDataVo.getId());
if (count == null) { if (count == null) {
count = 0; count = 0;
} }
...@@ -201,8 +202,11 @@ public class EventAnalysisController { ...@@ -201,8 +202,11 @@ public class EventAnalysisController {
if (fakeNum == null) { if (fakeNum == null) {
fakeNum = Constants.FAKE_NUM; fakeNum = Constants.FAKE_NUM;
} }
List<SubjectAnalysis> cacheList = analysisService.eventContext(subjectId, fakeNum); List<SubjectAnalysis> eventContextList = analysisService.eventContext(subjectId, fakeNum);
return Result.OK(cacheList); if (CollectionUtils.isNotEmpty(eventContextList)) {
eventContextList.forEach(e->e.setOrigin(Constants.getRealOrigin(e.getOrigin())));
}
return Result.OK(eventContextList);
} }
/** /**
......
...@@ -497,7 +497,7 @@ public class EsService { ...@@ -497,7 +497,7 @@ public class EsService {
for (Terms.Bucket bucket : buckets) { for (Terms.Bucket bucket : buckets) {
String origin = bucket.getKeyAsString(); String origin = bucket.getKeyAsString();
if (StringUtils.isNotEmpty(origin)) { if (StringUtils.isNotEmpty(origin)) {
originList.add(origin); originList.add(Constants.getRealOrigin(origin));
} }
} }
} catch (Exception e) { } catch (Exception e) {
......
...@@ -108,13 +108,13 @@ public class AnalysisServiceImpl implements AnalysisService { ...@@ -108,13 +108,13 @@ public class AnalysisServiceImpl implements AnalysisService {
//获取发布时间最早的前10的资讯(来源不重复) //获取发布时间最早的前10的资讯(来源不重复)
List<PropagationPathVo> secondList = new ArrayList<>(); List<PropagationPathVo> secondList = new ArrayList<>();
List<SubjectDataVo> earlyList = topN(specialDataList,Constants.FAKE_NUM); List<SubjectDataVo> earlyList = topN(specialDataList,Constants.FAKE_NUM);
earlyList.forEach(e->allOriginList.add(e.getOrigin())); earlyList.forEach(e->allOriginList.add(Constants.getRealOrigin(e.getOrigin())));
for (SubjectDataVo subjectDataVo : earlyList) { for (SubjectDataVo subjectDataVo : earlyList) {
String origin = subjectDataVo.getOrigin(); String origin = subjectDataVo.getOrigin();
String time = subjectDataVo.getPublishDate(); String time = subjectDataVo.getPublishDate();
if (StringUtils.isNotEmpty(origin)) { if (StringUtils.isNotEmpty(origin)) {
PropagationPathVo second = new PropagationPathVo(); PropagationPathVo second = new PropagationPathVo();
second.setName(origin); second.setName(Constants.getRealOrigin(origin));
second.setTime(time); second.setTime(time);
secondList.add(second); secondList.add(second);
List<String> thirdList = esService.groupByOrigin(subjectDataVo.getTitle(), subjectDataVo.getPublishDate()); List<String> thirdList = esService.groupByOrigin(subjectDataVo.getTitle(), subjectDataVo.getPublishDate());
......
...@@ -187,25 +187,11 @@ public class EsStatisticsServiceImpl implements EsStatisticsService { ...@@ -187,25 +187,11 @@ public class EsStatisticsServiceImpl implements EsStatisticsService {
Terms groupSource = aggregations.get("group_origin"); Terms groupSource = aggregations.get("group_origin");
List<? extends Terms.Bucket> buckets = groupSource.getBuckets(); List<? extends Terms.Bucket> buckets = groupSource.getBuckets();
if (CollectionUtils.isNotEmpty(buckets)) { if (CollectionUtils.isNotEmpty(buckets)) {
String[] splitArr = new String[]{"-","-"};
for (Terms.Bucket bucket : buckets) { for (Terms.Bucket bucket : buckets) {
boolean flag = false; boolean flag = false;
long count = bucket.getDocCount(); long count = bucket.getDocCount();
//获取真正的来源 //获取真正的来源
String originName = bucket.getKeyAsString(); String originName = Constants.getRealOrigin(bucket.getKeyAsString());
String split = null;
boolean contain = false;
for (String s : splitArr) {
if (originName.contains(s)) {
contain = true;
split = s;
break;
}
}
if (contain) {
int index = originName.indexOf(split);
originName = originName.substring(0, index);
}
//先判断是否存在,不存在则新增 //先判断是否存在,不存在则新增
for (CountVO countVO : list) { for (CountVO countVO : list) {
if (countVO.getName().equals(originName)) { if (countVO.getName().equals(originName)) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论