Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
E
event
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
陈世强
event
Commits
bf99fd94
提交
bf99fd94
authored
7月 28, 2025
作者:
925993793@qq.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
事件分析新版本功能开发
上级
7f3569c8
隐藏空白字符变更
内嵌
并排
正在显示
18 个修改的文件
包含
437 行增加
和
450 行删除
+437
-450
EventAnalysisController.java
...va/com/zzsn/event/controller/EventAnalysisController.java
+94
-82
EventManageController.java
...java/com/zzsn/event/controller/EventManageController.java
+15
-26
KeywordController.java
...a/com/zzsn/event/controller/common/KeywordController.java
+17
-0
LLmConfigController.java
...com/zzsn/event/controller/common/LLmConfigController.java
+49
-0
KeywordConf.java
src/main/java/com/zzsn/event/entity/KeywordConf.java
+62
-0
AnalysisColumnEnum.java
src/main/java/com/zzsn/event/enums/AnalysisColumnEnum.java
+11
-17
KafkaConsumer.java
src/main/java/com/zzsn/event/kafka/KafkaConsumer.java
+0
-97
KeywordConfMapper.java
src/main/java/com/zzsn/event/mapper/KeywordConfMapper.java
+20
-0
EventAnalysisVersionRecordService.java
...zzsn/event/service/EventAnalysisVersionRecordService.java
+2
-0
EventAnalysisVersionService.java
...a/com/zzsn/event/service/EventAnalysisVersionService.java
+8
-0
EventLlmConfigService.java
...in/java/com/zzsn/event/service/EventLlmConfigService.java
+2
-0
AnalysisServiceImpl.java
...java/com/zzsn/event/service/impl/AnalysisServiceImpl.java
+37
-9
EventAnalysisVersionRecordServiceImpl.java
...t/service/impl/EventAnalysisVersionRecordServiceImpl.java
+14
-0
EventAnalysisVersionServiceImpl.java
...n/event/service/impl/EventAnalysisVersionServiceImpl.java
+15
-5
EventLlmConfigServiceImpl.java
...om/zzsn/event/service/impl/EventLlmConfigServiceImpl.java
+37
-0
EventServiceImpl.java
...in/java/com/zzsn/event/service/impl/EventServiceImpl.java
+19
-7
AnalysisTask.java
src/main/java/com/zzsn/event/task/AnalysisTask.java
+32
-207
EventVO.java
src/main/java/com/zzsn/event/vo/EventVO.java
+3
-0
没有找到文件。
src/main/java/com/zzsn/event/controller/EventAnalysisController.java
浏览文件 @
bf99fd94
...
...
@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateField;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUtil
;
import
com.alibaba.fastjson2.JSON
;
import
com.alibaba.fastjson2.JSONArray
;
import
com.alibaba.fastjson2.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
...
...
@@ -154,12 +155,13 @@ public class EventAnalysisController {
@GetMapping
(
"/eventContext"
)
public
Result
<?>
eventContext
(
@RequestParam
String
eventId
,
@RequestParam
(
required
=
false
)
String
versionId
)
{
if
(
StringUtils
.
is
Not
Empty
(
versionId
))
{
String
versionData
=
getVersionData
(
versionId
,
AnalysisColumnEnum
.
EVENT_CONTEXT
.
getCode
()
);
return
Result
.
OK
(
versionData
);
if
(
StringUtils
.
isEmpty
(
versionId
))
{
EventAnalysisVersion
eventAnalysisVersion
=
eventAnalysisVersionService
.
latestVersion
(
eventId
);
versionId
=
eventAnalysisVersion
.
getId
(
);
}
List
<
Map
<
String
,
Object
>>
eventContext
=
eventContextService
.
eventContext
(
eventId
);
return
Result
.
OK
(
eventContext
);
String
versionData
=
eventAnalysisVersionRecordService
.
getVersionData
(
versionId
,
AnalysisColumnEnum
.
EVENT_CONTEXT
.
getCode
());
//List<Map<String, Object>> versionData = eventContextService.eventContext(eventId);
return
Result
.
OK
(
JSON
.
parseArray
(
versionData
,
JSONObject
.
class
));
}
/**
...
...
@@ -245,12 +247,13 @@ public class EventAnalysisController {
@RequestParam
(
required
=
false
)
String
startTime
,
@RequestParam
(
required
=
false
)
String
endTime
,
@RequestParam
(
required
=
false
)
String
versionId
)
{
if
(
StringUtils
.
is
Not
Empty
(
versionId
))
{
String
versionData
=
getVersionData
(
versionId
,
AnalysisColumnEnum
.
KEYWORD_TREND
.
getCode
()
);
return
Result
.
OK
(
versionData
);
if
(
StringUtils
.
isEmpty
(
versionId
))
{
EventAnalysisVersion
eventAnalysisVersion
=
eventAnalysisVersionService
.
latestVersion
(
eventId
);
versionId
=
eventAnalysisVersion
.
getId
(
);
}
List
<
CountVO
>
countVOS
=
analysisService
.
wordTrend
(
eventId
,
startTime
,
endTime
);
return
Result
.
OK
(
countVOS
);
String
versionData
=
eventAnalysisVersionRecordService
.
getVersionData
(
versionId
,
AnalysisColumnEnum
.
KEYWORD_TREND
.
getCode
());
//List<CountVO> versionData = analysisService.wordTrend(eventId, startTime, endTime);
return
Result
.
OK
(
JSON
.
parseArray
(
versionData
,
JSONObject
.
class
));
}
...
...
@@ -267,22 +270,13 @@ public class EventAnalysisController {
@RequestParam
(
required
=
false
)
String
startTime
,
@RequestParam
(
required
=
false
)
String
endTime
,
@RequestParam
(
required
=
false
)
String
versionId
)
{
if
(
StringUtils
.
isNotEmpty
(
versionId
))
{
String
versionData
=
getVersionData
(
versionId
,
AnalysisColumnEnum
.
CO_OCCURRENCE
.
getCode
());
return
Result
.
OK
(
versionData
);
}
//增加缓存逻辑,提升查询效率
String
key
=
Constants
.
SUBJECT_ANALYSIS_PRE
+
Constants
.
CO_OCCURRENCE
+
eventId
;
Object
cacheObject
=
redisUtil
.
get
(
key
);
if
(
cacheObject
!=
null
)
{
return
Result
.
OK
(
cacheObject
);
}
else
{
List
<
CoOccurrenceVO
>
coOccurrenceVOS
=
analysisService
.
coOccurrence
(
eventId
,
startTime
,
endTime
);
if
(
CollectionUtils
.
isNotEmpty
(
coOccurrenceVOS
))
{
redisUtil
.
set
(
key
,
coOccurrenceVOS
,
3600
*
24
);
}
return
Result
.
OK
(
coOccurrenceVOS
);
if
(
StringUtils
.
isEmpty
(
versionId
))
{
EventAnalysisVersion
eventAnalysisVersion
=
eventAnalysisVersionService
.
latestVersion
(
eventId
);
versionId
=
eventAnalysisVersion
.
getId
();
}
String
versionData
=
eventAnalysisVersionRecordService
.
getVersionData
(
versionId
,
AnalysisColumnEnum
.
CO_OCCURRENCE
.
getCode
());
//List<CoOccurrenceVO> versionData = analysisService.coOccurrence(eventId, startTime, endTime);
return
Result
.
OK
(
JSON
.
parseArray
(
versionData
,
JSONObject
.
class
));
}
/**
...
...
@@ -430,12 +424,13 @@ public class EventAnalysisController {
@RequestParam
(
required
=
false
)
String
startTime
,
@RequestParam
(
required
=
false
)
String
endTime
,
@RequestParam
(
required
=
false
)
String
versionId
)
{
if
(
StringUtils
.
is
Not
Empty
(
versionId
))
{
String
versionData
=
getVersionData
(
versionId
,
AnalysisColumnEnum
.
IMPACT_ASSESSMENT
.
getCode
()
);
return
Result
.
OK
(
versionData
);
if
(
StringUtils
.
isEmpty
(
versionId
))
{
EventAnalysisVersion
eventAnalysisVersion
=
eventAnalysisVersionService
.
latestVersion
(
eventId
);
versionId
=
eventAnalysisVersion
.
getId
(
);
}
String
result
=
analysisService
.
llmResult
(
eventId
,
startTime
,
endTime
,
AnalysisColumnEnum
.
IMPACT_ASSESSMENT
.
getCode
());
return
Result
.
OK
(
result
);
String
versionData
=
eventAnalysisVersionRecordService
.
getVersionData
(
versionId
,
AnalysisColumnEnum
.
IMPACT_ASSESSMENT
.
getCode
());
//String result = analysisService.llmResult(eventId, startTime, endTime, AnalysisColumnEnum.IMPACT_ASSESSMENT.getCode());
return
Result
.
OK
(
JSON
.
parseArray
(
versionData
,
JSONObject
.
class
));
}
/**
...
...
@@ -452,12 +447,13 @@ public class EventAnalysisController {
@RequestParam
(
required
=
false
)
String
startTime
,
@RequestParam
(
required
=
false
)
String
endTime
,
@RequestParam
(
required
=
false
)
String
versionId
)
{
if
(
StringUtils
.
is
Not
Empty
(
versionId
))
{
String
versionData
=
getVersionData
(
versionId
,
AnalysisColumnEnum
.
MEASURE_SUGGEST
.
getCode
()
);
return
Result
.
OK
(
versionData
);
if
(
StringUtils
.
isEmpty
(
versionId
))
{
EventAnalysisVersion
eventAnalysisVersion
=
eventAnalysisVersionService
.
latestVersion
(
eventId
);
versionId
=
eventAnalysisVersion
.
getId
(
);
}
String
result
=
analysisService
.
llmResult
(
eventId
,
startTime
,
endTime
,
AnalysisColumnEnum
.
MEASURE_SUGGEST
.
getCode
());
return
Result
.
OK
(
result
);
String
versionData
=
eventAnalysisVersionRecordService
.
getVersionData
(
versionId
,
AnalysisColumnEnum
.
MEASURE_SUGGEST
.
getCode
());
//String result = analysisService.llmResult(eventId, startTime, endTime, AnalysisColumnEnum.MEASURE_SUGGEST.getCode());
return
Result
.
OK
(
JSON
.
parseArray
(
versionData
,
JSONObject
.
class
));
}
/**
...
...
@@ -474,12 +470,13 @@ public class EventAnalysisController {
@RequestParam
(
required
=
false
)
String
startTime
,
@RequestParam
(
required
=
false
)
String
endTime
,
@RequestParam
(
required
=
false
)
String
versionId
)
{
if
(
StringUtils
.
is
Not
Empty
(
versionId
))
{
String
versionData
=
getVersionData
(
versionId
,
AnalysisColumnEnum
.
KNOWLEDGE_ENTRY
.
getCode
()
);
return
Result
.
OK
(
versionData
);
if
(
StringUtils
.
isEmpty
(
versionId
))
{
EventAnalysisVersion
eventAnalysisVersion
=
eventAnalysisVersionService
.
latestVersion
(
eventId
);
versionId
=
eventAnalysisVersion
.
getId
(
);
}
String
result
=
analysisService
.
llmResult
(
eventId
,
startTime
,
endTime
,
AnalysisColumnEnum
.
KNOWLEDGE_ENTRY
.
getCode
());
return
Result
.
OK
(
result
);
String
versionData
=
eventAnalysisVersionRecordService
.
getVersionData
(
versionId
,
AnalysisColumnEnum
.
KNOWLEDGE_ENTRY
.
getCode
());
//String result = analysisService.llmResult(eventId, startTime, endTime, AnalysisColumnEnum.KNOWLEDGE_ENTRY.getCode());
return
Result
.
OK
(
JSON
.
parseArray
(
versionData
,
JSONObject
.
class
));
}
/**
...
...
@@ -496,12 +493,13 @@ public class EventAnalysisController {
@RequestParam
(
required
=
false
)
String
startTime
,
@RequestParam
(
required
=
false
)
String
endTime
,
@RequestParam
(
required
=
false
)
String
versionId
)
{
if
(
StringUtils
.
is
Not
Empty
(
versionId
))
{
String
versionData
=
getVersionData
(
versionId
,
AnalysisColumnEnum
.
ENTERPRISE_CASE
.
getCode
()
);
return
Result
.
OK
(
versionData
);
if
(
StringUtils
.
isEmpty
(
versionId
))
{
EventAnalysisVersion
eventAnalysisVersion
=
eventAnalysisVersionService
.
latestVersion
(
eventId
);
versionId
=
eventAnalysisVersion
.
getId
(
);
}
String
result
=
analysisService
.
llmResult
(
eventId
,
startTime
,
endTime
,
AnalysisColumnEnum
.
ENTERPRISE_CASE
.
getCode
());
return
Result
.
OK
(
result
);
String
versionData
=
eventAnalysisVersionRecordService
.
getVersionData
(
versionId
,
AnalysisColumnEnum
.
ENTERPRISE_CASE
.
getCode
());
//String result = analysisService.llmResult(eventId, startTime, endTime, AnalysisColumnEnum.ENTERPRISE_CASE.getCode());
return
Result
.
OK
(
JSON
.
parseArray
(
versionData
,
JSONObject
.
class
));
}
/**
...
...
@@ -518,16 +516,49 @@ public class EventAnalysisController {
@RequestParam
(
required
=
false
)
String
startTime
,
@RequestParam
(
required
=
false
)
String
endTime
,
@RequestParam
(
required
=
false
)
String
versionId
)
{
if
(
StringUtils
.
isNotEmpty
(
versionId
))
{
String
versionData
=
getVersionData
(
versionId
,
AnalysisColumnEnum
.
COUNTRY_POLICY
.
getCode
());
return
Result
.
OK
(
versionData
);
if
(
StringUtils
.
isEmpty
(
versionId
))
{
EventAnalysisVersion
eventAnalysisVersion
=
eventAnalysisVersionService
.
latestVersion
(
eventId
);
versionId
=
eventAnalysisVersion
.
getId
();
}
String
versionData
=
eventAnalysisVersionRecordService
.
getVersionData
(
versionId
,
AnalysisColumnEnum
.
COUNTRY_POLICY
.
getCode
());
//String result = analysisService.llmResult(eventId, startTime, endTime, AnalysisColumnEnum.COUNTRY_POLICY.getCode());
return
Result
.
OK
(
JSON
.
parseArray
(
versionData
,
JSONObject
.
class
));
}
/**
* 类似事件
*
* @param eventId 事件id
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2024/4/12
*/
@GetMapping
(
"/similarEvent"
)
public
Result
<?>
similarEvent
(
@RequestParam
String
eventId
,
@RequestParam
(
required
=
false
)
String
startTime
,
@RequestParam
(
required
=
false
)
String
endTime
,
@RequestParam
(
required
=
false
)
String
versionId
)
{
if
(
StringUtils
.
isEmpty
(
versionId
))
{
EventAnalysisVersion
eventAnalysisVersion
=
eventAnalysisVersionService
.
latestVersion
(
eventId
);
versionId
=
eventAnalysisVersion
.
getId
();
}
String
result
=
analysisService
.
llmResult
(
eventId
,
startTime
,
endTime
,
AnalysisColumnEnum
.
COUNTRY_POLICY
.
getCode
());
return
Result
.
OK
(
result
);
List
<
Map
<
String
,
Object
>>
dataList
=
new
ArrayList
<>();
Map
<
String
,
Object
>
domestic
=
new
HashMap
<>();
String
domesticSimilarEvent
=
eventAnalysisVersionRecordService
.
getVersionData
(
versionId
,
AnalysisColumnEnum
.
DOMESTIC_SIMILAR_EVENT
.
getCode
());
domestic
.
put
(
"type"
,
AnalysisColumnEnum
.
DOMESTIC_SIMILAR_EVENT
.
getName
());
domestic
.
put
(
"data"
,
JSON
.
parseArray
(
domesticSimilarEvent
,
JSONObject
.
class
));
dataList
.
add
(
domestic
);
Map
<
String
,
Object
>
foreign
=
new
HashMap
<>();
String
foreignSimilarEvent
=
eventAnalysisVersionRecordService
.
getVersionData
(
versionId
,
AnalysisColumnEnum
.
FOREIGN_SIMILAR_EVENT
.
getCode
());
foreign
.
put
(
"type"
,
AnalysisColumnEnum
.
FOREIGN_SIMILAR_EVENT
.
getName
());
foreign
.
put
(
"data"
,
JSON
.
parseArray
(
foreignSimilarEvent
,
JSONObject
.
class
));
dataList
.
add
(
foreign
);
return
Result
.
OK
(
dataList
);
}
/**
*
本
国类似事件
*
中
国类似事件
*
* @param eventId 事件id
* @param startTime 开始时间
...
...
@@ -540,12 +571,13 @@ public class EventAnalysisController {
@RequestParam
(
required
=
false
)
String
startTime
,
@RequestParam
(
required
=
false
)
String
endTime
,
@RequestParam
(
required
=
false
)
String
versionId
)
{
if
(
StringUtils
.
is
Not
Empty
(
versionId
))
{
String
versionData
=
getVersionData
(
versionId
,
AnalysisColumnEnum
.
DOMESTIC_SIMILAR_EVENT
.
getCode
()
);
return
Result
.
OK
(
versionData
);
if
(
StringUtils
.
isEmpty
(
versionId
))
{
EventAnalysisVersion
eventAnalysisVersion
=
eventAnalysisVersionService
.
latestVersion
(
eventId
);
versionId
=
eventAnalysisVersion
.
getId
(
);
}
String
result
=
analysisService
.
llmResult
(
eventId
,
startTime
,
endTime
,
AnalysisColumnEnum
.
DOMESTIC_SIMILAR_EVENT
.
getCode
());
return
Result
.
OK
(
result
);
String
versionData
=
eventAnalysisVersionRecordService
.
getVersionData
(
versionId
,
AnalysisColumnEnum
.
DOMESTIC_SIMILAR_EVENT
.
getCode
());
//String result = analysisService.llmResult(eventId, startTime, endTime, AnalysisColumnEnum.DOMESTIC_SIMILAR_EVENT.getCode());
return
Result
.
OK
(
JSON
.
parseArray
(
versionData
,
JSONObject
.
class
));
}
/**
...
...
@@ -562,12 +594,13 @@ public class EventAnalysisController {
@RequestParam
(
required
=
false
)
String
startTime
,
@RequestParam
(
required
=
false
)
String
endTime
,
@RequestParam
(
required
=
false
)
String
versionId
)
{
if
(
StringUtils
.
is
Not
Empty
(
versionId
))
{
String
versionData
=
getVersionData
(
versionId
,
AnalysisColumnEnum
.
FOREIGN_SIMILAR_EVENT
.
getCode
()
);
return
Result
.
OK
(
versionData
);
if
(
StringUtils
.
isEmpty
(
versionId
))
{
EventAnalysisVersion
eventAnalysisVersion
=
eventAnalysisVersionService
.
latestVersion
(
eventId
);
versionId
=
eventAnalysisVersion
.
getId
(
);
}
String
result
=
analysisService
.
llmResult
(
eventId
,
startTime
,
endTime
,
AnalysisColumnEnum
.
FOREIGN_SIMILAR_EVENT
.
getCode
());
return
Result
.
OK
(
result
);
String
versionData
=
eventAnalysisVersionRecordService
.
getVersionData
(
versionId
,
AnalysisColumnEnum
.
FOREIGN_SIMILAR_EVENT
.
getCode
());
//String result = analysisService.llmResult(eventId, startTime, endTime, AnalysisColumnEnum.FOREIGN_SIMILAR_EVENT.getCode());
return
Result
.
OK
(
JSON
.
parseArray
(
versionData
,
JSONObject
.
class
));
}
...
...
@@ -644,27 +677,6 @@ public class EventAnalysisController {
/**
* 获取接口的版本数据
*
* @param versionId 版本id
* @param columnCode 栏目编码
* @author lkg
* @date 2025/7/16
*/
private
String
getVersionData
(
String
versionId
,
Integer
columnCode
)
{
String
result
=
null
;
LambdaQueryWrapper
<
EventAnalysisVersionRecord
>
queryWrapper
=
Wrappers
.
lambdaQuery
();
queryWrapper
.
eq
(
EventAnalysisVersionRecord:
:
getVersionId
,
versionId
)
.
eq
(
EventAnalysisVersionRecord:
:
getColumnCode
,
columnCode
);
EventAnalysisVersionRecord
eventAnalysisVersionRecord
=
eventAnalysisVersionRecordService
.
getOne
(
queryWrapper
);
if
(
eventAnalysisVersionRecord
!=
null
)
{
result
=
eventAnalysisVersionRecord
.
getReturnData
();
}
return
result
;
}
/**
* 获取趋势图数据的实际时间范围
*
* @param startTime 专题开始时间
...
...
src/main/java/com/zzsn/event/controller/EventManageController.java
浏览文件 @
bf99fd94
package
com
.
zzsn
.
event
.
controller
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson2.JSON
;
import
com.alibaba.fastjson2.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.zzsn.clb.common.model.task.dto.titr.KeyWordsDTO
;
import
com.zzsn.event.constant.Constants
;
import
com.zzsn.event.constant.Result
;
import
com.zzsn.event.entity.ClbModelArrangeSubjectMap
;
import
com.zzsn.event.entity.Event
;
import
com.zzsn.event.entity.EventAnalysisVersionRecord
;
import
com.zzsn.event.entity.KeyWords
;
import
com.zzsn.event.entity.SubjectInfoSourceMap
;
import
com.zzsn.event.entity.*
;
import
com.zzsn.event.enums.AnalysisColumnEnum
;
import
com.zzsn.event.service.*
;
import
com.zzsn.event.service.*
;
import
com.zzsn.event.service.impl.CaiJiCenterHttpService
;
import
com.zzsn.event.service.impl.ConfigurationMessageService
;
import
com.zzsn.event.util.HttpUtil
;
import
com.zzsn.event.util.ObjectUtil
;
import
com.zzsn.event.util.RedisUtil
;
import
com.zzsn.event.util.user.UserUtil
;
import
com.zzsn.event.util.user.UserVo
;
import
com.zzsn.event.vo.*
;
...
...
@@ -32,14 +23,16 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.kafka.core.KafkaTemplate
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.CompletableFuture
;
/**
...
...
@@ -68,13 +61,12 @@ public class EventManageController {
private
IKeyWordsService
keyWordsService
;
@Autowired
private
ClbModelArrangeSubjectMapService
clbModelArrangeSubjectMapService
;
@Autowired
private
RedisUtil
redisUtil
;
@Resource
private
KafkaTemplate
<
String
,
String
>
kafkaTemplate
;
@Autowired
private
EventAnalysisVersionRecordService
eventAnalysisVersionRecordService
;
@Autowired
private
EventAnalysisVersionService
eventAnalysisVersionService
;
@Value
((
"${serviceProject.url:}"
))
private
String
SERVICE_PROJECT_URL
;
...
...
@@ -133,22 +125,19 @@ public class EventManageController {
/**
* 通过id查询
*
* @param
i
d 事件id
* @param
eventI
d 事件id
* @return
*/
@GetMapping
(
value
=
"/queryById"
)
public
Result
<?>
queryById
(
@RequestParam
(
name
=
"id"
)
String
i
d
,
public
Result
<?>
queryById
(
@RequestParam
String
eventI
d
,
@RequestParam
(
required
=
false
)
String
versionId
)
{
EventVO
eventVO
=
eventService
.
queryInfo
(
id
);
if
(
StringUtils
.
isNotEmpty
(
versionId
))
{
LambdaQueryWrapper
<
EventAnalysisVersionRecord
>
queryWrapper
=
Wrappers
.
lambdaQuery
();
queryWrapper
.
eq
(
EventAnalysisVersionRecord:
:
getVersionId
,
versionId
)
.
eq
(
EventAnalysisVersionRecord:
:
getColumnCode
,
AnalysisColumnEnum
.
CORE_SUMMARY
.
getCode
());
EventAnalysisVersionRecord
eventAnalysisVersionRecord
=
eventAnalysisVersionRecordService
.
getOne
(
queryWrapper
);
if
(
eventAnalysisVersionRecord
!=
null
)
{
eventVO
.
setEventDescribe
(
eventAnalysisVersionRecord
.
getReturnData
());
}
EventVO
eventVO
=
eventService
.
queryInfo
(
eventId
);
if
(
StringUtils
.
isEmpty
(
versionId
))
{
EventAnalysisVersion
eventAnalysisVersion
=
eventAnalysisVersionService
.
latestVersion
(
eventId
);
versionId
=
eventAnalysisVersion
.
getId
();
}
String
versionData
=
eventAnalysisVersionRecordService
.
getVersionData
(
versionId
,
AnalysisColumnEnum
.
CORE_SUMMARY
.
getCode
());
eventVO
.
setEventDescribe
(
versionData
);
return
Result
.
OK
(
eventVO
);
}
...
...
src/main/java/com/zzsn/event/controller/common/KeywordController.java
浏览文件 @
bf99fd94
...
...
@@ -4,9 +4,11 @@ import com.alibaba.fastjson2.JSONObject;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.zzsn.event.constant.Result
;
import
com.zzsn.event.entity.KeyWords
;
import
com.zzsn.event.entity.KeywordConf
;
import
com.zzsn.event.entity.KeywordsType
;
import
com.zzsn.event.service.IKeyWordsService
;
import
com.zzsn.event.service.IKeywordsTypeService
;
import
com.zzsn.event.service.KeywordConfService
;
import
com.zzsn.event.vo.KeyWordsPage
;
import
com.zzsn.event.vo.KeywordsTypeVo
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -28,6 +30,8 @@ public class KeywordController {
private
IKeywordsTypeService
keywordsTypeService
;
@Autowired
private
IKeyWordsService
keyWordsService
;
@Autowired
private
KeywordConfService
keywordConfService
;
/**
* 通过父级id列表查询
...
...
@@ -189,4 +193,17 @@ public class KeywordController {
KeyWordsPage
keyWords
=
keyWordsService
.
getKeyWordsById
(
id
);
return
Result
.
OK
(
keyWords
);
}
/**
* 添加关键词过滤配置
*
* @param keywordConf 过滤词信息
* @author lkg
* @date 2025/7/28
*/
@PostMapping
(
"/conf/add"
)
public
Result
<?>
configAdd
(
@RequestBody
List
<
KeywordConf
>
keywordConf
){
keywordConfService
.
saveBatch
(
keywordConf
);
return
Result
.
OK
();
}
}
src/main/java/com/zzsn/event/controller/common/LLmConfigController.java
0 → 100644
浏览文件 @
bf99fd94
package
com
.
zzsn
.
event
.
controller
.
common
;
import
com.zzsn.event.constant.Result
;
import
com.zzsn.event.entity.EventLlmConfig
;
import
com.zzsn.event.service.EventLlmConfigService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
* 大模型配置
*
* @author lkg
* @date 2025/7/28
*/
@RestController
@RequestMapping
(
"/llm/config"
)
public
class
LLmConfigController
{
@Autowired
private
EventLlmConfigService
llmConfigService
;
/**
* 事件下大模型配置信息
*
* @param eventId 事件id
* @author lkg
* @date 2025/7/28
*/
@GetMapping
(
"/list"
)
public
Result
<?>
list
(
@RequestParam
String
eventId
)
{
List
<
EventLlmConfig
>
configList
=
llmConfigService
.
getConfigList
(
eventId
);
return
Result
.
OK
(
configList
);
}
/**
* 编辑事件的大模型配置信息
*
* @param eventLlmConfigList 大模型配置信息
* @author lkg
* @date 2025/7/28
*/
@PostMapping
(
"/modify"
)
public
Result
<?>
modify
(
@RequestBody
List
<
EventLlmConfig
>
eventLlmConfigList
)
{
llmConfigService
.
modify
(
eventLlmConfigList
);
return
Result
.
OK
();
}
}
src/main/java/com/zzsn/event/entity/KeywordConf.java
0 → 100644
浏览文件 @
bf99fd94
package
com
.
zzsn
.
event
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModel
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* 关键词过滤配置
* @TableName clb_keyword_conf
*/
@Data
@TableName
(
"clb_keyword_conf"
)
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
false
)
@ApiModel
(
value
=
"clb_keyword_conf对象"
,
description
=
"关键词过滤配置"
)
public
class
KeywordConf
implements
Serializable
{
/**
*
*/
@TableId
(
type
=
IdType
.
ASSIGN_ID
)
private
String
id
;
/**
* 分类id
*/
private
String
databaseId
;
/**
* 分类类型
*/
private
String
databaseType
;
/**
* 关键词
*/
private
String
keyword
;
/**
* 0:黑名单 1:白名单
*/
private
Integer
type
;
/**
* 作用范围 0:全库 1:本库
*/
private
Integer
rangeType
;
/**
* 创建人
*/
private
String
createBy
;
/**
* 创建时间
*/
@JsonFormat
(
timezone
=
"GMT+8"
,
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
createTime
;
}
src/main/java/com/zzsn/event/enums/AnalysisColumnEnum.java
浏览文件 @
bf99fd94
...
...
@@ -11,33 +11,27 @@ import java.util.List;
public
enum
AnalysisColumnEnum
{
CORE_SUMMARY
(
1
,
"核心摘要"
,
"string"
,
1
),
CORE_SUMMARY
(
1
,
"核心摘要"
,
"string"
,
1
),
EVENT_CONTEXT
(
2
,
"事件脉络"
,
"array"
,
0
),
EVENT_CONTEXT
(
2
,
"事件脉络"
,
"array"
,
0
),
KEYWORD_TREND
(
3
,
"关键词趋势分析"
,
"array"
,
0
),
KEYWORD_TREND
(
3
,
"关键词趋势分析"
,
"array"
,
0
),
CO_OCCURRENCE
(
4
,
"关键词共现"
,
"array"
,
0
),
CO_OCCURRENCE
(
4
,
"关键词共现"
,
"array"
,
0
),
IMPACT_ASSESSMENT
(
5
,
"影响评估"
,
"array"
,
1
),
IMPACT_ASSESSMENT
(
5
,
"影响评估"
,
"array"
,
1
),
MEASURE_SUGGEST
(
6
,
"举措建议"
,
"array"
,
1
),
MEASURE_SUGGEST
(
6
,
"举措建议"
,
"array"
,
1
),
KNOWLEDGE_ENTRY
(
7
,
"知识词条"
,
"array"
,
1
),
KNOWLEDGE_ENTRY
(
7
,
"知识词条"
,
"array"
,
1
),
ENTERPRISE_CASE
(
8
,
"企业案例"
,
"array"
,
1
),
ENTERPRISE_CASE
(
8
,
"企业案例"
,
"array"
,
1
),
COUNTRY_POLICY
(
9
,
"各国政策"
,
"array"
,
1
),
COUNTRY_POLICY
(
9
,
"各国政策"
,
"array"
,
1
),
DOMESTIC_SIMILAR_EVENT
(
10
,
"本国类似事件"
,
"array"
,
1
),
DOMESTIC_SIMILAR_EVENT
(
10
,
"中国类似事件"
,
"array"
,
1
),
FOREIGN_SIMILAR_EVENT
(
11
,
"各国类似事件"
,
"array"
,
1
),
//GENERATE_OUTLINE(12,"生成大纲","array", 1),
//GENERATE_PPT(13,"生成ppt","array", 1),
;
FOREIGN_SIMILAR_EVENT
(
11
,
"各国类似事件"
,
"array"
,
1
);
//栏目编码
private
final
Integer
code
;
...
...
src/main/java/com/zzsn/event/kafka/KafkaConsumer.java
浏览文件 @
bf99fd94
package
com
.
zzsn
.
event
.
kafka
;
import
com.alibaba.fastjson2.JSON
;
import
com.alibaba.fastjson2.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.zzsn.event.constant.Constants
;
import
com.zzsn.event.entity.EventAnalysisReport
;
import
com.zzsn.event.entity.EventContext
;
import
com.zzsn.event.entity.SubjectAnalysis
;
import
com.zzsn.event.service.EventAnalysisReportService
;
import
com.zzsn.event.service.EventContextService
;
import
com.zzsn.event.service.SubjectAnalysisService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -31,10 +25,6 @@ import java.util.List;
@Component
public
class
KafkaConsumer
{
@Autowired
private
SubjectAnalysisService
subjectAnalysisService
;
@Autowired
private
EventAnalysisReportService
eventAnalysisReportService
;
@Autowired
private
EventContextService
eventContextService
;
...
...
@@ -85,91 +75,4 @@ public class KafkaConsumer {
}
}
}
/**
* 获取-事件脉络-分析结果数据,并入库
*
* @param record 接收的kafka数据
*/
@KafkaListener
(
topics
=
{
Constants
.
EVENT_CONTEXT_RECEIVE_TOPIC
})
public
void
eventContext
(
ConsumerRecord
<
String
,
String
>
record
)
{
String
value
=
record
.
value
();
if
(
StringUtils
.
isNotEmpty
(
value
))
{
String
subjectId
;
Integer
category
=
2
;
try
{
List
<
SubjectAnalysis
>
subjectAnalyses
=
JSON
.
parseArray
(
value
,
SubjectAnalysis
.
class
);
subjectId
=
subjectAnalyses
.
get
(
0
).
getSubjectId
();
subjectAnalyses
.
forEach
(
e
->
{
e
.
setCategory
(
category
);
e
.
setTitle
(
removeNonBmpUniCodes
(
e
.
getTitle
()));
});
LambdaQueryWrapper
<
SubjectAnalysis
>
queryWrapper
=
Wrappers
.
lambdaQuery
();
queryWrapper
.
eq
(
SubjectAnalysis:
:
getSubjectId
,
subjectId
).
eq
(
SubjectAnalysis:
:
getCategory
,
category
);
int
count
=
subjectAnalysisService
.
count
(
queryWrapper
);
if
(
count
>
0
)
{
subjectAnalysisService
.
remove
(
queryWrapper
);
}
subjectAnalysisService
.
saveBatch
(
subjectAnalyses
);
log
.
info
(
"id为-{}-的专题,此次-事件脉络-数据更新完成"
,
subjectId
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
/**
* 获取-伪事件脉络-分析结果数据,并入库
*
* @param record 接收的kafka数据
*/
@KafkaListener
(
topics
=
{
Constants
.
FAKE_EVENT_CONTEXT_RECEIVE_TOPIC
})
public
void
eventContext_fake
(
ConsumerRecord
<
String
,
String
>
record
)
{
String
value
=
record
.
value
();
if
(
StringUtils
.
isNotEmpty
(
value
))
{
String
subjectId
;
Integer
category
=
3
;
try
{
List
<
SubjectAnalysis
>
subjectAnalyses
=
JSON
.
parseArray
(
value
,
SubjectAnalysis
.
class
);
subjectId
=
subjectAnalyses
.
get
(
0
).
getSubjectId
();
subjectAnalyses
.
forEach
(
e
->
{
e
.
setCategory
(
category
);
e
.
setTitle
(
removeNonBmpUniCodes
(
e
.
getTitle
()));
});
LambdaQueryWrapper
<
SubjectAnalysis
>
queryWrapper
=
Wrappers
.
lambdaQuery
();
queryWrapper
.
eq
(
SubjectAnalysis:
:
getSubjectId
,
subjectId
).
eq
(
SubjectAnalysis:
:
getCategory
,
category
);
int
count
=
subjectAnalysisService
.
count
(
queryWrapper
);
if
(
count
>
0
)
{
subjectAnalysisService
.
remove
(
queryWrapper
);
}
subjectAnalysisService
.
saveBatch
(
subjectAnalyses
);
log
.
info
(
"id为-{}-的专题,此次-伪事件脉络-数据更新完成"
,
subjectId
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
/**
* 获取事件的分析报告数据
*
* @param record 接收的kafka数据
* @author lkg
* @date 2024/4/12
*/
@KafkaListener
(
topics
=
{
Constants
.
EVENT_REPORT_RECEIVE_TOPIC
})
public
void
eventReport
(
ConsumerRecord
<
String
,
String
>
record
)
{
String
value
=
record
.
value
();
EventAnalysisReport
eventAnalysisReport
=
JSONObject
.
parseObject
(
value
,
EventAnalysisReport
.
class
);
eventAnalysisReportService
.
modify
(
eventAnalysisReport
.
getEventId
(),
eventAnalysisReport
.
getFilePath
());
log
.
info
(
"id为-{}-的事件,分析报告更新完成"
,
eventAnalysisReport
.
getEventId
());
}
//去除特殊的字符,例如表情符
private
String
removeNonBmpUniCodes
(
String
str
)
{
return
StringUtils
.
isEmpty
(
str
)
?
null
:
str
.
replaceAll
(
"[^\\u0000-\\uFFFF]"
,
""
);
}
}
src/main/java/com/zzsn/event/mapper/KeywordConfMapper.java
0 → 100644
浏览文件 @
bf99fd94
package
com
.
zzsn
.
event
.
mapper
;
import
com.zzsn.event.entity.KeywordConf
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* @author lenovo
* @description 针对表【clb_keyword_conf(关键词过滤配置)】的数据库操作Mapper
* @createDate 2025-07-28 10:25:56
* @Entity com.zzsn.event.entity.KeywordConf
*/
@Mapper
public
interface
KeywordConfMapper
extends
BaseMapper
<
KeywordConf
>
{
}
src/main/java/com/zzsn/event/service/EventAnalysisVersionRecordService.java
浏览文件 @
bf99fd94
...
...
@@ -10,4 +10,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public
interface
EventAnalysisVersionRecordService
extends
IService
<
EventAnalysisVersionRecord
>
{
String
getVersionData
(
String
versionId
,
Integer
columnCode
);
}
src/main/java/com/zzsn/event/service/EventAnalysisVersionService.java
浏览文件 @
bf99fd94
...
...
@@ -10,4 +10,12 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public
interface
EventAnalysisVersionService
extends
IService
<
EventAnalysisVersion
>
{
/**
* 获取事件分析的最新版本
*
* @param eventId 事件id
* @author lkg
* @date 2025/7/28
*/
EventAnalysisVersion
latestVersion
(
String
eventId
);
}
src/main/java/com/zzsn/event/service/EventLlmConfigService.java
浏览文件 @
bf99fd94
...
...
@@ -15,4 +15,6 @@ public interface EventLlmConfigService extends IService<EventLlmConfig> {
List
<
EventLlmConfig
>
getConfigList
(
String
eventId
);
EventLlmConfig
getConfig
(
String
eventId
,
Integer
columnCode
);
void
modify
(
List
<
EventLlmConfig
>
eventLlmConfigList
);
}
src/main/java/com/zzsn/event/service/impl/AnalysisServiceImpl.java
浏览文件 @
bf99fd94
...
...
@@ -294,14 +294,42 @@ public class AnalysisServiceImpl implements AnalysisService {
@Override
public
String
llmResult
(
String
eventName
,
String
startTime
,
String
endTime
,
EventLlmConfig
llmConfig
)
{
return
llmService
.
model
(
llmConfig
.
getLlmName
(),
llmConfig
.
getLlmPrompt
(),
eventName
);
String
result
=
llmService
.
model
(
llmConfig
.
getLlmName
(),
llmConfig
.
getLlmPrompt
(),
eventName
);
if
(
llmConfig
.
getColumnCode
().
equals
(
AnalysisColumnEnum
.
IMPACT_ASSESSMENT
.
getCode
()))
{
String
prompt
=
"根据提供的事件名称,以及其%s的概述,详细的描述下该事件的%s"
;
List
<
JSONObject
>
impactList
=
JSON
.
parseArray
(
result
,
JSONObject
.
class
);
for
(
JSONObject
impact
:
impactList
)
{
String
theme
=
impact
.
getString
(
"theme"
);
JSONObject
params
=
new
JSONObject
();
params
.
put
(
"eventName"
,
eventName
);
params
.
put
(
"impactOutline"
,
impact
);
String
impactDetail
=
llmService
.
model
(
llmConfig
.
getLlmName
(),
String
.
format
(
prompt
,
theme
,
theme
),
params
.
toJSONString
());
impact
.
put
(
"impactDetail"
,
impactDetail
);
}
result
=
JSON
.
toJSONString
(
impactList
);
}
return
result
;
}
@Override
public
String
llmResult
(
String
eventId
,
String
startTime
,
String
endTime
,
Integer
columnCode
)
{
Event
event
=
eventService
.
getById
(
eventId
);
EventLlmConfig
llmConfig
=
eventLlmConfigService
.
getConfig
(
eventId
,
columnCode
);
return
llmService
.
model
(
llmConfig
.
getLlmName
(),
llmConfig
.
getLlmPrompt
(),
event
.
getEventName
());
EventLlmConfig
llmConfig
=
eventLlmConfigService
.
getConfig
(
eventId
,
columnCode
);
String
result
=
llmService
.
model
(
llmConfig
.
getLlmName
(),
llmConfig
.
getLlmPrompt
(),
event
.
getEventName
());
if
(
columnCode
.
equals
(
AnalysisColumnEnum
.
IMPACT_ASSESSMENT
.
getCode
()))
{
String
prompt
=
"根据提供的事件名称,以及其%s的概述,详细的描述下该事件的%s"
;
List
<
JSONObject
>
impactList
=
JSON
.
parseArray
(
result
,
JSONObject
.
class
);
for
(
JSONObject
impact
:
impactList
)
{
String
theme
=
impact
.
getString
(
"theme"
);
JSONObject
params
=
new
JSONObject
();
params
.
put
(
"eventName"
,
event
.
getEventName
());
params
.
put
(
"impactOutline"
,
impact
);
String
impactDetail
=
llmService
.
model
(
llmConfig
.
getLlmName
(),
String
.
format
(
prompt
,
theme
,
theme
),
params
.
toJSONString
());
impact
.
put
(
"impactDetail"
,
impactDetail
);
}
result
=
JSON
.
toJSONString
(
impactList
);
}
return
result
;
}
@Override
...
...
@@ -333,33 +361,33 @@ public class AnalysisServiceImpl implements AnalysisService {
if
(
CollectionUtils
.
isNotEmpty
(
eventContext
))
{
EventAnalysisVersionRecord
record
=
EventAnalysisVersionRecord
.
of
(
versionId
,
AnalysisColumnEnum
.
EVENT_CONTEXT
,
JSON
.
toJSONString
(
eventContext
));
records
.
add
(
record
);
log
.
info
(
"{}-事件分析【{}】重新生成逻辑完成。"
,
eventName
,
"事件脉络"
);
log
.
info
(
"{}-事件分析【{}】重新生成逻辑完成。"
,
eventName
,
"事件脉络"
);
}
//关键词趋势分析
List
<
CountVO
>
wordTrend
=
this
.
wordTrend
(
eventId
,
null
,
null
);
if
(
CollectionUtils
.
isNotEmpty
(
wordTrend
))
{
EventAnalysisVersionRecord
record
=
EventAnalysisVersionRecord
.
of
(
versionId
,
AnalysisColumnEnum
.
KEYWORD_TREND
,
JSON
.
toJSONString
(
wordTrend
));
records
.
add
(
record
);
log
.
info
(
"{}-事件分析【{}】重新生成逻辑完成。"
,
eventName
,
"关键词趋势分析"
);
log
.
info
(
"{}-事件分析【{}】重新生成逻辑完成。"
,
eventName
,
"关键词趋势分析"
);
}
//关键词共现关系
/*
List<CoOccurrenceVO> coOccurrenceVOS = this.coOccurrence(eventId, null, null);
List
<
CoOccurrenceVO
>
coOccurrenceVOS
=
this
.
coOccurrence
(
eventId
,
null
,
null
);
if
(
CollectionUtils
.
isNotEmpty
(
coOccurrenceVOS
))
{
EventAnalysisVersionRecord
record
=
EventAnalysisVersionRecord
.
of
(
versionId
,
AnalysisColumnEnum
.
CO_OCCURRENCE
,
JSON
.
toJSONString
(
coOccurrenceVOS
));
records
.
add
(
record
);
log
.
info
(
"{}-事件分析【{}】重新生成逻辑完成。"
,
eventName
,
"关键词共现关系"
);
}
*/
}
//大模型相关逻辑生成的结果(影响评估,举措建议等)
List
<
EventLlmConfig
>
collect
=
configList
.
stream
().
filter
(
e
->
!
e
.
getColumnCode
().
equals
(
AnalysisColumnEnum
.
CORE_SUMMARY
.
getCode
())).
collect
(
Collectors
.
toList
());
for
(
EventLlmConfig
config
:
collect
)
{
String
llmResult
=
this
.
llmResult
(
eventName
,
null
,
null
,
config
);
EventAnalysisVersionRecord
record
=
EventAnalysisVersionRecord
.
of
(
versionId
,
Objects
.
requireNonNull
(
AnalysisColumnEnum
.
getByCode
(
config
.
getColumnCode
())),
llmResult
);
records
.
add
(
record
);
log
.
info
(
"{}-事件分析【{}】重新生成逻辑完成。"
,
eventName
,
config
.
getColumnName
());
log
.
info
(
"{}-事件分析【{}】重新生成逻辑完成。"
,
eventName
,
config
.
getColumnName
());
}
//保存版本记录信息
eventAnalysisVersionRecordService
.
saveBatch
(
records
);
log
.
info
(
"{}-事件分析重新生成逻辑完成。"
,
eventName
);
log
.
info
(
"{}-事件分析重新生成逻辑完成。"
,
eventName
);
}
@Override
...
...
src/main/java/com/zzsn/event/service/impl/EventAnalysisVersionRecordServiceImpl.java
浏览文件 @
bf99fd94
package
com
.
zzsn
.
event
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.zzsn.event.entity.EventAnalysisVersionRecord
;
import
com.zzsn.event.service.EventAnalysisVersionRecordService
;
...
...
@@ -15,6 +17,18 @@ import org.springframework.stereotype.Service;
public
class
EventAnalysisVersionRecordServiceImpl
extends
ServiceImpl
<
EventAnalysisVersionRecordMapper
,
EventAnalysisVersionRecord
>
implements
EventAnalysisVersionRecordService
{
@Override
public
String
getVersionData
(
String
versionId
,
Integer
columnCode
)
{
String
result
=
null
;
LambdaQueryWrapper
<
EventAnalysisVersionRecord
>
queryWrapper
=
Wrappers
.
lambdaQuery
();
queryWrapper
.
eq
(
EventAnalysisVersionRecord:
:
getVersionId
,
versionId
)
.
eq
(
EventAnalysisVersionRecord:
:
getColumnCode
,
columnCode
);
EventAnalysisVersionRecord
eventAnalysisVersionRecord
=
this
.
getOne
(
queryWrapper
);
if
(
eventAnalysisVersionRecord
!=
null
)
{
result
=
eventAnalysisVersionRecord
.
getReturnData
();
}
return
result
;
}
}
...
...
src/main/java/com/zzsn/event/service/impl/EventAnalysisVersionServiceImpl.java
浏览文件 @
bf99fd94
package
com
.
zzsn
.
event
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.zzsn.event.entity.EventAnalysisVersion
;
import
com.zzsn.event.service.EventAnalysisVersionService
;
...
...
@@ -7,14 +9,22 @@ import com.zzsn.event.mapper.EventAnalysisVersionMapper;
import
org.springframework.stereotype.Service
;
/**
* @author lenovo
* @description 针对表【event_analysis_version(事件分析版本表)】的数据库操作Service实现
* @createDate 2025-07-16 16:34:46
*/
* @author lenovo
* @description 针对表【event_analysis_version(事件分析版本表)】的数据库操作Service实现
* @createDate 2025-07-16 16:34:46
*/
@Service
public
class
EventAnalysisVersionServiceImpl
extends
ServiceImpl
<
EventAnalysisVersionMapper
,
EventAnalysisVersion
>
implements
EventAnalysisVersionService
{
implements
EventAnalysisVersionService
{
@Override
public
EventAnalysisVersion
latestVersion
(
String
eventId
)
{
LambdaQueryWrapper
<
EventAnalysisVersion
>
queryWrapper
=
Wrappers
.
lambdaQuery
();
queryWrapper
.
eq
(
EventAnalysisVersion:
:
getEventId
,
eventId
)
.
orderByDesc
(
EventAnalysisVersion:
:
getCreateTime
)
.
last
(
"limit 1"
);
return
this
.
getOne
(
queryWrapper
);
}
}
...
...
src/main/java/com/zzsn/event/service/impl/EventLlmConfigServiceImpl.java
浏览文件 @
bf99fd94
package
com
.
zzsn
.
event
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.ObjectUtils
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
...
...
@@ -9,8 +10,10 @@ import com.zzsn.event.service.EventLlmConfigService;
import
com.zzsn.event.mapper.EventLlmConfigMapper
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @author lenovo
...
...
@@ -45,6 +48,40 @@ public class EventLlmConfigServiceImpl extends ServiceImpl<EventLlmConfigMapper,
}
return
config
;
}
@Override
@Transactional
public
void
modify
(
List
<
EventLlmConfig
>
eventLlmConfigList
)
{
if
(
CollectionUtils
.
isEmpty
(
eventLlmConfigList
))
{
return
;
}
String
eventId
=
eventLlmConfigList
.
get
(
0
).
getEventId
();
LambdaQueryWrapper
<
EventLlmConfig
>
queryWrapper
=
Wrappers
.
lambdaQuery
();
queryWrapper
.
eq
(
EventLlmConfig:
:
getEventId
,
eventId
);
List
<
EventLlmConfig
>
configList
=
this
.
list
(
queryWrapper
);
if
(
CollectionUtils
.
isEmpty
(
configList
))
{
List
<
Integer
>
configCodeList
=
eventLlmConfigList
.
stream
().
map
(
EventLlmConfig:
:
getColumnCode
).
collect
(
Collectors
.
toList
());
LambdaQueryWrapper
<
EventLlmConfig
>
query
=
Wrappers
.
lambdaQuery
();
query
.
eq
(
EventLlmConfig:
:
getYnDefault
,
1
).
orderByAsc
(
EventLlmConfig:
:
getColumnCode
);
List
<
EventLlmConfig
>
defaultConfigList
=
this
.
list
(
query
);
if
(
defaultConfigList
.
size
()
>
eventLlmConfigList
.
size
())
{
List
<
EventLlmConfig
>
collect
=
defaultConfigList
.
stream
().
filter
(
config
->
!
configCodeList
.
contains
(
config
.
getColumnCode
())).
collect
(
Collectors
.
toList
());
for
(
EventLlmConfig
config
:
collect
)
{
config
.
setId
(
null
);
config
.
setEventId
(
eventId
);
config
.
setYnDefault
(
0
);
}
eventLlmConfigList
.
addAll
(
collect
);
}
this
.
saveBatch
(
eventLlmConfigList
);
}
else
{
for
(
EventLlmConfig
eventLlmConfig
:
eventLlmConfigList
)
{
LambdaUpdateWrapper
<
EventLlmConfig
>
update
=
Wrappers
.
lambdaUpdate
();
update
.
eq
(
EventLlmConfig:
:
getEventId
,
eventId
).
eq
(
EventLlmConfig:
:
getColumnCode
,
eventLlmConfig
.
getColumnCode
());
this
.
update
(
eventLlmConfig
,
update
);
}
}
}
}
...
...
src/main/java/com/zzsn/event/service/impl/EventServiceImpl.java
浏览文件 @
bf99fd94
...
...
@@ -2,6 +2,7 @@ package com.zzsn.event.service.impl;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
...
...
@@ -102,8 +103,6 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
@Autowired
private
EventAnalysisReportService
eventAnalysisReportService
;
@Autowired
private
IXxlJobInfoService
iXxlJobInfoService
;
@Autowired
private
CommonService
commonService
;
@Resource
private
RestHighLevelClient
client
;
...
...
@@ -121,6 +120,10 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
private
IClbModelArrangeService
clbModelArrangeService
;
@Autowired
private
ClbModelArrangeSubjectMapService
clbModelArrangeSubjectMapService
;
@Autowired
private
EventCollectMapService
eventCollMapService
;
@Autowired
private
AnalysisService
analysisService
;
@Value
(
"${kafka.topic.event.run:}"
)
private
String
EVENT_MODEL_KAFKA_CHANNEL
;
...
...
@@ -141,6 +144,11 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
@Override
public
EventVO
queryInfo
(
String
eventId
)
{
EventVO
eventVO
=
baseMapper
.
queryInfo
(
eventId
);
UserVo
loginUser
=
UserUtil
.
getLoginUser
();
LambdaQueryWrapper
<
EventCollectMap
>
queryWrapper
=
Wrappers
.
lambdaQuery
();
queryWrapper
.
eq
(
EventCollectMap:
:
getEventId
,
eventId
).
eq
(
EventCollectMap:
:
getUserId
,
loginUser
.
getId
());
int
count
=
eventCollMapService
.
count
(
queryWrapper
);
eventVO
.
setYnAttention
(
count
>
0
);
String
relationEvents
=
eventVO
.
getRelationEvents
();
if
(
null
!=
relationEvents
)
{
List
<
String
>
split
=
Arrays
.
asList
(
relationEvents
.
split
(
","
));
...
...
@@ -153,7 +161,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
eventVO
.
setEventTag
(
one
);
List
<
RegionVO
>
regionList
=
eventRegionMapService
.
regionList
(
eventId
);
eventVO
.
setRegionList
(
regionList
);
//
KeywordsVO keywordsVO = keyWordsService.keywordInfoByEventId(eventId);
//
KeywordsVO keywordsVO = keyWordsService.keywordInfoByEventId(eventId);
KeywordsVO
keywordsVO
=
new
KeywordsVO
();
List
<
KeywordsVO
>
keywordsVOS
=
keyWordsService
.
keywordInfoByEventIdList
(
eventId
);
keywordsVOS
.
stream
().
filter
(
f
->
StrUtil
.
equals
(
f
.
getBindingType
(),
"1"
)).
findFirst
().
ifPresent
(
f
->
keywordsVO
.
setKeyword
(
f
.
getKeyword
()));
...
...
@@ -374,10 +382,11 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
Event
event
=
new
Event
();
BeanUtils
.
copyProperties
(
addEventParam
,
event
);
event
.
setStatus
(
1
);
event
.
setFirstOpenTime
(
new
Date
());
Date
now
=
new
Date
();
event
.
setFirstOpenTime
(
now
);
Date
endTime
=
event
.
getEndTime
();
if
(
endTime
==
null
)
{
endTime
=
DateUtil
.
addDate
(
new
Date
(),
15
);
endTime
=
cn
.
hutool
.
core
.
date
.
DateUtil
.
offsetWeek
(
now
,
3
);
}
event
.
setEndTime
(
endTime
);
//事件专题的默认分析规则参数-必填
...
...
@@ -388,14 +397,13 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
event
.
setEventCode
(
subjectCode
);
//默认发布
event
.
setPublishStatus
(
1
);
event
.
setPublishDate
(
DateUtil
.
dateToString
(
n
ew
Date
()
));
event
.
setPublishDate
(
DateUtil
.
dateToString
(
n
ow
));
event
.
setUnit
(
"2"
);
event
.
setSpace
(
1
);
String
cron
=
CronUtil
.
generateCron
(
"2"
,
1
);
event
.
setCron
(
cron
);
baseMapper
.
insert
(
event
);
String
eventId
=
event
.
getId
();
CompletableFuture
.
runAsync
(()
->
{
try
{
log
.
info
(
"开始补充redis日期缓存-{}"
,
event
.
getEventCode
());
...
...
@@ -419,6 +427,10 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
throw
new
RuntimeException
(
e
);
}
});
CompletableFuture
.
runAsync
(()
->
{
//立马执行一次事件分析
analysisService
.
regenerate
(
eventId
);
});
return
event
;
}
...
...
src/main/java/com/zzsn/event/task/AnalysisTask.java
浏览文件 @
bf99fd94
package
com
.
zzsn
.
event
.
task
;
import
com.alibaba.fastjson2.JSON
;
import
com.alibaba.fastjson2.JSONWriter
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.CollectionUtils
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.zzsn.event.constant.Constants
;
import
com.zzsn.event.entity.
SubjectAnalysis
;
import
com.zzsn.event.entity.
Event
;
import
com.zzsn.event.es.EsService
;
import
com.zzsn.event.service.AnalysisService
;
import
com.zzsn.event.service.IEventService
;
import
com.zzsn.event.service.SubjectAnalysisService
;
import
com.zzsn.event.util.DateUtil
;
import
com.zzsn.event.util.RedisUtil
;
import
com.zzsn.event.util.SimilarityUtil
;
import
com.zzsn.event.vo.*
;
import
com.zzsn.event.vo.es.SpecialInformation
;
import
com.zzsn.event.vo.PropagationPathVo
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.ListUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.
springframework.beans.Bean
Utils
;
import
org.
apache.commons.lang3.String
Utils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.kafka.core.KafkaTemplate
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
java
x.annotation.Resourc
e
;
import
java.util.
*
;
import
java
.util.Dat
e
;
import
java.util.
List
;
import
java.util.concurrent.CompletableFuture
;
/**
...
...
@@ -43,14 +35,10 @@ public class AnalysisTask {
private
IEventService
eventService
;
@Autowired
private
EsService
esService
;
@Resource
private
KafkaTemplate
<
String
,
String
>
kafkaTemplate
;
@Autowired
private
RedisUtil
redisUtil
;
@Autowired
private
AnalysisService
analysisService
;
@Autowired
private
SubjectAnalysisService
subjectAnalysisService
;
@Value
(
"${scheduling.yjzxEnable:false}"
)
Boolean
yjzxEnable
;
...
...
@@ -63,221 +51,58 @@ public class AnalysisTask {
* @author lkg
* @date 2025/7/9
*/
//@Scheduled(cron = "0 0 0/3 * * ?")
public
void
eventContext
()
{
Date
today
=
new
Date
();
Date
disableDate
=
DateUtil
.
addDate
(
today
,
-
1
);
List
<
SubjectKafkaVo
>
subjectList
=
eventService
.
progressList
(
disableDate
);
InfoDataSearchCondition
searchCondition
=
new
InfoDataSearchCondition
();
searchCondition
.
setCategory
(
2
);
String
startTime
=
DateUtil
.
format
(
today
,
"yyyy-MM-dd 00:00:00"
);
searchCondition
.
setStartTime
(
startTime
);
String
endTime
=
DateUtil
.
format
(
today
,
"yyyy-MM-dd 23:59:59"
);
searchCondition
.
setEndTime
(
endTime
);
String
[]
fetchFields
=
new
String
[]{
"id"
,
"title"
,
"origin"
,
"publishDate"
,
"sourceAddress"
};
searchCondition
.
setFetchFields
(
fetchFields
);
for
(
SubjectKafkaVo
subjectKafkaVo
:
subjectList
)
{
String
eventId
=
subjectKafkaVo
.
getId
();
searchCondition
.
setSubjectId
(
eventId
);
int
pageNo
=
1
;
int
size
=
100
;
searchCondition
.
setPageSize
(
size
);
boolean
flag
=
true
;
List
<
EventContextVO
>
dataList
=
new
ArrayList
<>();
do
{
searchCondition
.
setPageNo
(
pageNo
);
List
<
SpecialInformation
>
informationList
=
esService
.
informationList
(
searchCondition
);
if
(
CollectionUtils
.
isNotEmpty
(
informationList
))
{
informationList
.
forEach
(
e
->
{
double
similarity
=
SimilarityUtil
.
levenshteinSimilarity
(
subjectKafkaVo
.
getSubjectName
(),
e
.
getTitle
());
if
(
similarity
>
0
)
{
EventContextVO
eventContextVO
=
new
EventContextVO
();
BeanUtils
.
copyProperties
(
e
,
eventContextVO
);
eventContextVO
.
setDistance
(
similarity
);
dataList
.
add
(
eventContextVO
);
}
});
if
(
informationList
.
size
()
<
size
)
{
flag
=
false
;
}
else
{
pageNo
++;
//@Scheduled(cron = "0 30 0 * * ?")
public
void
analysis
()
{
Date
now
=
new
Date
();
LambdaQueryWrapper
<
Event
>
queryWrapper
=
Wrappers
.
lambdaQuery
();
queryWrapper
.
eq
(
Event:
:
getStatus
,
1
).
gt
(
Event:
:
getCreateTime
,
"2025-07-27"
);
List
<
Event
>
eventList
=
eventService
.
list
(
queryWrapper
);
for
(
Event
event
:
eventList
)
{
CompletableFuture
.
runAsync
(()
->
{
String
eventId
=
event
.
getId
();
String
estimateStatus
=
event
.
getEstimateStatus
();
if
(
StringUtils
.
isNotBlank
(
estimateStatus
)
&&
!
estimateStatus
.
equals
(
"已完成"
))
{
if
(
DateUtil
.
stringToDate
(
estimateStatus
,
"yyyy-MM-dd HH:mm:ss"
).
compareTo
(
now
)
>
0
)
{
analysisService
.
regenerate
(
eventId
);
}
}
else
{
flag
=
false
;
}
}
while
(
flag
);
if
(
CollectionUtils
.
isEmpty
(
dataList
))
{
continue
;
}
List
<
EventContextVO
>
list
=
supplyMain
(
dataList
);
LambdaQueryWrapper
<
SubjectAnalysis
>
queryWrapper
=
Wrappers
.
lambdaQuery
();
queryWrapper
.
eq
(
SubjectAnalysis:
:
getSubjectId
,
eventId
)
.
eq
(
SubjectAnalysis:
:
getCategory
,
4
)
.
between
(
SubjectAnalysis:
:
getPublishDate
,
startTime
,
endTime
);
int
count
=
subjectAnalysisService
.
count
(
queryWrapper
);
if
(
count
>
0
)
{
subjectAnalysisService
.
remove
(
queryWrapper
);
}
List
<
SubjectAnalysis
>
analysisList
=
new
ArrayList
<>();
for
(
EventContextVO
eventContextVO
:
list
)
{
SubjectAnalysis
subjectAnalysis
=
new
SubjectAnalysis
();
subjectAnalysis
.
setSubjectId
(
eventId
);
subjectAnalysis
.
setDataId
(
eventContextVO
.
getId
());
subjectAnalysis
.
setTitle
(
eventContextVO
.
getTitle
());
subjectAnalysis
.
setOrigin
(
eventContextVO
.
getOrigin
());
subjectAnalysis
.
setPublishDate
(
DateUtil
.
stringToDate
(
eventContextVO
.
getPublishDate
(),
"yyyy-MM-dd HH:mm:ss"
));
subjectAnalysis
.
setSourceAddress
(
eventContextVO
.
getSourceAddress
());
subjectAnalysis
.
setIsMain
(
eventContextVO
.
getIsMain
()
?
1
:
0
);
subjectAnalysis
.
setCategory
(
4
);
subjectAnalysis
.
setAnalysisDate
(
new
Date
());
analysisList
.
add
(
subjectAnalysis
);
}
subjectAnalysisService
.
saveBatch
(
analysisList
);
}
}
//补充是否主要资讯标识以及排序后截取
private
List
<
EventContextVO
>
supplyMain
(
List
<
EventContextVO
>
list
)
{
EventContextVO
dataVo
=
null
;
double
minDistance
=
Double
.
MAX_VALUE
;
for
(
EventContextVO
eventContextVO
:
list
)
{
Double
similarity
=
eventContextVO
.
getDistance
();
if
(
similarity
==
0
)
{
continue
;
}
if
(
similarity
==
1.0
)
{
dataVo
=
eventContextVO
;
break
;
}
else
if
(
similarity
<
minDistance
)
{
minDistance
=
similarity
;
dataVo
=
eventContextVO
;
}
}
if
(
dataVo
==
null
)
{
list
.
get
(
0
).
setIsMain
(
true
);
}
else
{
for
(
EventContextVO
eventContextVO
:
list
)
{
if
(
eventContextVO
.
getId
().
equals
(
dataVo
.
getId
()))
{
eventContextVO
.
setIsMain
(
true
);
break
;
}
}
}
//先按是否是主事件排序,再按相似度算法(编辑距离)返回值正序排序,最后按时间倒序排序
list
.
sort
(
Comparator
.
comparing
(
EventContextVO:
:
getIsMain
,
Comparator
.
reverseOrder
())
.
thenComparing
((
o1
,
o2
)
->
{
Double
distance1
=
o1
.
getDistance
();
Double
distance2
=
o2
.
getDistance
();
if
(
distance1
==
0
&&
distance2
==
0
)
{
return
0
;
}
if
(
distance1
==
0
)
{
return
1
;
}
if
(
distance2
==
0
)
{
return
-
1
;
}
return
distance1
.
compareTo
(
distance2
);
})
.
thenComparing
(
EventContextVO:
:
getPublishDate
,
Comparator
.
reverseOrder
()));
if
(
list
.
size
()
>
3
)
{
list
=
list
.
subList
(
0
,
3
);
}
return
list
;
}
/**
* 每天凌晨0点20分执行一次
* 发送 伪事件脉络 所需信息到kafka对应的topic
*/
@Scheduled
(
cron
=
"0 20 0 * * ?"
)
public
void
eventContext_fake
()
{
if
(
yjzxEnable
)
{
//研究中心不需要此任务
return
;
}
Date
today
=
new
Date
();
Date
disableDate
=
DateUtil
.
addDate
(
today
,
-
1
);
List
<
SubjectKafkaVo
>
fakeEventIdList
=
new
ArrayList
<>();
List
<
SubjectKafkaVo
>
subjectList
=
eventService
.
progressList
(
disableDate
);
subjectList
.
forEach
(
e
->
{
LambdaQueryWrapper
<
SubjectAnalysis
>
queryWrapper
=
Wrappers
.
lambdaQuery
();
queryWrapper
.
eq
(
SubjectAnalysis:
:
getSubjectId
,
e
.
getId
()).
eq
(
SubjectAnalysis:
:
getCategory
,
2
);
int
count
=
subjectAnalysisService
.
count
(
queryWrapper
);
if
(
count
<
Constants
.
FAKE_NUM
)
{
fakeEventIdList
.
add
(
e
);
}
});
for
(
SubjectKafkaVo
subjectKafkaVo
:
fakeEventIdList
)
{
List
<
KafkaDataVo
>
kafkaDataVoList
=
new
ArrayList
<>();
String
subjectId
=
subjectKafkaVo
.
getId
();
String
keyWord
=
subjectKafkaVo
.
getKeyWord
();
List
<
SubjectDataVo
>
dataList
=
esService
.
getDataBySubjectId
(
subjectId
,
null
,
null
,
Constants
.
FETCH_FIELDS_DATA
);
format
(
subjectId
,
kafkaDataVoList
,
dataList
);
splitSend
(
Constants
.
FAKE_EVENT_CONTEXT_SEND_TOPIC
,
subjectId
,
kafkaDataVoList
,
keyWord
);
});
}
}
private
void
format
(
String
subjectId
,
List
<
KafkaDataVo
>
kafkaDataVoList
,
List
<
SubjectDataVo
>
dataList
)
{
dataList
.
forEach
(
e
->
{
String
dataId
=
e
.
getId
();
KafkaDataVo
kafkaDataVo
=
new
KafkaDataVo
();
BeanUtils
.
copyProperties
(
e
,
kafkaDataVo
);
List
<
String
>
idList
=
new
ArrayList
<>();
idList
.
add
(
dataId
);
Map
<
String
,
Integer
>
similarNumber
=
esService
.
getSimilarNumber
(
subjectId
,
idList
);
Integer
count
=
similarNumber
.
get
(
dataId
);
if
(
count
==
null
)
{
count
=
0
;
}
kafkaDataVo
.
setRepeatNum
(
count
);
kafkaDataVoList
.
add
(
kafkaDataVo
);
});
}
//防止数据量太大,超过kafka的最大值,所以分批发送,一次20条数据
private
void
splitSend
(
String
topic
,
String
subjectId
,
List
<
KafkaDataVo
>
list
,
String
keyWord
)
{
List
<
List
<
KafkaDataVo
>>
partition
=
ListUtils
.
partition
(
list
,
20
);
partition
.
forEach
(
e
->
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"keyword"
,
keyWord
);
map
.
put
(
"data"
,
e
);
kafkaTemplate
.
send
(
topic
,
subjectId
,
JSON
.
toJSONString
(
map
,
JSONWriter
.
Feature
.
WriteMapNullValue
));
});
}
/**
* 定时生成传播路径
* 每天凌晨0点10分执行一次
*/
@Scheduled
(
cron
=
"0 0
1
* * ?"
)
@Scheduled
(
cron
=
"0 0
0
* * ?"
)
public
void
propagationPath
()
{
Date
today
=
new
Date
();
Date
deadlineDate
=
DateUtil
.
addDate
(
today
,
-
1
);
List
<
SubjectKafkaVo
>
subjects
=
eventService
.
eventSubjectList
();
for
(
SubjectKafkaVo
subject
:
subjects
)
{
LambdaQueryWrapper
<
Event
>
queryWrapper
=
Wrappers
.
lambdaQuery
();
queryWrapper
.
eq
(
Event:
:
getStatus
,
1
);
List
<
Event
>
eventList
=
eventService
.
list
(
queryWrapper
);
for
(
Event
event
:
eventList
)
{
CompletableFuture
.
runAsync
(()
->
{
String
subjectId
=
subjec
t
.
getId
();
int
count
=
esService
.
count
(
subjec
tId
,
null
,
null
);
String
eventId
=
even
t
.
getId
();
int
count
=
esService
.
count
(
even
tId
,
null
,
null
);
if
(
count
>
0
)
{
String
key
=
Constants
.
SUBJECT_ANALYSIS_PRE
+
Constants
.
PROPAGATION_KEY
+
subjec
tId
;
Date
timeDisable
=
subject
.
getTimeDisabl
e
();
String
key
=
Constants
.
SUBJECT_ANALYSIS_PRE
+
Constants
.
PROPAGATION_KEY
+
even
tId
;
Date
timeDisable
=
event
.
getEndTim
e
();
//已经结束的事件专题,永久缓存
if
(
timeDisable
!=
null
&&
deadlineDate
.
compareTo
(
timeDisable
)
>
0
)
{
Object
cacheObject
=
redisUtil
.
get
(
key
);
if
(
cacheObject
==
null
)
{
PropagationPathVo
pathVo
=
analysisService
.
propagationPath
(
subjec
tId
);
PropagationPathVo
pathVo
=
analysisService
.
propagationPath
(
even
tId
);
if
(
ObjectUtils
.
isNotEmpty
(
pathVo
))
{
redisUtil
.
set
(
key
,
pathVo
);
log
.
info
(
"
专题-{},传播路径数据【永久】缓存成功!"
,
subject
.
getSubjec
tName
());
log
.
info
(
"
事件-{},传播路径数据【永久】缓存成功!"
,
event
.
getEven
tName
());
}
}
}
else
{
//已经结束的事件专题,缓存有效期一天
PropagationPathVo
pathVo
=
analysisService
.
propagationPath
(
subjec
tId
);
PropagationPathVo
pathVo
=
analysisService
.
propagationPath
(
even
tId
);
if
(
ObjectUtils
.
isNotEmpty
(
pathVo
))
{
redisUtil
.
set
(
key
,
pathVo
,
3600
*
24
);
log
.
info
(
"
专题-{},传播路径数据缓存成功!"
,
subject
.
getSubjec
tName
());
log
.
info
(
"
事件-{},传播路径数据缓存成功!"
,
event
.
getEven
tName
());
}
}
}
...
...
src/main/java/com/zzsn/event/vo/EventVO.java
浏览文件 @
bf99fd94
...
...
@@ -79,4 +79,7 @@ public class EventVO {
/**关键词*/
private
KeywordsVO
keywordsVO
;
private
String
dataScope
;
/**是否关注*/
private
Boolean
ynAttention
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论