提交 9502a411 作者: 925993793@qq.com

事件分析逻辑修改(主要是和python对接方面)

上级 d88d5df0
......@@ -7,7 +7,6 @@ import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.obs.services.model.PutObjectResult;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.EventAnalysisReport;
......@@ -20,6 +19,7 @@ import com.zzsn.event.util.HttpUtil;
import com.zzsn.event.util.ObsUtil;
import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.vo.CountVO;
import com.zzsn.event.vo.EventViewVO;
import com.zzsn.event.vo.SubjectDataVo;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.CollectionUtils;
......@@ -79,7 +79,7 @@ public class EventAnalysisController {
* @date 2024/8/16
*/
@PostMapping("/uploadFile")
public Result<?> uploadFile(MultipartFile file){
public Result<?> uploadFile(MultipartFile file) {
String downloadUrl = null;
try {
if (file != null) {
......@@ -105,7 +105,7 @@ public class EventAnalysisController {
* @date 2024/8/16
*/
@PostMapping("/deleteFile")
public Result<?> deleteFile(@RequestBody JSONObject param){
public Result<?> deleteFile(@RequestBody JSONObject param) {
if (param != null) {
String path = param.get("path").toString();
String objectKey = path.replace(prefix, "");
......@@ -141,8 +141,8 @@ public class EventAnalysisController {
List<String> subjectIdList = new ArrayList<>();
subjectIdList.add(subjectId);
DateTime beforeHour = DateUtil.offsetHour(DateUtil.parseDateTime(endTime), -1);
long lastHour = esStatisticsService.totalCount(subjectIdList, DateUtil.formatDateTime(beforeHour),endTime);
map.put("lastHour",String.valueOf(lastHour));
long lastHour = esStatisticsService.totalCount(subjectIdList, DateUtil.formatDateTime(beforeHour), endTime);
map.put("lastHour", String.valueOf(lastHour));
return Result.OK(map);
}
......@@ -157,7 +157,7 @@ public class EventAnalysisController {
@GetMapping("/hotList")
public Result<?> hotList(@RequestParam(name = "subjectId") String subjectId,
@RequestParam(name = "size", defaultValue = "10") Integer size) {
String[] fetchFields = new String[]{"id","subjectId", "title", "origin", "publishDate", "sourceAddress"};
String[] fetchFields = new String[]{"id", "subjectId", "title", "origin", "publishDate", "sourceAddress"};
List<SubjectDataVo> pageList = esService.pageList(subjectId, null, null, fetchFields, 2, 1, size);
if (CollectionUtils.isNotEmpty(pageList)) {
List<String> idList = new ArrayList<>();
......@@ -208,24 +208,17 @@ public class EventAnalysisController {
}
/**
* 3.8 观点
* 3.8 媒体观点/专家观点信息列表
*
* @author lkg
* @date 2024/1/12
*/
@ApiOperation(value = "专题信息列表-分页列表查询", notes = "专题信息列表-分页列表查询")
@ApiOperation(value = "媒体观点/专家观点信息列表", notes = "媒体观点/专家观点信息列表")
@GetMapping(value = "/listEventAnalysis")
public Result<?> listEventAnalysis(@RequestParam(name = "eventId") String eventId,
@RequestParam(name = "type") Integer type) {
LambdaQueryWrapper<SubjectAnalysis> wrapper = new LambdaQueryWrapper<SubjectAnalysis>()
.eq(SubjectAnalysis::getSubjectId, eventId)
.eq(SubjectAnalysis::getCategory, 1)
.eq(SubjectAnalysis::getType, type);
List<SubjectAnalysis> list = subjectAnalysisService.list(wrapper);
if (CollectionUtils.isEmpty(list) && type == 1) {
list = esService.eventAnalysisByOrigin(eventId);
}
return Result.OK(list);
@RequestParam(name = "relationId") String relationId) {
List<EventViewVO> viewpointList = esService.viewpointList(eventId, relationId);
return Result.OK(viewpointList);
}
/**
......@@ -255,7 +248,7 @@ public class EventAnalysisController {
* @date 2024/5/9
*/
@GetMapping("/orientationCount")
public Result<?> orientationCount(@RequestParam String subjectId){
public Result<?> orientationCount(@RequestParam String subjectId) {
List<CountVO> countVOS = esStatisticsService.orientationCount(subjectId, null, null);
return Result.OK(countVOS);
}
......@@ -364,9 +357,9 @@ public class EventAnalysisController {
* @date 2024/4/12
*/
@GetMapping("/reportInfo")
public Result<?> reportInfo(@RequestParam String eventId){
public Result<?> reportInfo(@RequestParam String eventId) {
LambdaQueryWrapper<EventAnalysisReport> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(EventAnalysisReport::getEventId,eventId);
queryWrapper.eq(EventAnalysisReport::getEventId, eventId);
EventAnalysisReport one = eventAnalysisReportService.getOne(queryWrapper);
return Result.OK(one);
}
......@@ -379,7 +372,7 @@ public class EventAnalysisController {
* @date 2024/4/12
*/
@PostMapping("/reportEdit")
public Result<?> edit(@RequestBody EventAnalysisReport report){
public Result<?> edit(@RequestBody EventAnalysisReport report) {
eventAnalysisReportService.edit(report);
return Result.OK();
}
......@@ -412,7 +405,7 @@ public class EventAnalysisController {
startTime = DateUtil.formatDateTime(startDate);
}
DateTime endDate = DateUtil.offsetDay(DateUtil.parseDate(maxTime), 7);
if (endDate.compareTo(DateUtil.parseDateTime(endTime)) < 0){
if (endDate.compareTo(DateUtil.parseDateTime(endTime)) < 0) {
endTime = DateUtil.formatDateTime(endDate);
}
}
......
......@@ -7,7 +7,7 @@ package com.zzsn.event.enums;
*/
public enum CodePrefixEnum {
INFO_SOURCE_DEFAULT("IN","信息源编码默认前缀"),
SUBJECT_DEFAULT("SJ", "专题编码默认前缀"),
SUBJECT_DEFAULT("EVENT_ANALYSIS", "事件编码默认前缀"),
PROJECT_DEFAULT("PJ", "项目编码默认前缀"),
CUSTOMER_DEFAULT("CS", "客户编码默认前缀"),
SPECIAL_INFO_SOURCE_DEFAULT("PY","信息源编码默认前缀"),
......
......@@ -1159,6 +1159,59 @@ public class EsService {
return dataList;
}
/**
* 媒体观点/专家观点信息列表
*
* @param eventId 事件id
* @param relationId 关联标签id
* @author lkg
* @date 2024/10/10
*/
public List<EventViewVO> viewpointList(String eventId, String relationId) {
List<EventViewVO> dataList = new ArrayList<>();
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//排序方式 按发布时间升序
searchSourceBuilder.sort("publishDate", SortOrder.DESC);
searchSourceBuilder.trackTotalHits(true);
String[] fetchFields = new String[]{"id", "title", "origin", "publishDate", "subjectId", "sourceAddress","labels"};
searchSourceBuilder.fetchSource(fetchFields, null);
//创建查询对象
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must(QueryBuilders.termQuery("subjectId.keyword", eventId));
boolQuery.must(QueryBuilders.nestedQuery("labels", QueryBuilders.termQuery("labels.relationId", relationId), ScoreMode.None));
searchSourceBuilder.query(boolQuery);
searchRequest.source(searchSourceBuilder);
try {
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
SearchHit[] hits = searchResponse.getHits().getHits();
if (hits != null && hits.length > 0) {
for (SearchHit hit : hits) {
String index = hit.getIndex();
String sourceAsString = hit.getSourceAsString();
EventViewVO eventViewVO = JSON.parseObject(sourceAsString, EventViewVO.class);
eventViewVO.setPublishDate(EsDateUtil.esFieldDateMapping(eventViewVO.getPublishDate()));
eventViewVO.setIndex(index);
List<Label> labels = eventViewVO.getLabels();
String professionName = null;
for (Label label : labels) {
String labelRelationId = label.getRelationId();
if (StringUtils.isEmpty(labelRelationId)) {
professionName = label.getRelationName();
break;
}
}
eventViewVO.setProfessionName(professionName);
dataList.add(eventViewVO);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return dataList;
}
public List<SubjectDataVo> listByIds(List<String> ids) {
List<SubjectDataVo> dataList = new ArrayList<>();
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
......
......@@ -43,7 +43,7 @@ public class KafkaConsumer {
*
* @param record 接收的kafka数据
*/
@KafkaListener(topics = {Constants.VIEWPOINT_RECEIVE_TOPIC})
/*@KafkaListener(topics = {Constants.VIEWPOINT_RECEIVE_TOPIC})
public void viewPointAnalysis(ConsumerRecord<String, String> record) {
String value = record.value();
if (StringUtils.isNotEmpty(value)) {
......@@ -68,7 +68,7 @@ public class KafkaConsumer {
}
log.info("id为-{}-的专题,此次-观点分析-数据更新完成", subjectId);
}
}
}*/
/**
* 获取-事件脉络-分析结果数据,并入库
......
......@@ -44,7 +44,7 @@ public class AnalysisServiceImpl implements AnalysisService {
* 2.2 若有伪事件脉络就展示,若无则根据发布时间倒序后,默认取前15条资讯为事件脉络。
* 3.若事件脉络资讯数量大于/等于展示伪事件脉络的阈值(6),则直接展示
*
* 此种情况一般是专题资讯少或者刚建立的专题的事件专题,才会触发。
* 伪事件脉络/资讯作为事件脉络的情况一般是资讯数量少/刚建立/时间脉络抽取失败的事件专题,才会触发。
*/
@Override
public List<SubjectAnalysis> eventContext(String subjectId, int fakeNum) {
......
......@@ -62,7 +62,7 @@ public class AnalysisTask {
* 每天凌晨0点执行一次
* 按天发送kafka 获取进行中(未结束)的事件专题列表
*/
@Scheduled(cron = "0 0 0 * * ?")
// @Scheduled(cron = "0 0 0 * * ?")
public void subjectList() {
List<SubjectKafkaVo> data = new ArrayList<>();
Date today = new Date();
......@@ -109,7 +109,7 @@ public class AnalysisTask {
* 按天发送 事件脉络 所需信息到kafka对应的topic
* 保证信息采集的及时性,审核人员审核的及时性
*/
@Scheduled(cron = "0 5 0 * * ?")
// @Scheduled(cron = "0 5 0 * * ?")
public void eventContext() {
Date today = new Date();
Date disableDate = DateUtil.addDate(today, -1);
......
package com.zzsn.event.vo;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
*
*
* @author lkg
* @date 2024/10/10
*/
@Getter
@Setter
public class EventViewVO {
/*主键id*/
private String id;
/*专题id*/
private String subjectId;
/*标题*/
private String title;
/*来源*/
private String origin;
/*发布时间*/
private String publishDate;
/*链接*/
private String sourceAddress;
/**关联标签*/
private List<Label> labels;
/**es索引名称*/
private String index;
/**专家名称*/
private String professionName;
}
......@@ -51,12 +51,12 @@ spring:
master:
url: jdbc:mysql://114.116.44.11:3306/clb_project?useUnicode=true&characterEncoding=utf-8&AllowPublicKeyRetrieval=True&serverTimezone=Asia/Shanghai&autoReconnect=true&rewriteBatchedStatements=true
username: ciglobal
password: qwer@9988&zzsn
password: _PSuWVQ4CLpX
driver-class-name: com.mysql.cj.jdbc.Driver
multi-datasource1:
url: jdbc:mysql://114.116.44.11:3306/clb_xxl_job?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: ciglobal
password: qwer@9988&zzsn
password: _PSuWVQ4CLpX
driver-class-name: com.mysql.cj.jdbc.Driver
elasticsearch:
uris: ["1.95.38.69:9700","1.95.3.121:9200","1.95.87.177:9700"]
......@@ -82,7 +82,7 @@ spring:
min-idle: 0 #最小等待连接中的数量,设 0 为没有限制
shutdown-timeout: 100ms
port: 6380
password: clbzzsn
password: RPHZgkDQ4zGJ
kafka:
bootstrap-servers: 1.95.78.131:9092
producer: # 生产者
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论