Commit 87d2654a by lzy

选择设备

parent eac35281
......@@ -95,4 +95,4 @@ PLATFORM.ERROR.SPACE.NOT.DEL=该空间下存在下级或者房间,不可删除
PLATFORM.ERROR.ROOM.EXIT.BAD=房间中存在床位,不可删除
PLATFORM.ERROR.ROOM.BAD.NUMBER.NOT.AUTH=床位数量不能改小
PLATFORM.ERROR.BAD.NAME.EXIT=床位名称已存在
PLATFORM.ERROR.BAD.NOT.DEL=床位已绑定长者,不可删除
\ No newline at end of file
PLATFORM.ERROR.BAD.NOT.DEL=床位已绑定长者或设备,不可删除
\ No newline at end of file
......@@ -5,9 +5,11 @@ 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.PlatBedEditDTO;
import com.makeit.dto.platform.space.PlatBedQueryDTO;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.space.PlatBedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -45,7 +47,6 @@ public class PlatBedController {
return ApiResponseUtils.success(data);
}
@ApiOperation("编辑")
@PostMapping("edit")
public ApiResponseEntity<?> edit(@Validated @RequestBody PlatBedEditDTO dto) {
......@@ -60,4 +61,11 @@ public class PlatBedController {
return ApiResponseUtils.success();
}
@ApiOperation("设备列表(选择设备)")
@PostMapping("pageDevice")
public ApiResponseEntity<PageVO<PlatDeviceDTO>> pageDevice(@RequestBody PageReqDTO<PlatDeviceDTO> page) {
PageVO<PlatDeviceDTO> data = platBedService.pageDevice(page);
return ApiResponseUtils.success(data);
}
}
package com.makeit.dto.platform.device;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author:lzy
* @Date:2023/9/6 15:09
* @Describe:
*/
@Data
@ApiModel("PlatDeviceDTO 模型")
public class PlatDeviceDTO {
@ApiModelProperty(value = "原始设备ID")
private String oriDeviceId;
@ApiModelProperty(value = "设备名称")
private String name;
@ApiModelProperty(value = "产品名称")
private String productName;
@ApiModelProperty(value = "状态 数据字典 1 在线 0离线")
private String status;
}
......@@ -65,5 +65,8 @@ public class PlatDevice extends BaseBusEntity {
@ApiModelProperty(value = "组织路径")
private String orgPath;
@ApiModelProperty(value = "设备类型 0-呼吸心率雷达 1-空间人体雷达 2-跌倒检测雷达")
private String category;
}
......@@ -18,4 +18,18 @@ public class PlatDeviceEnum {
}
}
public enum CategoryEnum implements BaseEnum {
HEART("device.category.heart"), FALL("device.status.fall"), SPACE("device.status.space");
private String code;
CategoryEnum(String code) {
this.code = code;
}
public String getValue() {
return SysDictUtil.getValue(code);
}
}
}
......@@ -3,6 +3,7 @@ package com.makeit.service.platform.space;
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.PlatBedEditDTO;
import com.makeit.dto.platform.space.PlatBedQueryDTO;
import com.makeit.entity.platform.space.PlatBed;
......@@ -47,5 +48,12 @@ public interface PlatBedService extends IService<PlatBed> {
*/
void del(String id);
/**
* 未绑定设备列表
* @param pageReqDTO
* @return
*/
PageVO<PlatDeviceDTO> pageDevice(PageReqDTO<PlatDeviceDTO> pageReqDTO);
}
......@@ -5,22 +5,29 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.PlatBedEditDTO;
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.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.platform.device.PlatDeviceEnum;
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.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.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author:lzy
......@@ -30,6 +37,9 @@ import java.util.List;
@Service
public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> implements PlatBedService {
@Autowired
private PlatDeviceService platDeviceService;
@Override
@Transactional(rollbackFor = Exception.class)
public void add(PlatRoom platRoom) {
......@@ -106,6 +116,35 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
if(CommonEnum.NO.getValue().equals(platBed.getStatus())){
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_BAD_NOT_DEL);
}
if(StringUtil.isNotEmpty(platBed.getEquipmentId())){
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_BAD_NOT_DEL);
}
removeById(id);
}
@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());
PlatDeviceDTO dto = pageReqDTO.getData();
Page<PlatDevice> p = PageUtil.toMpPage(pageReqDTO);
LambdaQueryWrapper<PlatDevice> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatDevice::getCategory, PlatDeviceEnum.CategoryEnum.HEART);
queryWrapper.notIn(PlatDevice::getId,listEquipmentIds);
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);
}
}
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