提交 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");
......
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论