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
19d93d08
authored
Dec 19, 2023
by
罗志长
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix: 平台端设备管理列表关联长者
parent
7aeedc74
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
4 deletions
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
server-service/src/main/java/com/makeit/vo/platform/device/PlatDeviceListVO.java
server-service/src/main/resources/mappers/PlatDeviceMapper.xml
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
View file @
19d93d08
...
...
@@ -81,6 +81,7 @@ import com.makeit.vo.platform.device.PlatDeviceListVO;
import
com.makeit.vo.platform.device.PlatDeviceViewVO
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.aspectj.weaver.ast.Var
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -176,6 +177,15 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
List
<
PlatSpace
>
platSpaces
=
platSpaceService
.
listByIds
(
spaceIdList
);
Map
<
String
,
String
>
spaceIdNameMap
=
platSpaces
.
stream
().
collect
(
Collectors
.
toMap
(
BaseEntity:
:
getId
,
vo
->
vo
.
getName
(),
(
v1
,
v2
)
->
v1
));
List
<
String
>
deviceIds
=
StreamUtil
.
map
(
records
,
PlatDeviceListVO:
:
getId
);
List
<
PlatRoomBedDevice
>
platRoomBedDevices
=
platRoomBedDeviceService
.
list
(
new
QueryWrapper
<
PlatRoomBedDevice
>().
lambda
()
.
in
(
PlatRoomBedDevice:
:
getDeviceId
,
deviceIds
));
List
<
String
>
roomIds
=
StreamUtil
.
map
(
platRoomBedDevices
,
PlatRoomBedDevice:
:
getRoomId
).
stream
().
distinct
().
collect
(
Collectors
.
toList
());
List
<
String
>
bedIds
=
StreamUtil
.
filterMap
(
platRoomBedDevices
,
b
->
b
.
getBedId
()
!=
null
,
PlatRoomBedDevice:
:
getBedId
);
List
<
PlatElder
>
roomElders
=
platElderService
.
list
(
new
QueryWrapper
<
PlatElder
>().
lambda
().
in
(
PlatElder:
:
getRoomId
,
roomIds
));
List
<
PlatElder
>
bedElders
=
platElderService
.
list
(
new
QueryWrapper
<
PlatElder
>().
lambda
().
in
(
PlatElder:
:
getBedId
,
bedIds
));
Map
<
String
,
List
<
PlatElder
>>
roomEldersMap
=
roomElders
.
stream
().
collect
(
Collectors
.
groupingBy
(
PlatElder:
:
getRoomId
,
Collectors
.
toList
()));
Map
<
String
,
List
<
PlatElder
>>
bedEldersMap
=
bedElders
.
stream
().
collect
(
Collectors
.
groupingBy
(
PlatElder:
:
getBedId
,
Collectors
.
toList
()));
for
(
PlatDeviceListVO
record
:
records
)
{
String
spaceParentPath
=
record
.
getSpaceParentPath
();
...
...
@@ -196,6 +206,14 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
spaceName
=
spaceName
+
"-"
+
record
.
getBedName
();
}
record
.
setSpaceName
(
spaceName
);
String
elderNames
=
""
;
if
(
PlatDeviceEnum
.
CategoryEnum
.
HEART
.
getValue
().
equals
(
record
.
getCategory
()))
{
elderNames
=
bedEldersMap
.
getOrDefault
(
record
.
getBedId
(),
Lists
.
newArrayList
()).
stream
().
map
(
PlatElder:
:
getName
).
collect
(
Collectors
.
joining
(
","
));
}
else
{
elderNames
=
roomEldersMap
.
getOrDefault
(
record
.
getRoomId
(),
Lists
.
newArrayList
()).
stream
().
map
(
PlatElder:
:
getName
).
collect
(
Collectors
.
joining
(
","
));
}
record
.
setElderName
(
elderNames
);
}
JoinUtil
.
join
(
records
,
platOrgService
,
PlatDeviceListVO:
:
getOrgId
,
PlatOrg:
:
getId
,
(
d
,
o
)
->
{
...
...
server-service/src/main/java/com/makeit/vo/platform/device/PlatDeviceListVO.java
View file @
19d93d08
...
...
@@ -90,8 +90,12 @@ public class PlatDeviceListVO extends BaseTenantDTO {
private
String
spaceName
;
private
String
roomId
;
private
String
roomName
;
private
String
bedId
;
private
String
bedName
;
private
String
elderName
;
...
...
server-service/src/main/resources/mappers/PlatDeviceMapper.xml
View file @
19d93d08
...
...
@@ -62,20 +62,22 @@
<select
id=
"getDeviceIdsBySpaceIdAndElder"
resultType=
"com.makeit.vo.platform.device.PlatDeviceListVO"
>
select
distinct
pd.*,
ps.parent_path as spaceParentPath,
ps.name as spaceName,
pr.name as roomName,
pb.name as bedName,
GROUP_CONCAT(pe.`name`) as elderName
pr.id as roomId,
pb.id as bedId
from plat_device pd
left join plat_room_bed_device prbd on (pd.id = prbd.device_id and prbd.del_flag = '0')
left join plat_room pr on (pr.id = prbd.room_id and pr.del_flag = '0' )
left join plat_bed pb on ( pb.id = prbd.bed_id and pb.del_flag = '0')
left join plat_space ps on (ps.id = pr.space_id and ps.del_flag = '0')
left join plat_elder pe on (pe.
room_id = prbd.room_
id and pe.del_flag = '0')
left join plat_elder pe on (pe.
space_id = ps.
id and pe.del_flag = '0')
<where>
pd.del_flag =
0
pd.del_flag =
'0'
<if
test=
"param.spaceId != null and param.spaceId != ''"
>
and ( FIND_IN_SET(#{param.spaceId},ps.parent_path) or ps.id = #{param.spaceId})
</if>
...
...
@@ -117,7 +119,6 @@
</if>
</where>
GROUP BY pd.ori_device_id
order by pd.update_date desc,pd.id desc
</select>
...
...
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