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
a5907113
authored
Sep 08, 2023
by
lzy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
更新
parent
eee34240
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
283 additions
and
105 deletions
server-module/src/main/java/com/makeit/module/controller/space/PlatBedController.java
server-module/src/main/java/com/makeit/module/controller/space/PlatRoomBedDeviceController.java
server-service/src/main/java/com/makeit/dto/platform/space/PlatBedDeviceQueryDTO.java
server-service/src/main/java/com/makeit/dto/platform/space/PlatRoomBindDeviceDTO.java
server-service/src/main/java/com/makeit/dto/platform/space/PlatSpaceDeviceQueryDTO.java
server-service/src/main/java/com/makeit/dto/platform/space/PlatUnbindingDeviceDTO.java
server-service/src/main/java/com/makeit/entity/platform/space/PlatRoomBedDevice.java
server-service/src/main/java/com/makeit/service/platform/space/PlatBedService.java
server-service/src/main/java/com/makeit/service/platform/space/PlatRoomBedDeviceService.java
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatBedServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatRoomBedDeviceServiceImpl.java
server-module/src/main/java/com/makeit/module/controller/space/PlatBedController.java
View file @
a5907113
...
@@ -5,11 +5,8 @@ import com.makeit.common.page.PageReqDTO;
...
@@ -5,11 +5,8 @@ import com.makeit.common.page.PageReqDTO;
import
com.makeit.common.page.PageVO
;
import
com.makeit.common.page.PageVO
;
import
com.makeit.common.response.ApiResponseEntity
;
import
com.makeit.common.response.ApiResponseEntity
;
import
com.makeit.common.response.ApiResponseUtils
;
import
com.makeit.common.response.ApiResponseUtils
;
import
com.makeit.dto.platform.device.PlatDeviceDTO
;
import
com.makeit.dto.platform.space.PlatBedDeviceQueryDTO
;
import
com.makeit.dto.platform.space.PlatBedEditDTO
;
import
com.makeit.dto.platform.space.PlatBedEditDTO
;
import
com.makeit.dto.platform.space.PlatBedQueryDTO
;
import
com.makeit.dto.platform.space.PlatBedQueryDTO
;
import
com.makeit.dto.platform.space.PlatSpaceDeviceQueryDTO
;
import
com.makeit.entity.platform.space.PlatBed
;
import
com.makeit.entity.platform.space.PlatBed
;
import
com.makeit.service.platform.space.PlatBedService
;
import
com.makeit.service.platform.space.PlatBedService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -21,8 +18,6 @@ import org.springframework.web.bind.annotation.RequestBody;
...
@@ -21,8 +18,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
/**
* @Author:lzy
* @Author:lzy
* @Date:2023/9/6 11:56
* @Date:2023/9/6 11:56
...
@@ -64,18 +59,4 @@ public class PlatBedController {
...
@@ -64,18 +59,4 @@ public class PlatBedController {
return
ApiResponseUtils
.
success
();
return
ApiResponseUtils
.
success
();
}
}
@ApiOperation
(
"设备列表(选择设备)"
)
@PostMapping
(
"pageDevice"
)
public
ApiResponseEntity
<
PageVO
<
PlatDeviceDTO
>>
pageDevice
(
@RequestBody
PageReqDTO
<
PlatSpaceDeviceQueryDTO
>
page
)
{
PageVO
<
PlatDeviceDTO
>
data
=
platBedService
.
pageDevice
(
page
);
return
ApiResponseUtils
.
success
(
data
);
}
@ApiOperation
(
"已绑定设备列表"
)
@PostMapping
(
"listBindDevice"
)
public
ApiResponseEntity
<
List
<
PlatDeviceDTO
>>
listBindDevice
(
@RequestBody
PlatBedDeviceQueryDTO
dto
)
{
List
<
PlatDeviceDTO
>
data
=
platBedService
.
listBindDevice
(
dto
);
return
ApiResponseUtils
.
success
(
data
);
}
}
}
server-module/src/main/java/com/makeit/module/controller/space/PlatRoomBedDeviceController.java
0 → 100644
View file @
a5907113
package
com
.
makeit
.
module
.
controller
.
space
;
import
com.makeit.common.page.PageReqDTO
;
import
com.makeit.common.page.PageVO
;
import
com.makeit.common.response.ApiResponseEntity
;
import
com.makeit.common.response.ApiResponseUtils
;
import
com.makeit.dto.platform.device.PlatDeviceDTO
;
import
com.makeit.dto.platform.space.PlatBedDeviceQueryDTO
;
import
com.makeit.dto.platform.space.PlatRoomBindDeviceDTO
;
import
com.makeit.dto.platform.space.PlatSpaceDeviceQueryDTO
;
import
com.makeit.dto.platform.space.PlatUnbindingDeviceDTO
;
import
com.makeit.enums.CommonEnum
;
import
com.makeit.service.platform.space.PlatRoomBedDeviceService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
* @Author:lzy
* @Date:2023/9/8 9:54
* @Describe:
*/
@Api
(
tags
=
"绑定设备"
)
@RestController
@RequestMapping
(
"/plat/binding/device"
)
public
class
PlatRoomBedDeviceController
{
@Autowired
private
PlatRoomBedDeviceService
platRoomBedDeviceService
;
@ApiOperation
(
"设备列表(选择设备)"
)
@PostMapping
(
"pageDevice"
)
public
ApiResponseEntity
<
PageVO
<
PlatDeviceDTO
>>
pageDevice
(
@RequestBody
PageReqDTO
<
PlatSpaceDeviceQueryDTO
>
page
)
{
page
.
getData
().
setIsRoom
(
CommonEnum
.
YES
.
getValue
());
PageVO
<
PlatDeviceDTO
>
data
=
platRoomBedDeviceService
.
pageDevice
(
page
);
return
ApiResponseUtils
.
success
(
data
);
}
@ApiOperation
(
"已绑定设备列表"
)
@PostMapping
(
"listBindDevice"
)
public
ApiResponseEntity
<
List
<
PlatDeviceDTO
>>
listBindDevice
(
@RequestBody
PlatBedDeviceQueryDTO
dto
)
{
List
<
PlatDeviceDTO
>
data
=
platRoomBedDeviceService
.
listBindDevice
(
dto
);
return
ApiResponseUtils
.
success
(
data
);
}
@ApiOperation
(
"绑定设备"
)
@PostMapping
(
"bindingDevice"
)
public
ApiResponseEntity
<?>
bindingDevice
(
@RequestBody
PlatRoomBindDeviceDTO
dto
)
{
platRoomBedDeviceService
.
bindingDevice
(
dto
);
return
ApiResponseUtils
.
success
();
}
@ApiOperation
(
"解绑设备"
)
@PostMapping
(
"bindingDevice"
)
public
ApiResponseEntity
<?>
unbindingDevice
(
@RequestBody
PlatUnbindingDeviceDTO
dto
)
{
platRoomBedDeviceService
.
unbindingDevice
(
dto
);
return
ApiResponseUtils
.
success
();
}
}
server-service/src/main/java/com/makeit/dto/platform/space/PlatBedDeviceQueryDTO.java
View file @
a5907113
...
@@ -15,4 +15,7 @@ public class PlatBedDeviceQueryDTO {
...
@@ -15,4 +15,7 @@ public class PlatBedDeviceQueryDTO {
@ApiModelProperty
(
"房间Id"
)
@ApiModelProperty
(
"房间Id"
)
private
String
roomId
;
private
String
roomId
;
@ApiModelProperty
(
"床位Id"
)
private
String
bedId
;
}
}
server-service/src/main/java/com/makeit/dto/platform/space/PlatRoomBindDeviceDTO.java
View file @
a5907113
...
@@ -15,10 +15,10 @@ import java.util.List;
...
@@ -15,10 +15,10 @@ import java.util.List;
@ApiModel
(
"PlatRoomBindDeviceDTO 设备绑定"
)
@ApiModel
(
"PlatRoomBindDeviceDTO 设备绑定"
)
public
class
PlatRoomBindDeviceDTO
{
public
class
PlatRoomBindDeviceDTO
{
@ApiModelProperty
(
value
=
"房间ID"
)
@ApiModelProperty
(
value
=
"房间ID"
,
required
=
true
)
private
String
roomId
;
private
String
roomId
;
@ApiModelProperty
(
value
=
"设备Id"
)
@ApiModelProperty
(
value
=
"设备Id"
,
required
=
true
)
private
List
<
String
>
listEquipmentId
;
private
List
<
String
>
listEquipmentId
;
@ApiModelProperty
(
value
=
"床位Id"
)
@ApiModelProperty
(
value
=
"床位Id"
)
...
...
server-service/src/main/java/com/makeit/dto/platform/space/PlatSpaceDeviceQueryDTO.java
View file @
a5907113
...
@@ -27,4 +27,10 @@ public class PlatSpaceDeviceQueryDTO {
...
@@ -27,4 +27,10 @@ public class PlatSpaceDeviceQueryDTO {
@ApiModelProperty
(
value
=
"设备类型 device.category 0-呼吸心率雷达 1-空间人体雷达 2-跌倒检测雷达"
)
@ApiModelProperty
(
value
=
"设备类型 device.category 0-呼吸心率雷达 1-空间人体雷达 2-跌倒检测雷达"
)
private
String
category
;
private
String
category
;
@ApiModelProperty
(
value
=
"是否房间绑定 0-床位绑定 1-房间绑定"
)
private
String
isRoom
;
@ApiModelProperty
(
value
=
"房间ID 绑定的床位使用"
)
private
String
roomId
;
}
}
server-service/src/main/java/com/makeit/dto/platform/space/PlatUnbindingDeviceDTO.java
0 → 100644
View file @
a5907113
package
com
.
makeit
.
dto
.
platform
.
space
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* @Author:lzy
* @Date:2023/9/8 10:35
* @Describe:
*/
@Data
@ApiModel
(
"解绑设备"
)
public
class
PlatUnbindingDeviceDTO
{
@ApiModelProperty
(
"设备Id"
)
private
String
equipmentId
;
@ApiModelProperty
(
"房间Id"
)
private
String
roomId
;
@ApiModelProperty
(
"床位Id"
)
private
String
bedId
;
}
server-service/src/main/java/com/makeit/entity/platform/space/PlatRoomBedDevice.java
View file @
a5907113
package
com
.
makeit
.
entity
.
platform
.
space
;
package
com
.
makeit
.
entity
.
platform
.
space
;
import
com.baomidou.mybatisplus.annotation.FieldStrategy
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.makeit.common.entity.BaseBusEntity
;
import
com.makeit.common.entity.BaseBusEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
...
@@ -16,13 +18,13 @@ import lombok.EqualsAndHashCode;
...
@@ -16,13 +18,13 @@ import lombok.EqualsAndHashCode;
@ApiModel
(
value
=
"PlatRoomBedDevice对象"
,
description
=
"房间床位设备中间表"
)
@ApiModel
(
value
=
"PlatRoomBedDevice对象"
,
description
=
"房间床位设备中间表"
)
public
class
PlatRoomBedDevice
extends
BaseBusEntity
{
public
class
PlatRoomBedDevice
extends
BaseBusEntity
{
@ApiModelProperty
(
value
=
"房间ID"
,
required
=
true
)
@ApiModelProperty
(
value
=
"房间ID"
)
private
String
roomId
;
private
String
roomId
;
@ApiModelProperty
(
value
=
"设备Id"
)
@ApiModelProperty
(
value
=
"设备Id"
,
required
=
true
)
private
String
equipmentId
;
private
String
equipmentId
;
@TableField
(
updateStrategy
=
FieldStrategy
.
IGNORED
)
@ApiModelProperty
(
value
=
"床位Id"
)
@ApiModelProperty
(
value
=
"床位Id"
)
private
String
bedId
;
private
String
bedId
;
}
}
server-service/src/main/java/com/makeit/service/platform/space/PlatBedService.java
View file @
a5907113
...
@@ -51,27 +51,6 @@ public interface PlatBedService extends IService<PlatBed> {
...
@@ -51,27 +51,6 @@ public interface PlatBedService extends IService<PlatBed> {
void
del
(
String
id
);
void
del
(
String
id
);
void
changeStatus
(
StatusDTO
dto
);
void
changeStatus
(
StatusDTO
dto
);
/**
* 未绑定设备列表
* @param pageReqDTO
* @return
*/
PageVO
<
PlatDeviceDTO
>
pageDevice
(
PageReqDTO
<
PlatSpaceDeviceQueryDTO
>
pageReqDTO
);
/**
* 已绑定设备
* @param dto
* @return
*/
List
<
PlatDeviceDTO
>
listBindDevice
(
PlatBedDeviceQueryDTO
dto
);
/**
*
* @param dto
*/
void
bindDevice
(
PlatRoomBindDeviceDTO
dto
);
}
}
server-service/src/main/java/com/makeit/service/platform/space/PlatRoomBedDeviceService.java
View file @
a5907113
package
com
.
makeit
.
service
.
platform
.
space
;
package
com
.
makeit
.
service
.
platform
.
space
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.makeit.common.page.PageReqDTO
;
import
com.makeit.common.page.PageVO
;
import
com.makeit.dto.platform.device.PlatDeviceDTO
;
import
com.makeit.dto.platform.space.PlatBedDeviceQueryDTO
;
import
com.makeit.dto.platform.space.PlatRoomBindDeviceDTO
;
import
com.makeit.dto.platform.space.PlatSpaceDeviceQueryDTO
;
import
com.makeit.dto.platform.space.PlatUnbindingDeviceDTO
;
import
com.makeit.entity.platform.space.PlatRoomBedDevice
;
import
com.makeit.entity.platform.space.PlatRoomBedDevice
;
import
java.util.List
;
/**
/**
* @Author:lzy
* @Author:lzy
* @Date:2023/9/6 17:44
* @Date:2023/9/6 17:44
* @Describe:
* @Describe:
*/
*/
public
interface
PlatRoomBedDeviceService
extends
IService
<
PlatRoomBedDevice
>
{
public
interface
PlatRoomBedDeviceService
extends
IService
<
PlatRoomBedDevice
>
{
/**
* 绑定设备
* @param dto
*/
void
bindingDevice
(
PlatRoomBindDeviceDTO
dto
);
/**
* 未绑定设备列表
* @param pageReqDTO
* @return
*/
PageVO
<
PlatDeviceDTO
>
pageDevice
(
PageReqDTO
<
PlatSpaceDeviceQueryDTO
>
pageReqDTO
);
/**
* 已绑定设备
* @param dto
* @return
*/
List
<
PlatDeviceDTO
>
listBindDevice
(
PlatBedDeviceQueryDTO
dto
);
/**
* 解绑设备
* @param dto
*/
void
unbindingDevice
(
PlatUnbindingDeviceDTO
dto
);
}
}
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatBedServiceImpl.java
View file @
a5907113
...
@@ -7,10 +7,7 @@ import com.makeit.common.dto.StatusDTO;
...
@@ -7,10 +7,7 @@ import com.makeit.common.dto.StatusDTO;
import
com.makeit.common.page.PageReqDTO
;
import
com.makeit.common.page.PageReqDTO
;
import
com.makeit.common.page.PageVO
;
import
com.makeit.common.page.PageVO
;
import
com.makeit.dto.platform.device.PlatDeviceDTO
;
import
com.makeit.dto.platform.device.PlatDeviceDTO
;
import
com.makeit.dto.platform.space.PlatBedDeviceQueryDTO
;
import
com.makeit.dto.platform.space.*
;
import
com.makeit.dto.platform.space.PlatBedEditDTO
;
import
com.makeit.dto.platform.space.PlatBedQueryDTO
;
import
com.makeit.dto.platform.space.PlatSpaceDeviceQueryDTO
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.entity.platform.space.PlatBed
;
import
com.makeit.entity.platform.space.PlatBed
;
import
com.makeit.entity.platform.space.PlatRoom
;
import
com.makeit.entity.platform.space.PlatRoom
;
...
@@ -149,61 +146,5 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
...
@@ -149,61 +146,5 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
updateById
(
bed
);
updateById
(
bed
);
}
}
@Override
public
PageVO
<
PlatDeviceDTO
>
pageDevice
(
PageReqDTO
<
PlatSpaceDeviceQueryDTO
>
pageReqDTO
)
{
LambdaQueryWrapper
<
PlatRoomBedDevice
>
queryWrapper1
=
new
LambdaQueryWrapper
<>();
queryWrapper1
.
select
(
PlatRoomBedDevice:
:
getEquipmentId
);
List
<
PlatRoomBedDevice
>
list
=
platRoomBedDeviceService
.
list
(
queryWrapper1
);
List
<
String
>
listEquipmentIds
=
list
.
stream
().
map
(
item
->
item
.
getEquipmentId
()).
collect
(
Collectors
.
toList
());
PlatSpaceDeviceQueryDTO
dto
=
pageReqDTO
.
getData
();
Page
<
PlatDevice
>
p
=
PageUtil
.
toMpPage
(
pageReqDTO
);
LambdaQueryWrapper
<
PlatDevice
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
notIn
(
PlatDevice:
:
getId
,
listEquipmentIds
);
queryWrapper
.
eq
(
PlatDevice:
:
getCategory
,
dto
.
getCategory
());
queryWrapper
.
like
(
StringUtil
.
isNotEmpty
(
dto
.
getOriDeviceId
()),
PlatDevice:
:
getOriDeviceId
,
dto
.
getOriDeviceId
());
queryWrapper
.
like
(
StringUtil
.
isNotEmpty
(
dto
.
getName
()),
PlatDevice:
:
getName
,
dto
.
getName
());
queryWrapper
.
like
(
StringUtil
.
isNotEmpty
(
dto
.
getProductName
()),
PlatDevice:
:
getProductName
,
dto
.
getProductName
());
queryWrapper
.
eq
(
StringUtil
.
isNotEmpty
(
dto
.
getStatus
()),
PlatDevice:
:
getStatus
,
dto
.
getStatus
());
Page
<
PlatDevice
>
pages
=
platDeviceService
.
page
(
p
,
queryWrapper
);
List
<
PlatDeviceDTO
>
listRecord
=
BeanDtoVoUtils
.
listVo
(
pages
.
getRecords
(),
PlatDeviceDTO
.
class
);
return
PageUtil
.
toPageVO
(
listRecord
,
pages
);
}
@Override
public
List
<
PlatDeviceDTO
>
listBindDevice
(
PlatBedDeviceQueryDTO
dto
)
{
LambdaQueryWrapper
<
PlatRoomBedDevice
>
queryWrapper1
=
new
LambdaQueryWrapper
<>();
queryWrapper1
.
eq
(
PlatRoomBedDevice:
:
getRoomId
,
dto
.
getRoomId
());
List
<
PlatRoomBedDevice
>
list
=
platRoomBedDeviceService
.
list
(
queryWrapper1
);
List
<
String
>
listEquipmentIds
=
list
.
stream
().
map
(
item
->
item
.
getEquipmentId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
listBedIds
=
list
.
stream
().
map
(
item
->
item
.
getBedId
()).
collect
(
Collectors
.
toList
());
LambdaQueryWrapper
<
PlatBed
>
queryWrapper2
=
new
LambdaQueryWrapper
<>();
queryWrapper2
.
in
(
PlatBed:
:
getId
,
listBedIds
);
List
<
PlatBed
>
listBeds
=
list
(
queryWrapper2
);
Map
<
String
,
String
>
map
=
listBeds
.
stream
().
collect
(
Collectors
.
toMap
(
PlatBed:
:
getId
,
PlatBed:
:
getName
,(
k1
,
k2
)->
k1
));
Map
<
String
,
String
>
mapName
=
new
HashMap
<>();
list
.
forEach
(
item
->{
if
(
map
.
containsKey
(
item
.
getBedId
())){
mapName
.
put
(
item
.
getEquipmentId
(),
map
.
get
(
item
.
getBedId
()));
}
});
List
<
PlatDeviceDTO
>
data
=
new
ArrayList
<>();
if
(!
listEquipmentIds
.
isEmpty
()){
LambdaQueryWrapper
<
PlatDevice
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
PlatDevice:
:
getCategory
,
PlatDeviceEnum
.
CategoryEnum
.
HEART
);
queryWrapper
.
in
(
PlatDevice:
:
getId
,
listEquipmentIds
);
List
<
PlatDevice
>
listDevices
=
platDeviceService
.
list
(
queryWrapper
);
data
=
BeanDtoVoUtils
.
listVo
(
listDevices
,
PlatDeviceDTO
.
class
);
data
.
forEach
(
item
->{
item
.
setBedName
(
mapName
.
get
(
item
.
getId
()));
});
}
return
data
;
}
}
}
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatRoomBedDeviceServiceImpl.java
View file @
a5907113
package
com
.
makeit
.
service
.
platform
.
space
.
impl
;
package
com
.
makeit
.
service
.
platform
.
space
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.makeit.common.page.PageReqDTO
;
import
com.makeit.common.page.PageVO
;
import
com.makeit.dto.platform.device.PlatDeviceDTO
;
import
com.makeit.dto.platform.space.PlatBedDeviceQueryDTO
;
import
com.makeit.dto.platform.space.PlatRoomBindDeviceDTO
;
import
com.makeit.dto.platform.space.PlatSpaceDeviceQueryDTO
;
import
com.makeit.dto.platform.space.PlatUnbindingDeviceDTO
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.entity.platform.space.PlatBed
;
import
com.makeit.entity.platform.space.PlatRoomBedDevice
;
import
com.makeit.entity.platform.space.PlatRoomBedDevice
;
import
com.makeit.enums.CommonEnum
;
import
com.makeit.enums.platform.device.PlatDeviceEnum
;
import
com.makeit.mapper.platform.space.PlatRoomBedDeviceMapper
;
import
com.makeit.mapper.platform.space.PlatRoomBedDeviceMapper
;
import
com.makeit.service.platform.device.PlatDeviceService
;
import
com.makeit.service.platform.space.PlatBedService
;
import
com.makeit.service.platform.space.PlatRoomBedDeviceService
;
import
com.makeit.service.platform.space.PlatRoomBedDeviceService
;
import
com.makeit.utils.data.convert.BeanDtoVoUtils
;
import
com.makeit.utils.data.convert.PageUtil
;
import
jodd.util.StringUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
/**
* @Author:lzy
* @Author:lzy
...
@@ -13,4 +39,120 @@ import org.springframework.stereotype.Service;
...
@@ -13,4 +39,120 @@ import org.springframework.stereotype.Service;
*/
*/
@Service
@Service
public
class
PlatRoomBedDeviceServiceImpl
extends
ServiceImpl
<
PlatRoomBedDeviceMapper
,
PlatRoomBedDevice
>
implements
PlatRoomBedDeviceService
{
public
class
PlatRoomBedDeviceServiceImpl
extends
ServiceImpl
<
PlatRoomBedDeviceMapper
,
PlatRoomBedDevice
>
implements
PlatRoomBedDeviceService
{
@Autowired
private
PlatDeviceService
platDeviceService
;
@Autowired
private
PlatBedService
platBedService
;
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
bindingDevice
(
PlatRoomBindDeviceDTO
dto
)
{
List
<
String
>
listEquipmentIds
=
dto
.
getListEquipmentId
();
List
<
PlatRoomBedDevice
>
list
=
new
ArrayList
<>();
listEquipmentIds
.
forEach
(
item
->{
PlatRoomBedDevice
data
=
new
PlatRoomBedDevice
();
data
.
setEquipmentId
(
item
);
data
.
setRoomId
(
dto
.
getRoomId
());
data
.
setBedId
(
dto
.
getBedId
());
list
.
add
(
data
);
});
if
(!
list
.
isEmpty
()){
saveBatch
(
list
);
}
}
@Override
public
PageVO
<
PlatDeviceDTO
>
pageDevice
(
PageReqDTO
<
PlatSpaceDeviceQueryDTO
>
pageReqDTO
)
{
PlatSpaceDeviceQueryDTO
dto
=
pageReqDTO
.
getData
();
LambdaQueryWrapper
<
PlatRoomBedDevice
>
queryWrapper1
=
new
LambdaQueryWrapper
<>();
queryWrapper1
.
select
(
PlatRoomBedDevice:
:
getEquipmentId
);
if
(
StringUtil
.
isNotEmpty
(
dto
.
getRoomId
())){
queryWrapper1
.
ne
(
PlatRoomBedDevice:
:
getRoomId
,
dto
.
getRoomId
());
}
if
(
CommonEnum
.
NO
.
getValue
().
equals
(
dto
.
getIsRoom
())){
queryWrapper1
.
isNull
(
PlatRoomBedDevice:
:
getBedId
);
}
List
<
PlatRoomBedDevice
>
list
=
list
(
queryWrapper1
);
List
<
String
>
listEquipmentIds
=
list
.
stream
().
map
(
item
->
item
.
getEquipmentId
()).
collect
(
Collectors
.
toList
());
Page
<
PlatDevice
>
p
=
PageUtil
.
toMpPage
(
pageReqDTO
);
LambdaQueryWrapper
<
PlatDevice
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
notIn
(
PlatDevice:
:
getId
,
listEquipmentIds
);
queryWrapper
.
eq
(
PlatDevice:
:
getCategory
,
dto
.
getCategory
());
queryWrapper
.
like
(
StringUtil
.
isNotEmpty
(
dto
.
getOriDeviceId
()),
PlatDevice:
:
getOriDeviceId
,
dto
.
getOriDeviceId
());
queryWrapper
.
like
(
StringUtil
.
isNotEmpty
(
dto
.
getName
()),
PlatDevice:
:
getName
,
dto
.
getName
());
queryWrapper
.
like
(
StringUtil
.
isNotEmpty
(
dto
.
getProductName
()),
PlatDevice:
:
getProductName
,
dto
.
getProductName
());
queryWrapper
.
eq
(
StringUtil
.
isNotEmpty
(
dto
.
getStatus
()),
PlatDevice:
:
getStatus
,
dto
.
getStatus
());
Page
<
PlatDevice
>
pages
=
platDeviceService
.
page
(
p
,
queryWrapper
);
List
<
PlatDeviceDTO
>
listRecord
=
BeanDtoVoUtils
.
listVo
(
pages
.
getRecords
(),
PlatDeviceDTO
.
class
);
return
PageUtil
.
toPageVO
(
listRecord
,
pages
);
}
@Override
public
List
<
PlatDeviceDTO
>
listBindDevice
(
PlatBedDeviceQueryDTO
dto
)
{
LambdaQueryWrapper
<
PlatRoomBedDevice
>
queryWrapper1
=
new
LambdaQueryWrapper
<>();
queryWrapper1
.
eq
(
PlatRoomBedDevice:
:
getRoomId
,
dto
.
getRoomId
());
queryWrapper1
.
eq
(
StringUtil
.
isNotEmpty
(
dto
.
getBedId
()),
PlatRoomBedDevice:
:
getBedId
,
dto
.
getBedId
());
List
<
PlatRoomBedDevice
>
list
=
list
(
queryWrapper1
);
List
<
String
>
listEquipmentIds
=
list
.
stream
().
map
(
item
->
item
.
getEquipmentId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
listBedIds
=
list
.
stream
().
map
(
item
->
item
.
getBedId
()).
collect
(
Collectors
.
toList
());
LambdaQueryWrapper
<
PlatBed
>
queryWrapper2
=
new
LambdaQueryWrapper
<>();
queryWrapper2
.
in
(
PlatBed:
:
getId
,
listBedIds
);
List
<
PlatBed
>
listBeds
=
platBedService
.
list
(
queryWrapper2
);
Map
<
String
,
String
>
map
=
listBeds
.
stream
().
collect
(
Collectors
.
toMap
(
PlatBed:
:
getId
,
PlatBed:
:
getName
,(
k1
,
k2
)->
k1
));
Map
<
String
,
String
>
mapName
=
new
HashMap
<>();
list
.
forEach
(
item
->{
if
(
map
.
containsKey
(
item
.
getBedId
())){
mapName
.
put
(
item
.
getEquipmentId
(),
map
.
get
(
item
.
getBedId
()));
}
});
List
<
PlatDeviceDTO
>
data
=
new
ArrayList
<>();
if
(!
listEquipmentIds
.
isEmpty
()){
LambdaQueryWrapper
<
PlatDevice
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
PlatDevice:
:
getCategory
,
PlatDeviceEnum
.
CategoryEnum
.
HEART
);
queryWrapper
.
in
(
PlatDevice:
:
getId
,
listEquipmentIds
);
List
<
PlatDevice
>
listDevices
=
platDeviceService
.
list
(
queryWrapper
);
data
=
BeanDtoVoUtils
.
listVo
(
listDevices
,
PlatDeviceDTO
.
class
);
data
.
forEach
(
item
->{
item
.
setBedName
(
mapName
.
get
(
item
.
getId
()));
});
}
return
data
;
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
unbindingDevice
(
PlatUnbindingDeviceDTO
dto
)
{
LambdaQueryWrapper
<
PlatRoomBedDevice
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
PlatRoomBedDevice:
:
getEquipmentId
,
dto
.
getEquipmentId
());
queryWrapper
.
eq
(
PlatRoomBedDevice:
:
getRoomId
,
dto
.
getRoomId
());
queryWrapper
.
eq
(
StringUtil
.
isNotEmpty
(
dto
.
getBedId
()),
PlatRoomBedDevice:
:
getBedId
,
dto
.
getBedId
());
List
<
PlatRoomBedDevice
>
list
=
list
(
queryWrapper
);
if
(
StringUtil
.
isNotEmpty
(
dto
.
getBedId
())){
list
.
forEach
(
item
->{
item
.
setBedId
(
null
);
});
updateBatchById
(
list
);
}
else
{
List
<
String
>
ids
=
list
.
stream
().
map
(
item
->
item
.
getId
()).
collect
(
Collectors
.
toList
());
removeByIds
(
ids
);
}
}
}
}
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