Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
E
event
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
陈世强
event
Commits
7abc41da
提交
7abc41da
authored
4月 25, 2025
作者:
925993793@qq.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
根据需求补充接口
上级
feb81032
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
146 行增加
和
10 行删除
+146
-10
InformationController.java
...m/zzsn/event/controller/common/InformationController.java
+54
-7
EsService.java
src/main/java/com/zzsn/event/es/EsService.java
+15
-2
InformationService.java
src/main/java/com/zzsn/event/service/InformationService.java
+18
-0
InformationServiceImpl.java
...a/com/zzsn/event/service/impl/InformationServiceImpl.java
+46
-0
InfoDataSearchCondition.java
src/main/java/com/zzsn/event/vo/InfoDataSearchCondition.java
+11
-1
DisplayInfo.java
src/main/java/com/zzsn/event/vo/es/DisplayInfo.java
+2
-0
没有找到文件。
src/main/java/com/zzsn/event/controller/common/InformationController.java
浏览文件 @
7abc41da
...
@@ -13,11 +13,11 @@ import com.zzsn.event.enums.LabelTypeEnum;
...
@@ -13,11 +13,11 @@ import com.zzsn.event.enums.LabelTypeEnum;
import
com.zzsn.event.es.EsService
;
import
com.zzsn.event.es.EsService
;
import
com.zzsn.event.service.*
;
import
com.zzsn.event.service.*
;
import
com.zzsn.event.util.PythonUtil
;
import
com.zzsn.event.util.PythonUtil
;
import
com.zzsn.event.util.tree.Node
;
import
com.zzsn.event.util.user.UserUtil
;
import
com.zzsn.event.util.user.UserUtil
;
import
com.zzsn.event.util.user.UserVo
;
import
com.zzsn.event.util.user.UserVo
;
import
com.zzsn.event.vo.*
;
import
com.zzsn.event.vo.*
;
import
com.zzsn.event.vo.es.DisplayInfo
;
import
com.zzsn.event.vo.es.DisplayInfo
;
import
com.zzsn.event.vo.es.Label
;
import
com.zzsn.event.vo.es.SpecialInformation
;
import
com.zzsn.event.vo.es.SpecialInformation
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -564,8 +564,9 @@ public class InformationController {
...
@@ -564,8 +564,9 @@ public class InformationController {
@PostMapping
(
"/addToFavorites"
)
@PostMapping
(
"/addToFavorites"
)
public
Result
<?>
addToFavorites
(
@RequestBody
InfoDataSearchCondition
searchCondition
)
{
public
Result
<?>
addToFavorites
(
@RequestBody
InfoDataSearchCondition
searchCondition
)
{
String
subjectId
=
searchCondition
.
getSubjectId
();
String
subjectId
=
searchCondition
.
getSubjectId
();
if
(
StringUtils
.
isEmpty
(
subjectId
))
{
List
<
String
>
ids
=
searchCondition
.
getIds
();
return
Result
.
FAIL
(
"专题id不能为空"
);
if
(
StringUtils
.
isEmpty
(
subjectId
)
&&
CollectionUtils
.
isEmpty
(
ids
))
{
return
Result
.
FAIL
(
"专题id和资讯id集合不能同时为空"
);
}
}
informationService
.
addToFavorites
(
searchCondition
);
informationService
.
addToFavorites
(
searchCondition
);
return
Result
.
OK
();
return
Result
.
OK
();
...
@@ -581,8 +582,9 @@ public class InformationController {
...
@@ -581,8 +582,9 @@ public class InformationController {
@PostMapping
(
"/addToPend"
)
@PostMapping
(
"/addToPend"
)
public
Result
<?>
addToPend
(
@RequestBody
InfoDataSearchCondition
searchCondition
)
{
public
Result
<?>
addToPend
(
@RequestBody
InfoDataSearchCondition
searchCondition
)
{
String
subjectId
=
searchCondition
.
getSubjectId
();
String
subjectId
=
searchCondition
.
getSubjectId
();
if
(
StringUtils
.
isEmpty
(
subjectId
))
{
List
<
String
>
ids
=
searchCondition
.
getIds
();
return
Result
.
FAIL
(
"专题id不能为空"
);
if
(
StringUtils
.
isEmpty
(
subjectId
)
&&
CollectionUtils
.
isEmpty
(
ids
))
{
return
Result
.
FAIL
(
"专题id和资讯id集合不能同时为空"
);
}
}
informationService
.
addToPend
(
searchCondition
);
informationService
.
addToPend
(
searchCondition
);
return
Result
.
OK
();
return
Result
.
OK
();
...
@@ -598,8 +600,9 @@ public class InformationController {
...
@@ -598,8 +600,9 @@ public class InformationController {
@PostMapping
(
"/addToRemove"
)
@PostMapping
(
"/addToRemove"
)
public
Result
<?>
addToRemove
(
@RequestBody
InfoDataSearchCondition
searchCondition
)
{
public
Result
<?>
addToRemove
(
@RequestBody
InfoDataSearchCondition
searchCondition
)
{
String
subjectId
=
searchCondition
.
getSubjectId
();
String
subjectId
=
searchCondition
.
getSubjectId
();
if
(
StringUtils
.
isEmpty
(
subjectId
))
{
List
<
String
>
ids
=
searchCondition
.
getIds
();
return
Result
.
FAIL
(
"专题id不能为空"
);
if
(
StringUtils
.
isEmpty
(
subjectId
)
&&
CollectionUtils
.
isEmpty
(
ids
))
{
return
Result
.
FAIL
(
"专题id和资讯id集合不能同时为空"
);
}
}
informationService
.
addToRemove
(
searchCondition
);
informationService
.
addToRemove
(
searchCondition
);
return
Result
.
OK
();
return
Result
.
OK
();
...
@@ -650,5 +653,49 @@ public class InformationController {
...
@@ -650,5 +653,49 @@ public class InformationController {
return
Result
.
OK
();
return
Result
.
OK
();
}
}
/**
* 资讯批量打标
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/4/23
*/
@PostMapping
(
"/markTag"
)
public
Result
<?>
markTag
(
@RequestBody
InfoDataSearchCondition
searchCondition
)
{
String
subjectId
=
searchCondition
.
getSubjectId
();
List
<
String
>
ids
=
searchCondition
.
getIds
();
if
(
StringUtils
.
isEmpty
(
subjectId
)
&&
CollectionUtils
.
isEmpty
(
ids
))
{
return
Result
.
FAIL
(
"专题id和资讯id集合不能同时为空"
);
}
List
<
Label
>
markTags
=
searchCondition
.
getMarkTags
();
if
(
CollectionUtils
.
isEmpty
(
markTags
))
{
return
Result
.
FAIL
(
"标签不能为空"
);
}
informationService
.
markTag
(
searchCondition
);
return
Result
.
OK
();
}
/**
* 资讯批量删除标签
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/4/23
*/
@PostMapping
(
"/removeTag"
)
public
Result
<?>
removeTag
(
@RequestBody
InfoDataSearchCondition
searchCondition
)
{
String
subjectId
=
searchCondition
.
getSubjectId
();
List
<
String
>
ids
=
searchCondition
.
getIds
();
if
(
StringUtils
.
isEmpty
(
subjectId
)
&&
CollectionUtils
.
isEmpty
(
ids
))
{
return
Result
.
FAIL
(
"专题id和资讯id集合不能同时为空"
);
}
List
<
Label
>
markTags
=
searchCondition
.
getMarkTags
();
if
(
CollectionUtils
.
isEmpty
(
markTags
))
{
return
Result
.
FAIL
(
"标签不能为空"
);
}
informationService
.
removeTag
(
searchCondition
);
return
Result
.
OK
();
}
}
}
src/main/java/com/zzsn/event/es/EsService.java
浏览文件 @
7abc41da
...
@@ -845,10 +845,10 @@ public class EsService {
...
@@ -845,10 +845,10 @@ public class EsService {
break
;
break
;
default
:
default
:
NestedSortBuilder
nestedWordSortBuilder
=
new
NestedSortBuilder
(
"sortField"
);
NestedSortBuilder
nestedWordSortBuilder
=
new
NestedSortBuilder
(
"sortField"
);
nestedWordSortBuilder
.
setFilter
(
QueryBuilders
.
term
Query
(
"sortField.fieldType"
,
column
));
nestedWordSortBuilder
.
setFilter
(
QueryBuilders
.
term
sQuery
(
"sortField.fieldType"
,
Arrays
.
asList
(
column
.
split
(
","
))
));
FieldSortBuilder
fieldWordSortBuilder
=
SortBuilders
.
fieldSort
(
"sortField.fieldLong"
)
FieldSortBuilder
fieldWordSortBuilder
=
SortBuilders
.
fieldSort
(
"sortField.fieldLong"
)
.
order
(
sortOrder
)
.
order
(
sortOrder
)
.
sortMode
(
SortMode
.
MAX
)
.
sortMode
(
SortMode
.
SUM
)
.
setNestedSort
(
nestedWordSortBuilder
);
.
setNestedSort
(
nestedWordSortBuilder
);
searchSourceBuilder
.
sort
(
fieldWordSortBuilder
);
searchSourceBuilder
.
sort
(
fieldWordSortBuilder
);
break
;
break
;
...
@@ -2225,6 +2225,19 @@ public class EsService {
...
@@ -2225,6 +2225,19 @@ public class EsService {
if
(
maxScore
!=
null
)
{
if
(
maxScore
!=
null
)
{
boolQuery
.
filter
(
QueryBuilders
.
rangeQuery
(
"score"
).
lte
(
maxScore
));
boolQuery
.
filter
(
QueryBuilders
.
rangeQuery
(
"score"
).
lte
(
maxScore
));
}
}
//正文长度筛选
Integer
minContentLength
=
searchCondition
.
getMinContentLength
();
if
(
minContentLength
!=
null
)
{
NestedQueryBuilder
nestedQueryBuilder
=
QueryBuilders
.
nestedQuery
(
"sortField"
,
QueryBuilders
.
rangeQuery
(
"sortField.fieldLong"
).
gte
(
minContentLength
),
ScoreMode
.
None
);
boolQuery
.
filter
(
nestedQueryBuilder
);
}
Integer
maxContentLength
=
searchCondition
.
getMaxContentLength
();
if
(
maxContentLength
!=
null
)
{
NestedQueryBuilder
nestedQueryBuilder
=
QueryBuilders
.
nestedQuery
(
"sortField"
,
QueryBuilders
.
rangeQuery
(
"sortField.fieldLong"
).
lte
(
maxContentLength
),
ScoreMode
.
None
);
boolQuery
.
filter
(
nestedQueryBuilder
);
}
//时间过滤筛选-前端传参
//时间过滤筛选-前端传参
if
(
StringUtils
.
isNotBlank
(
searchCondition
.
getStartTime
()))
{
if
(
StringUtils
.
isNotBlank
(
searchCondition
.
getStartTime
()))
{
boolQuery
.
filter
(
QueryBuilders
.
rangeQuery
(
"publishDate"
).
gte
(
EsDateUtil
.
esFieldDateFormat
(
searchCondition
.
getStartTime
())));
boolQuery
.
filter
(
QueryBuilders
.
rangeQuery
(
"publishDate"
).
gte
(
EsDateUtil
.
esFieldDateFormat
(
searchCondition
.
getStartTime
())));
...
...
src/main/java/com/zzsn/event/service/InformationService.java
浏览文件 @
7abc41da
...
@@ -324,4 +324,22 @@ public interface InformationService {
...
@@ -324,4 +324,22 @@ public interface InformationService {
* @date 2025/4/23
* @date 2025/4/23
*/
*/
void
charReplace
(
InfoDataSearchCondition
searchCondition
);
void
charReplace
(
InfoDataSearchCondition
searchCondition
);
/**
* 打标签
*
* @param searchCondition 资讯检索条件
* @author lkg
* @date 2025/4/23
*/
void
markTag
(
InfoDataSearchCondition
searchCondition
);
/**
* 打标签
*
* @param searchCondition 资讯检索条件
* @author lkg
* @date 2025/4/23
*/
void
removeTag
(
InfoDataSearchCondition
searchCondition
);
}
}
src/main/java/com/zzsn/event/service/impl/InformationServiceImpl.java
浏览文件 @
7abc41da
...
@@ -1274,6 +1274,52 @@ public class InformationServiceImpl implements InformationService {
...
@@ -1274,6 +1274,52 @@ public class InformationServiceImpl implements InformationService {
esOpUtil
.
batchReplaceScript
(
indexArr
,
buildQuery
,
modifyFields
,
oldWord
,
newWord
);
esOpUtil
.
batchReplaceScript
(
indexArr
,
buildQuery
,
modifyFields
,
oldWord
,
newWord
);
}
}
@Override
public
void
markTag
(
InfoDataSearchCondition
searchCondition
)
{
List
<
String
>
subjectIdList
=
new
ArrayList
<>();
subjectIdList
.
add
(
searchCondition
.
getSubjectId
());
String
minCreateTime
=
subjectService
.
getMinCreateTime
(
subjectIdList
);
String
[]
indexArr
=
EsIndexUtil
.
getIndexIntervalYearStr
(
Constants
.
SUBJECT_INDEX
,
minCreateTime
);
List
<
String
>
ids
=
searchCondition
.
getIds
();
BoolQueryBuilder
buildQuery
;
if
(
CollectionUtils
.
isEmpty
(
ids
))
{
buildQuery
=
esService
.
buildQuery
(
searchCondition
,
subjectIdList
);
}
else
{
buildQuery
=
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
termsQuery
(
"id"
,
ids
));
}
Map
<
String
,
Object
>
addParams
=
new
HashMap
<>();
for
(
Label
markTag
:
searchCondition
.
getMarkTags
())
{
Map
<
String
,
String
>
addTag
=
ObjectUtil
.
objectToMap
(
markTag
);
addParams
.
put
(
"labels"
,
addTag
);
esOpUtil
.
batchNestedAddScript
(
indexArr
,
buildQuery
,
addParams
,
"labels"
,
"relationId"
);
}
}
@Override
public
void
removeTag
(
InfoDataSearchCondition
searchCondition
)
{
List
<
String
>
subjectIdList
=
new
ArrayList
<>();
subjectIdList
.
add
(
searchCondition
.
getSubjectId
());
String
minCreateTime
=
subjectService
.
getMinCreateTime
(
subjectIdList
);
String
[]
indexArr
=
EsIndexUtil
.
getIndexIntervalYearStr
(
Constants
.
SUBJECT_INDEX
,
minCreateTime
);
List
<
String
>
ids
=
searchCondition
.
getIds
();
BoolQueryBuilder
buildQuery
;
if
(
CollectionUtils
.
isEmpty
(
ids
))
{
buildQuery
=
esService
.
buildQuery
(
searchCondition
,
subjectIdList
);
}
else
{
buildQuery
=
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
termsQuery
(
"id"
,
ids
));
}
List
<
Label
>
markTags
=
searchCondition
.
getMarkTags
();
List
<
String
>
tagIds
=
markTags
.
stream
().
map
(
Label:
:
getRelationId
).
collect
(
Collectors
.
toList
());
buildQuery
.
must
(
QueryBuilders
.
nestedQuery
(
"labels"
,
QueryBuilders
.
termsQuery
(
"labels.relationId"
,
tagIds
),
ScoreMode
.
None
));
for
(
String
tagId
:
tagIds
)
{
Map
<
String
,
Object
>
deleteParams
=
new
HashMap
<>();
deleteParams
.
put
(
"relationId"
,
tagId
);
esOpUtil
.
batchNestedDeleteScript
(
indexArr
,
buildQuery
,
deleteParams
,
"labels"
);
}
}
private
void
formatLabel
(
List
<
LabelModelVo
>
labelModelVos
,
DisplayInfo
info
)
{
private
void
formatLabel
(
List
<
LabelModelVo
>
labelModelVos
,
DisplayInfo
info
)
{
if
(
CollectionUtils
.
isNotEmpty
(
labelModelVos
))
{
if
(
CollectionUtils
.
isNotEmpty
(
labelModelVos
))
{
List
<
Label
>
list
=
info
.
getLabels
();
List
<
Label
>
list
=
info
.
getLabels
();
...
...
src/main/java/com/zzsn/event/vo/InfoDataSearchCondition.java
浏览文件 @
7abc41da
...
@@ -76,7 +76,7 @@ public class InfoDataSearchCondition {
...
@@ -76,7 +76,7 @@ public class InfoDataSearchCondition {
//爬虫类型
//爬虫类型
private
String
crawler
;
private
String
crawler
;
//组合标签查询(不同类标签之间是与的关系,同一类标签之间是或的关系),示例: "a
,b;c,d;e,f
"
//组合标签查询(不同类标签之间是与的关系,同一类标签之间是或的关系),示例: "a
1,a2;c1,c2
"
private
String
composeSearchLabelIds
;
private
String
composeSearchLabelIds
;
/**----企业类标签筛选----**/
/**----企业类标签筛选----**/
...
@@ -120,6 +120,12 @@ public class InfoDataSearchCondition {
...
@@ -120,6 +120,12 @@ public class InfoDataSearchCondition {
//最大得分
//最大得分
private
Integer
maxScore
;
private
Integer
maxScore
;
//正文长度-研究中心
//最小长度
private
Integer
minContentLength
;
//最大长度
private
Integer
maxContentLength
;
//es查询字段数组
//es查询字段数组
private
String
[]
fetchFields
;
private
String
[]
fetchFields
;
//排除字段数组
//排除字段数组
...
@@ -178,4 +184,8 @@ public class InfoDataSearchCondition {
...
@@ -178,4 +184,8 @@ public class InfoDataSearchCondition {
/*-----字符串替换---start-------------------*/
/*-----字符串替换---start-------------------*/
private
String
replaceWord
;
private
String
replaceWord
;
/*------字符串替换---end-------------------*/
/*------字符串替换---end-------------------*/
/*-----打标签---start-------------------*/
private
List
<
Label
>
markTags
;
/*------打标签---end-------------------*/
}
}
src/main/java/com/zzsn/event/vo/es/DisplayInfo.java
浏览文件 @
7abc41da
...
@@ -44,6 +44,8 @@ public class DisplayInfo {
...
@@ -44,6 +44,8 @@ public class DisplayInfo {
private
String
summaryRaw
;
private
String
summaryRaw
;
//关键词
//关键词
private
String
keyWords
;
private
String
keyWords
;
//命中词列表
private
List
<
String
>
keyWordsList
;
//标题
//标题
private
String
title
;
private
String
title
;
private
String
titleRaw
;
private
String
titleRaw
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论