Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-trialdrive-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0f012eea
authored
Sep 29, 2021
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化分批获取省市区的方法
1 parent
a0fab913
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
6 deletions
src/main/java/cn/com/glsx/admin/modules/service/OrganizationApiService.java
src/test/java/cn/com/glsx/admin/modules/service/VehicleServiceTest.java
src/main/java/cn/com/glsx/admin/modules/service/OrganizationApiService.java
View file @
0f012ee
...
...
@@ -20,6 +20,7 @@ import org.apache.commons.collections4.CollectionUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -28,6 +29,7 @@ import java.util.stream.Collectors;
@Slf4j
@Service
public
class
OrganizationApiService
{
private
static
final
int
BATCH_COUNT
=
500
;
@Autowired
private
OrganizationService
organizationService
;
...
...
@@ -126,11 +128,29 @@ public class OrganizationApiService {
}
List
<
Long
>
userIds
=
list
.
stream
().
map
(
ReportOrgDto:
:
getCreatedBy
).
collect
(
Collectors
.
toList
());
OrganizationSearch
organizationSearch
=
new
OrganizationSearch
();
organizationSearch
.
setUserIds
(
userIds
);
R
<
List
<
Organization
>>
orgsR
=
organizationService
.
getTenantPathsByUserIds
(
organizationSearch
);
List
<
Organization
>
orgList
=
orgsR
.
getDataList
(
new
TypeToken
<
List
<
Organization
>>()
{
}.
getType
());
List
<
Organization
>
orgList
=
new
ArrayList
<>();
int
length
=
userIds
.
size
()
/
BATCH_COUNT
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
List
<
Long
>
searchList
;
if
(
i
!=
length
-
1
)
{
searchList
=
userIds
.
subList
(
i
*
BATCH_COUNT
,
(
i
+
1
)
*
BATCH_COUNT
);
OrganizationSearch
organizationSearch
=
new
OrganizationSearch
();
organizationSearch
.
setUserIds
(
searchList
);
R
<
List
<
Organization
>>
orgsR
=
organizationService
.
getTenantPathsByUserIds
(
organizationSearch
);
List
<
Organization
>
orgListSplit
=
orgsR
.
getDataList
(
new
TypeToken
<
List
<
Organization
>>()
{
}.
getType
());
orgList
.
addAll
(
orgListSplit
);
}
else
{
searchList
=
userIds
.
subList
(
i
*
BATCH_COUNT
,
list
.
size
());
OrganizationSearch
organizationSearch
=
new
OrganizationSearch
();
organizationSearch
.
setUserIds
(
searchList
);
R
<
List
<
Organization
>>
orgsR
=
organizationService
.
getTenantPathsByUserIds
(
organizationSearch
);
List
<
Organization
>
orgListSplit
=
orgsR
.
getDataList
(
new
TypeToken
<
List
<
Organization
>>()
{
}.
getType
());
orgList
.
addAll
(
orgListSplit
);
}
}
if
(
CollectionUtils
.
isNotEmpty
(
orgList
))
{
list
.
forEach
(
efd
->
{
List
<
Organization
>
organizations
=
orgList
.
stream
().
filter
(
index
->
index
.
getUserId
().
equals
(
efd
.
getCreatedBy
())).
collect
(
Collectors
.
toList
());
...
...
src/test/java/cn/com/glsx/admin/modules/service/VehicleServiceTest.java
View file @
0f012ee
...
...
@@ -2176,8 +2176,17 @@ public class VehicleServiceTest {
}
@Test
public
void
test
()
{
public
void
test
17
()
{
User
superiorUserById
=
userApiService
.
getSuperiorUserById
(
8102L
);
System
.
out
.
println
(
"superiorUserById = "
+
JSON
.
toJSONString
(
superiorUserById
));
}
@Test
public
void
test18
()
{
int
length
=
Math
.
floorMod
(
1590
,
500
);
System
.
out
.
println
(
"length = "
+
length
);
int
length1
=
1590
/
500
;
System
.
out
.
println
(
"length = "
+
length1
);
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment