Commit 2432fac0 by lzy

绑定设备

parent 6639acb3
......@@ -46,7 +46,6 @@ CREATE TABLE `plat_bed`
`room_id` varchar(64) NOT NULL COMMENT '房间id',
`space_id` varchar(64) NOT NULL COMMENT '空间id',
`sort` INT(4) NOT NULL COMMENT '序号',
`equipment_id` varchar(64) DEFAULT NULL COMMENT '设备id',
`status` char(1) DEFAULT 1 COMMENT '是否空闲 1 是 0 否 ',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建者',
`create_date` datetime DEFAULT NULL COMMENT '创建时间',
......@@ -59,6 +58,24 @@ CREATE TABLE `plat_bed`
DEFAULT CHARSET = utf8mb4 COMMENT ='床位管理';
CREATE TABLE `plat_room_bed_device`
(
`id` varchar(64) NOT NULL COMMENT 'id',
`name` varchar(128) NOT NULL COMMENT '床位名称 床位1,床位2',
`room_id` varchar(64) NOT NULL COMMENT '房间id',
`bed_id` varchar(64) NOT NULL COMMENT '空间id',
`equipment_id` varchar(64) DEFAULT NULL COMMENT '设备id',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建者',
`create_date` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(64) DEFAULT NULL COMMENT '更新者',
`update_date` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int(1) DEFAULT '0' COMMENT '删除标记',
`tenant_id` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT ' 租户id ',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='设备房间床位关联表';
-- 待完善 区域设置表
CREATE TABLE `plat_region_setting`
......
......@@ -25,9 +25,6 @@ public class PlatBed extends BaseBusEntity {
@ApiModelProperty(value = "空间Id")
private String spaceId;
@ApiModelProperty(value = "设备Id")
private String equipmentId;
@ApiModelProperty(value = "是否空闲 1 是 0 否")
private String status;
......
package com.makeit.entity.platform.space;
import com.makeit.common.entity.BaseBusEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @Author:lzy
* @Date:2023/9/6 17:41
* @Describe:
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "PlatRoomBedDevice对象", description = "房间床位设备中间表")
public class PlatRoomBedDevice extends BaseBusEntity {
@ApiModelProperty(value = "房间ID")
private String roomId;
@ApiModelProperty(value = "设备Id")
private String equipmentId;
@ApiModelProperty(value = "床位Id")
private String bedId;
}
package com.makeit.mapper.platform.space;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
/**
* @Author:lzy
* @Date:2023/9/6 17:43
* @Describe:
*/
public interface PlatRoomBedDeviceMapper extends BaseMapper<PlatRoomBedDevice> {
}
package com.makeit.service.platform.space;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
/**
* @Author:lzy
* @Date:2023/9/6 17:44
* @Describe:
*/
public interface PlatRoomBedDeviceService extends IService<PlatRoomBedDevice> {
}
......@@ -12,6 +12,7 @@ import com.makeit.dto.platform.space.PlatBedQueryDTO;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.platform.device.PlatDeviceEnum;
......@@ -19,6 +20,7 @@ import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.space.PlatBedMapper;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.space.PlatBedService;
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;
......@@ -42,6 +44,9 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
@Autowired
private PlatDeviceService platDeviceService;
@Autowired
private PlatRoomBedDeviceService platRoomBedDeviceService;
@Override
@Transactional(rollbackFor = Exception.class)
public void add(PlatRoom platRoom) {
......@@ -119,7 +124,9 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_BAD_NOT_DEL);
}
if(StringUtil.isNotEmpty(platBed.getEquipmentId())){
LambdaQueryWrapper<PlatRoomBedDevice> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatRoomBedDevice::getBedId,id);
if(platRoomBedDeviceService.count(queryWrapper) > 0){
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_BAD_NOT_DEL);
}
......@@ -129,11 +136,11 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
@Override
public PageVO<PlatDeviceDTO> pageDevice(PageReqDTO<PlatDeviceDTO> pageReqDTO) {
LambdaQueryWrapper<PlatBed> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.select(PlatBed::getEquipmentId);
queryWrapper1.isNotNull(PlatBed::getEquipmentId);
List<PlatBed> listBed = list(queryWrapper1);
List<String> listEquipmentIds = listBed.stream().map(item->item.getEquipmentId()).collect(Collectors.toList());
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());
PlatDeviceDTO dto = pageReqDTO.getData();
Page<PlatDevice> p = PageUtil.toMpPage(pageReqDTO);
......@@ -153,12 +160,16 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
@Override
public List<PlatDeviceDTO> listBindDevice(PlatBedDeviceQueryDTO dto) {
LambdaQueryWrapper<PlatBed> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.select(PlatBed::getEquipmentId,PlatBed::getName);
queryWrapper1.isNotNull(PlatBed::getEquipmentId);
queryWrapper1.eq(PlatBed::getRoomId,dto.getRoomId());
List<PlatBed> listBed = list(queryWrapper1);
List<String> listEquipmentIds = listBed.stream().map(item->item.getEquipmentId()).collect(Collectors.toList());
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<>();
Map<String,String> map = listBed.stream().collect(Collectors.toMap(PlatBed::getEquipmentId,PlatBed::getName,(k1,k2)->k1));
List<PlatDeviceDTO> data = new ArrayList<>();
......
package com.makeit.service.platform.space.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
import com.makeit.mapper.platform.space.PlatRoomBedDeviceMapper;
import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import org.springframework.stereotype.Service;
/**
* @Author:lzy
* @Date:2023/9/6 17:44
* @Describe:
*/
@Service
public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceMapper, PlatRoomBedDevice> implements PlatRoomBedDeviceService {
}
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