提交 c5ed869c 作者: 925993793@qq.com

增加专题正面资讯数量统计接口

上级 d9a23857
......@@ -199,6 +199,19 @@ public class EventAnalysisController {
}
}
/**
* 专题下情感类标签下资讯数量统计
*
* @param subjectId 专题id
* @author lkg
* @date 2024/5/9
*/
@GetMapping("/orientationCount")
public Result<?> orientationCount(@RequestParam String subjectId){
List<CountVO> countVOS = esStatisticsService.orientationCount(subjectId, null, null);
return Result.OK(countVOS);
}
/**
* 3.5 情感判断分析
......
......@@ -26,6 +26,17 @@ public interface EsStatisticsService {
*/
Map<String, String> totalAndMax(String subjectId, String startTime, String endTime, Integer type);
/**
* 情感判断数量统计
*
* @param subjectId 专题id
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2024/1/25
*/
List<CountVO> orientationCount(String subjectId, String startTime, String endTime);
/**
* 情感判断分析
......
......@@ -32,6 +32,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.CompletableFuture;
/**
* 舆情信息统计 es查询工具类
......@@ -89,6 +90,41 @@ public class EsStatisticsServiceImpl implements EsStatisticsService {
return map;
}
@Override
public List<CountVO> orientationCount(String subjectId, String startTime, String endTime) {
List<CountVO> list = new ArrayList<>();
String labelTypeId = "1631119596744265729";
List<LabelEntity> labelEntities = labelEntityService.listByType(labelTypeId);
for (LabelEntity labelEntity : labelEntities) {
CompletableFuture<CountVO> async = CompletableFuture.supplyAsync(() -> {
String labelId = labelEntity.getId();
String name = labelEntity.getName();
CountVO countVO = new CountVO();
countVO.setName(name);
long count = 0L;
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = formatSourceBuilder(subjectId, labelId, startTime, endTime);
searchSourceBuilder.size(0);
searchSourceBuilder.trackTotalHits(true);
searchRequest.source(searchSourceBuilder);
try {
SearchResponse response = client.search(searchRequest, RequestOptions.DEFAULT);
count = response.getHits().getTotalHits().value;
} catch (Exception e) {
e.printStackTrace();
}
countVO.setValue(count);
return countVO;
});
try {
CountVO countVO = async.get();
list.add(countVO);
} catch (Exception e) {
e.printStackTrace();
}
}
return list;
}
@Override
public CountVO orientation(String subjectId, String labelId, String startTime, String endTime, Integer type) {
......@@ -217,6 +253,7 @@ public class EsStatisticsServiceImpl implements EsStatisticsService {
.field("repeatMark")
.order(BucketOrder.count(false))
.size(1);
searchSourceBuilder.query(boolQuery);
searchSourceBuilder.aggregation(aggregationBuilder);
searchRequest.source(searchSourceBuilder);
try {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论