Commit f3f9905e by 罗志长

feat: 平台端设备管理列表新增关联长者

parent efe19e6e
......@@ -51,7 +51,7 @@ public class PlatDeviceController {
@ApiOperation("分页列表")
@PostMapping("page")
public ApiResponseEntity<PageVO<PlatDeviceListVO>> page(@RequestBody PageReqDTO<PlatDeviceQueryDTO> pageReqDTO) {
return ApiResponseUtils.success(platDeviceService.page(pageReqDTO));
return ApiResponseUtils.success(platDeviceService.platPage(pageReqDTO));
}
@ApiOperation("编辑")
......
......@@ -21,5 +21,7 @@ public interface PlatDeviceMapper extends BaseMapper<PlatDevice> {
Page<PlatDeviceListVO> getDeviceIdsBySpaceId(@Param("param")PlatDeviceQueryDTO param, Page page);
Page<PlatDeviceListVO> getDeviceIdsBySpaceIdAndElder(@Param("param")PlatDeviceQueryDTO param, Page page);
Page<PlatDeviceListVO> getDevices(@Param("param")PlatDataScreenQueryDTO param, Page<PlatDevice> page);
}
......@@ -32,6 +32,8 @@ import java.util.List;
*/
public interface PlatDeviceService extends IService<PlatDevice> {
PageVO<PlatDeviceListVO> platPage(PageReqDTO<PlatDeviceQueryDTO> pageReqDTO);
PageVO<PlatDeviceListVO> page(PageReqDTO<PlatDeviceQueryDTO> pageReqDTO);
void edit(PlatDeviceEditDTO dto);
......
......@@ -153,6 +153,64 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
* @return
*/
@Override
public PageVO<PlatDeviceListVO> platPage(PageReqDTO<PlatDeviceQueryDTO> pageReqDTO) {
PlatDeviceQueryDTO dto = pageReqDTO.getData();
Page<PlatDevice> p = PageUtil.toMpPage(pageReqDTO);
Page<PlatDeviceListVO> page = baseMapper.getDeviceIdsBySpaceIdAndElder(dto, p);
List<PlatDeviceListVO> records = page.getRecords();
if (CollectionUtils.isEmpty(records)) {
return PageVO.emptyPage();
}
List<String> spaceIdList = records.stream().flatMap(vo -> {
String spaceParentPath = vo.getSpaceParentPath();
String spp = Optional.ofNullable(spaceParentPath).orElse("");
return Stream.of(spp.split(","));
}).collect(Collectors.toList());
spaceIdList.add("-1");
List<PlatSpace> platSpaces = platSpaceService.listByIds(spaceIdList);
Map<String, String> spaceIdNameMap = platSpaces.stream().collect(Collectors.toMap(BaseEntity::getId, vo -> vo.getName(), (v1, v2) -> v1));
for (PlatDeviceListVO record : records) {
String spaceParentPath = record.getSpaceParentPath();
String spaceName = "";
if (StringUtils.isNotBlank(spaceParentPath)) {
String spaceNameJoin = Stream.of(spaceParentPath.split(",")).map(vo -> spaceIdNameMap.get(vo)).collect(Collectors.joining("-"));
spaceName = spaceNameJoin + "-" + record.getSpaceName() + "-" + record.getRoomName();
} else {
if (StringUtils.isNotEmpty(record.getSpaceName())) {
spaceName = record.getSpaceName();
}
if (StringUtils.isNotEmpty(record.getRoomName())) {
spaceName += "-" + record.getRoomName();
}
}
if (StringUtils.isNotBlank(record.getBedName())) {
spaceName = spaceName + "-" + record.getBedName();
}
record.setSpaceName(spaceName);
}
JoinUtil.join(records, platOrgService, PlatDeviceListVO::getOrgId, PlatOrg::getId, (d, o) -> {
d.setOrgName(o.getName());
});
JoinUtil.joinSplit(records, platOrgService, PlatDeviceListVO::getOrgPath, PlatOrg::getId, (d, o) -> {
d.setOrgPathName(StreamUtil.join(o, PlatOrg::getName));
});
return PageUtil.toPageVO(records, page);
}
@Override
public PageVO<PlatDeviceListVO> page(PageReqDTO<PlatDeviceQueryDTO> pageReqDTO) {
PlatDeviceQueryDTO dto = pageReqDTO.getData();
Page<PlatDevice> p = PageUtil.toMpPage(pageReqDTO);
......
......@@ -93,6 +93,9 @@ public class PlatDeviceListVO extends BaseTenantDTO {
private String roomName;
private String bedName;
private String elderName;
@ApiModelProperty(value = "许可证")
private String deviceLicense;
......
......@@ -60,6 +60,67 @@
order by pd.update_date desc,pd.id desc
</select>
<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,
pe.`name` as elderName
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')
<where>
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>
<if test="param.oriDeviceId != null and param.oriDeviceId != ''">
and pd.ori_device_id like concat('%',#{param.oriDeviceId},'%')
</if>
<if test="param.name != null and param.name != ''">
and pd.name like concat('%',#{param.name},'%')
</if>
<if test="param.status != null and param.status != '' ">
and pd.status = #{param.status}
</if>
<if test="param.productName != null and param.productName != '' ">
and pd.product_name like concat('%',#{param.productName},'%')
</if>
<if test="param.productId != null and param.productId != '' ">
and pd.product_id = #{param.productId}
</if>
<if test="param.orgId != null and param.orgId != '' ">
and pd.org_id = #{param.orgId}
</if>
<if test="param.tenantId != null and param.tenantId != ''">
and pd.tenant_id = #{param.tenantId}
</if>
<if test="param.active !=null and param.active == 1">
and pd.device_license is not null
</if>
<if test="param.active !=null and param.active == 0">
and pd.device_license is null
</if>
<if test="param.elderId !=null and param.elderId != ''">
and pe.id = #{param.elderId}
</if>
<if test="param.orgIds != null and param.orgIds.size() > 0 ">
AND pd.org_id in
<foreach collection="param.orgIds" item="item" separator="," open="(" close=")" index="">
#{item}
</foreach>
</if>
</where>
order by pd.update_date desc,pd.id desc
</select>
<select id="getDevices" resultType="com.makeit.vo.platform.device.PlatDeviceListVO">
select
distinct
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment