提交 678e2d4e 作者: 925993793@qq.com

【专题】编辑关键词时,同步更新通用打分配置

上级 07631f3f
......@@ -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);
}
......@@ -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();
......
......@@ -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", collect.stream().map(SearchWordVO::getSearchInfo).collect(Collectors.joining("|")));
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流程
......@@ -151,16 +145,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", collect.stream().map(SearchWordVO::getSearchInfo).collect(Collectors.joining("|")));
scoreModelService.commonModifyByKeyword(subjectId, collect);
}
ScoreModel scoreModel = new ScoreModel();
scoreModel.setSubjectId(subjectId);
scoreModel.setType("1");
scoreModel.setData(defaultConfig);
scoreModelService.save(scoreModel);
//默认绑定tpu流程
ClbModelArrangeSubjectMap tpu = new ClbModelArrangeSubjectMap();
tpu.setSubjectId(subject.getId());
......@@ -380,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);
}
}
......@@ -395,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);
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论