Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
E
event
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
陈世强
event
Commits
2a3aea33
提交
2a3aea33
authored
5月 10, 2025
作者:
925993793@qq.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
专题资讯列表和专题报告数据接口条件统一
上级
da59cb28
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
216 行增加
和
30 行删除
+216
-30
ReportDataController.java
...zsn/event/controller/reportData/ReportDataController.java
+157
-16
SearchCondition.java
...com/zzsn/event/controller/reportData/SearchCondition.java
+18
-6
EsService.java
src/main/java/com/zzsn/event/es/EsService.java
+29
-2
InfoDataSearchCondition.java
src/main/java/com/zzsn/event/vo/InfoDataSearchCondition.java
+12
-6
没有找到文件。
src/main/java/com/zzsn/event/controller/reportData/ReportDataController.java
浏览文件 @
2a3aea33
package
com
.
zzsn
.
event
.
controller
.
reportData
;
import
cn.hutool.core.net.URLDecoder
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson2.JSON
;
import
com.alibaba.fastjson2.JSONArray
;
import
com.alibaba.fastjson2.JSONObject
;
import
com.baomidou.mybatisplus.core.toolkit.CollectionUtils
;
import
com.google.common.base.Charsets
;
import
com.zzsn.event.constant.Constants
;
import
com.zzsn.event.constant.Result
;
import
com.zzsn.event.entity.SysDictItem
;
...
...
@@ -14,6 +19,7 @@ import com.zzsn.event.util.EsIndexUtil;
import
com.zzsn.event.util.FieldUtil
;
import
com.zzsn.event.vo.CountVO
;
import
com.zzsn.event.vo.es.Label
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.lucene.search.join.ScoreMode
;
import
org.elasticsearch.action.search.SearchRequest
;
...
...
@@ -50,6 +56,7 @@ import java.util.stream.Collectors;
* @author lkg
* @date 2025/4/9
*/
@Slf4j
@RestController
@RequestMapping
(
"/report/data/api"
)
public
class
ReportDataController
{
...
...
@@ -341,22 +348,6 @@ public class ReportDataController {
searchSourceBuilder
.
sort
(
"publishDate"
,
SortOrder
.
DESC
);
break
;
}
//审核状态
Integer
status
=
searchCondition
.
getStatus
();
if
(
status
!=
null
)
{
if
(
status
==
1
)
{
searchCondition
.
setCheckStatus
(
1
);
}
else
if
(
status
==
2
)
{
searchCondition
.
setCheckStatus
(
0
);
searchCondition
.
setDeleteFlag
(
0
);
}
else
if
(
status
==
3
)
{
searchCondition
.
setCheckStatus
(
3
);
}
else
if
(
status
==
4
)
{
searchCondition
.
setDeleteFlag
(
1
);
}
else
if
(
status
==
5
)
{
searchCondition
.
setIsFreeCheck
(
1
);
}
}
//构建es查询条件
BoolQueryBuilder
boolQuery
=
buildQuery
(
searchCondition
);
searchSourceBuilder
.
query
(
boolQuery
);
...
...
@@ -395,6 +386,27 @@ public class ReportDataController {
boolQuery
.
must
(
QueryBuilders
.
matchPhraseQuery
(
searchScope
,
searchWord
));
}
}
//高级查询数据处理
BoolQueryBuilder
superQuery
=
buildSuperQuery
(
searchCondition
.
getSuperQueryMatchType
(),
searchCondition
.
getSuperQueryParams
());
if
(
superQuery
!=
null
)
{
boolQuery
.
must
(
superQuery
);
}
//审核状态
Integer
status
=
searchCondition
.
getAuditStatus
();
if
(
status
!=
null
)
{
if
(
status
==
1
)
{
searchCondition
.
setCheckStatus
(
1
);
}
else
if
(
status
==
2
)
{
searchCondition
.
setCheckStatus
(
0
);
searchCondition
.
setDeleteFlag
(
0
);
}
else
if
(
status
==
3
)
{
searchCondition
.
setCheckStatus
(
3
);
}
else
if
(
status
==
4
)
{
searchCondition
.
setDeleteFlag
(
1
);
}
else
if
(
status
==
5
)
{
searchCondition
.
setIsFreeCheck
(
1
);
}
}
Integer
checkStatus
=
searchCondition
.
getCheckStatus
();
Integer
deleteFlag
=
searchCondition
.
getDeleteFlag
();
if
(
checkStatus
!=
null
)
{
...
...
@@ -509,4 +521,133 @@ public class ReportDataController {
String
minDate
=
subjectService
.
getMinCreateTime
(
subjectIdList
);
return
EsIndexUtil
.
getIndexIntervalYearStr
(
Constants
.
SUBJECT_INDEX
,
minDate
);
}
/**
* 高级检索条件封装
*
* @param superQueryMatchType 规则
* @param superQueryParams 条件(url转码后的json)
* @author lkg
* @date 2025/3/13
*/
private
BoolQueryBuilder
buildSuperQuery
(
String
superQueryMatchType
,
String
superQueryParams
)
{
if
(
StringUtils
.
isNotEmpty
(
superQueryParams
))
{
try
{
BoolQueryBuilder
superBuilder
=
QueryBuilders
.
boolQuery
();
String
params
=
URLDecoder
.
decode
(
superQueryParams
,
Charsets
.
UTF_8
);
JSONArray
array
=
JSON
.
parseArray
(
params
);
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
JSONObject
item
=
array
.
getJSONObject
(
i
);
BoolQueryBuilder
builder2
=
QueryBuilders
.
boolQuery
();
String
type
=
item
.
getString
(
"type"
);
String
rule
=
item
.
getString
(
"rule"
);
String
field
=
item
.
getString
(
"field"
);
String
val
=
item
.
getString
(
"val"
);
if
(
"date"
.
equals
(
type
))
{
//日期类型处理
if
(
"eq"
.
equals
(
rule
))
{
builder2
.
must
(
QueryBuilders
.
rangeQuery
(
field
).
from
(
val
+
"T00:00:00"
).
to
(
val
+
"T23:59:59"
));
}
if
(
"ne"
.
equals
(
rule
))
{
builder2
.
mustNot
(
QueryBuilders
.
rangeQuery
(
field
).
from
(
val
+
"T00:00:00"
).
to
(
val
+
"T23:59:59"
));
}
else
if
(
"gt"
.
equals
(
rule
))
{
builder2
.
must
(
QueryBuilders
.
rangeQuery
(
field
).
from
((
val
+
"T23:59:59"
)));
}
else
if
(
"ge"
.
equals
(
rule
))
{
builder2
.
must
(
QueryBuilders
.
rangeQuery
(
field
).
from
((
val
+
"T00:00:00"
)));
}
else
if
(
"lt"
.
equals
(
rule
))
{
builder2
.
must
(
QueryBuilders
.
rangeQuery
(
field
).
to
((
val
+
"T00:00:00"
)));
}
else
if
(
"le"
.
equals
(
rule
))
{
builder2
.
must
(
QueryBuilders
.
rangeQuery
(
field
).
to
((
val
+
"T23:59:59"
)));
}
}
else
if
(
"list"
.
equals
(
type
))
{
//列表(数组)类查询
if
(
"eq"
.
equals
(
rule
))
{
builder2
.
must
(
QueryBuilders
.
termQuery
(
field
+
".keyword"
,
val
));
}
else
if
(
"ne"
.
equals
(
rule
))
{
builder2
.
mustNot
(
QueryBuilders
.
termQuery
(
field
+
".keyword"
,
val
));
}
else
if
(
"in"
.
equals
(
rule
))
{
builder2
.
must
(
QueryBuilders
.
termsQuery
(
field
+
".keyword"
,
val
.
split
(
" |\\+|,|,|;|;"
)));
}
else
if
(
"not_in"
.
equals
(
rule
))
{
builder2
.
mustNot
(
QueryBuilders
.
termsQuery
(
field
+
".keyword"
,
val
.
split
(
" |\\+|,|,|;|;"
)));
}
else
if
(
"keyWordsGroup"
.
equals
(
rule
))
{
if
(
StringUtils
.
isNotEmpty
(
val
))
{
BoolQueryBuilder
wordAllBoolQuery
=
QueryBuilders
.
boolQuery
();
String
[]
andWords
=
val
.
split
(
"\\+"
);
for
(
String
words
:
andWords
)
{
String
replace
=
words
.
replace
(
"("
,
""
).
replace
(
")"
,
""
);
BoolQueryBuilder
wordOrBoolQuery
=
QueryBuilders
.
boolQuery
();
for
(
String
word
:
replace
.
split
(
"\\|"
))
{
wordOrBoolQuery
.
should
(
QueryBuilders
.
termQuery
(
field
+
".keyword"
,
word
));
}
wordAllBoolQuery
.
must
(
wordOrBoolQuery
);
}
builder2
.
must
(
wordAllBoolQuery
);
}
}
}
else
if
(
"string"
.
equals
(
type
))
{
//文本类查询
if
(
"fullText"
.
equals
(
field
))
{
BoolQueryBuilder
fullTextBoolQuery
=
multiMatchQuery
(
val
);
if
(
"like"
.
equals
(
rule
))
{
builder2
.
must
(
fullTextBoolQuery
);
}
else
if
(
"not_like"
.
equals
(
rule
))
{
builder2
.
mustNot
(
fullTextBoolQuery
);
}
else
if
(
"keyWordsGroup"
.
equals
(
rule
))
{
BoolQueryBuilder
wordAllBoolQuery
=
QueryBuilders
.
boolQuery
();
String
[]
andWords
=
val
.
split
(
"\\+"
);
for
(
String
words
:
andWords
)
{
String
replace
=
words
.
replace
(
"("
,
""
).
replace
(
")"
,
""
);
BoolQueryBuilder
wordOrBoolQuery
=
QueryBuilders
.
boolQuery
();
for
(
String
word
:
replace
.
split
(
"\\|"
))
{
wordOrBoolQuery
.
should
(
multiMatchQuery
(
word
));
}
wordAllBoolQuery
.
must
(
wordOrBoolQuery
);
}
builder2
.
must
(
wordAllBoolQuery
);
}
}
else
if
(
"eq"
.
equals
(
rule
))
{
builder2
.
must
(
QueryBuilders
.
termQuery
(
field
+
".keyword"
,
val
));
}
else
if
(
"ne"
.
equals
(
rule
))
{
builder2
.
mustNot
(
QueryBuilders
.
termQuery
(
field
+
".keyword"
,
val
));
}
else
if
(
"in"
.
equals
(
rule
))
{
builder2
.
must
(
QueryBuilders
.
termsQuery
(
field
+
".keyword"
,
val
.
split
(
" |\\+|,|,|;|;"
)));
}
else
if
(
"not_in"
.
equals
(
rule
))
{
builder2
.
mustNot
(
QueryBuilders
.
termsQuery
(
field
+
".keyword"
,
val
.
split
(
" |\\+|,|,|;|;"
)));
}
else
if
(
"like"
.
equals
(
rule
))
{
builder2
.
must
(
QueryBuilders
.
matchPhrasePrefixQuery
(
field
,
val
));
}
else
if
(
"not_like"
.
equals
(
rule
))
{
builder2
.
mustNot
(
QueryBuilders
.
matchPhrasePrefixQuery
(
field
,
val
));
}
else
if
(
"keyWordsGroup"
.
equals
(
rule
))
{
BoolQueryBuilder
wordAllBoolQuery
=
QueryBuilders
.
boolQuery
();
String
[]
andWords
=
val
.
split
(
"\\+"
);
for
(
String
words
:
andWords
)
{
String
replace
=
words
.
replace
(
"("
,
""
).
replace
(
")"
,
""
);
BoolQueryBuilder
wordOrBoolQuery
=
QueryBuilders
.
boolQuery
();
for
(
String
word
:
replace
.
split
(
"\\|"
))
{
wordOrBoolQuery
.
should
(
QueryBuilders
.
matchPhraseQuery
(
field
,
word
));
}
wordAllBoolQuery
.
must
(
wordOrBoolQuery
);
}
builder2
.
must
(
wordAllBoolQuery
);
}
}
if
(
"or"
.
equals
(
superQueryMatchType
))
{
superBuilder
.
should
(
builder2
);
}
else
{
superBuilder
.
must
(
builder2
);
}
}
return
superBuilder
;
}
catch
(
Exception
e
)
{
log
.
error
(
"高级查询条件封装失败,e:{},params:{}"
,
e
.
getMessage
(),
superQueryParams
);
}
}
return
null
;
}
private
BoolQueryBuilder
multiMatchQuery
(
String
word
)
{
BoolQueryBuilder
fullTextBoolQuery
=
QueryBuilders
.
boolQuery
();
String
[]
fullTextFields
=
new
String
[]{
"title"
,
"summary"
,
"content"
};
for
(
String
fullTextField
:
fullTextFields
)
{
fullTextBoolQuery
.
should
(
QueryBuilders
.
matchPhraseQuery
(
fullTextField
,
word
));
}
return
fullTextBoolQuery
;
}
}
src/main/java/com/zzsn/event/controller/reportData/SearchCondition.java
浏览文件 @
2a3aea33
...
...
@@ -22,6 +22,13 @@ public class SearchCondition {
@FieldDescription
(
value
=
"搜索词"
)
private
String
searchWord
;
/*------高级查询条件---start-------------------*/
//规则
private
String
superQueryMatchType
;
//条件(url转码后的json)
private
String
superQueryParams
;
/*------高级查询条件---end-------------------*/
//开始时间
@JsonFormat
(
timezone
=
"GMT+8"
,
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
...
...
@@ -36,14 +43,15 @@ public class SearchCondition {
@FieldDescription
(
value
=
"专题库类型"
)
private
List
<
Integer
>
classificationType
;
/**原创性(0-非原创;1-原创;2-疑似)*/
/**
* 原创性(0-非原创;1-原创;2-疑似)
*/
@FieldDescription
(
value
=
"原创性"
)
private
String
originality
;
//审核状态(1-通过;2-未审核;3-暂定;4-删除;5-免审核)
//审核状态(
null-全部;
1-通过;2-未审核;3-暂定;4-删除;5-免审核)
@FieldDescription
(
value
=
"审核状态"
)
private
Integer
status
;
private
Integer
auditStatus
;
//审核操作(0:未审核 1:审核通过 2:审核未通过 3:暂定 默认值为0)
private
Integer
checkStatus
;
//删除标记(1:删除;0:未删除)
...
...
@@ -59,14 +67,18 @@ public class SearchCondition {
@FieldDescription
(
value
=
"组合标签查询"
)
private
String
composeSearchLabelIds
;
/**----企业类标签筛选----**/
/**
* ----企业类标签筛选----
**/
//企业类标签id集合
@FieldDescription
(
value
=
"企业类标签id集合"
)
private
List
<
String
>
enterpriseLabelTypeIds
;
//企业信用代码集合
@FieldDescription
(
value
=
"企业信用代码集合"
)
private
List
<
String
>
socialCreditCodeList
;
/**----企业类标签id集合----**/
/**
* ----企业类标签id集合----
**/
//专题关联标签值id集合
@FieldDescription
(
value
=
"专题关联标签值id集合"
)
private
List
<
String
>
labelIds
;
...
...
src/main/java/com/zzsn/event/es/EsService.java
浏览文件 @
2a3aea33
...
...
@@ -2132,7 +2132,18 @@ public class EsService {
if
(
CollectionUtils
.
isNotEmpty
(
searchWordList
))
{
handlerSearchWordList
(
boolQuery
,
searchWordList
);
}
else
{
//平台 搜索词方式
if
(
StringUtils
.
isNotEmpty
(
searchCondition
.
getSearch
()))
{
String
searchScope
=
searchCondition
.
getSearchScope
();
String
searchWord
=
searchCondition
.
getSearchWord
();
if
(
StringUtils
.
isNotEmpty
(
searchWord
))
{
if
(
"all"
.
equalsIgnoreCase
(
searchScope
))
{
MultiMatchQueryBuilder
multiMatchQuery
=
QueryBuilders
.
multiMatchQuery
(
searchWord
,
"title"
,
"content"
,
"origin"
);
multiMatchQuery
.
type
(
MultiMatchQueryBuilder
.
Type
.
PHRASE
);
boolQuery
.
must
(
multiMatchQuery
);
}
else
{
boolQuery
.
must
(
QueryBuilders
.
matchPhraseQuery
(
searchScope
,
searchWord
));
}
}
/*if (StringUtils.isNotEmpty(searchCondition.getSearch())) {
boolQuery.must(QueryBuilders.multiMatchQuery(searchCondition.getSearch(), "title", "content"));
}
if (StringUtils.isNotEmpty(searchCondition.getContent())) {
...
...
@@ -2149,7 +2160,7 @@ public class EsService {
MatchPhraseQueryBuilder relationNameQuery = QueryBuilders.matchPhraseQuery("labels.relationName", searchCondition.getLabelName());
nestedBoolQueryBuilder.should(QueryBuilders.nestedQuery("labels", relationNameQuery, ScoreMode.None));
boolQuery.must(nestedBoolQueryBuilder);
}
}
*/
}
if
(
searchCondition
.
getLabelMark
()
!=
null
)
{
BoolQueryBuilder
nestedBoolQueryBuilder
=
QueryBuilders
.
boolQuery
();
...
...
@@ -2174,6 +2185,22 @@ public class EsService {
boolQuery
.
must
(
QueryBuilders
.
termQuery
(
"deleteFlag"
,
1
));
}
}
else
{
//审核状态-平台(null-全部;1-通过;2-未审核;3-暂定;4-删除;5-免审核)
Integer
auditStatus
=
searchCondition
.
getAuditStatus
();
if
(
auditStatus
!=
null
)
{
if
(
auditStatus
==
1
)
{
searchCondition
.
setCheckStatus
(
1
);
}
else
if
(
auditStatus
==
2
)
{
searchCondition
.
setCheckStatus
(
0
);
searchCondition
.
setDeleteFlag
(
0
);
}
else
if
(
auditStatus
==
3
)
{
searchCondition
.
setCheckStatus
(
3
);
}
else
if
(
auditStatus
==
4
)
{
searchCondition
.
setDeleteFlag
(
1
);
}
else
if
(
auditStatus
==
5
)
{
searchCondition
.
setIsFreeCheck
(
1
);
}
}
Integer
checkStatus
=
searchCondition
.
getCheckStatus
();
Integer
deleteFlag
=
searchCondition
.
getDeleteFlag
();
if
(
checkStatus
!=
null
)
{
...
...
src/main/java/com/zzsn/event/vo/InfoDataSearchCondition.java
浏览文件 @
2a3aea33
...
...
@@ -25,12 +25,18 @@ public class InfoDataSearchCondition {
//内容
private
String
content
;
//发布时间
private
String
publishDate
;
//来源
private
String
origin
;
//搜索范围(all、title、content、origin)
private
String
searchScope
;
//搜索词
private
String
searchWord
;
//发布时间
private
String
publishDate
;
//开始时间
private
String
startTime
;
...
...
@@ -50,15 +56,15 @@ public class InfoDataSearchCondition {
/**原创性(0-非原创;1-原创;2-疑似)*/
private
String
originality
;
//资讯状态-研究中心(0-全部;1-模型推荐;2-精选;3-待定;4-移除),和
checkStatus、deleteFlag、isFreeCheck
互斥
//资讯状态-研究中心(0-全部;1-模型推荐;2-精选;3-待定;4-移除),和
auditStatus
互斥
private
Integer
status
;
//平台-审核状态(null-全部;1-通过;2-未审核;3-暂定;4-删除;5-免审核)
private
Integer
auditStatus
;
//审核操作(0:未审核 1:审核通过 2:审核未通过 3:暂定 默认值为0)
private
Integer
checkStatus
;
//删除标记(1:删除;0:未删除)
private
Integer
deleteFlag
;
//是否免审核(1-是;0-否)
private
Integer
isFreeCheck
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论