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
5aa497e3
Commit
5aa497e3
authored
Nov 07, 2023
by
赵剑炜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加了装备类别的模糊查询
parent
ef262676
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
82 行增加
和
32 行删除
+82
-32
EquipmentTypeDto.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/dto/EquipmentTypeDto.java
+6
-0
OrgDto.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/dto/OrgDto.java
+1
-0
EquipmentTypeController.java
jyzb-biz/src/main/java/com/junmp/jyzb/controller/EquipmentTypeController.java
+6
-1
EquipmentType.java
jyzb-biz/src/main/java/com/junmp/jyzb/entity/EquipmentType.java
+2
-0
EquipmentTypeService.java
jyzb-biz/src/main/java/com/junmp/jyzb/service/EquipmentTypeService.java
+1
-1
EquipmentTypeServiceImpl.java
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/EquipmentTypeServiceImpl.java
+60
-25
PubOrgServiceImpl.java
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/PubOrgServiceImpl.java
+3
-2
ElasticsearchUtil.java
jyzb-biz/src/main/java/com/junmp/jyzb/utils/ElasticsearchUtil.java
+3
-3
没有找到文件。
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/dto/EquipmentTypeDto.java
View file @
5aa497e3
...
...
@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.ArrayList
;
import
java.util.List
;
@Data
...
...
@@ -22,4 +23,9 @@ public class EquipmentTypeDto {
private
Boolean
isLeaf
;
private
List
<
String
>
supplierList
;
private
String
photo
;
private
List
<
EquipmentTypeDto
>
children
=
new
ArrayList
<>();
public
void
addChild
(
EquipmentTypeDto
child
)
{
children
.
add
(
child
);
}
}
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/dto/OrgDto.java
View file @
5aa497e3
...
...
@@ -12,6 +12,7 @@ public class OrgDto {
private
String
orgCode
;
private
Integer
isDepartment
;
private
Long
orgParentId
;
private
String
orgParentIds
;
private
String
areaName
;
private
String
levelFlag
;
private
String
dName
;
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/controller/EquipmentTypeController.java
View file @
5aa497e3
...
...
@@ -15,6 +15,7 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.util.List
;
@RestController
...
...
@@ -49,7 +50,11 @@ public class EquipmentTypeController {
public
ApiRes
<
List
<
EquipmentTypeDto
>>
ShowEquipmentList
(
@RequestBody
QueryEquipmentTypeReq
req
)
{
return
ApiRes
.
success
(
equipmentTypeService
.
getEquipmentList
(
req
));
}
@PostMapping
(
"/ShowEquipmentESList"
)
@ApiOperation
(
"通过ES模糊检索类别列表"
)
public
ApiRes
<
List
<
EquipmentTypeDto
>>
ShowEquipmentESList
(
@RequestBody
QueryEquipmentTypeReq
req
)
throws
IOException
{
return
ApiRes
.
success
(
equipmentTypeService
.
getTypeTreeByEs
(
req
));
}
@PostMapping
(
"/GetEquipmentDetail"
)
@ApiOperation
(
"查询单个物资信息"
)
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/entity/EquipmentType.java
View file @
5aa497e3
package
com
.
junmp
.
jyzb
.
entity
;
import
com.baomidou.mybatisplus.annotation.*
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serializable
;
...
...
@@ -17,6 +18,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
@NoArgsConstructor
@TableName
(
"base_equipment_type"
)
@Document
(
indexName
=
"type_pinyin"
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
EquipmentType
implements
Serializable
{
/**
* 装备类型ID
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/service/EquipmentTypeService.java
View file @
5aa497e3
...
...
@@ -25,7 +25,7 @@ public interface EquipmentTypeService extends IService<EquipmentType> {
List
<
EquipmentTypeDto
>
getLowType
(
QueryEquipmentTypeReq
orgId
);
ResponseResult
setTypeParentIds
();
List
<
EquipmentTypeDto
>
getTypeTreeByEs
(
Query
Org
Req
req
)
throws
IOException
;
List
<
EquipmentTypeDto
>
getTypeTreeByEs
(
Query
EquipmentType
Req
req
)
throws
IOException
;
List
<
EquipmentTreeDto
>
GetTypeTree
();
}
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/EquipmentTypeServiceImpl.java
View file @
5aa497e3
...
...
@@ -271,36 +271,71 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
return
new
ResponseResult
(
HttpStatus
.
SUCCESS
,
ReturnMsg
.
PASS
);
}
@Override
public
List
<
EquipmentTypeDto
>
getTypeTreeByEs
(
QueryOrgReq
req
)
throws
IOException
{
return
null
;
public
List
<
EquipmentTypeDto
>
getTypeTreeByEs
(
QueryEquipmentTypeReq
req
)
throws
IOException
{
ElasticsearchUtil
es
=
new
ElasticsearchUtil
<>(
client
);
// 先从ES中拿到检索数据
List
<
EquipmentType
>
searchResults
=
es
.
searchEntities
(
"type_pinyin"
,
"name"
,
0
,
10
,
req
.
getTypeName
(),
EquipmentType
.
class
);
LambdaQueryWrapper
<
EquipmentType
>
wp
=
this
.
createWrapper
(
req
);
// 获取所有组织机构数据
List
<
EquipmentType
>
allTypes
=
this
.
list
(
wp
);
List
<
EquipmentTypeDto
>
treeResult
=
buildTypeTree
(
searchResults
,
allTypes
);
return
treeResult
;
}
public
List
<
EquipmentTypeDto
>
buildTypeTree
(
List
<
EquipmentType
>
searchResults
,
List
<
EquipmentType
>
allTypes
)
{
Map
<
String
,
EquipmentTypeDto
>
typeDtoMap
=
new
HashMap
<>();
public
List
<
EquipmentTypeDto
>
getTypeTreeByEs
(
QueryEquipmentTypeReq
req
)
throws
IOException
{
// LambdaQueryWrapper<EquipmentType> wp = this.createWrapper(req);
// ElasticsearchUtil esUtil=new ElasticsearchUtil<>(client);
// // 1. 从 Elasticsearch 中搜索组织机构数据
// List<EquipmentType> searchResults = esUtil.searchEntities("name","type_pinyin",0, 20, req.getTypeName(),EquipmentType.class);
// // 2. 从数据库中获取完整的组织机构数据
// List<EquipmentType> fullOrgData = this.list(wp);
//
// // 3. 构建树状结构
// List<OrgDto> tree = new ArrayList<>();
// for (PubOrg searchResult : searchResults) {
// // 在完整数据中查找匹配的组织机构
// PubOrg fullOrg = findOrgById(fullOrgData, searchResult.getOrgId());
//
// // 将完整数据转换为前端需要的 DTO
// OrgDto orgDto = convertToDto(fullOrg, fullOrgData);
//
// // TODO: 根据需求决定是否加入树状结构
// tree.add(orgDto);
// }
// return tree;
return
null
;
// 将所有组织机构转换为OrgDto并放入map中
for
(
EquipmentType
type
:
allTypes
)
{
EquipmentTypeDto
typeDto
=
new
EquipmentTypeDto
();
BeanPlusUtil
.
copyProperties
(
type
,
typeDto
);
// 其他字段的映射...
// 将OrgDto放入map中,以orgId为键
typeDtoMap
.
put
(
typeDto
.
getId
(),
typeDto
);
}
List
<
EquipmentTypeDto
>
tree
=
new
ArrayList
<>();
// 遍历所有搜索到的组织机构数据,构建树
for
(
EquipmentType
searchResult
:
searchResults
)
{
EquipmentTypeDto
typeDto
=
typeDtoMap
.
get
(
searchResult
.
getId
());
// 如果找到对应的OrgDto
if
(
typeDto
!=
null
&&
!
tree
.
contains
(
typeDto
))
{
// 从当前节点开始,依次向上查找上级节点,直到最顶层
String
parentId
=
typeDto
.
getParentId
();
// 将当前节点及其相关节点加入树中
while
(
parentId
!=
null
)
{
EquipmentTypeDto
parentDto
=
typeDtoMap
.
get
(
parentId
);
if
(
parentDto
!=
null
)
{
// 将当前节点添加到上级节点的children中,确保不重复添加
if
(!
parentDto
.
getChildren
().
contains
(
typeDto
))
{
parentDto
.
getChildren
().
add
(
typeDto
);
}
// 如果上级节点是最顶层,将上级节点添加到树中,确保不重复添加
if
(
parentDto
.
getParentId
().
equals
(
"00000000-0000-0000-0000-000000000000"
)
&&
parentDto
.
getId
()!=
"00000000-0000-0000-0000-000000000000"
&&
!
tree
.
contains
(
parentDto
))
{
tree
.
add
(
parentDto
);
}
// 将上级节点设为当前节点,继续向上查找
typeDto
=
parentDto
;
parentId
=
typeDto
.
getParentId
();
}
else
{
parentId
=
null
;
// 上级节点不存在,跳出循环
}
}
}
}
return
tree
;
}
//获取整棵type树
public
List
<
EquipmentTreeDto
>
GetTypeTree
()
{
List
<
EquipmentType
>
list
=
list
(
new
LambdaQueryWrapper
<
EquipmentType
>()
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/PubOrgServiceImpl.java
View file @
5aa497e3
...
...
@@ -394,11 +394,11 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem
// 添加 MatchQueryBuilder 作为 must 条件
MatchQueryBuilder
matchQueryBuilder
=
QueryBuilders
.
matchQuery
(
"orgName"
,
keyword
).
operator
(
Operator
.
AND
);
//
MatchQueryBuilder matchQueryBuilder2 = QueryBuilders.matchQuery("orgName.pinyin", keyword).operator(Operator.AND);
MatchQueryBuilder
matchQueryBuilder2
=
QueryBuilders
.
matchQuery
(
"orgName.pinyin"
,
keyword
).
operator
(
Operator
.
AND
);
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
boolQueryBuilder
.
should
(
matchQueryBuilder
);
//
boolQueryBuilder.should(matchQueryBuilder2);
boolQueryBuilder
.
should
(
matchQueryBuilder2
);
// 添加过滤条件,只获取 delFlag 为 1 的数据
builder
.
postFilter
(
QueryBuilders
.
termQuery
(
"delFlag"
,
1
));
...
...
@@ -447,6 +447,7 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem
orgDto
.
setLevelFlag
(
String
.
valueOf
(
org
.
getLevelFlag
()));
orgDto
.
setStatusFlag
(
org
.
getStatusFlag
());
orgDto
.
setDName
(
org
.
getDName
());
orgDto
.
setOrgParentIds
(
org
.
getOrgParentIds
());
// 其他字段的映射...
// 将OrgDto放入map中,以orgId为键
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/utils/ElasticsearchUtil.java
View file @
5aa497e3
...
...
@@ -28,14 +28,14 @@ public class ElasticsearchUtil<T> {
public
List
<
T
>
searchEntities
(
String
typeName
,
String
index
,
Integer
pageNum
,
Integer
pageSize
,
String
keyword
,
Class
<
T
>
entityClass
)
throws
IOException
{
if
(
pageNum
<
0
)
pageNum
=
0
;
SearchRequest
request
=
new
SearchRequest
(
index
);
SearchRequest
request
=
new
SearchRequest
(
typeName
);
SearchSourceBuilder
builder
=
new
SearchSourceBuilder
();
builder
.
from
(
pageNum
);
builder
.
size
(
pageSize
);
MatchQueryBuilder
matchQueryBuilder
=
QueryBuilders
.
matchQuery
(
typeName
,
keyword
).
operator
(
Operator
.
AND
);
MatchQueryBuilder
matchQueryBuilder2
=
QueryBuilders
.
matchQuery
(
typeName
+
".pinyin"
,
keyword
).
operator
(
Operator
.
AND
);
MatchQueryBuilder
matchQueryBuilder
=
QueryBuilders
.
matchQuery
(
index
,
keyword
).
operator
(
Operator
.
AND
);
MatchQueryBuilder
matchQueryBuilder2
=
QueryBuilders
.
matchQuery
(
index
+
".pinyin"
,
keyword
).
operator
(
Operator
.
AND
);
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
boolQueryBuilder
.
should
(
matchQueryBuilder
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论