Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
E
event
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
陈世强
event
Commits
25b0bb27
提交
25b0bb27
authored
8月 08, 2025
作者:
925993793@qq.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
模型逻辑优化、增加驱动因素和相关指标接口
上级
3880a65a
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
216 行增加
和
88 行删除
+216
-88
LlmProperties.java
.../java/com/zzsn/event/config/properties/LlmProperties.java
+53
-0
EventAnalysisController.java
...va/com/zzsn/event/controller/EventAnalysisController.java
+50
-0
EventManageController.java
...java/com/zzsn/event/controller/EventManageController.java
+3
-1
LLmConfigController.java
...com/zzsn/event/controller/common/LLmConfigController.java
+8
-5
AnalysisColumnEnum.java
src/main/java/com/zzsn/event/enums/AnalysisColumnEnum.java
+6
-1
LlmServiceImpl.java
src/main/java/com/zzsn/event/llm/LlmServiceImpl.java
+59
-57
AnalysisService.java
src/main/java/com/zzsn/event/service/AnalysisService.java
+2
-2
AnalysisServiceImpl.java
...java/com/zzsn/event/service/impl/AnalysisServiceImpl.java
+12
-8
application-test.yml
src/main/resources/application-test.yml
+23
-14
没有找到文件。
src/main/java/com/zzsn/event/config/properties/LlmProperties.java
0 → 100644
浏览文件 @
25b0bb27
package
com
.
zzsn
.
event
.
config
.
properties
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
import
java.util.Map
;
/**
* 大模型配置参数
* @author wangFeng
* @date 2025/1/9 17:57
*/
@Data
@Component
@ConfigurationProperties
(
prefix
=
"model"
)
public
class
LlmProperties
{
private
String
defaultModelType
;
private
List
<
ModelConfig
>
configs
;
@Data
public
static
class
ModelConfig
{
//模型类型
private
String
modelType
;
//模型类型中文名称
private
String
modelTypeName
;
//模型url
private
String
url
;
//模型apiKey
private
String
apiKey
;
//默认模型
private
String
defaultModel
;
//是否开启网络搜索
private
Boolean
webSearch
;
}
/**
* 根据模型类型获取模型配置
*
* @param modelType 模型类型
* @author lkg
* @date 2025/8/6
*/
public
ModelConfig
getModelConfig
(
String
modelType
){
for
(
ModelConfig
config
:
configs
)
{
if
(
config
.
getModelType
().
equals
(
modelType
)){
return
config
;
}
}
return
null
;
}
}
src/main/java/com/zzsn/event/controller/EventAnalysisController.java
浏览文件 @
25b0bb27
...
...
@@ -454,6 +454,56 @@ public class EventAnalysisController {
}
/**
* 驱动因素
*
* @param eventId 事件id
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2024/4/12
*/
@GetMapping
(
"/drivingFactors"
)
public
Result
<?>
drivingFactors
(
@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
);
if
(
eventAnalysisVersion
!=
null
)
{
versionId
=
eventAnalysisVersion
.
getId
();
}
}
String
versionData
=
eventAnalysisVersionRecordService
.
getVersionData
(
versionId
,
AnalysisColumnEnum
.
DRIVING_FACTORS
.
getCode
());
//String result = analysisService.llmResult(eventId, startTime, endTime, AnalysisColumnEnum.DRIVING_FACTORS.getCode());
return
Result
.
OK
(
versionData
);
}
/**
* 相关指标
*
* @param eventId 事件id
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2024/4/12
*/
@GetMapping
(
"/relatedIndicator"
)
public
Result
<?>
relatedIndicator
(
@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
);
if
(
eventAnalysisVersion
!=
null
)
{
versionId
=
eventAnalysisVersion
.
getId
();
}
}
String
versionData
=
eventAnalysisVersionRecordService
.
getVersionData
(
versionId
,
AnalysisColumnEnum
.
RELATED_INDICATOR
.
getCode
());
//String result = analysisService.llmResult(eventId, startTime, endTime, AnalysisColumnEnum.RELATED_INDICATOR.getCode());
return
Result
.
OK
(
versionData
);
}
/**
* 举措建议
*
* @param eventId 事件id
...
...
src/main/java/com/zzsn/event/controller/EventManageController.java
浏览文件 @
25b0bb27
...
...
@@ -6,6 +6,7 @@ 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.event.constant.Constants
;
import
com.zzsn.event.constant.Result
;
import
com.zzsn.event.entity.*
;
import
com.zzsn.event.enums.AnalysisColumnEnum
;
...
...
@@ -181,7 +182,8 @@ public class EventManageController {
//事件分析
log
.
info
(
"新增事件,事件分析,事件id:{}"
,
event
.
getId
());
kafkaTemplate
.
send
(
EVENT_MODEL_KAFKA_CHANNEL
,
event
.
getEventCode
());
});
CompletableFuture
.
runAsync
(()
->
{
//立马执行一次事件分析
analysisService
.
regenerate
(
event
.
getId
());
});
...
...
src/main/java/com/zzsn/event/controller/common/LLmConfigController.java
浏览文件 @
25b0bb27
...
...
@@ -5,11 +5,9 @@ import com.zzsn.event.entity.EventAnalysisVersion;
import
com.zzsn.event.entity.EventAnalysisVersionRecord
;
import
com.zzsn.event.entity.EventLlmConfig
;
import
com.zzsn.event.enums.AnalysisColumnEnum
;
import
com.zzsn.event.service.AnalysisService
;
import
com.zzsn.event.service.EventAnalysisVersionRecordService
;
import
com.zzsn.event.service.EventAnalysisVersionService
;
import
com.zzsn.event.service.EventLlmConfigService
;
import
com.zzsn.event.service.*
;
import
com.zzsn.event.util.DateUtil
;
import
com.zzsn.event.vo.EventVO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -35,6 +33,8 @@ public class LLmConfigController {
private
EventAnalysisVersionService
eventAnalysisVersionService
;
@Autowired
private
EventAnalysisVersionRecordService
eventAnalysisVersionRecordService
;
@Autowired
private
IEventService
eventService
;
/**
* 事件下大模型配置信息
...
...
@@ -73,8 +73,11 @@ public class LLmConfigController {
llmConfigService
.
modifySingle
(
eventLlmConfig
);
CompletableFuture
.
runAsync
(()
->{
String
eventId
=
eventLlmConfig
.
getEventId
();
EventVO
event
=
eventService
.
queryInfo
(
eventId
);
String
eventName
=
event
.
getEventName
();
String
content
=
"事件标题;"
+
eventName
+
"\n采集关键词:"
+
event
.
getKeywordsVO
().
getKeyword
();
//调用大模型更细结果
String
llmResult
=
analysisService
.
llmResult
(
eventId
,
null
,
null
,
eventLlmConfig
.
getColumnCode
());
String
llmResult
=
analysisService
.
llmResult
(
eventId
,
content
,
null
,
null
,
eventLlmConfig
.
getColumnCode
());
EventAnalysisVersion
eventAnalysisVersion
=
eventAnalysisVersionService
.
latestVersion
(
eventId
);
String
versionId
;
if
(
eventAnalysisVersion
==
null
)
{
...
...
src/main/java/com/zzsn/event/enums/AnalysisColumnEnum.java
浏览文件 @
25b0bb27
...
...
@@ -31,7 +31,12 @@ public enum AnalysisColumnEnum {
DOMESTIC_SIMILAR_EVENT
(
10
,
"中国类似事件"
,
"array"
,
1
),
FOREIGN_SIMILAR_EVENT
(
11
,
"各国类似事件"
,
"array"
,
1
);
FOREIGN_SIMILAR_EVENT
(
11
,
"各国类似事件"
,
"array"
,
1
),
DRIVING_FACTORS
(
12
,
"事件核心驱动因素"
,
"string"
,
1
),
RELATED_INDICATOR
(
13
,
"事件相关指标"
,
"string"
,
1
)
;
//栏目编码
private
final
Integer
code
;
...
...
src/main/java/com/zzsn/event/llm/LlmServiceImpl.java
浏览文件 @
25b0bb27
差异被折叠。
点击展开。
src/main/java/com/zzsn/event/service/AnalysisService.java
浏览文件 @
25b0bb27
...
...
@@ -92,8 +92,8 @@ public interface AnalysisService {
* @author lkg
* @date 2025/7/17
*/
String
llmResult
(
String
eventName
,
String
startTime
,
String
endTime
,
EventLlmConfig
llmConfig
);
String
llmResult
(
String
eventId
,
String
startTime
,
String
endTime
,
Integer
columnCode
);
String
llmResult
(
String
eventName
,
String
content
,
String
startTime
,
String
endTime
,
EventLlmConfig
llmConfig
);
String
llmResult
(
String
eventId
,
String
content
,
String
startTime
,
String
endTime
,
Integer
columnCode
);
/**
* 重新生成
...
...
src/main/java/com/zzsn/event/service/impl/AnalysisServiceImpl.java
浏览文件 @
25b0bb27
...
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON;
import
com.alibaba.fastjson2.JSONArray
;
import
com.alibaba.fastjson2.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.CollectionUtils
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.obs.services.model.PutObjectResult
;
...
...
@@ -302,11 +303,11 @@ public class AnalysisServiceImpl implements AnalysisService {
}
@Override
public
String
llmResult
(
String
eventName
,
String
startTime
,
String
endTime
,
EventLlmConfig
llmConfig
)
{
public
String
llmResult
(
String
eventName
,
String
content
,
String
startTime
,
String
endTime
,
EventLlmConfig
llmConfig
)
{
if
(
llmConfig
==
null
)
{
return
null
;
}
String
result
=
llmService
.
model
(
llmConfig
.
getLlmName
(),
llmConfig
.
getLlmPrompt
(),
eventName
);
String
result
=
llmService
.
model
(
llmConfig
.
getLlmName
(),
llmConfig
.
getLlmPrompt
(),
content
);
AnalysisColumnEnum
analysisColumnEnum
=
AnalysisColumnEnum
.
getByCode
(
llmConfig
.
getColumnCode
());
String
startHeader
=
null
;
if
(
analysisColumnEnum
!=
null
)
{
...
...
@@ -343,10 +344,10 @@ public class AnalysisServiceImpl implements AnalysisService {
}
@Override
public
String
llmResult
(
String
eventId
,
String
startTime
,
String
endTime
,
Integer
columnCode
)
{
public
String
llmResult
(
String
eventId
,
String
content
,
String
startTime
,
String
endTime
,
Integer
columnCode
)
{
Event
event
=
eventService
.
getById
(
eventId
);
EventLlmConfig
llmConfig
=
eventLlmConfigService
.
getConfig
(
eventId
,
columnCode
);
return
llmResult
(
event
.
getEventName
(),
startTime
,
endTime
,
llmConfig
);
return
llmResult
(
event
.
getEventName
(),
content
,
startTime
,
endTime
,
llmConfig
);
}
@Override
...
...
@@ -356,8 +357,9 @@ public class AnalysisServiceImpl implements AnalysisService {
String
today
=
DateUtil
.
dateToString
(
new
Date
());
//保存版本信息
String
versionId
=
saveVersion
(
eventId
,
today
);
Event
event
=
eventService
.
getById
(
eventId
);
Event
VO
event
=
eventService
.
queryInfo
(
eventId
);
String
eventName
=
event
.
getEventName
();
String
content
=
"事件标题;"
+
eventName
+
"\n采集关键词:"
+
event
.
getKeywordsVO
().
getKeyword
();
log
.
info
(
"{}-事件分析重新生成逻辑开始。。。"
,
eventName
);
String
eventDescribe
=
event
.
getEventDescribe
();
//核心摘要
...
...
@@ -366,10 +368,12 @@ public class AnalysisServiceImpl implements AnalysisService {
//历史核心摘要是否为空
boolean
empty
=
StringUtils
.
isEmpty
(
eventDescribe
);
EventLlmConfig
config
=
configList
.
stream
().
filter
(
e
->
e
.
getColumnCode
().
equals
(
AnalysisColumnEnum
.
CORE_SUMMARY
.
getCode
())).
findFirst
().
orElse
(
new
EventLlmConfig
());
eventDescribe
=
this
.
llmResult
(
eventName
,
null
,
null
,
config
);
eventDescribe
=
this
.
llmResult
(
eventName
,
content
,
null
,
null
,
config
);
if
(
empty
)
{
event
.
setEventDescribe
(
eventDescribe
);
eventService
.
updateById
(
event
);
LambdaUpdateWrapper
<
Event
>
update
=
Wrappers
.
lambdaUpdate
();
update
.
set
(
Event:
:
getEventDescribe
,
eventDescribe
).
eq
(
Event:
:
getId
,
eventId
);
eventService
.
update
(
update
);
}
}
EventAnalysisVersionRecord
coreSummaryRecord
=
EventAnalysisVersionRecord
.
of
(
versionId
,
AnalysisColumnEnum
.
CORE_SUMMARY
,
eventDescribe
);
...
...
@@ -399,7 +403,7 @@ public class AnalysisServiceImpl implements AnalysisService {
//大模型相关逻辑生成的结果(影响评估,举措建议等)
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
);
String
llmResult
=
this
.
llmResult
(
eventName
,
content
,
null
,
null
,
config
);
EventAnalysisVersionRecord
record
=
EventAnalysisVersionRecord
.
of
(
versionId
,
Objects
.
requireNonNull
(
AnalysisColumnEnum
.
getByCode
(
config
.
getColumnCode
())),
llmResult
);
records
.
add
(
record
);
log
.
info
(
"{}-事件分析【{}】重新生成逻辑完成。"
,
eventName
,
config
.
getColumnName
());
...
...
src/main/resources/application-test.yml
浏览文件 @
25b0bb27
...
...
@@ -180,18 +180,27 @@ infoSource:
columnListByWait
:
http://1.95.79.85:8823/baseSourceInfo/api/infoSource/columnListByWait
columnDetail
:
http://1.95.79.85:8823/baseSourceInfo/api/infoSource/columnDetail
model
:
aichain
:
url
:
https://open.bigmodel.cn/api/paas/v4/chat/completions
authorization
:
Bearer 3262d41a17a9490a8528eaf52a2be6a0.LNbHPCRmnzFgPHRp
cookie
:
acw_tc=2760822c17247248406261468e6c541507ba9035f95078363549469047ee74
qwen
:
apiKey
:
sk-01ee9a6efa394178993a950b768e3753
deepseek
:
url
:
https://api.deepseek.com/v1/chat/completions
# api-key: sk-0e374c2ff9a147a2822c36d1c971fda1
api-key
:
sk-656a8ec451dc47aaad3dacf24fe36f20
doubao
:
url
:
https://ark.cn-beijing.volces.com/api/v3/chat/completions
api-key
:
ab54c534-4f3c-41b9-9b27-132cb7954b6f
default-model
:
doubao-1-5-pro-32k-250115
# Doubao-1.5-pro-32k # 收费
default-modelType
:
zhipu
configs
:
-
modelType
:
zhipu
modelTypeName
:
智谱
url
:
https://open.bigmodel.cn/api/paas/v4/chat/completions
api-key
:
c5a53bd5f95a4e37a8997deb5d0c6031.orXyRRPNvZiqRaxF
default-model
:
glm-4-flash
#免费
web-search
:
true
-
modelType
:
qwen
modelTypeName
:
千问
url
:
https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions
api-key
:
sk-01ee9a6efa394178993a950b768e3753
default-model
:
qwen-plus
#收费
-
modelType
:
deepseek
modelTypeName
:
deepseek
url
:
https://api.deepseek.com/v1/chat/completions
api-key
:
sk-656a8ec451dc47aaad3dacf24fe36f20
default-model
:
deepseek-chat
#收费
-
modelType
:
doubao
modelTypeName
:
豆包
url
:
https://ark.cn-beijing.volces.com/api/v3/chat/completions
api-key
:
ab54c534-4f3c-41b9-9b27-132cb7954b6f
default-model
:
doubao-1-5-pro-32k-250115
# Doubao-1.5-pro-32k #收费
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论