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
baef3ddd
authored
Sep 14, 2023
by
lzy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
空间树到床位
parent
18be80ee
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
0 deletions
server-module/src/main/java/com/makeit/module/controller/space/PlatSpaceController.java
server-service/src/main/java/com/makeit/service/platform/space/PlatSpaceService.java
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
server-module/src/main/java/com/makeit/module/controller/space/PlatSpaceController.java
View file @
baef3ddd
...
@@ -73,4 +73,11 @@ public class PlatSpaceController {
...
@@ -73,4 +73,11 @@ public class PlatSpaceController {
return
ApiResponseUtils
.
success
(
data
);
return
ApiResponseUtils
.
success
(
data
);
}
}
@ApiOperation
(
"树-无权限-到床位"
)
@PostMapping
(
"listTreeAuthIgnoreByBed"
)
public
ApiResponseEntity
<
List
<
PlatSpaceVO
>>
listTreeAuthIgnoreByBed
(
@RequestBody
PlatSpaceQueryDTO
dto
)
{
List
<
PlatSpaceVO
>
data
=
spaceService
.
treeByBed
(
dto
);
return
ApiResponseUtils
.
success
(
data
);
}
}
}
server-service/src/main/java/com/makeit/service/platform/space/PlatSpaceService.java
View file @
baef3ddd
...
@@ -49,4 +49,11 @@ public interface PlatSpaceService extends IService<PlatSpace> {
...
@@ -49,4 +49,11 @@ public interface PlatSpaceService extends IService<PlatSpace> {
PlatSpaceAddDTO
view
(
String
id
);
PlatSpaceAddDTO
view
(
String
id
);
List
<
PlatSpaceAndRoomVO
>
spaceListExcludeLast
();
List
<
PlatSpaceAndRoomVO
>
spaceListExcludeLast
();
/**
* 空间树 到 床位
* @param dto
* @return
*/
List
<
PlatSpaceVO
>
treeByBed
(
PlatSpaceQueryDTO
dto
);
}
}
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
View file @
baef3ddd
...
@@ -6,12 +6,14 @@ import com.makeit.dto.platform.space.PlatSpaceAddDTO;
...
@@ -6,12 +6,14 @@ import com.makeit.dto.platform.space.PlatSpaceAddDTO;
import
com.makeit.dto.platform.space.PlatSpaceQueryDTO
;
import
com.makeit.dto.platform.space.PlatSpaceQueryDTO
;
import
com.makeit.dto.platform.space.PlatSpaceVO
;
import
com.makeit.dto.platform.space.PlatSpaceVO
;
import
com.makeit.entity.platform.auth.PlatOrg
;
import
com.makeit.entity.platform.auth.PlatOrg
;
import
com.makeit.entity.platform.space.PlatBed
;
import
com.makeit.entity.platform.space.PlatRoom
;
import
com.makeit.entity.platform.space.PlatRoom
;
import
com.makeit.entity.platform.space.PlatSpace
;
import
com.makeit.entity.platform.space.PlatSpace
;
import
com.makeit.enums.CodeMessageEnum
;
import
com.makeit.enums.CodeMessageEnum
;
import
com.makeit.exception.BusinessException
;
import
com.makeit.exception.BusinessException
;
import
com.makeit.mapper.platform.space.PlatSpaceMapper
;
import
com.makeit.mapper.platform.space.PlatSpaceMapper
;
import
com.makeit.service.platform.auth.PlatOrgService
;
import
com.makeit.service.platform.auth.PlatOrgService
;
import
com.makeit.service.platform.space.PlatBedService
;
import
com.makeit.service.platform.space.PlatRoomService
;
import
com.makeit.service.platform.space.PlatRoomService
;
import
com.makeit.service.platform.space.PlatSpaceService
;
import
com.makeit.service.platform.space.PlatSpaceService
;
import
com.makeit.utils.data.convert.BeanDtoVoUtils
;
import
com.makeit.utils.data.convert.BeanDtoVoUtils
;
...
@@ -39,6 +41,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -39,6 +41,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
@Autowired
@Autowired
private
PlatRoomService
platRoomService
;
private
PlatRoomService
platRoomService
;
@Autowired
@Autowired
private
PlatBedService
platBedService
;
@Autowired
private
PlatOrgService
platOrgService
;
private
PlatOrgService
platOrgService
;
private
void
check
(
PlatSpaceAddDTO
dto
){
private
void
check
(
PlatSpaceAddDTO
dto
){
...
@@ -142,6 +146,73 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -142,6 +146,73 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
return
baseMapper
.
spaceListExcludeLast
();
return
baseMapper
.
spaceListExcludeLast
();
}
}
@Override
public
List
<
PlatSpaceVO
>
treeByBed
(
PlatSpaceQueryDTO
dto
)
{
//房间
List
<
PlatRoom
>
listRoom
=
platRoomService
.
list
(
new
LambdaQueryWrapper
<>());
//床位
List
<
PlatBed
>
listBeds
=
platBedService
.
list
(
new
LambdaQueryWrapper
<>());
Map
<
String
,
List
<
PlatBed
>>
mapBed
=
listBeds
.
stream
().
collect
(
Collectors
.
groupingBy
(
PlatBed:
:
getRoomId
));
List
<
PlatSpaceVO
>
listRoomVo
=
new
ArrayList
<>();
listRoom
.
forEach
(
item
->{
PlatSpaceVO
vo
=
new
PlatSpaceVO
();
vo
.
setId
(
item
.
getId
());
vo
.
setName
(
item
.
getName
());
vo
.
setParentId
(
item
.
getSpaceId
());
listRoomVo
.
add
(
vo
);
});
listBeds
.
forEach
(
item
->{
PlatSpaceVO
vo
=
new
PlatSpaceVO
();
vo
.
setId
(
item
.
getId
());
vo
.
setName
(
item
.
getName
());
vo
.
setParentId
(
item
.
getRoomId
());
listRoomVo
.
add
(
vo
);
});
LambdaQueryWrapper
<
PlatSpace
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
like
(
StringUtil
.
isNotEmpty
(
dto
.
getName
()),
PlatSpace:
:
getName
,
dto
.
getName
());
List
<
PlatSpace
>
list
=
this
.
list
(
queryWrapper
);
List
<
PlatSpaceVO
>
listSpaceVo
=
BeanDtoVoUtils
.
listVo
(
list
,
PlatSpaceVO
.
class
);
listSpaceVo
.
addAll
(
listRoomVo
);
//父级
List
<
PlatSpaceVO
>
listParent
=
listSpaceVo
.
stream
().
filter
(
item
->
StringUtil
.
isEmpty
(
item
.
getParentId
())).
collect
(
Collectors
.
toList
());
//子集
List
<
PlatSpaceVO
>
listChild
=
listSpaceVo
.
stream
().
filter
(
item
->
item
.
getParentId
()
!=
null
).
collect
(
Collectors
.
toList
());
Map
<
String
,
List
<
PlatSpaceVO
>>
map
=
listChild
.
stream
().
collect
(
Collectors
.
groupingBy
(
PlatSpaceVO:
:
getParentId
));
List
<
PlatSpaceVO
>
data
=
new
ArrayList
<>();
for
(
PlatSpaceVO
space:
listParent
){
space
=
childVo
(
space
,
map
);
data
.
add
(
space
);
}
return
data
;
}
private
PlatSpaceVO
childVo
(
PlatSpaceVO
vo
,
Map
<
String
,
List
<
PlatSpaceVO
>>
map
){
if
(!
map
.
containsKey
(
vo
.
getId
())){
return
vo
;
}
List
<
PlatSpaceVO
>
list
=
map
.
get
(
vo
.
getId
());
List
<
PlatSpaceVO
>
listChild
=
new
ArrayList
<>();
for
(
PlatSpaceVO
item:
list
){
this
.
childVo
(
item
,
map
);
listChild
.
add
(
item
);
}
vo
.
setChildren
(
listChild
);
return
vo
;
}
private
PlatSpaceVO
child
(
PlatSpaceVO
vo
,
Map
<
String
,
List
<
PlatSpace
>>
map
){
private
PlatSpaceVO
child
(
PlatSpaceVO
vo
,
Map
<
String
,
List
<
PlatSpace
>>
map
){
if
(!
map
.
containsKey
(
vo
.
getId
())){
if
(!
map
.
containsKey
(
vo
.
getId
())){
...
...
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