Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
4c68fcc1
Commit
4c68fcc1
authored
May 15, 2024
by
李秀明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pref: 消防建筑建筑左侧公司建筑树查询接口性能优化
parent
83aeaae1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
25 deletions
+36
-25
BuildingServiceImpl.java
...yeejoin/equipmanage/service/impl/BuildingServiceImpl.java
+36
-25
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/BuildingServiceImpl.java
View file @
4c68fcc1
...
@@ -64,6 +64,7 @@ import java.io.IOException;
...
@@ -64,6 +64,7 @@ import java.io.IOException;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -541,12 +542,14 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
...
@@ -541,12 +542,14 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
}
}
private
List
<
BuildingTreeVo
>
getBuildingTreeVos
(
Boolean
isContainRootNode
,
String
bizOrgCode
)
{
private
List
<
BuildingTreeVo
>
getBuildingTreeVos
(
Boolean
isContainRootNode
,
String
bizOrgCode
)
{
FormGroup
formGroup
=
iFormGroupService
.
getByUniqueKey
(
GroupCodeEnum
.
ALL_BUILDING
.
getGroupCode
());
CompletableFuture
<
FormGroup
>
formGroupFuture
=
CompletableFuture
.
supplyAsync
(()
->
iFormGroupService
.
getByUniqueKey
(
GroupCodeEnum
.
ALL_BUILDING
.
getGroupCode
()));
List
<
Map
<
String
,
Object
>>
allList
=
iFormInstanceService
.
getSpecialChildrenList
(
null
,
bizOrgCode
);
CompletableFuture
<
List
<
Map
<
String
,
Object
>>
>
allListFuture
=
CompletableFuture
.
supplyAsync
(()
->
iFormInstanceService
.
getSpecialChildrenList
(
null
,
bizOrgCode
));
List
<
BuildingTreeVo
>
allListVo
=
buildBuildingData
(
formGroup
,
allList
,
isContainRootNode
);
return
CompletableFuture
.
allOf
(
formGroupFuture
,
allListFuture
).
thenApply
(
v
->
{
Map
<
Long
,
String
>
absolutePositionMap
=
getBuildingAbsolutePosition
(
allListVo
);
List
<
BuildingTreeVo
>
allListVo
=
buildBuildingData
(
formGroupFuture
.
join
(),
allListFuture
.
join
(),
isContainRootNode
);
allListVo
.
forEach
(
s
->
s
.
setAbsolutePosition
(
absolutePositionMap
.
get
(
s
.
getId
())));
Map
<
Long
,
String
>
absolutePositionMap
=
getBuildingAbsolutePosition
(
allListVo
);
return
allListVo
;
allListVo
.
forEach
(
s
->
s
.
setAbsolutePosition
(
absolutePositionMap
.
get
(
s
.
getId
())));
return
allListVo
;
}).
join
();
}
}
...
@@ -1309,10 +1312,16 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
...
@@ -1309,10 +1312,16 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
@Override
@Override
public
Map
<
Long
,
String
>
getBuildingAbsolutePosition
()
{
public
Map
<
Long
,
String
>
getBuildingAbsolutePosition
()
{
FormGroup
formGroup
=
iFormGroupService
.
getByUniqueKey
(
GroupCodeEnum
.
ALL_BUILDING
.
getGroupCode
());
CompletableFuture
<
FormGroup
>
formGroupCompletableFuture
=
CompletableFuture
.
supplyAsync
(()
->
List
<
Map
<
String
,
Object
>>
allList
=
iFormInstanceService
.
getSpecialChildrenList
(
null
,
null
);
iFormGroupService
.
getByUniqueKey
(
GroupCodeEnum
.
ALL_BUILDING
.
getGroupCode
())
List
<
BuildingTreeVo
>
allListVo
=
buildBuildingData
(
formGroup
,
allList
,
true
);
);
return
getBuildingAbsolutePosition
(
allListVo
);
CompletableFuture
<
List
<
Map
<
String
,
Object
>>>
allListCompletableFuture
=
CompletableFuture
.
supplyAsync
(()
->
iFormInstanceService
.
getSpecialChildrenList
(
null
,
null
)
);
return
formGroupCompletableFuture
.
thenCombine
(
allListCompletableFuture
,
(
formGroup
,
allList
)
->
{
List
<
BuildingTreeVo
>
allListVo
=
buildBuildingData
(
formGroup
,
allList
,
true
);
return
getBuildingAbsolutePosition
(
allListVo
);
}).
join
();
}
}
@Override
@Override
...
@@ -1418,23 +1427,25 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
...
@@ -1418,23 +1427,25 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
//1.组装数据
//1.组装数据
List
<
BuildingTreeVo
>
companyBuildingList
=
buildBuildingAndCompanyListVos
(
authKey
,
type
,
"building"
);
List
<
BuildingTreeVo
>
companyBuildingList
=
buildBuildingAndCompanyListVos
(
authKey
,
type
,
"building"
);
//2.list to tree
//2.list to tree
List
<
BuildingTreeVo
>
buildingTreeVos
=
companyBuildingList
.
stream
().
filter
(
a
->
companyBuildingList
.
stream
().
noneMatch
(
c
->
c
.
getId
().
toString
().
equals
(
a
.
getParentId
()))).
peek
(
b
->
b
.
setChildren
(
getCompanyBuildingChildrenTree
(
b
.
getId
().
toString
(),
companyBuildingList
))).
collect
(
Collectors
.
toList
());
List
<
BuildingTreeVo
>
buildingTreeVos
=
companyBuildingList
.
parallelStream
()
.
filter
(
a
->
companyBuildingList
.
stream
().
noneMatch
(
c
->
c
.
getId
().
toString
().
equals
(
a
.
getParentId
()))
).
peek
(
b
->
b
.
setChildren
(
getCompanyBuildingChildrenTree
(
b
.
getId
().
toString
(),
companyBuildingList
))
).
collect
(
Collectors
.
toList
());
// 任务 7481
// 任务 7481
if
(
buildingTreeVos
.
size
()
==
1
&&
buildingTreeVos
.
get
(
0
).
getChildren
().
size
()
>
0
)
{
if
(
buildingTreeVos
.
size
()
==
1
&&
!
CollectionUtils
.
isEmpty
(
buildingTreeVos
.
get
(
0
).
getChildren
()))
{
List
<
BuildingTreeVo
>
buildingTreeVosNew
=
buildingTreeVos
.
get
(
0
).
getChildren
().
stream
().
sorted
(
new
Comparator
<
BuildingTreeVo
>()
{
List
<
BuildingTreeVo
>
buildingTreeVosNew
=
buildingTreeVos
.
get
(
0
).
getChildren
().
stream
().
sorted
((
o1
,
o2
)
->
{
@Override
if
(
o1
.
getGroupType
().
equals
(
o2
.
getGroupType
()))
{
public
int
compare
(
BuildingTreeVo
o1
,
BuildingTreeVo
o2
)
{
if
(
o1
.
getGroupType
().
equals
(
o2
.
getGroupType
()))
{
return
0
;
}
if
(
o1
.
getGroupType
().
equals
(
"building"
)
)
{
return
-
1
;
}
if
(
o2
.
getGroupType
().
equals
(
"building"
)
)
{
return
1
;
}
return
0
;
return
0
;
}
}
if
(
o1
.
getGroupType
().
equals
(
"building"
)
)
{
return
-
1
;
}
if
(
o2
.
getGroupType
().
equals
(
"building"
)
)
{
return
1
;
}
return
0
;
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
buildingTreeVos
.
get
(
0
).
setChildren
(
buildingTreeVosNew
);
buildingTreeVos
.
get
(
0
).
setChildren
(
buildingTreeVosNew
);
}
}
...
@@ -1676,7 +1687,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
...
@@ -1676,7 +1687,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
}
}
private
List
<
BuildingTreeVo
>
getCompanyBuildingChildrenTree
(
String
parentId
,
List
<
BuildingTreeVo
>
all
)
{
private
List
<
BuildingTreeVo
>
getCompanyBuildingChildrenTree
(
String
parentId
,
List
<
BuildingTreeVo
>
all
)
{
return
all
.
s
tream
().
filter
(
a
->
parentId
.
equals
(
a
.
getParentId
())).
peek
(
a
->
{
return
all
.
parallelS
tream
().
filter
(
a
->
parentId
.
equals
(
a
.
getParentId
())).
peek
(
a
->
{
a
.
setChildren
(
getCompanyBuildingChildrenTree
(
a
.
getId
().
toString
(),
all
));
a
.
setChildren
(
getCompanyBuildingChildrenTree
(
a
.
getId
().
toString
(),
all
));
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment