提交 90674b0a 作者: 刘凯歌

合并分支 'dev_0710' 到 'event_fusion'

逻辑调整,优化

查看合并请求 !9
...@@ -255,10 +255,10 @@ public class EventAnalysisController { ...@@ -255,10 +255,10 @@ public class EventAnalysisController {
@RequestParam(required = false) String startTime, @RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime, @RequestParam(required = false) String endTime,
@RequestParam(required = false) String versionId) { @RequestParam(required = false) String versionId) {
if (StringUtils.isNotEmpty(versionId)) { //if (StringUtils.isNotEmpty(versionId)) {
String versionData = eventAnalysisVersionRecordService.getVersionData(versionId, AnalysisColumnEnum.KEYWORD_TREND.getCode()); // String versionData = eventAnalysisVersionRecordService.getVersionData(versionId, AnalysisColumnEnum.KEYWORD_TREND.getCode());
return Result.OK(JSON.parseArray(versionData,JSONObject.class)); // return Result.OK(JSON.parseArray(versionData,JSONObject.class));
} //}
List<CountVO> versionData = analysisService.wordTrend(eventId, startTime, endTime); List<CountVO> versionData = analysisService.wordTrend(eventId, startTime, endTime);
return Result.OK(versionData); return Result.OK(versionData);
} }
...@@ -279,10 +279,10 @@ public class EventAnalysisController { ...@@ -279,10 +279,10 @@ public class EventAnalysisController {
@RequestParam(required = false) String startTime, @RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime, @RequestParam(required = false) String endTime,
@RequestParam(required = false) String versionId) { @RequestParam(required = false) String versionId) {
if (StringUtils.isNotEmpty(versionId)) { //if (StringUtils.isNotEmpty(versionId)) {
String versionData = eventAnalysisVersionRecordService.getVersionData(versionId, AnalysisColumnEnum.CO_OCCURRENCE.getCode()); // String versionData = eventAnalysisVersionRecordService.getVersionData(versionId, AnalysisColumnEnum.CO_OCCURRENCE.getCode());
return Result.OK(JSON.parseArray(versionData,JSONObject.class)); // return Result.OK(JSON.parseArray(versionData,JSONObject.class));
} //}
//增加缓存逻辑,提升查询效率 //增加缓存逻辑,提升查询效率
String key = Constants.SUBJECT_ANALYSIS_PRE + Constants.CO_OCCURRENCE + eventId; String key = Constants.SUBJECT_ANALYSIS_PRE + Constants.CO_OCCURRENCE + eventId;
Object cacheObject = redisUtil.get(key); Object cacheObject = redisUtil.get(key);
...@@ -783,16 +783,35 @@ public class EventAnalysisController { ...@@ -783,16 +783,35 @@ public class EventAnalysisController {
} }
/**
* 导出ppt
*
* @param params 参数
* @author lkg
* @date 2025/8/15
*/
@PostMapping("/exportPPT") @PostMapping("/exportPPT")
public void exportPPT(@RequestBody JSONObject params, HttpServletResponse response) throws IOException { public void exportPPT(@RequestBody JSONObject params, HttpServletResponse response) throws IOException {
String eventId = params.getString("eventId"); String versionId = params.getString("versionId");
JSONArray content = params.getJSONArray("content"); if (StringUtils.isEmpty(versionId)) {
String ppt = analysisService.exportPPT(eventId, content);
if (ppt == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "PPT文件生成失败");
return; return;
} }
commonService.downloadTemplate(response, ppt); String pptPath;
EventAnalysisVersion eventAnalysisVersion = eventAnalysisVersionService.getById(versionId);
if (eventAnalysisVersion != null && StringUtils.isNotEmpty(eventAnalysisVersion.getPptPath())) {
pptPath = eventAnalysisVersion.getPptPath();
} else {
String eventId = params.getString("eventId");
JSONArray content = params.getJSONArray("content");
String ppt = analysisService.exportPPT(eventId, versionId,content);
if (ppt == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "PPT文件生成失败");
return;
} else {
pptPath = ppt;
}
}
commonService.downloadTemplate(response, pptPath);
} }
/** /**
......
...@@ -36,6 +36,10 @@ public class EventAnalysisVersion implements Serializable { ...@@ -36,6 +36,10 @@ public class EventAnalysisVersion implements Serializable {
*/ */
private String versionName; private String versionName;
/** /**
* ppt地址
*/
private String pptPath;
/**
* 创建人 * 创建人
*/ */
private String createBy; private String createBy;
......
...@@ -10,10 +10,13 @@ import org.apache.commons.collections4.CollectionUtils; ...@@ -10,10 +10,13 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.annotation.KafkaListener; import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author lkg * @author lkg
...@@ -27,13 +30,12 @@ public class KafkaConsumer { ...@@ -27,13 +30,12 @@ public class KafkaConsumer {
@Autowired @Autowired
private EventContextService eventContextService; private EventContextService eventContextService;
/** /**
* 获取-事件脉络-分析结果数据,并入库 * 获取-事件脉络-分析结果数据,并入库
* *
* @param record 接收的kafka数据 * @param record 接收的kafka数据
*/ */
@KafkaListener(topics = {"eventContextTopic"}) @KafkaListener(topics = {"${kafka.topic.eventContext}"})
public void eventContext_new(ConsumerRecord<String, String> record) { public void eventContext_new(ConsumerRecord<String, String> record) {
String value = record.value(); String value = record.value();
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
......
...@@ -107,9 +107,10 @@ public interface AnalysisService { ...@@ -107,9 +107,10 @@ public interface AnalysisService {
* 导出ppt * 导出ppt
* *
* @param eventId 事件id * @param eventId 事件id
* @param versionId 版本id
* @param content 导出内容 * @param content 导出内容
* @author lkg * @author lkg
* @date 2025/7/19 * @date 2025/7/19
*/ */
String exportPPT(String eventId, JSONArray content); String exportPPT(String eventId,String versionId, JSONArray content);
} }
...@@ -390,7 +390,7 @@ public class AnalysisServiceImpl implements AnalysisService { ...@@ -390,7 +390,7 @@ public class AnalysisServiceImpl implements AnalysisService {
// log.info("{}-事件分析【{}】重新生成逻辑完成。", eventName, AnalysisColumnEnum.EVENT_CONTEXT.getName()); // log.info("{}-事件分析【{}】重新生成逻辑完成。", eventName, AnalysisColumnEnum.EVENT_CONTEXT.getName());
//} //}
//关键词趋势分析 //关键词趋势分析
int count = esService.count(eventId, null, null); /*int count = esService.count(eventId, null, null);
if (count > 0) { if (count > 0) {
List<CountVO> wordTrend = this.wordTrend(eventId, null, null); List<CountVO> wordTrend = this.wordTrend(eventId, null, null);
if (CollectionUtils.isNotEmpty(wordTrend)) { if (CollectionUtils.isNotEmpty(wordTrend)) {
...@@ -405,7 +405,7 @@ public class AnalysisServiceImpl implements AnalysisService { ...@@ -405,7 +405,7 @@ public class AnalysisServiceImpl implements AnalysisService {
eventAnalysisVersionRecordService.save(record); eventAnalysisVersionRecordService.save(record);
log.info("{}-事件分析【{}】重新生成逻辑完成。", eventName, AnalysisColumnEnum.CO_OCCURRENCE.getName()); log.info("{}-事件分析【{}】重新生成逻辑完成。", eventName, AnalysisColumnEnum.CO_OCCURRENCE.getName());
} }
} }*/
//大模型相关逻辑生成的结果(影响评估,举措建议等) //大模型相关逻辑生成的结果(影响评估,举措建议等)
List<EventLlmConfig> collect = configList.stream() List<EventLlmConfig> collect = configList.stream()
.filter(e -> !e.getColumnCode().equals(AnalysisColumnEnum.CORE_SUMMARY.getCode()) .filter(e -> !e.getColumnCode().equals(AnalysisColumnEnum.CORE_SUMMARY.getCode())
...@@ -414,9 +414,12 @@ public class AnalysisServiceImpl implements AnalysisService { ...@@ -414,9 +414,12 @@ public class AnalysisServiceImpl implements AnalysisService {
String content = "事件标题;" + eventName + "\n事件摘要:" + event.getEventDescribe(); String content = "事件标题;" + eventName + "\n事件摘要:" + event.getEventDescribe();
for (EventLlmConfig config : collect) { for (EventLlmConfig config : collect) {
try { try {
String llmResult = this.llmResult(event,content, null, null, config); AnalysisColumnEnum analysisColumnEnum = AnalysisColumnEnum.getByCode(config.getColumnCode());
EventAnalysisVersionRecord record = EventAnalysisVersionRecord.of(versionId, Objects.requireNonNull(AnalysisColumnEnum.getByCode(config.getColumnCode())), llmResult); if (analysisColumnEnum != null) {
eventAnalysisVersionRecordService.save(record); String llmResult = this.llmResult(event,content, null, null, config);
EventAnalysisVersionRecord record = EventAnalysisVersionRecord.of(versionId, analysisColumnEnum, llmResult);
eventAnalysisVersionRecordService.save(record);
}
log.info("{}-事件分析【{}】重新生成逻辑完成。", eventName, config.getColumnName()); log.info("{}-事件分析【{}】重新生成逻辑完成。", eventName, config.getColumnName());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -426,7 +429,7 @@ public class AnalysisServiceImpl implements AnalysisService { ...@@ -426,7 +429,7 @@ public class AnalysisServiceImpl implements AnalysisService {
} }
@Override @Override
public String exportPPT(String eventId, JSONArray content) { public String exportPPT(String eventId,String versionId, JSONArray content) {
String pptFile = null; String pptFile = null;
Event event = eventService.getById(eventId); Event event = eventService.getById(eventId);
String eventName = event.getEventName(); String eventName = event.getEventName();
...@@ -492,6 +495,9 @@ public class AnalysisServiceImpl implements AnalysisService { ...@@ -492,6 +495,9 @@ public class AnalysisServiceImpl implements AnalysisService {
InputStream inputStream = connection.getInputStream(); InputStream inputStream = connection.getInputStream();
PutObjectResult putObjectResult = obsUtil.uploadFile("event_ppt/" + eventId + "_" + timestamp + ".pptx", inputStream); PutObjectResult putObjectResult = obsUtil.uploadFile("event_ppt/" + eventId + "_" + timestamp + ".pptx", inputStream);
pptFile = putObjectResult.getObjectKey(); pptFile = putObjectResult.getObjectKey();
LambdaUpdateWrapper<EventAnalysisVersion> update = Wrappers.lambdaUpdate();
update.set(EventAnalysisVersion::getPptPath, pptFile).eq(EventAnalysisVersion::getId, versionId);
eventAnalysisVersionService.update(update);
break; break;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -89,11 +89,11 @@ public class NetWorkEventTask { ...@@ -89,11 +89,11 @@ public class NetWorkEventTask {
if (CollectionUtils.isNotEmpty(finalList)) { if (CollectionUtils.isNotEmpty(finalList)) {
finalList.forEach(network -> network.setLatest(1)); finalList.forEach(network -> network.setLatest(1));
String response = llmService.model(null, PROMPT, JSONObject.toJSONString(finalList)); String response = llmService.model(null, PROMPT, JSONObject.toJSONString(finalList));
if (response.startsWith("```json")) {
response = response.substring(7, response.length() - 3);
}
if (StringUtils.isNotEmpty(response)) { if (StringUtils.isNotEmpty(response)) {
try { try {
if (response.contains("```json")) {
response = response.substring(response.indexOf("```json") + 7, response.lastIndexOf("```"));
}
List<EventNetwork> hitList = JSON.parseArray(response, EventNetwork.class); List<EventNetwork> hitList = JSON.parseArray(response, EventNetwork.class);
finalList.forEach(network -> { finalList.forEach(network -> {
List<String> titleLis = hitList.stream().map(EventNetwork::getTitle).collect(Collectors.toList()); List<String> titleLis = hitList.stream().map(EventNetwork::getTitle).collect(Collectors.toList());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论