Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄嘉阳
/
iot-platform-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ba73f159
authored
Jan 08, 2024
by
罗志长
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix: 区域固化数据兼容
parent
1f1fbb58
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatRegionSettingFixServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatRegionSettingFixServiceImpl.java
View file @
ba73f159
...
...
@@ -10,6 +10,7 @@ import com.makeit.entity.platform.space.PlatRegionSettingFix;
import
com.makeit.mapper.platform.space.PlatRegionSettingFixMapper
;
import
com.makeit.service.platform.device.PlatDeviceService
;
import
com.makeit.service.platform.space.PlatRegionSettingFixService
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -18,9 +19,7 @@ import org.springframework.stereotype.Service;
import
java.time.format.DateTimeFormatter
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.function.Function
;
import
java.util.function.Predicate
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -50,9 +49,18 @@ public class PlatRegionSettingFixServiceImpl extends ServiceImpl<PlatRegionSetti
}
else
{
queryWrapper
.
eq
(
PlatRegionSettingFix:
:
getHappenDate
,
dateTimeFormatter
.
format
(
dto
.
getEndTime
()));
}
queryWrapper
.
orderByDesc
(
PlatRegionSettingFix:
:
getCreateDate
);
List
<
PlatRegionSettingFix
>
list
=
this
.
list
(
queryWrapper
);
list
=
list
.
stream
().
filter
(
distinctByKey
(
PlatRegionSettingFix:
:
getDeviceId
)).
collect
(
Collectors
.
toList
());
// 兼容部分没有关联长者的数据
if
(
CollectionUtils
.
isEmpty
(
list
))
{
LambdaQueryWrapper
<
PlatRegionSettingFix
>
queryWrapper1
=
new
LambdaQueryWrapper
<>();
queryWrapper1
.
eq
(
PlatRegionSettingFix:
:
getRoomId
,
dto
.
getRoomId
());
if
(
"0"
.
equals
(
dto
.
getReportType
()))
{
queryWrapper1
.
eq
(
PlatRegionSettingFix:
:
getHappenDate
,
dateTimeFormatter
.
format
(
dto
.
getNow
()));
}
else
{
queryWrapper1
.
eq
(
PlatRegionSettingFix:
:
getHappenDate
,
dateTimeFormatter
.
format
(
dto
.
getEndTime
()));
}
list
=
this
.
list
(
queryWrapper1
);
}
List
<
String
>
deviceIds
=
list
.
stream
().
map
(
PlatRegionSettingFix:
:
getDeviceId
).
collect
(
Collectors
.
toList
());
Map
<
String
,
PlatDevice
>
deviceMap
=
platDeviceService
.
listByIds
(
deviceIds
).
stream
().
collect
(
Collectors
.
toMap
(
PlatDevice:
:
getId
,
Function
.
identity
()));
return
list
.
stream
().
map
(
p
->
{
...
...
@@ -66,9 +74,4 @@ public class PlatRegionSettingFixServiceImpl extends ServiceImpl<PlatRegionSetti
}).
collect
(
Collectors
.
toList
());
}
private
static
<
T
>
Predicate
<
T
>
distinctByKey
(
Function
<?
super
T
,
Object
>
keyExtractor
)
{
Map
<
Object
,
Boolean
>
seen
=
new
ConcurrentHashMap
<>();
return
t
->
seen
.
putIfAbsent
(
keyExtractor
.
apply
(
t
),
Boolean
.
TRUE
)
==
null
;
}
}
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