提交 10470084 作者: 刘凯歌

合并分支 'event_fusion_dev' 到 'event_fusion'

【事件分析】-企业案例增加标记功能以及其他联动修改

查看合并请求 !22
...@@ -599,7 +599,6 @@ public class EventAnalysisController { ...@@ -599,7 +599,6 @@ public class EventAnalysisController {
} }
} }
String versionData = eventAnalysisVersionRecordService.getVersionData(versionId, AnalysisColumnEnum.ENTERPRISE_CASE.getCode()); String versionData = eventAnalysisVersionRecordService.getVersionData(versionId, AnalysisColumnEnum.ENTERPRISE_CASE.getCode());
//String result = analysisService.llmResult(eventId, startTime, endTime, AnalysisColumnEnum.ENTERPRISE_CASE.getCode());
List<JSONObject> data = null; List<JSONObject> data = null;
try { try {
if (versionData != null && (!versionData.endsWith("]") && versionData.contains("]"))) { if (versionData != null && (!versionData.endsWith("]") && versionData.contains("]"))) {
...@@ -621,7 +620,8 @@ public class EventAnalysisController { ...@@ -621,7 +620,8 @@ public class EventAnalysisController {
* @author lkg * @author lkg
* @date 2024/4/12 * @date 2024/4/12
*/ */
/*@GetMapping("/countryPolicy") @Deprecated
@GetMapping("/countryPolicy")
public Result<?> countryPolicy(@RequestParam String eventId, public Result<?> countryPolicy(@RequestParam String eventId,
@RequestParam(required = false) String startTime, @RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime, @RequestParam(required = false) String endTime,
...@@ -635,7 +635,7 @@ public class EventAnalysisController { ...@@ -635,7 +635,7 @@ public class EventAnalysisController {
String versionData = eventAnalysisVersionRecordService.getVersionData(versionId, AnalysisColumnEnum.COUNTRY_POLICY.getCode()); String versionData = eventAnalysisVersionRecordService.getVersionData(versionId, AnalysisColumnEnum.COUNTRY_POLICY.getCode());
//String result = analysisService.llmResult(eventId, startTime, endTime, AnalysisColumnEnum.COUNTRY_POLICY.getCode()); //String result = analysisService.llmResult(eventId, startTime, endTime, AnalysisColumnEnum.COUNTRY_POLICY.getCode());
return Result.OK(JSON.parseArray(versionData,JSONObject.class)); return Result.OK(JSON.parseArray(versionData,JSONObject.class));
}*/ }
/** /**
...@@ -699,6 +699,7 @@ public class EventAnalysisController { ...@@ -699,6 +699,7 @@ public class EventAnalysisController {
* @author lkg * @author lkg
* @date 2024/4/12 * @date 2024/4/12
*/ */
@Deprecated
@GetMapping("/similarEvent") @GetMapping("/similarEvent")
public Result<?> similarEvent(@RequestParam String eventId, public Result<?> similarEvent(@RequestParam String eventId,
@RequestParam(required = false) String startTime, @RequestParam(required = false) String startTime,
......
...@@ -12,6 +12,7 @@ import com.zzsn.event.service.EventAnalysisVersionRecordService; ...@@ -12,6 +12,7 @@ import com.zzsn.event.service.EventAnalysisVersionRecordService;
import com.zzsn.event.service.EventLlmConfigService; import com.zzsn.event.service.EventLlmConfigService;
import com.zzsn.event.service.IEventService; import com.zzsn.event.service.IEventService;
import com.zzsn.event.vo.EventLlmConfigModifyVO; import com.zzsn.event.vo.EventLlmConfigModifyVO;
import com.zzsn.event.vo.es.SpecialInformation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -98,7 +99,16 @@ public class LLmConfigController { ...@@ -98,7 +99,16 @@ public class LLmConfigController {
//调用大模型更细结果 //调用大模型更细结果
//应对建议需要把 驱动因素和影响评估作为输入 //应对建议需要把 驱动因素和影响评估作为输入
specialProcess(content, versionId, columnCode); specialProcess(content, versionId, columnCode);
llmResult = analysisService.llmResult(eventId, content.toString(), null, null, columnCode); boolean webSearch = true;
if (Objects.equals(columnCode, AnalysisColumnEnum.ENTERPRISE_CASE.getCode())) {
//企业案例,需要传入资讯且补联网查询
webSearch = false;
List<SpecialInformation> informationList = analysisService.modelAnalysisInformationList(eventId, eventName);
if (CollectionUtils.isNotEmpty(informationList)) {
content.append("\n参考资讯:").append(JSON.toJSONString(informationList));
}
}
llmResult = analysisService.llmResult(eventId, content.toString(),webSearch, null, null, columnCode);
log.info("{}-事件分析【{}】重新生成逻辑完成。", eventName, analysisColumnEnum.getName()); log.info("{}-事件分析【{}】重新生成逻辑完成。", eventName, analysisColumnEnum.getName());
} else { } else {
log.info("未找到对应的事件栏目【{}】", columnCode); log.info("未找到对应的事件栏目【{}】", columnCode);
......
...@@ -186,7 +186,7 @@ public class EventHomeController { ...@@ -186,7 +186,7 @@ public class EventHomeController {
"示例: \n" + "示例: \n" +
"描述:苹果新款iPhone发布引发市场反响\n" + "描述:苹果新款iPhone发布引发市场反响\n" +
"输出:(苹果|iPhone)+(発売|価格|予約状況|市場シェア|消費者反応)"; "输出:(苹果|iPhone)+(発売|価格|予約状況|市場シェア|消費者反応)";
String result = llmService.model(null,null, prompt, networkName); String result = llmService.model(null,null,true, prompt, networkName);
if (result.startsWith("```json")) { if (result.startsWith("```json")) {
result = result.substring(7, result.length() - 3); result = result.substring(7, result.length() - 3);
} else if (result.startsWith("```")) { } else if (result.startsWith("```")) {
......
...@@ -247,7 +247,7 @@ public class ExternalController { ...@@ -247,7 +247,7 @@ public class ExternalController {
"示例:\n" + "示例:\n" +
"输入: 特斯拉刹车失灵\n" + "输入: 特斯拉刹车失灵\n" +
"输出: 该专题聚焦于特斯拉电动汽车系列车型涉及的刹车系统性能与安全问题。近年来,全球多地车主报告在驾驶过程中遭遇疑似刹车失灵或制动距离异常延长的案例,引发了消费者对车辆安全性的广泛担忧。事件导致了多起交通事故,并促使美国国家公路交通安全管理局等权威机构启动缺陷调查。专题将涵盖相关事故报告、技术分析、监管机构的调查进展、特斯拉官方的回应及后续软件更新措施,旨在全面审视此类事件的真实性与潜在技术根源。"; "输出: 该专题聚焦于特斯拉电动汽车系列车型涉及的刹车系统性能与安全问题。近年来,全球多地车主报告在驾驶过程中遭遇疑似刹车失灵或制动距离异常延长的案例,引发了消费者对车辆安全性的广泛担忧。事件导致了多起交通事故,并促使美国国家公路交通安全管理局等权威机构启动缺陷调查。专题将涵盖相关事故报告、技术分析、监管机构的调查进展、特斯拉官方的回应及后续软件更新措施,旨在全面审视此类事件的真实性与潜在技术根源。";
String description = llmService.model("qwen", "qwen-max-latest", prompt, remark); String description = llmService.model("qwen", "qwen-max-latest",true, prompt, remark);
Map<String, String> resultMap = new HashMap<>(); Map<String, String> resultMap = new HashMap<>();
resultMap.put("language", language); resultMap.put("language", language);
resultMap.put("model", description); resultMap.put("model", description);
...@@ -609,7 +609,7 @@ public class ExternalController { ...@@ -609,7 +609,7 @@ public class ExternalController {
"{\"subject\":\"机器学习可解释性\",\"summaryList\":[{\"summary\":\"提出梯度解释法...验证准确率提升15%\"},{\"summary\":\"对比LIME与SHAP...指出计算效率缺陷\"},{\"summary\":\"医疗领域应用研究...模型透明度不足影响临床采纳\"}]}\n" + "{\"subject\":\"机器学习可解释性\",\"summaryList\":[{\"summary\":\"提出梯度解释法...验证准确率提升15%\"},{\"summary\":\"对比LIME与SHAP...指出计算效率缺陷\"},{\"summary\":\"医疗领域应用研究...模型透明度不足影响临床采纳\"}]}\n" +
"输出(示例段落):\n" + "输出(示例段落):\n" +
"多篇关于机器学习可解释性(XAI)的研究聚焦于提升复杂模型透明度。核心共识在于有效解释技术(如梯度解释法、LIME、SHAP)能增强用户信任并提升决策准确率。然而,在方法实用性上存在分歧,部分研究指出主流技术存在显著计算效率缺陷,尤其在资源受限场景;同时,医疗领域应用突显透明度不足是阻碍临床采纳的关键瓶颈。研究趋势显示从开发基础解释方法(如早期梯度法)转向评估实际场景效能及效率优化。当前主要知识缺口在于缺乏统一标准评估解释的可靠性与临床相关性,亟需开发兼顾高效性和领域适配性的XAI解决方案。"; "多篇关于机器学习可解释性(XAI)的研究聚焦于提升复杂模型透明度。核心共识在于有效解释技术(如梯度解释法、LIME、SHAP)能增强用户信任并提升决策准确率。然而,在方法实用性上存在分歧,部分研究指出主流技术存在显著计算效率缺陷,尤其在资源受限场景;同时,医疗领域应用突显透明度不足是阻碍临床采纳的关键瓶颈。研究趋势显示从开发基础解释方法(如早期梯度法)转向评估实际场景效能及效率优化。当前主要知识缺口在于缺乏统一标准评估解释的可靠性与临床相关性,亟需开发兼顾高效性和领域适配性的XAI解决方案。";
String model = llmService.model("qwen", "qwen-max-latest", prompt, JSONObject.toJSONString(params)); String model = llmService.model("qwen", "qwen-max-latest",true, prompt, JSONObject.toJSONString(params));
if (StringUtils.isNotBlank(model)) { if (StringUtils.isNotBlank(model)) {
resultMap = new HashMap<>(); resultMap = new HashMap<>();
resultMap.put("idList", idList); resultMap.put("idList", idList);
......
...@@ -12,11 +12,12 @@ public interface LlmService { ...@@ -12,11 +12,12 @@ public interface LlmService {
* *
* @param modelType 模型类型 * @param modelType 模型类型
* @param modelName 模型名称 * @param modelName 模型名称
* @param webSearch 是否联网搜索
* @param system 提示词 * @param system 提示词
* @param content 引用内容 * @param content 引用内容
* @return 大模型响应结果 * @return 大模型响应结果
*/ */
String model(String modelType, String modelName, String system, String content); String model(String modelType, String modelName,Boolean webSearch, String system, String content);
/** /**
* 千问模型调用 * 千问模型调用
......
...@@ -45,7 +45,7 @@ public class LlmServiceImpl implements LlmService { ...@@ -45,7 +45,7 @@ public class LlmServiceImpl implements LlmService {
private LlmProperties llmProperties; private LlmProperties llmProperties;
@Override @Override
public String model(String modelType,String modelName, String system, String content) { public String model(String modelType, String modelName, Boolean webSearch, String system, String content) {
if (StringUtils.isEmpty(modelType)) { if (StringUtils.isEmpty(modelType)) {
modelType = llmProperties.getDefaultModelType(); modelType = llmProperties.getDefaultModelType();
} }
...@@ -54,7 +54,7 @@ public class LlmServiceImpl implements LlmService { ...@@ -54,7 +54,7 @@ public class LlmServiceImpl implements LlmService {
modelConfig.setDefaultModel(modelName); modelConfig.setDefaultModel(modelName);
} }
if (modelType.equalsIgnoreCase("zhipu")) { if (modelType.equalsIgnoreCase("zhipu")) {
return glmModel(modelConfig, system, content); return glmModel(modelConfig, webSearch, system, content);
} else if (modelType.equalsIgnoreCase("qwen")) { } else if (modelType.equalsIgnoreCase("qwen")) {
return qwenModel(modelConfig, system, content); return qwenModel(modelConfig, system, content);
} else if (modelType.equalsIgnoreCase("deepseek")) { } else if (modelType.equalsIgnoreCase("deepseek")) {
...@@ -69,11 +69,12 @@ public class LlmServiceImpl implements LlmService { ...@@ -69,11 +69,12 @@ public class LlmServiceImpl implements LlmService {
* glm模型调用 * glm模型调用
* *
* @param modelConfig 模型配置信息 * @param modelConfig 模型配置信息
* @param webSearchFlag 是否联网搜索
* @param system 提示词 * @param system 提示词
* @param content 引用内容 * @param content 引用内容
* @return 大模型响应结果 * @return 大模型响应结果
*/ */
public String glmModel(LlmProperties.ModelConfig modelConfig, String system, String content) { public String glmModel(LlmProperties.ModelConfig modelConfig, Boolean webSearchFlag, String system, String content) {
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("model", modelConfig.getDefaultModel()); params.put("model", modelConfig.getDefaultModel());
List<Map<String, Object>> messageList = new ArrayList<>(); List<Map<String, Object>> messageList = new ArrayList<>();
...@@ -90,8 +91,7 @@ public class LlmServiceImpl implements LlmService { ...@@ -90,8 +91,7 @@ public class LlmServiceImpl implements LlmService {
params.put("top_p", 0.7); params.put("top_p", 0.7);
//params.put("temperature", 0.75);\ //params.put("temperature", 0.75);\
//是否开启联网搜索 //是否开启联网搜索
Boolean webSearchFlag = modelConfig.getWebSearch(); if (webSearchFlag) {
if (webSearchFlag != null && webSearchFlag) {
Map<String, Object> webSearch = new HashMap<>(); Map<String, Object> webSearch = new HashMap<>();
webSearch.put("enable", true); webSearch.put("enable", true);
webSearch.put("search_result", true); webSearch.put("search_result", true);
......
...@@ -7,6 +7,8 @@ import com.zzsn.event.entity.Event; ...@@ -7,6 +7,8 @@ import com.zzsn.event.entity.Event;
import com.zzsn.event.entity.EventLlmConfig; import com.zzsn.event.entity.EventLlmConfig;
import com.zzsn.event.entity.SubjectAnalysis; import com.zzsn.event.entity.SubjectAnalysis;
import com.zzsn.event.vo.*; import com.zzsn.event.vo.*;
import com.zzsn.event.vo.es.SpecialInformation;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
...@@ -84,6 +86,8 @@ public interface AnalysisService { ...@@ -84,6 +86,8 @@ public interface AnalysisService {
* 利用大模型生成的结果 * 利用大模型生成的结果
* *
* @param event 事件信息 * @param event 事件信息
* @param content 输入内容
* @param webSearch 是否联网搜索
* @param startTime 开始时间 * @param startTime 开始时间
* @param endTime 结束时间 * @param endTime 结束时间
* @param llmConfig 模型配置信息 * @param llmConfig 模型配置信息
...@@ -91,9 +95,9 @@ public interface AnalysisService { ...@@ -91,9 +95,9 @@ public interface AnalysisService {
* @author lkg * @author lkg
* @date 2025/7/17 * @date 2025/7/17
*/ */
String llmResult(EventVO event, String content, String startTime, String endTime, EventLlmConfig llmConfig, Map<Integer, String> extraContentParams); String llmResult(EventVO event, String content, Boolean webSearch, String startTime, String endTime, EventLlmConfig llmConfig, Map<Integer, String> extraContentParams);
String llmResult(String eventId, String content, String startTime, String endTime, Integer columnCode); String llmResult(String eventId, String content, Boolean webSearch, String startTime, String endTime, Integer columnCode);
/** /**
* 重新生成 * 重新生成
...@@ -114,4 +118,14 @@ public interface AnalysisService { ...@@ -114,4 +118,14 @@ public interface AnalysisService {
* @date 2025/7/19 * @date 2025/7/19
*/ */
String exportPPT(String eventId, String versionId, JSONArray content); String exportPPT(String eventId, String versionId, JSONArray content);
/**
* 大模型分析(企业案例)时,需要传入资讯列表
*
* @param eventId 事件id
* @param eventName 事件名称
* @author lkg
* @date 2025/7/19
*/
List<SpecialInformation> modelAnalysisInformationList(String eventId, String eventName);
} }
...@@ -15,9 +15,7 @@ import com.zzsn.event.enums.AnalysisColumnEnum; ...@@ -15,9 +15,7 @@ import com.zzsn.event.enums.AnalysisColumnEnum;
import com.zzsn.event.es.EsService; import com.zzsn.event.es.EsService;
import com.zzsn.event.llm.LlmService; import com.zzsn.event.llm.LlmService;
import com.zzsn.event.service.*; import com.zzsn.event.service.*;
import com.zzsn.event.util.DateUtil; import com.zzsn.event.util.*;
import com.zzsn.event.util.HotWordUtil;
import com.zzsn.event.util.ObsUtil;
import com.zzsn.event.util.ppt.ApiAuthAlgorithm; import com.zzsn.event.util.ppt.ApiAuthAlgorithm;
import com.zzsn.event.util.ppt.CreateResponse; import com.zzsn.event.util.ppt.CreateResponse;
import com.zzsn.event.util.ppt.PPTUtil; import com.zzsn.event.util.ppt.PPTUtil;
...@@ -66,6 +64,8 @@ public class AnalysisServiceImpl implements AnalysisService { ...@@ -66,6 +64,8 @@ public class AnalysisServiceImpl implements AnalysisService {
private ObsUtil obsUtil; private ObsUtil obsUtil;
@Autowired @Autowired
private EventLlmConfigService eventLlmConfigService; private EventLlmConfigService eventLlmConfigService;
@Autowired
private PythonUtil pythonUtil;
/* /*
* 优先级:事件脉络 > 伪事件脉络 > 资讯 * 优先级:事件脉络 > 伪事件脉络 > 资讯
...@@ -308,11 +308,11 @@ public class AnalysisServiceImpl implements AnalysisService { ...@@ -308,11 +308,11 @@ public class AnalysisServiceImpl implements AnalysisService {
} }
@Override @Override
public String llmResult(EventVO event,String content, String startTime, String endTime, EventLlmConfig llmConfig,Map<Integer,String> extraContentParams) { public String llmResult(EventVO event,String content,Boolean webSearch, String startTime, String endTime, EventLlmConfig llmConfig,Map<Integer,String> extraContentParams) {
if (llmConfig == null) { if (llmConfig == null) {
return null; return null;
} }
String result = llmService.model(llmConfig.getLlmName(),null, llmConfig.getLlmPrompt(), content); String result = llmService.model(llmConfig.getLlmName(),null,webSearch, llmConfig.getLlmPrompt(), content);
AnalysisColumnEnum analysisColumnEnum = AnalysisColumnEnum.getByCode(llmConfig.getColumnCode()); AnalysisColumnEnum analysisColumnEnum = AnalysisColumnEnum.getByCode(llmConfig.getColumnCode());
String startHeader = null; String startHeader = null;
if (analysisColumnEnum != null) { if (analysisColumnEnum != null) {
...@@ -350,7 +350,7 @@ public class AnalysisServiceImpl implements AnalysisService { ...@@ -350,7 +350,7 @@ public class AnalysisServiceImpl implements AnalysisService {
params.put("keyIssue", event.getKeyIssue()); params.put("keyIssue", event.getKeyIssue());
} }
params.put("impactOutline", impact); params.put("impactOutline", impact);
String impactDetail = llmService.model(detailConfig.getLlmName(),null, detailConfig.getLlmPrompt(), params.toJSONString()); String impactDetail = llmService.model(detailConfig.getLlmName(),null, false,detailConfig.getLlmPrompt(), params.toJSONString());
impact.put("impactDetail", impactDetail); impact.put("impactDetail", impactDetail);
log.info("{}-事件分析【{}-{}详情】重新生成逻辑完成。", event.getEventName(), AnalysisColumnEnum.IMPACT_ASSESSMENT.getName(),impact.getString("theme")); log.info("{}-事件分析【{}-{}详情】重新生成逻辑完成。", event.getEventName(), AnalysisColumnEnum.IMPACT_ASSESSMENT.getName(),impact.getString("theme"));
} catch (Exception e) { } catch (Exception e) {
...@@ -367,10 +367,10 @@ public class AnalysisServiceImpl implements AnalysisService { ...@@ -367,10 +367,10 @@ public class AnalysisServiceImpl implements AnalysisService {
} }
@Override @Override
public String llmResult(String eventId,String content, String startTime, String endTime, Integer columnCode) { public String llmResult(String eventId,String content,Boolean webSearch, String startTime, String endTime, Integer columnCode) {
EventVO event = eventService.queryInfo(eventId); EventVO event = eventService.queryInfo(eventId);
EventLlmConfig llmConfig = eventLlmConfigService.getConfig(eventId, columnCode); EventLlmConfig llmConfig = eventLlmConfigService.getConfig(eventId, columnCode);
return llmResult(event,content, startTime, endTime, llmConfig,null); return llmResult(event,content,webSearch, startTime, endTime, llmConfig,null);
} }
@Override @Override
...@@ -432,7 +432,7 @@ public class AnalysisServiceImpl implements AnalysisService { ...@@ -432,7 +432,7 @@ public class AnalysisServiceImpl implements AnalysisService {
//历史核心摘要是否为空 //历史核心摘要是否为空
boolean empty = StringUtils.isEmpty(eventDescribe); boolean empty = StringUtils.isEmpty(eventDescribe);
EventLlmConfig config = configList.stream().filter(e -> e.getColumnCode().equals(AnalysisColumnEnum.CORE_SUMMARY.getCode())).findFirst().orElse(new EventLlmConfig()); EventLlmConfig config = configList.stream().filter(e -> e.getColumnCode().equals(AnalysisColumnEnum.CORE_SUMMARY.getCode())).findFirst().orElse(new EventLlmConfig());
eventDescribe = this.llmResult(event,content, null, null, config,null); eventDescribe = this.llmResult(event,content, false,null, null, config,null);
if (empty) { if (empty) {
event.setEventDescribe(eventDescribe); event.setEventDescribe(eventDescribe);
LambdaUpdateWrapper<Event> update = Wrappers.lambdaUpdate(); LambdaUpdateWrapper<Event> update = Wrappers.lambdaUpdate();
...@@ -469,7 +469,15 @@ public class AnalysisServiceImpl implements AnalysisService { ...@@ -469,7 +469,15 @@ public class AnalysisServiceImpl implements AnalysisService {
content += "\n驱动因素:" + extraContentParams.get(AnalysisColumnEnum.DRIVING_FACTORS.getCode()); content += "\n驱动因素:" + extraContentParams.get(AnalysisColumnEnum.DRIVING_FACTORS.getCode());
} }
} }
String llmResult = this.llmResult(event,content, null, null, config,extraContentParams); boolean webSearch = true;
if (Objects.equals(columnCode, AnalysisColumnEnum.ENTERPRISE_CASE.getCode())) {
webSearch = false;
List<SpecialInformation> informationList = modelAnalysisInformationList(eventId, eventName);
if (CollectionUtils.isNotEmpty(informationList)) {
content += "\n参考资讯:" + JSON.toJSONString(informationList);
}
}
String llmResult = this.llmResult(event,content, webSearch,null, null, config,extraContentParams);
eventAnalysisVersionRecordService.modify(versionId, analysisColumnEnum, llmResult); eventAnalysisVersionRecordService.modify(versionId, analysisColumnEnum, llmResult);
log.info("{}-事件分析【{}】重新生成逻辑完成。", eventName, config.getColumnName()); log.info("{}-事件分析【{}】重新生成逻辑完成。", eventName, config.getColumnName());
} catch (Exception e) { } catch (Exception e) {
...@@ -478,6 +486,95 @@ public class AnalysisServiceImpl implements AnalysisService { ...@@ -478,6 +486,95 @@ public class AnalysisServiceImpl implements AnalysisService {
} }
} }
@Override
public List<SpecialInformation> modelAnalysisInformationList(String eventId, String eventName) {
List<SpecialInformation> informationList = enterpriseCaseDataList(eventId);
if (CollectionUtils.isEmpty(informationList)) {
informationList = webSearchCaseDataList(eventName);
}
return informationList;
}
/**
* 事件下企业资讯列表
*
* @param eventId 事件id
* @author lkg
* @date 2025/9/19
*/
private List<SpecialInformation> enterpriseCaseDataList(String eventId) {
List<SpecialInformation> infoList = new ArrayList<>();
InfoDataSearchCondition searchCondition = new InfoDataSearchCondition();
String[] fetchFields = new String[]{"id", "title", "content", "origin"};
searchCondition.setFetchFields(fetchFields);
searchCondition.setSubjectId(eventId);
searchCondition.setCategory(2);
searchCondition.setComposeSearchLabelIds("1947596156752150530");
searchCondition.setPageSize(50);
for (int i = 1; ; i++) {
searchCondition.setPageNo(i);
List<SpecialInformation> informationList = esService.informationList(searchCondition);
log.info("事件分析-企业案例获取资讯:本次循环-{},数据量为-{}", i, informationList.size());
if (CollectionUtils.isNotEmpty(informationList)) {
List<SpecialInformation> caseFilterList = pythonUtil.enterpriseCaseFilter(informationList);
if (CollectionUtils.isEmpty(caseFilterList)) {
continue;
}
infoList.addAll(caseFilterList);
if (infoList.size() >= 20) {
log.info("事件分析-企业案例获取资讯:企业案例资讯数据量为-{}", infoList.size());
break;
}
if (informationList.size() < 50) {
break;
}
} else {
break;
}
}
return infoList;
}
/**
* 智谱接口-联网获取资讯
*
* 事件下企业资讯为空时,使用此接口获取数据
*
*
* @param eventName 事件标题
* @author lkg
* @date 2025/9/19
*/
private List<SpecialInformation> webSearchCaseDataList(String eventName) {
List<SpecialInformation> infoList = new ArrayList<>();
Map<String,String> headers = new HashMap<>();
headers.put("Authorization", "c5a53bd5f95a4e37a8997deb5d0c6031.orXyRRPNvZiqRaxF");
JSONObject params = new JSONObject();
params.put("search_query", eventName);
params.put("search_engine", "search_std");
params.put("search_intent", true);
try {
String response = HttpUtil.doPostWithHeader("https://open.bigmodel.cn/api/paas/v4/web_search", params, 30000, headers);
JSONObject jsonObject = JSONObject.parseObject(response);
String dataListStr = jsonObject.getString("search_result");
List<JSONObject> jsonObjects = JSON.parseArray(dataListStr, JSONObject.class);
for (JSONObject data : jsonObjects) {
SpecialInformation info = new SpecialInformation();
info.setId(data.getString("refer"));
info.setTitle(data.getString("title"));
info.setContent(data.getString("content"));
info.setOrigin(data.getString("media"));
info.setSourceAddress(data.getString("link"));
info.setPublishDate(data.getString("publish_date"));
infoList.add(info);
}
} catch (IOException e) {
e.printStackTrace();
}
return infoList;
}
@Override @Override
public String exportPPT(String eventId,String versionId, JSONArray content) { public String exportPPT(String eventId,String versionId, JSONArray content) {
......
...@@ -70,7 +70,7 @@ public class NetWorkEventTask { ...@@ -70,7 +70,7 @@ public class NetWorkEventTask {
public void test(Integer type) { public void test(Integer type) {
List<EventNetwork> networkList = getNetWordEventList(type); List<EventNetwork> networkList = getNetWordEventList(type);
String response = llmService.model(null,null, PROMPT, JSONObject.toJSONString(networkList)); String response = llmService.model(null,null,true, PROMPT, JSONObject.toJSONString(networkList));
if (response.contains("```json")) { if (response.contains("```json")) {
response = response.substring(response.indexOf("```json") + 7, response.lastIndexOf("```")); response = response.substring(response.indexOf("```json") + 7, response.lastIndexOf("```"));
} }
...@@ -108,7 +108,7 @@ public class NetWorkEventTask { ...@@ -108,7 +108,7 @@ 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,null, PROMPT, JSONObject.toJSONString(finalList)); String response = llmService.model(null,null,true, PROMPT, JSONObject.toJSONString(finalList));
if (StringUtils.isNotEmpty(response)) { if (StringUtils.isNotEmpty(response)) {
try { try {
if (response.contains("```json")) { if (response.contains("```json")) {
......
...@@ -4,7 +4,6 @@ import com.alibaba.fastjson2.JSON; ...@@ -4,7 +4,6 @@ import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.zzsn.event.vo.es.SpecialInformation; import com.zzsn.event.vo.es.SpecialInformation;
import com.zzsn.event.vo.log.Source;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论