提交 2ee5f358 作者: 925993793@qq.com

自定义专题改版接口开发

上级 4b08e8ba
...@@ -536,4 +536,112 @@ public class InformationController { ...@@ -536,4 +536,112 @@ public class InformationController {
informationService.supplyByCondition(subjectId, JSONArray.parseArray(themeIds.toJSONString(), String.class)); informationService.supplyByCondition(subjectId, JSONArray.parseArray(themeIds.toJSONString(), String.class));
return Result.OK(); return Result.OK();
} }
/**
* 批量删除关键词
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/4/23
*/
@PostMapping("/removeWord")
public Result<?> removeWordLabel(@RequestBody InfoDataSearchCondition searchCondition) {
List<String> keywordList = searchCondition.getKeywordList();
if (CollectionUtils.isEmpty(keywordList)) {
return Result.FAIL("关键词不能为空");
}
CompletableFuture.runAsync(()-> informationService.removeWordLabel(searchCondition));
return Result.OK();
}
/**
* 批量添加到精选
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/4/23
*/
@PostMapping("/addToFavorites")
public Result<?> addToFavorites(@RequestBody InfoDataSearchCondition searchCondition) {
String subjectId = searchCondition.getSubjectId();
if (StringUtils.isEmpty(subjectId)) {
return Result.FAIL("专题id不能为空");
}
informationService.addToFavorites(searchCondition);
return Result.OK();
}
/**
* 批量添加到待定
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/4/23
*/
@PostMapping("/addToPend")
public Result<?> addToPend(@RequestBody InfoDataSearchCondition searchCondition) {
String subjectId = searchCondition.getSubjectId();
if (StringUtils.isEmpty(subjectId)) {
return Result.FAIL("专题id不能为空");
}
informationService.addToPend(searchCondition);
return Result.OK();
}
/**
* 批量添加到移除
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/4/23
*/
@PostMapping("/addToRemove")
public Result<?> addToRemove(@RequestBody InfoDataSearchCondition searchCondition) {
String subjectId = searchCondition.getSubjectId();
if (StringUtils.isEmpty(subjectId)) {
return Result.FAIL("专题id不能为空");
}
informationService.addToRemove(searchCondition);
return Result.OK();
}
/**
* 初始化数据
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/4/23
*/
@PostMapping("/initialData")
public Result<?> initialData(@RequestBody InfoDataSearchCondition searchCondition) {
String subjectId = searchCondition.getSubjectId();
if (StringUtils.isEmpty(subjectId)) {
return Result.FAIL("专题id不能为空");
}
informationService.initialData(searchCondition);
return Result.OK();
}
/**
* 字符串替换
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/4/23
*/
@PostMapping("/charReplace")
public Result<?> charReplace(@RequestBody InfoDataSearchCondition searchCondition) {
String subjectId = searchCondition.getSubjectId();
if (StringUtils.isEmpty(subjectId)) {
return Result.FAIL("专题id不能为空");
}
List<SearchWordVO> searchWordList = searchCondition.getSearchWordList();
if (CollectionUtils.isEmpty(searchWordList)) {
return Result.FAIL("检索词不能为空");
}
informationService.charReplace(searchCondition);
return Result.OK();
}
} }
...@@ -261,4 +261,58 @@ public interface InformationService { ...@@ -261,4 +261,58 @@ public interface InformationService {
List<SpecialInformation> informationAllList(InfoDataSearchCondition searchCondition); List<SpecialInformation> informationAllList(InfoDataSearchCondition searchCondition);
void removeLabelById(String index, String id, String relationId); void removeLabelById(String index, String id, String relationId);
/**
* 删除关键词标签
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/4/22
*/
void removeWordLabel(InfoDataSearchCondition searchCondition);
/**
* 批量添加到精选
*
* @param searchCondition 资讯检索条件
* @author lkg
* @date 2025/4/23
*/
void addToFavorites(InfoDataSearchCondition searchCondition);
/**
* 批量添加到精选
*
* @param searchCondition 资讯检索条件
* @author lkg
* @date 2025/4/23
*/
void addToPend(InfoDataSearchCondition searchCondition);
/**
* 批量添加到精选
*
* @param searchCondition 资讯检索条件
* @author lkg
* @date 2025/4/23
*/
void addToRemove(InfoDataSearchCondition searchCondition);
/**
* 初始化数据(数据状态全部重置为待审核、未删除)
*
* @param searchCondition 资讯检索条件
* @author lkg
* @date 2025/4/23
*/
void initialData(InfoDataSearchCondition searchCondition);
/**
* 字符串替换
*
* @param searchCondition 资讯检索条件
* @author lkg
* @date 2025/4/23
*/
void charReplace(InfoDataSearchCondition searchCondition);
} }
...@@ -30,6 +30,10 @@ import lombok.extern.slf4j.Slf4j; ...@@ -30,6 +30,10 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.search.join.ScoreMode;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.TermsQueryBuilder;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -430,6 +434,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -430,6 +434,7 @@ public class InformationServiceImpl implements InformationService {
labels.add(dataSet); labels.add(dataSet);
} }
} else { } else {
labels = new ArrayList<>();
labels.add(dataSet); labels.add(dataSet);
} }
information.setLabels(labels); information.setLabels(labels);
...@@ -659,9 +664,9 @@ public class InformationServiceImpl implements InformationService { ...@@ -659,9 +664,9 @@ public class InformationServiceImpl implements InformationService {
List<DictVO> boundList = dataBindLabelFrom.getBindList(); List<DictVO> boundList = dataBindLabelFrom.getBindList();
List<String> labelMarks = new ArrayList<>(); List<String> labelMarks = new ArrayList<>();
for (DictVO dictVO : boundList) { for (DictVO dictVO : boundList) {
if(StringUtils.isNotEmpty(dictVO.getCode())){ if (StringUtils.isNotEmpty(dictVO.getCode())) {
labelMarks.add(dictVO.getCode()); labelMarks.add(dictVO.getCode());
}else{ } else {
labelMarks.add(dictVO.getLabelMark()); labelMarks.add(dictVO.getLabelMark());
} }
} }
...@@ -675,7 +680,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -675,7 +680,7 @@ public class InformationServiceImpl implements InformationService {
label.setRelationName(sysDictItem.getItemText()); label.setRelationName(sysDictItem.getItemText());
newLabels.add(label); newLabels.add(label);
} }
if (CollectionUtils.isNotEmpty(dbLabels)) { if (CollectionUtils.isNotEmpty(dbLabels)) {
List<Label> collect = dbLabels.stream().filter(label -> labelMarks.contains(label.getLabelMark())).collect(Collectors.toList()); List<Label> collect = dbLabels.stream().filter(label -> labelMarks.contains(label.getLabelMark())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) { if (CollectionUtils.isNotEmpty(collect)) {
...@@ -1139,12 +1144,111 @@ public class InformationServiceImpl implements InformationService { ...@@ -1139,12 +1144,111 @@ public class InformationServiceImpl implements InformationService {
@Override @Override
public void removeLabelById(String index, String id, String relationId) { public void removeLabelById(String index, String id, String relationId) {
List<Label> labels = esService.getLabelsById(index,id); List<Label> labels = esService.getLabelsById(index, id);
if(labels == null){ if (labels == null) {
return; return;
} }
labels.removeIf(e -> e.getRelationId().equals(relationId)); labels.removeIf(e -> e.getRelationId().equals(relationId));
esService.updateLabelsById(index,id,labels); esService.updateLabelsById(index, id, labels);
}
@Override
public void removeWordLabel(InfoDataSearchCondition searchCondition) {
List<String> subjectIdList = new ArrayList<>();
subjectIdList.add(searchCondition.getSubjectId());
String minCreateTime = subjectService.getMinCreateTime(subjectIdList);
String[] indexArr = EsIndexUtil.getIndexIntervalYearStr(Constants.SUBJECT_INDEX, minCreateTime);
BoolQueryBuilder buildQuery = esService.buildQuery(searchCondition, subjectIdList);
buildQuery.must(QueryBuilders.nestedQuery("sortField",
QueryBuilders.termsQuery("sortField.fieldType", searchCondition.getKeywordList()),
ScoreMode.None));
List<String> keywordList = searchCondition.getKeywordList();
for (String word : keywordList) {
Map<String, Object> deleteParams = new HashMap<>();
deleteParams.put("fieldType", word);
esOpUtil.batchNestedDeleteScript(indexArr, buildQuery, deleteParams, "sortField");
}
}
@Override
public void addToFavorites(InfoDataSearchCondition searchCondition) {
List<String> subjectIdList = new ArrayList<>();
subjectIdList.add(searchCondition.getSubjectId());
String minCreateTime = subjectService.getMinCreateTime(subjectIdList);
String[] indexArr = EsIndexUtil.getIndexIntervalYearStr(Constants.SUBJECT_INDEX, minCreateTime);
BoolQueryBuilder buildQuery = esService.buildQuery(searchCondition, subjectIdList);
Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("checkStatus", 1);
modifyParams.put("deleteFlag",0);
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
}
@Override
public void addToPend(InfoDataSearchCondition searchCondition) {
List<String> subjectIdList = new ArrayList<>();
subjectIdList.add(searchCondition.getSubjectId());
String minCreateTime = subjectService.getMinCreateTime(subjectIdList);
String[] indexArr = EsIndexUtil.getIndexIntervalYearStr(Constants.SUBJECT_INDEX, minCreateTime);
BoolQueryBuilder buildQuery = esService.buildQuery(searchCondition, subjectIdList);
Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("checkStatus",3);
modifyParams.put("deleteFlag",0);
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
}
@Override
public void addToRemove(InfoDataSearchCondition searchCondition) {
List<String> subjectIdList = new ArrayList<>();
subjectIdList.add(searchCondition.getSubjectId());
String minCreateTime = subjectService.getMinCreateTime(subjectIdList);
String[] indexArr = EsIndexUtil.getIndexIntervalYearStr(Constants.SUBJECT_INDEX, minCreateTime);
BoolQueryBuilder buildQuery = esService.buildQuery(searchCondition, subjectIdList);
Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("deleteFlag",1);
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
}
@Override
public void initialData(InfoDataSearchCondition searchCondition) {
List<String> subjectIdList = new ArrayList<>();
subjectIdList.add(searchCondition.getSubjectId());
String minCreateTime = subjectService.getMinCreateTime(subjectIdList);
String[] indexArr = EsIndexUtil.getIndexIntervalYearStr(Constants.SUBJECT_INDEX, minCreateTime);
BoolQueryBuilder buildQuery = esService.buildQuery(searchCondition, subjectIdList);
Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("checkStatus",0);
modifyParams.put("deleteFlag",0);
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
}
@Override
public void charReplace(InfoDataSearchCondition searchCondition) {
SearchWordVO searchWordVO = searchCondition.getSearchWordList().get(0);
Integer searchScope = searchWordVO.getSearchScope();
String oldWord = searchWordVO.getSearchInfo();
String newWord = searchCondition.getReplaceWord();
if(StringUtils.isEmpty(newWord)) {
newWord = "";
}
List<String> modifyFields = new ArrayList<>();
if (searchScope == 1) {
modifyFields.add("title");
} else if (searchScope == 2) {
modifyFields.add("content");
modifyFields.add("contentWithTag");
} else if (searchScope == 3) {
modifyFields.add("title");
modifyFields.add("content");
modifyFields.add("contentWithTag");
} else if (searchScope == 4) {
modifyFields.add("origin");
}
List<String> subjectIdList = new ArrayList<>();
subjectIdList.add(searchCondition.getSubjectId());
String minCreateTime = subjectService.getMinCreateTime(subjectIdList);
String[] indexArr = EsIndexUtil.getIndexIntervalYearStr(Constants.SUBJECT_INDEX, minCreateTime);
BoolQueryBuilder buildQuery = esService.buildQuery(searchCondition, subjectIdList);
esOpUtil.batchReplaceScript(indexArr, buildQuery, modifyFields, oldWord, newWord);
} }
private void formatLabel(List<LabelModelVo> labelModelVos, DisplayInfo info) { private void formatLabel(List<LabelModelVo> labelModelVos, DisplayInfo info) {
......
...@@ -114,7 +114,7 @@ public class HanlpUtil { ...@@ -114,7 +114,7 @@ public class HanlpUtil {
* @创建时间 2020/8/27 19:56 * @创建时间 2020/8/27 19:56
* @Version 1.0 * @Version 1.0
*/ */
private static int countKeyWordInContent(String keyword, String srcContent){ public static int countKeyWordInContent(String keyword, String srcContent){
if(keyword==null ||keyword.trim().equals("")){ if(keyword==null ||keyword.trim().equals("")){
return 0; return 0;
} }
......
...@@ -50,11 +50,17 @@ public class InfoDataSearchCondition { ...@@ -50,11 +50,17 @@ public class InfoDataSearchCondition {
/**原创性(0-非原创;1-原创;2-疑似)*/ /**原创性(0-非原创;1-原创;2-疑似)*/
private String originality; private String originality;
//资讯状态-研究中心(0-全部;1-模型推荐;2-精选;3-待定;4-移除),和checkStatus、deleteFlag、isFreeCheck互斥
private Integer status;
//审核操作(0:未审核 1:审核通过 2:审核未通过 3:暂定 默认值为0) //审核操作(0:未审核 1:审核通过 2:审核未通过 3:暂定 默认值为0)
private Integer checkStatus; private Integer checkStatus;
//删除标记(1:删除;0:未删除) //删除标记(1:删除;0:未删除)
private Integer deleteFlag = 0; private Integer deleteFlag;
//是否免审核(1-是;0-否)
private Integer isFreeCheck;
//关联标签名称 //关联标签名称
private String labelName; private String labelName;
...@@ -104,15 +110,10 @@ public class InfoDataSearchCondition { ...@@ -104,15 +110,10 @@ public class InfoDataSearchCondition {
//待删除的标签id(多个用逗号隔开)-研究中心 //待删除的标签id(多个用逗号隔开)-研究中心
private String removeRelationId; private String removeRelationId;
//关键词信息;推荐信息源时使用-研究中心 //关键词信息;推荐信息源时使用-研究中心
private List<String> wordsList; private List<String> wordsList;
//是否免审核(1-是;0-否)
private Integer isFreeCheck;
//得分范围-研究中心 //得分范围-研究中心
//最小得分 //最小得分
private Integer minScore; private Integer minScore;
...@@ -126,7 +127,7 @@ public class InfoDataSearchCondition { ...@@ -126,7 +127,7 @@ public class InfoDataSearchCondition {
//排序参数 //排序参数
//排序字段 //排序字段
private String column = "publishDate"; private String column;
//排序方式 asc/desc //排序方式 asc/desc
private String order = "desc"; private String order = "desc";
//置顶排序是否起效(1-是;0-否) //置顶排序是否起效(1-是;0-否)
...@@ -166,7 +167,15 @@ public class InfoDataSearchCondition { ...@@ -166,7 +167,15 @@ public class InfoDataSearchCondition {
/*------添加至精选时,主题列表---start-------------------*/ /*------添加至精选时,主题列表---start-------------------*/
//聚合分组类型-按日期集合分析时使用
private List<Label> themeList; private List<Label> themeList;
/*------添加至精选时,主题列表---end-------------------*/ /*------添加至精选时,主题列表---end-------------------*/
/*------待删除的关键词列表---start-------------------*/
private List<String> keywordList;
/*------待删除的关键词列表---end-------------------*/
/*-----字符串替换---start-------------------*/
private String replaceWord;
/*------字符串替换---end-------------------*/
} }
...@@ -54,6 +54,8 @@ public class DisplayInfo { ...@@ -54,6 +54,8 @@ public class DisplayInfo {
private String type; private String type;
//标签信息 //标签信息
private List<Label> labels; private List<Label> labels;
//排序字段信息
private List<SortField> sortField;
//模型打分信息 //模型打分信息
private List<ModelScore> modelScores; private List<ModelScore> modelScores;
//视频下载链接 //视频下载链接
......
package com.zzsn.event.vo.es;
import lombok.Data;
/**
* 排序字段
*
* @author lkg
* @date 2025/4/22
*/
@Data
public class SortField {
//字段 (摘要、内容、标签、词频统计)
private String fieldType;
//字段排序值
private String fieldKeyword;
//词频
private Long fieldLong;
public SortField(String fieldType, Long fieldLong) {
this.fieldType = fieldType;
this.fieldLong = fieldLong;
}
public SortField(String fieldType, String fieldKeyword) {
this.fieldType = fieldType;
this.fieldKeyword = fieldKeyword;
}
}
...@@ -53,6 +53,8 @@ public class SpecialInformation { ...@@ -53,6 +53,8 @@ public class SpecialInformation {
private String type; private String type;
//标签信息 //标签信息
private List<Label> labels; private List<Label> labels;
//排序字段信息
private List<SortField> sortField;
//模型打分信息 //模型打分信息
private List<ModelScore> modelScores; private List<ModelScore> modelScores;
//视频下载链接 //视频下载链接
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论