提交 b3b75c66 作者: obcy

Merge remote-tracking branch 'origin/event_fusion' into event_fusion

package com.zzsn.event.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
......
......@@ -33,6 +33,8 @@ public class LlmProperties {
private String defaultModel;
//是否开启网络搜索
private Boolean webSearch;
//温度
private Float temperature;
}
/**
......
......@@ -908,7 +908,20 @@ public class EventAnalysisController {
public void downloadPPT(@RequestParam String versionId, HttpServletResponse response) {
EventAnalysisVersion eventAnalysisVersion = eventAnalysisVersionService.getById(versionId);
if (eventAnalysisVersion != null && StringUtils.isNotEmpty(eventAnalysisVersion.getPptPath())) {
commonService.downloadTemplate(response, eventAnalysisVersion.getPptPath());
String pptPath = eventAnalysisVersion.getPptPath();
JSONObject jsonObject = JSON.parseObject(pptPath);
Integer code = jsonObject.getInteger("code");
if (code == 200) {
commonService.downloadTemplate(response, jsonObject.getString("result"));
} else {
String json = JSON.toJSONString(Result.FAIL("PPT生成失败"));
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=utf-8");
try (PrintWriter writer = response.getWriter()) {
writer.println(json);
} catch (Exception ignored) {
}
}
} else {
String json = JSON.toJSONString(Result.FAIL(201, "PPT还在生成中。。。"));
response.setCharacterEncoding("UTF-8");
......
......@@ -10,6 +10,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.config.properties.LlmProperties;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.Subject;
import com.zzsn.event.external.entity.ExternalSubjectInfoSourceMap;
......@@ -26,16 +27,16 @@ 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.vo.InfoDataSearchCondition;
import com.zzsn.event.vo.SubjectDetailVO;
import com.zzsn.event.vo.SubjectSimpleVO;
import com.zzsn.event.vo.TranslateVO;
import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*;
import com.zzsn.event.vo.es.DisplayInfo;
import com.zzsn.event.xxljob.entity.XxlJobInfo;
import com.zzsn.event.xxljob.service.IXxlJobInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -48,10 +49,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.CompletableFuture;
/**
......@@ -86,6 +84,8 @@ public class ExternalController {
private CaiJiCenterHttpService caiJiCenterHttpService;
@Autowired
private ConfigurationMessageService configurationMessageService;
@Resource
private LlmProperties llmProperties;
@Value("${caiji.keywordCrawler.url:}")
private String keywordCrawlerUrl;
......@@ -94,6 +94,52 @@ public class ExternalController {
@Value("${kafka.topic.subject.run:}")
private String SUBJECT_MODEL_KAFKA_CHANNEL;
/**
* 分页列表查询-研究中心
*
* @param subjectCondition 搜索条件
* @param pageNo 当前页
* @param pageSize 每页返回条数
* @author lkg
* @date 2025/1/7
*/
@GetMapping(("/pageList"))
public Result<?> researchCenterPageList(SubjectCondition subjectCondition,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@RequestParam(required = false) String flagCode, HttpServletRequest request) {
UserVo loginUser = UserUtil.getLoginUser();
Page<SubjectPage> pageList = subjectService.researchCenterPageList(subjectCondition, pageNo, pageSize, flagCode, request, loginUser.getUsername());
List<SubjectPage> records = pageList.getRecords();
if (CollectionUtils.isNotEmpty(records)) {
Date now = new Date();
for (SubjectPage record : records) {
Date timeDisable = record.getTimeDisable();
String estimateStatus = record.getEstimateStatus();
Integer status = record.getStatus();
if (status == 0) {
record.setCollectStatus("未启用");
} else {
if (timeDisable != null) {
if (timeDisable.before(now)) {
if ("已完成".equals(estimateStatus) && status == 1) {
record.setCollectStatus("已完成");
} else if (!"已完成".equals(estimateStatus) && status == 1) {
record.setCollectStatus("采集中");
}
} else if (status == 1){
record.setCollectStatus("采集中");
}
} else if (status == 1){
record.setCollectStatus("采集中");
}
}
}
}
return Result.OK(pageList);
}
/**
* 创建专题
*
......@@ -170,6 +216,45 @@ public class ExternalController {
/**
* 优化描述
*
* @param remark 描述
* @author lkg
* @date 2025/8/25
*/
@GetMapping("/optimizeDescription")
public Result<?> optimizeDescription(@RequestParam String remark, @RequestParam String language) {
String languageCN = "中文简体";
if ("zh-CN".equals(language)) {
languageCN = "中文,且为中文简体";
} else if ("en".equals(language)) {
languageCN = "英文";
} else if ("ja".equals(language)) {
languageCN = "日文";
}
String prompt = "【角色】 你是一名资深【行业分析师】和【技术文档撰写者】。你的任务是将一个简短的主题转化为一段定义清晰、内容充实、客观中立的专题概述。\n" +
"【核心任务】 根据用户提供的一个简短主题名称或初步想法,将其扩展成一段约150字的、详尽且准确的专题描述。这段描述需要全面覆盖该主题的核心定义、背景、关键组成部分、重要影响或相关应用场景,语言需保持专业、精炼和高信息密度,避免主观评价和浮夸修辞。\n" +
"【要求】\n" +
"客观全面:内容必须基于事实,涵盖主题,准确识别用户意图。\n" +
"意图扩展:识别用户意图,将意图扩展,而不是回答这个问题\n" +
"信息密集:优先使用名词和专业术语,尽量保留用户输入的关键词,确保段落内含大量关键实体和概念,为后续关键词提取提供丰富素材。\n" +
"逻辑连贯:语句之间逻辑顺畅,形成一段完整的概述,而非关键词罗列。\n" +
"精准简洁:严格控制字数在150字左右,直达核心,避免冗长。\n" +
"输出语种:输出的文字必须是" + languageCN + "\n" +
"最终输出:请直接生成一段约150字的专题描述,无需任何前置说明、标题或分点。\n" +
"【输入输出示例】\n" +
"示例:\n" +
"输入: 特斯拉刹车失灵\n" +
"输出: 该专题聚焦于特斯拉电动汽车系列车型涉及的刹车系统性能与安全问题。近年来,全球多地车主报告在驾驶过程中遭遇疑似刹车失灵或制动距离异常延长的案例,引发了消费者对车辆安全性的广泛担忧。事件导致了多起交通事故,并促使美国国家公路交通安全管理局等权威机构启动缺陷调查。专题将涵盖相关事故报告、技术分析、监管机构的调查进展、特斯拉官方的回应及后续软件更新措施,旨在全面审视此类事件的真实性与潜在技术根源。";
String description = llmService.model("qwen", "qwen-max-latest", prompt, remark);
Map<String, String> resultMap = new HashMap<>();
resultMap.put("language", language);
resultMap.put("model", description);
return Result.OK(resultMap);
}
/**
* 采集词推荐
*
* @param remark 专题描述
......@@ -181,16 +266,20 @@ public class ExternalController {
String prompt = "你是一个专业信息采集助手,根据用户专题描述生成关键词表达式:\n" +
"1. 用 + 表示与关系(必须同现),| 表示或关系(任一出现),用()分组\n" +
"2. 执行三步操作:\n" +
" (1) 提取核心实体(如企业/产品名)\n" +
" (1) 理解语意,识别用户需求,提取核心实体(如企业/产品名),实体词语必须完整不能有歧义\n" +
" (2) 将抽象词拆解为3-5个具体场景词(如\"动向\"→\"上升|下降|波动|结构调整\")\n" +
" (3) 扩展同义词/行业关联词\n" +
"3. 排除时间词,+号不超过2个,单组|内词不超过5个\n" +
"4. 输出仅含表达式\n" +
"3. 排除时间词,|两边只能是单个词语,不能是括号词组,\n" +
"4.+号不超过2个,尽量使用两组词表达,最多使用三组词\n" +
"5. 输出仅含表达式\n" +
"\n" +
"示例: \n" +
"描述:苹果新款iPhone发布引发市场反响\n" +
"输出:(苹果|iPhone)+(発売|価格|予約状況|市場シェア|消費者反応)";
String crawlerWord = llmService.model("qwen", "qwen-max-latest", prompt, remark);
LlmProperties.ModelConfig modelConfig = llmProperties.getModelConfig("qwen");
modelConfig.setDefaultModel("qwen-max-latest");
modelConfig.setTemperature(0.1f);
String crawlerWord = llmService.qwenModel(modelConfig, prompt, remark);
return Result.OK(crawlerWord);
}
......@@ -356,26 +445,24 @@ public class ExternalController {
String key = "GATHER_SUMMARY::" + subjectId;
if (redisUtil.hasKey(key)) {
Object data = redisUtil.get(key);
if (data instanceof Map) {
Map<String, Object> map = (Map<String, Object>) data;
List<String> idList = JSON.parseArray(map.get("idList").toString(), String.class);
InfoDataSearchCondition searchCondition = new InfoDataSearchCondition();
searchCondition.setSubjectId(subjectId);
searchCondition.setCategory(2);
searchCondition.setColumn("score");
searchCondition.setPageSize(20);
IPage<DisplayInfo> pageList = informationService.subjectPageList(searchCondition);
List<DisplayInfo> records = pageList.getRecords();
if (CollectionUtils.isNotEmpty(records)) {
List<String> ids = new ArrayList<>();
records.forEach(record -> ids.add(record.getId()));
if (!CollectionUtils.isEqualCollection(ids, idList)) {
Map<String, Object> resultMap = generateSummary(subjectId, records, language);
return Result.OK(resultMap);
}
Map<String, Object> map = (Map<String, Object>) data;
List<String> idList = JSON.parseArray(map.get("idList").toString(), String.class);
InfoDataSearchCondition searchCondition = new InfoDataSearchCondition();
searchCondition.setSubjectId(subjectId);
searchCondition.setCategory(2);
searchCondition.setColumn("score");
searchCondition.setPageSize(20);
IPage<DisplayInfo> pageList = informationService.subjectPageList(searchCondition);
List<DisplayInfo> records = pageList.getRecords();
if (CollectionUtils.isNotEmpty(records)) {
List<String> ids = new ArrayList<>();
records.forEach(record -> ids.add(record.getId()));
if (!CollectionUtils.isEqualCollection(ids, idList)) {
Map<String, Object> resultMap = generateSummary(subjectId, records, language);
return Result.OK(resultMap);
}
}
return Result.OK((Map<String, Object>) data);
return Result.OK(map);
} else {
List<DisplayInfo> dataList = getDataList(subjectId);
return Result.OK(generateSummary(subjectId, dataList, language));
......@@ -411,14 +498,15 @@ public class ExternalController {
List<String> content = new ArrayList<>();
content.add(summary);
translateVO.setContent(content);
List<String> data = new ArrayList<>();
String result = null;
try {
String s = HttpUtil.doPost(TRANSLATE_URL, ObjectUtil.objectToJSONObject(translateVO), 10000);
data = JSONArray.parseArray(s, String.class);
List<String> data = JSONArray.parseArray(s, String.class);
result = Jsoup.parse(data.get(0)).text();
} catch (Exception e) {
e.printStackTrace();
}
return Result.OK(data);
return Result.OK(result);
}
......@@ -458,14 +546,20 @@ public class ExternalController {
String prompt = "#目标:\n" +
"将用户上传的多篇资讯摘要文本和主题整合为一段连贯、精炼的综合摘要(约500字)。要求:\n" +
"1)将输入的json解析,subject是主题,summary是摘要,提炼核心主题与高度共识的关键发现;\n" +
"2)客观指出存在的分歧点及其原因;\n" +
"3)简述观点或技术的演进趋势;\n" +
"4)语言需严谨中性,直接输出整合后的段落,无需分节分段或小标题。\n" +
"2)信息提取:必须深入挖掘并优先包含以下有价值的信息:\n" +
"具体数据与量化指标(如:成功率、误差率、性能提升百分比、样本规模)。\n" +
"具体方法、技术或模型名称(如:LSTM、Transformer、ResNet-50)。\n" +
"明确的研究结论(如:“证明A方法在B任务上优于C方法”)。\n" +
"研究间的直接对比或矛盾(如:“研究一报告了85%的准确率,而研究二在相同条件下仅复现出70%的结果,推测源于数据预处理差异”)。\n" +
"明确指出的局限性与未来挑战(如:“所有研究均未在跨语言环境下进行验证”)。\n" +
"3)避免内容:摒弃模糊的表述(如“取得了良好效果”、“具有重大意义”),除非是连接上下文的必要过渡。\n" +
"4)所有信息必须来源于提供的摘要,不可以自行联想\n" +
"5)语言需严谨中性,直接输出整合后的段落,无需分节分段或小标题。\n" +
"\n" +
"#约束:\n" +
"1.输出禁止分段\n" +
"2.输出的文字必须是" + languageCN + "\n" +
"3.摘要长度必须为500字左右\n" +
"3.摘要长度必须为500字以内\n" +
"\n" +
"#使用示例:\n" +
"输入:\n" +
......@@ -473,11 +567,13 @@ public class ExternalController {
"输出(示例段落):\n" +
"多篇关于机器学习可解释性(XAI)的研究聚焦于提升复杂模型透明度。核心共识在于有效解释技术(如梯度解释法、LIME、SHAP)能增强用户信任并提升决策准确率。然而,在方法实用性上存在分歧,部分研究指出主流技术存在显著计算效率缺陷,尤其在资源受限场景;同时,医疗领域应用突显透明度不足是阻碍临床采纳的关键瓶颈。研究趋势显示从开发基础解释方法(如早期梯度法)转向评估实际场景效能及效率优化。当前主要知识缺口在于缺乏统一标准评估解释的可靠性与临床相关性,亟需开发兼顾高效性和领域适配性的XAI解决方案。";
String model = llmService.model("qwen", "qwen-max-latest", prompt, JSONObject.toJSONString(params));
resultMap = new HashMap<>();
resultMap.put("idList", idList);
resultMap.put("language", language);
resultMap.put("model", model);
redisUtil.set("GATHER_SUMMARY::" + subjectId, resultMap);
if (StringUtils.isNotBlank(model)) {
resultMap = new HashMap<>();
resultMap.put("idList", idList);
resultMap.put("language", language);
resultMap.put("model", model);
redisUtil.set("GATHER_SUMMARY::" + subjectId, resultMap);
}
}
return resultMap;
}
......
package com.zzsn.event.llm;
import com.zzsn.event.config.properties.LlmProperties;
/**
* 模型调用
*/
......@@ -15,4 +17,14 @@ public interface LlmService {
* @return 大模型响应结果
*/
String model(String modelType, String modelName, String system, String content);
/**
* 千问模型调用
*
* @param modelConfig 模型配置信息
* @param system 提示词
* @param content 引用内容
* @return 大模型响应结果
*/
String qwenModel(LlmProperties.ModelConfig modelConfig, String system, String content);
}
......@@ -136,6 +136,9 @@ public class LlmServiceImpl implements LlmService {
.messages(Arrays.asList(systemMsg, userMsg))
.resultFormat(GenerationParam.ResultFormat.MESSAGE)
.build();
if (modelConfig.getTemperature() != null) {
param.setTemperature(modelConfig.getTemperature());
}
GenerationResult call = gen.call(param);
return call.getOutput().getChoices().get(0).getMessage().getContent();
} catch (Exception e) {
......
......@@ -22,29 +22,29 @@ public interface SubjectDictMapMapper extends BaseMapper<SubjectDictMap> {
/**
* 专题绑定的数据字典信息
*
* @param subjectId 专题id
* @param subjectIdList 专题id
* @author lkg
* @date 2025/3/28
*/
List<DictVO> boundList(@Param("subjectId") String subjectId);
List<DictVO> boundList(@Param("subjectIdList") List<String> subjectIdList);
List<String> boundIdList(@Param("subjectId") String subjectId);
List<String> boundIdList(@Param("subjectIdList") List<String> subjectIdList);
/**
* 流程中标签模型绑定的数据字典信息
*
* @param subjectId
* @param subjectIdList
* @return
*/
List<DictVO> boundArrangeList(@Param("subjectId") String subjectId);
List<DictVO> boundArrangeList(@Param("subjectIdList") List<String> subjectIdList);
/**
* 老逻辑中标签模型绑定的数据字典信息
*
* @param subjectId
* @param subjectIdList
* @return
*/
List<DictVO> boundOldList(@Param("subjectId") String subjectId);
List<DictVO> boundOldList(@Param("subjectIdList") List<String> subjectIdList);
/**
* 查询非数据字典的标签类型
......
......@@ -125,4 +125,6 @@ public interface SubjectMapper extends BaseMapper<Subject> {
List<String> getBindSubjectIds(@Param("id") String id);
String getMinCreateTime(@Param("subjectIdList") List<String> subjectIdList);
List<String> getIdListByType(@Param("typeId") String typeId);
}
......@@ -16,12 +16,18 @@
select d.id,d.dict_code as code,d.dict_name as name,'bind' as type
from subject_dict_map m
inner join clb_system.sys_dict d on m.dict_id = d.id
where m.subject_id = #{subjectId}
where m.subject_id in
<foreach collection="subjectIdList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="boundIdList" resultType="String">
select dict_id
from subject_dict_map
where subject_id = #{subjectId}
where subject_id in
<foreach collection="subjectIdList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="boundArrangeList" resultType="com.zzsn.event.vo.DictVO">
......@@ -39,7 +45,11 @@
WHERE
arrange_id IN
(SELECT DISTINCT arrange_id FROM clb_model_arrange_subject_map
WHERE subject_id = #{subjectId} AND del_flag = 0 )
WHERE subject_id in
<foreach collection="subjectIdList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
AND del_flag = 0 )
AND del_flag = 0
AND base_node_id = '1872120615905812482')
and (label_id is not null or dict_code is not null)
......@@ -53,7 +63,11 @@
WHERE
type = 3 AND id IN
(SELECT DISTINCT model_id FROM subject_model_map
WHERE subject_id = #{subjectId} AND type = 3)
WHERE subject_id in
<foreach collection="subjectIdList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
AND type = 3)
</select>
<select id="findLabelType" resultType="com.zzsn.event.vo.DictVO">
......
......@@ -148,6 +148,8 @@
SELECT d.id,
d.subject_name,
d.subject_code,
d.time_enable,
d.time_disable,
d.library,
d.remark,
d.subject_type,
......@@ -327,4 +329,8 @@
</foreach>
</if>
</select>
<select id="getIdListByType" resultType="java.lang.String">
select DISTINCT subject_id from subject_type_map where type_id = #{typeId}
</select>
</mapper>
......@@ -4,20 +4,32 @@ import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.ScoreModel;
import com.zzsn.event.vo.ScoreModelVo;
import com.zzsn.event.vo.SearchWordVO;
import java.util.List;
/**
* @Description: 打分模型
* @Author: jeecg-boot
* @Date: 2021-12-17
* @Date: 2021-12-17
* @Version: V1.0
*/
public interface ScoreModelService extends IService<ScoreModel> {
void addOrUpdate(ScoreModelVo scoreModel,Integer category);
void addOrUpdate(ScoreModelVo scoreModel, Integer category);
List<ScoreModelVo> queryScoreModel(String subjectId, String type);
JSONObject scoreModelInfo(String subjectId, String type);
/**
* 通用打分模型编辑(关键词)
*
* @param subjectId 专题id
* @param keywords 关键词信息
* @author lkg
* @date 2025/9/1
*/
void commonModifyByKeyword(String subjectId, List<SearchWordVO> keywords);
}
......@@ -212,4 +212,11 @@ public interface SubjectService extends IService<Subject> {
Subject getSubjectOrEventById(String id);
/**根据编码查询专题或者事件*/
Subject getSubjectOrEvent(String subjectCode);
/**
* 根据分组获取专题id列表
* @param typeId
* @return
*/
List<String> getIdListByType(String typeId);
}
......@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.obs.services.model.PutObjectResult;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.*;
import com.zzsn.event.enums.AnalysisColumnEnum;
import com.zzsn.event.es.EsService;
......@@ -517,9 +518,6 @@ public class AnalysisServiceImpl implements AnalysisService {
InputStream inputStream = connection.getInputStream();
PutObjectResult putObjectResult = obsUtil.uploadFile("event_ppt/" + eventId + "_" + timestamp + ".pptx", inputStream);
pptFile = putObjectResult.getObjectKey();
LambdaUpdateWrapper<EventAnalysisVersion> update = Wrappers.lambdaUpdate();
update.set(EventAnalysisVersion::getPptPath, pptFile).eq(EventAnalysisVersion::getId, versionId);
eventAnalysisVersionService.update(update);
break;
} catch (IOException e) {
e.printStackTrace();
......@@ -535,6 +533,15 @@ public class AnalysisServiceImpl implements AnalysisService {
}
}
}
Result<String> result;
if (pptFile == null) {
result = Result.FAIL("ppt生成失败");
} else {
result = Result.OK(pptFile);
}
LambdaUpdateWrapper<EventAnalysisVersion> update = Wrappers.lambdaUpdate();
update.set(EventAnalysisVersion::getPptPath, JSON.toJSONString(result)).eq(EventAnalysisVersion::getId, versionId);
eventAnalysisVersionService.update(update);
return pptFile;
}
......
......@@ -14,6 +14,7 @@ import com.zzsn.event.service.ISubjectInfoSourceMapService;
import com.zzsn.event.service.ScoreModelService;
import com.zzsn.event.vo.InfoSourceGroupPage;
import com.zzsn.event.vo.ScoreModelVo;
import com.zzsn.event.vo.SearchWordVO;
import com.zzsn.event.vo.SubjectScoreModel;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -22,6 +23,8 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @Description: 打分模型
......@@ -81,8 +84,48 @@ public class ScoreModelServiceImpl extends ServiceImpl<ScoreModelMapper, ScoreMo
}
}
@Override
public void commonModifyByKeyword(String subjectId, List<SearchWordVO> keywordList) {
LambdaQueryWrapper<ScoreModel> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(ScoreModel::getSubjectId,subjectId)
.eq(ScoreModel::getType,"1");
ScoreModel scoreModel = this.getOne(queryWrapper);
String keyword = keywordList.stream().map(SearchWordVO::getSearchInfo).collect(Collectors.joining("|"));
if(scoreModel == null){
//默认通用打分配置
String defaultConfig = "[{\"id\": \"1-1\", \"name\": \"信息源组\", \"children\": [], \"indexWeight\": 10}, {\"id\": \"1-2\", \"name\": \"文章长度\", \"indexWeight\": 15, \"keyWordsTopLimit\": 2500, \"keyWordsLowerLimit\": 500}, {\"id\": \"1-3\", \"name\": \"内容\", \"children\": [{\"id\": \"1-3-1\", \"name\": \"内容-关键词\", \"keyWords\": \"KEY_WORD\", \"indexWeight\": 75, \"titleWeight\": 10, \"keyWordsTopLimit\": 15, \"keyWordsLowerLimit\": 3}]}]";
defaultConfig = defaultConfig.replace("KEY_WORD", keyword);
scoreModel = new ScoreModel();
scoreModel.setSubjectId(subjectId);
scoreModel.setType("1");
scoreModel.setData(defaultConfig);
this.save(scoreModel);
} else {
JSONArray jsonArray = JSON.parseArray((scoreModel.getData().toString()));
Optional<Object> first = jsonArray.stream().filter(e -> {
JSONObject jsonObject = (JSONObject) e;
String name = jsonObject.getString("name");
return "内容".equals(name);
}).findFirst();
if (first.isPresent()) {
JSONObject jsonObject = (JSONObject) first.get();
JSONArray children = jsonObject.getJSONArray("children");
Optional<Object> wordFirst = children.stream().filter(e -> {
JSONObject jsonObject1 = (JSONObject) e;
String name = jsonObject1.getString("name");
return "内容-关键词".equals(name);
}).findFirst();
if (wordFirst.isPresent()) {
JSONObject wordJsonObject = (JSONObject) wordFirst.get();
wordJsonObject.put("keyWords",keyword);
}
}
scoreModel.setData(JSON.toJSONString(jsonArray));
this.updateById(scoreModel);
}
}
private JSONObject defaultInfo(String subjectId,String type){
private JSONObject defaultInfo(String subjectId, String type){
JSONObject jsonObject = new JSONObject();
List<SubjectScoreModel> allList = new ArrayList<>();
SubjectScoreModel subjectScoreModel = new SubjectScoreModel();
......
......@@ -3,19 +3,19 @@ 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.Subject;
import com.zzsn.event.entity.SubjectDictMap;
import com.zzsn.event.service.SubjectDictMapService;
import com.zzsn.event.mapper.SubjectDictMapMapper;
import com.zzsn.event.service.SubjectService;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.DictVO;
import com.zzsn.event.vo.SubjectBindLabelParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.TreeSet;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -27,6 +27,9 @@ import java.util.stream.Stream;
@Service
public class SubjectDictMapServiceImpl extends ServiceImpl<SubjectDictMapMapper, SubjectDictMap> implements SubjectDictMapService{
@Autowired
private SubjectService subjectService;
@Override
public void modify(SubjectBindLabelParam bindLabelParam) {
String subjectId = bindLabelParam.getSubjectId();
......@@ -49,9 +52,18 @@ public class SubjectDictMapServiceImpl extends ServiceImpl<SubjectDictMapMapper,
@Override
public List<DictVO> boundList(String subjectId) {
Subject byId = subjectService.getById(subjectId);
List<String> subjectIdList = Collections.singletonList(subjectId);
if(byId == null){
//不是专题时,根据分组获取专题列表
subjectIdList = subjectService.getIdListByType(subjectId);
}
if(subjectIdList.isEmpty()){
return new ArrayList<>();
}
//直接绑定的字典
List<DictVO> dictVOS = baseMapper.boundList(subjectId);
List<String> boundIds = baseMapper.boundIdList(subjectId);
List<DictVO> dictVOS = baseMapper.boundList(subjectIdList);
List<String> boundIds = baseMapper.boundIdList(subjectIdList);
if(boundIds.size()>dictVOS.size()){
List<String> ids = dictVOS.stream().map(DictVO::getId).collect(Collectors.toList());
List<String> lids = new ArrayList<>(boundIds);
......@@ -64,11 +76,11 @@ public class SubjectDictMapServiceImpl extends ServiceImpl<SubjectDictMapMapper,
dictVOS.addAll(baseMapper.findLeaderLabelType(boundIds));
}
//流程中标签模型绑定字典
List<DictVO> dictArrange = baseMapper.boundArrangeList(subjectId);
List<DictVO> dictArrange = baseMapper.boundArrangeList(subjectIdList);
dictVOS.addAll(dictArrange);
if(dictArrange.isEmpty()){
//未绑定流程的(可能)查询老逻辑保定的字典
List<DictVO> dictOld = baseMapper.boundOldList(subjectId);
List<DictVO> dictOld = baseMapper.boundOldList(subjectIdList);
dictVOS.addAll(dictOld);
}
dictVOS.forEach(dictVO -> {
......
......@@ -1545,6 +1545,12 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
}
}
@Override
public List<String> getIdListByType(String typeId) {
return this.baseMapper.getIdListByType(typeId);
}
@Override
public Subject getSubjectOrEventById(String id) {
......
......@@ -110,16 +110,10 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
if (CollectionUtils.isNotEmpty(keywords)) {
modifyKeyword(subjectId, subject.getSubjectName(), keywords);
//默认通用打分配置
String defaultConfig = "[{\"id\": \"1-1\", \"name\": \"信息源组\", \"children\": [], \"indexWeight\": 10}, {\"id\": \"1-2\", \"name\": \"文章长度\", \"indexWeight\": 15, \"keyWordsTopLimit\": 2500, \"keyWordsLowerLimit\": 500}, {\"id\": \"1-3\", \"name\": \"内容\", \"children\": [{\"id\": \"1-3-1\", \"name\": \"内容-关键词\", \"keyWords\": \"KEY_WORD\", \"indexWeight\": 75, \"titleWeight\": 10, \"keyWordsTopLimit\": 15, \"keyWordsLowerLimit\": 3}]}]";
List<SearchWordVO> collect = keywords.stream().filter(searchWordVO -> !"NOT".equalsIgnoreCase(searchWordVO.getSearchLogicRelationship())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
defaultConfig = defaultConfig.replace("KEY_WORD", String.join("|", collect.stream().map(SearchWordVO::getSearchInfo).collect(Collectors.toList())));
scoreModelService.commonModifyByKeyword(subjectId, collect);
}
ScoreModel scoreModel = new ScoreModel();
scoreModel.setSubjectId(subjectId);
scoreModel.setType("1");
scoreModel.setData(defaultConfig);
scoreModelService.save(scoreModel);
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectId,null);
//默认绑定tpu流程
......@@ -150,8 +144,11 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
List<SearchWordVO> keywords = subjectSimpleVO.getKeywords();
if (CollectionUtils.isNotEmpty(keywords)) {
modifyKeyword(subjectId, subject.getSubjectName(), keywords);
//同步配置到采集
//configurationMessageService.bindKeyWordsSend(subjectId,1);
//默认通用打分配置
List<SearchWordVO> collect = keywords.stream().filter(searchWordVO -> !"NOT".equalsIgnoreCase(searchWordVO.getSearchLogicRelationship())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
scoreModelService.commonModifyByKeyword(subjectId, collect);
}
//默认绑定tpu流程
ClbModelArrangeSubjectMap tpu = new ClbModelArrangeSubjectMap();
tpu.setSubjectId(subject.getId());
......@@ -371,12 +368,18 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
BeanUtils.copyProperties(subjectSimpleVO, subjectPage);
subjectPage.setProjectId(PROJECT_ID);
subjectService.updateMain(subjectPage);
String subjectId = subjectSimpleVO.getId();
//关键词绑定
List<SearchWordVO> keywords = subjectSimpleVO.getKeywords();
if (CollectionUtils.isNotEmpty(keywords)) {
modifyKeyword(subjectSimpleVO.getId(), subjectSimpleVO.getSubjectName(), keywords);
//默认通用打分配置
List<SearchWordVO> collect = keywords.stream().filter(searchWordVO -> !"NOT".equalsIgnoreCase(searchWordVO.getSearchLogicRelationship())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
scoreModelService.commonModifyByKeyword(subjectId, collect);
}
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectSimpleVO.getId(),null);
configurationMessageService.bindKeyWordsSend(subjectId,null);
}
}
......@@ -386,12 +389,18 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
BeanUtils.copyProperties(subjectSimpleVO, subjectPage);
subjectPage.setProjectId("1955112691539480577");
subjectService.updateMain(subjectPage);
String subjectId = subjectSimpleVO.getId();
//关键词绑定
List<SearchWordVO> keywords = subjectSimpleVO.getKeywords();
if (CollectionUtils.isNotEmpty(keywords)) {
modifyKeyword(subjectSimpleVO.getId(), subjectSimpleVO.getSubjectName(), keywords);
//默认通用打分配置
List<SearchWordVO> collect = keywords.stream().filter(searchWordVO -> !"NOT".equalsIgnoreCase(searchWordVO.getSearchLogicRelationship())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
scoreModelService.commonModifyByKeyword(subjectId, collect);
}
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectSimpleVO.getId(),1);
configurationMessageService.bindKeyWordsSend(subjectId,1);
}
}
......
......@@ -203,4 +203,8 @@ public class SubjectPage {
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date latestDataDate;
/**采集状态(定制专题)*/
private String collectStatus;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论