Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jyzb_platformV2
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
赵剑炜
jyzb_platformV2
Commits
36328a71
Commit
36328a71
authored
Dec 25, 2023
by
赵剑炜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化查询
parent
dbd8c2d0
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
29 行增加
和
1 行删除
+29
-1
EquipmentTypeServiceImpl.java
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/EquipmentTypeServiceImpl.java
+2
-1
ElasticsearchUtil.java
jyzb-biz/src/main/java/com/junmp/jyzb/utils/ElasticsearchUtil.java
+27
-0
没有找到文件。
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/EquipmentTypeServiceImpl.java
View file @
36328a71
...
@@ -291,7 +291,8 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
...
@@ -291,7 +291,8 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
List
<
EquipmentType
>
searchResults
=
es
.
searchEntities
(
"type_pinyin"
,
req
.
getNickName
(),
"name"
,
0
,
50
,
req
.
getType
(),
req
.
getTypeName
(),
req
.
getSearchType
(),
EquipmentType
.
class
);
List
<
EquipmentType
>
searchResults
=
es
.
searchEntities
(
"type_pinyin"
,
req
.
getNickName
(),
"name"
,
0
,
50
,
req
.
getType
(),
req
.
getTypeName
(),
req
.
getSearchType
(),
EquipmentType
.
class
);
LambdaQueryWrapper
<
EquipmentType
>
wp
=
this
.
createWrapper
(
req
);
LambdaQueryWrapper
<
EquipmentType
>
wp
=
this
.
createWrapper
(
req
);
// 获取所有组织机构数据
// 获取所有组织机构数据
List
<
EquipmentType
>
allTypes
=
this
.
list
(
wp
);
List
<
EquipmentType
>
allTypes
=
es
.
searchAll
(
"type_pinyin"
,
0
,
3000
,
null
,
EquipmentType
.
class
);
// List<EquipmentType> allTypes = this.list(wp);
List
<
EquipmentTypeDto
>
treeResult
=
buildTypeTree
(
searchResults
,
allTypes
);
List
<
EquipmentTypeDto
>
treeResult
=
buildTypeTree
(
searchResults
,
allTypes
);
ESTypeDto
resultDto
=
new
ESTypeDto
();
ESTypeDto
resultDto
=
new
ESTypeDto
();
resultDto
.
setTypeDto
(
treeResult
);
resultDto
.
setTypeDto
(
treeResult
);
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/utils/ElasticsearchUtil.java
View file @
36328a71
...
@@ -27,6 +27,33 @@ public class ElasticsearchUtil<T> {
...
@@ -27,6 +27,33 @@ public class ElasticsearchUtil<T> {
this
.
client
=
client
;
this
.
client
=
client
;
}
}
public
List
<
T
>
searchAll
(
String
typeName
,
Integer
pageNum
,
Integer
pageSize
,
Integer
type
,
Class
<
T
>
entityClass
)
throws
IOException
{
if
(
pageNum
<
0
)
pageNum
=
0
;
SearchRequest
request
=
new
SearchRequest
(
typeName
);
SearchSourceBuilder
builder
=
new
SearchSourceBuilder
();
builder
.
from
(
pageNum
);
builder
.
size
(
pageSize
);
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
boolQueryBuilder
.
mustNot
(
QueryBuilders
.
matchQuery
(
"name"
,
"超级根"
));
builder
.
query
(
boolQueryBuilder
);
builder
.
timeout
(
new
TimeValue
(
60
,
TimeUnit
.
SECONDS
));
request
.
source
(
builder
);
SearchResponse
searchResponse
=
client
.
search
(
request
,
RequestOptions
.
DEFAULT
);
List
<
T
>
entityList
=
new
ArrayList
<>();
for
(
SearchHit
documentFields
:
searchResponse
.
getHits
().
getHits
())
{
Map
<
String
,
Object
>
sourceAsMap
=
documentFields
.
getSourceAsMap
();
T
entity
=
fromMap
(
sourceAsMap
,
entityClass
);
entityList
.
add
(
entity
);
}
return
entityList
;
}
public
List
<
T
>
searchEntities
(
String
typeName
,
String
nickName
,
String
index
,
Integer
pageNum
,
Integer
pageSize
,
Integer
type
,
String
keyword
,
String
searchType
,
Class
<
T
>
entityClass
)
throws
IOException
{
public
List
<
T
>
searchEntities
(
String
typeName
,
String
nickName
,
String
index
,
Integer
pageNum
,
Integer
pageSize
,
Integer
type
,
String
keyword
,
String
searchType
,
Class
<
T
>
entityClass
)
throws
IOException
{
if
(
pageNum
<
0
)
pageNum
=
0
;
if
(
pageNum
<
0
)
pageNum
=
0
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论