Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
device-new-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
device-new-platform
Commits
398f674b
Commit
398f674b
authored
Dec 16, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分组更新设备
parent
5c68a2b5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
device-manager/src/main/java/com/mortals/xhx/thread/DeviceUpdateComsumerThread.java
...va/com/mortals/xhx/thread/DeviceUpdateComsumerThread.java
+8
-3
No files found.
device-manager/src/main/java/com/mortals/xhx/thread/DeviceUpdateComsumerThread.java
View file @
398f674b
package
com.mortals.xhx.thread
;
package
com.mortals.xhx.thread
;
import
cn.hutool.core.collection.ListUtil
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.util.AbstractThread
;
import
com.mortals.framework.util.AbstractThread
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.key.RedisKey
;
...
@@ -56,8 +57,8 @@ public class DeviceUpdateComsumerThread extends AbstractThread {
...
@@ -56,8 +57,8 @@ public class DeviceUpdateComsumerThread extends AbstractThread {
if
(!
ObjectUtils
.
isEmpty
(
waitUpdateDeviceList
))
{
if
(!
ObjectUtils
.
isEmpty
(
waitUpdateDeviceList
))
{
log
.
info
(
"updateDeviceList size:{}"
,
waitUpdateDeviceList
.
size
());
log
.
info
(
"updateDeviceList size:{}"
,
waitUpdateDeviceList
.
size
());
Map
<
Long
,
List
<
DeviceEntity
>>
collect
=
waitUpdateDeviceList
.
parallelStream
().
collect
(
Collectors
.
groupingBy
(
x
->
x
.
getId
()));
Map
<
Long
,
List
<
DeviceEntity
>>
collect
=
waitUpdateDeviceList
.
parallelStream
().
collect
(
Collectors
.
groupingBy
(
x
->
x
.
getId
()));
collect
.
entrySet
().
s
tream
().
forEach
(
item
->{
collect
.
entrySet
().
parallelS
tream
().
forEach
(
item
->{
List
<
DeviceEntity
>
sortUpdateList
=
item
.
getValue
().
s
tream
().
sorted
(
new
Comparator
<
DeviceEntity
>()
{
List
<
DeviceEntity
>
sortUpdateList
=
item
.
getValue
().
parallelS
tream
().
sorted
(
new
Comparator
<
DeviceEntity
>()
{
@Override
@Override
public
int
compare
(
DeviceEntity
o1
,
DeviceEntity
o2
)
{
public
int
compare
(
DeviceEntity
o1
,
DeviceEntity
o2
)
{
if
(
o1
.
getUpdateTime
()
==
null
)
return
0
;
if
(
o1
.
getUpdateTime
()
==
null
)
return
0
;
...
@@ -73,7 +74,11 @@ public class DeviceUpdateComsumerThread extends AbstractThread {
...
@@ -73,7 +74,11 @@ public class DeviceUpdateComsumerThread extends AbstractThread {
}
}
}
}
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
deviceService
.
update
(
sortUpdateList
);
List
<
List
<
DeviceEntity
>>
partition
=
ListUtil
.
partition
(
sortUpdateList
,
50
);
for
(
List
<
DeviceEntity
>
deviceEntityList
:
partition
)
{
deviceService
.
update
(
deviceEntityList
);
}
});
});
/*
/*
...
...
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