|
|
@@ -1,25 +1,40 @@
|
|
|
package org.dromara.backstage.basics.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.collection.ListUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.dromara.backstage.basics.domain.PtRoom;
|
|
|
+import org.dromara.backstage.basics.domain.PtRoomType;
|
|
|
+import org.dromara.backstage.basics.domain.bo.PtRoomTypeBo;
|
|
|
+import org.dromara.backstage.basics.domain.bo.QueryFloorDataBo;
|
|
|
+import org.dromara.backstage.basics.domain.bo.QueryFloorRoomBo;
|
|
|
+import org.dromara.backstage.basics.domain.vo.*;
|
|
|
import org.dromara.backstage.basics.mapper.PtRoomMapper;
|
|
|
+import org.dromara.backstage.basics.mapper.PtRoomTypeMapper;
|
|
|
+import org.dromara.backstage.basics.service.IPtRoomTypeService;
|
|
|
import org.dromara.common.core.enums.BuildAreaTypeEnum;
|
|
|
+import org.dromara.common.core.enums.FJLXEnum;
|
|
|
+import org.dromara.common.core.enums.HotelRoomStatusEnum;
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.dromara.hotel.api.domain.vo.RemoteOrderVo;
|
|
|
+import org.dromara.hotel.api.service.RemoteOrderService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.dromara.backstage.basics.domain.bo.PtAreaBo;
|
|
|
-import org.dromara.backstage.basics.domain.vo.PtAreaVo;
|
|
|
import org.dromara.backstage.basics.domain.PtArea;
|
|
|
import org.dromara.backstage.basics.mapper.PtAreaMapper;
|
|
|
import org.dromara.backstage.basics.service.IPtAreaService;
|
|
|
|
|
|
+import java.text.Collator;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* 建筑物区域Service业务层处理
|
|
|
@@ -35,6 +50,11 @@ public class PtAreaServiceImpl implements IPtAreaService {
|
|
|
|
|
|
private final PtRoomMapper ptRoomMapper;
|
|
|
|
|
|
+ private final PtRoomTypeMapper roomTypeMapper;
|
|
|
+
|
|
|
+ @DubboReference
|
|
|
+ private RemoteOrderService remoteOrderService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询建筑物区域
|
|
|
*
|
|
|
@@ -59,8 +79,78 @@ public class PtAreaServiceImpl implements IPtAreaService {
|
|
|
return baseMapper.selectVoList(lqw);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<PtAreaVo> queryListNoLC() {
|
|
|
+// lqw.notIn(PtArea::getAreaType, BuildAreaTypeEnum.LC.code());
|
|
|
+
|
|
|
+ List<PtAreaVo> ptAreaVos = baseMapper.selectVoList();
|
|
|
+
|
|
|
+ List<PtAreaVo> rs = ptAreaVos.stream().filter(ptAreaVo -> !ptAreaVo.getAreaType().equals(BuildAreaTypeEnum.LC.code())).toList();
|
|
|
+
|
|
|
+ //楼层
|
|
|
+ //根据 楼层 查 类型为客房的房间 然后再 统计 房间总数量 和 ok房的数量 学校与校区的数量交给前端计算
|
|
|
+ List<Long> floorIds = ptAreaVos.stream().filter(ptAreaVo -> ptAreaVo.getAreaType().equals(BuildAreaTypeEnum.LC.code())).map(PtAreaVo::getAreaId).toList();
|
|
|
+ List<PtAreaVo> lcs = ptAreaVos.stream().filter(ptAreaVo -> ptAreaVo.getAreaType().equals(BuildAreaTypeEnum.LC.code())).toList();
|
|
|
+
|
|
|
+ // 客房房间
|
|
|
+ List<PtRoomVo> guestRooms = ptRoomMapper.selectVoList(Wrappers.lambdaQuery(PtRoom.class).eq(PtRoom::getRoomType, FJLXEnum.KF.code()).in(PtRoom::getAreaId, floorIds));
|
|
|
+
|
|
|
+// System.err.println(guestRooms.stream().filter(e -> e.getRoomId() == 101).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ lcs.forEach(ptAreaVo -> {
|
|
|
+ ptAreaVo.setAllCount(guestRooms.stream().filter(ptRoomVo -> ptRoomVo.getAreaId().equals(ptAreaVo.getAreaId())).count());
|
|
|
+ ptAreaVo.setFreeCount(guestRooms.stream()
|
|
|
+ .filter(ptRoomVo -> ptRoomVo.getAreaId().equals(ptAreaVo.getAreaId()))
|
|
|
+ .filter(ptRoomVo -> HotelRoomStatusEnum.OK.code().equals(ptRoomVo.getStatus())).count());
|
|
|
+ });
|
|
|
+
|
|
|
+ // 楼栋
|
|
|
+ List<PtAreaVo> lds = rs.stream().filter(ptAreaVo -> ptAreaVo.getAreaType().equals(BuildAreaTypeEnum.LD.code())).toList();
|
|
|
+
|
|
|
+ setCount(lcs, lds);
|
|
|
+
|
|
|
+ // 只输出 有客房的 校区 和 楼栋
|
|
|
+ // 过滤 掉无客房的楼栋
|
|
|
+ List<PtAreaVo> vos = rs.stream().filter(ptAreaVo -> !BuildAreaTypeEnum.LD.code().equals(ptAreaVo.getAreaType()) || ptAreaVo.getAllCount() > 0).toList();
|
|
|
+
|
|
|
+ // 还要过滤 掉 无客房的校区
|
|
|
+ // 校区
|
|
|
+ List<PtAreaVo> xqs = vos.stream().filter(ptAreaVo -> ptAreaVo.getAreaType().equals(BuildAreaTypeEnum.XQ.code())).toList();
|
|
|
+ // 排除 没有 子节点的 校区
|
|
|
+ List<PtAreaVo> result = vos.stream().filter(ptAreaVo -> {
|
|
|
+ if (ptAreaVo.getAreaType().equals(BuildAreaTypeEnum.XQ.code())) {
|
|
|
+ return vos.stream().anyMatch(ptAreaVo1 -> ptAreaVo1.getParentId().equals(ptAreaVo.getAreaId()));
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }).toList();
|
|
|
+ // 统计校区
|
|
|
+ List<PtAreaVo> capList = result.stream().filter(ptAreaVo -> BuildAreaTypeEnum.XQ.code().equals(ptAreaVo.getAreaType())).toList();
|
|
|
+ setCount(result, capList);
|
|
|
+
|
|
|
+ // 学校
|
|
|
+ List<PtAreaVo> schoolList = result.stream().filter(ptAreaVo -> BuildAreaTypeEnum.XX.code().equals(ptAreaVo.getAreaType())).toList();
|
|
|
+ setCount(result, schoolList);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
- * 查询楼层
|
|
|
+ * 统计某一类型的 房间总数和可用数量
|
|
|
+ * @param allList 所有数据
|
|
|
+ * @param setList 某一类型且需要统计的数据
|
|
|
+ */
|
|
|
+ private void setCount(List<PtAreaVo> allList, List<PtAreaVo> setList) {
|
|
|
+ setList.forEach(ptAreaVo -> {
|
|
|
+ List<PtAreaVo> list = allList.stream().filter(ptAreaVo1 -> ptAreaVo1.getParentId().equals(ptAreaVo.getAreaId())).toList();
|
|
|
+ ptAreaVo.setAllCount(list.stream().map(PtAreaVo::getAllCount).reduce(Long::sum).orElse(0L));
|
|
|
+ ptAreaVo.setFreeCount(list.stream().map(PtAreaVo::getFreeCount).reduce(Long::sum).orElse(0L));
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据楼栋id查询楼层
|
|
|
* @param areaId
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -78,6 +168,24 @@ public class PtAreaServiceImpl implements IPtAreaService {
|
|
|
return baseMapper.selectVoList(lqw);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据楼栋数据查询楼层
|
|
|
+ * @param dataList 楼栋数据
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<PtAreaVo> queryByLDList(List<PtAreaBo> dataList) {
|
|
|
+ if(dataList==null||dataList.isEmpty()) return ListUtil.empty();
|
|
|
+ LambdaQueryWrapper<PtArea> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(PtArea::getAreaType, BuildAreaTypeEnum.LC.code());
|
|
|
+ lqw.in(PtArea::getParentId, dataList.stream().map(PtAreaBo::getAreaId).collect(Collectors.toList()));
|
|
|
+ List<PtAreaVo> allFloors = baseMapper.selectVoList(lqw);
|
|
|
+ List<PtAreaVo> rs = BeanUtil.copyToList(dataList, PtAreaVo.class);
|
|
|
+ rs.forEach(ptAreaVo -> {
|
|
|
+ ptAreaVo.setChildren(allFloors.stream().filter(e->e.getParentId().equals(ptAreaVo.getAreaId())).collect(Collectors.toList()));
|
|
|
+ });
|
|
|
+ return rs;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Map<Long, PtAreaVo> queryMapByIds(List<Long> ids) {
|
|
|
List<PtArea> ptAreas = baseMapper.selectBatchIds(ids);
|
|
|
@@ -205,4 +313,275 @@ public class PtAreaServiceImpl implements IPtAreaService {
|
|
|
}
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据条件查询 房间状态 数据
|
|
|
+ *
|
|
|
+ * @param param 参数
|
|
|
+ * @return 房态数据
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<FloorDataVo> getRoomStatusByParams(QueryFloorDataBo param) {
|
|
|
+ List<FloorDataVo> rs = new ArrayList<>();
|
|
|
+// 校区-楼栋-楼层-房间
|
|
|
+// 根据 房态-房型-区域-房间号 查询数据,查完之后 在查订单里的名字/手机号
|
|
|
+ //如果有参数 multiParams
|
|
|
+ if(StringUtils.isNotBlank(param.getMultiParams())) {
|
|
|
+ // 1.优先查询 姓名/手机号/房间号
|
|
|
+ // 先查询 房间号
|
|
|
+ LambdaQueryWrapper<PtRoom> roomWrapper = Wrappers.lambdaQuery();
|
|
|
+ roomWrapper.eq(PtRoom::getRoomCode, param.getMultiParams());
|
|
|
+ List<PtRoomVo> ptRoomVos = ptRoomMapper.selectVoList(roomWrapper);
|
|
|
+
|
|
|
+ if(CollectionUtil.isNotEmpty(ptRoomVos)){
|
|
|
+ //房间编码是唯一的
|
|
|
+ PtRoomVo ptRoomVo = ptRoomVos.get(0);
|
|
|
+ PtAreaVo floor = baseMapper.selectVoById(ptRoomVo.getAreaId());
|
|
|
+
|
|
|
+ FloorDataVo floorDataVo = new FloorDataVo();
|
|
|
+ //楼层
|
|
|
+ floorDataVo.setFloor(floor);
|
|
|
+ floorDataVo.setAllCount(1L);
|
|
|
+ floorDataVo.setFreeCount(HotelRoomStatusEnum.OK.code().equals(ptRoomVo.getStatus())? 0L: 1L);
|
|
|
+ //楼栋
|
|
|
+ PtAreaVo building = baseMapper.selectVoById(floor.getParentId());
|
|
|
+ floorDataVo.setBuilding(building);
|
|
|
+ //校区
|
|
|
+ PtAreaVo campus = baseMapper.selectVoById(building.getParentId());
|
|
|
+ floorDataVo.setCampus(campus);
|
|
|
+ rs.add(floorDataVo);
|
|
|
+ }else{
|
|
|
+ // 2.如果房间号没有查询到,则查询姓名/手机号 查询客房系统的订单和客户信息
|
|
|
+ List<RemoteOrderVo> orders = remoteOrderService.getOrderAndGuestByNameOrPhone(param.getMultiParams());
|
|
|
+ if(CollectionUtil.isNotEmpty(orders)){
|
|
|
+ // 查询房间
|
|
|
+ LambdaQueryWrapper<PtRoom> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.in(PtRoom::getRoomCode, orders.stream().map(RemoteOrderVo::getRoomCode).toList());
|
|
|
+ List<PtRoomVo> roomVos = ptRoomMapper.selectVoList(queryWrapper);
|
|
|
+
|
|
|
+ FloorDataVo floorDataVo = new FloorDataVo();
|
|
|
+ /*String s = Integer.toString(orders.size());
|
|
|
+ floorDataVo.setAllCount(Long.valueOf(s));
|
|
|
+ floorDataVo.setFreeCount(roomVos.stream().filter(ptRoomVo -> HotelRoomStatusEnum.OK.code().equals(ptRoomVo.getStatus())).count());*/
|
|
|
+
|
|
|
+ //查询楼层 floor
|
|
|
+ List<Long> floorIds = roomVos.stream().map(PtRoomVo::getAreaId).toList();
|
|
|
+ List<PtAreaVo> floors = baseMapper.selectVoList(Wrappers.<PtArea>lambdaQuery().in(PtArea::getAreaId, floorIds));
|
|
|
+
|
|
|
+ LambdaQueryWrapper<PtArea> query = Wrappers.lambdaQuery();
|
|
|
+ query.in(PtArea::getAreaType, List.of(BuildAreaTypeEnum.XQ.code(), BuildAreaTypeEnum.LD.code()));
|
|
|
+ List<PtAreaVo> parentAreas = baseMapper.selectVoList(query);
|
|
|
+
|
|
|
+ for (PtAreaVo floor : floors) {
|
|
|
+ FloorDataVo floorData = new FloorDataVo();
|
|
|
+ floorData.setFloor(floor);
|
|
|
+ List<PtRoomVo> floorRooms = roomVos.stream().filter(ptRoomVo -> floor.getAreaId().equals(ptRoomVo.getAreaId())).toList();
|
|
|
+ floorData.setAllCount(Long.valueOf(Integer.toString(floorRooms.size())));
|
|
|
+ floorData.setFreeCount(floorRooms.stream().filter(ptRoomVo -> HotelRoomStatusEnum.OK.code().equals(ptRoomVo.getStatus())).count());
|
|
|
+ //楼栋
|
|
|
+ floorData.setBuilding(parentAreas.stream().filter(ptAreaVo -> ptAreaVo.getAreaId().equals(floor.getParentId())).findFirst().orElse(new PtAreaVo()));
|
|
|
+
|
|
|
+ // 校区
|
|
|
+ floorData.setCampus(parentAreas.stream().filter(ptAreaVo -> ptAreaVo.getAreaId().equals(floorData.getBuilding().getParentId())).findFirst().orElse(new PtAreaVo()));
|
|
|
+ rs.add(floorData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ // 如果 没有 参数 multiParams
|
|
|
+ // 1.先查询楼层
|
|
|
+ List<PtAreaVo> floors = new ArrayList<>();
|
|
|
+ if(CollectionUtil.isNotEmpty(param.getFinallyFloors())){
|
|
|
+ // a.先查询楼层 如果 finallyFloors 不为空就不查询了
|
|
|
+ List<PtArea> ptAreas = baseMapper.selectBatchIds(param.getFinallyFloors());
|
|
|
+ floors = MapstructUtils.convert(ptAreas, PtAreaVo.class);
|
|
|
+
|
|
|
+ }else if(CollectionUtil.isNotEmpty(param.getAreaLDs())){
|
|
|
+ // b.查询楼栋下的楼层
|
|
|
+ List<Long> longs = param.getAreaLDs().stream().map(PtAreaVo::getAreaId).toList();
|
|
|
+ LambdaQueryWrapper<PtArea> query = Wrappers.lambdaQuery();
|
|
|
+ query.in(PtArea::getParentId, longs);
|
|
|
+ floors = baseMapper.selectVoList(query);
|
|
|
+ }else{
|
|
|
+ // 查询所有楼层
|
|
|
+ LambdaQueryWrapper<PtArea> query = Wrappers.lambdaQuery();
|
|
|
+ query.eq(PtArea::getAreaType, BuildAreaTypeEnum.LC.code());
|
|
|
+ floors = baseMapper.selectVoList(query);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CollectionUtil.isEmpty(floors)){
|
|
|
+ return rs;
|
|
|
+ }
|
|
|
+ List<Long> floorIds = floors.stream().map(PtAreaVo::getAreaId).toList();
|
|
|
+ // 根据楼层查询所有房间
|
|
|
+ List<PtRoomVo> guestRooms = ptRoomMapper.selectVoList(Wrappers.lambdaQuery(PtRoom.class)
|
|
|
+ // 客房
|
|
|
+ .eq(PtRoom::getRoomType, FJLXEnum.KF.code())
|
|
|
+ //楼层
|
|
|
+ .in(PtRoom::getAreaId, floorIds)
|
|
|
+ // 2.查询 房态
|
|
|
+ .in(CollectionUtil.isNotEmpty(param.getRoomStatus()),PtRoom::getStatus, param.getRoomStatus())
|
|
|
+ // 3.查询 房型
|
|
|
+ .in(CollectionUtil.isNotEmpty(param.getRoomTypes()),PtRoom::getGuestRoomType, param.getRoomTypes())
|
|
|
+ );
|
|
|
+
|
|
|
+ if(CollectionUtil.isEmpty(guestRooms)){
|
|
|
+ return rs;
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<PtArea> query = Wrappers.lambdaQuery();
|
|
|
+ query.in(PtArea::getAreaType, List.of(BuildAreaTypeEnum.XQ.code(), BuildAreaTypeEnum.LD.code()));
|
|
|
+ List<PtAreaVo> parentAreas = baseMapper.selectVoList(query);
|
|
|
+ //组装数据
|
|
|
+ for (PtAreaVo floor : floors) {
|
|
|
+ FloorDataVo floorDataVo = new FloorDataVo();
|
|
|
+ floorDataVo.setFloor(floor);
|
|
|
+ List<PtRoomVo> rooms = guestRooms.stream().filter(guestRoom -> guestRoom.getAreaId().equals(floor.getAreaId())).toList();
|
|
|
+ int size = rooms.size();
|
|
|
+ String s = Integer.toString(size);
|
|
|
+ floorDataVo.setAllCount(Long.valueOf(s));
|
|
|
+ long count = rooms.stream().filter(ptRoomVo -> HotelRoomStatusEnum.OK.code().equals(ptRoomVo.getStatus())).count();
|
|
|
+ floorDataVo.setFreeCount(count);
|
|
|
+
|
|
|
+ if(CollectionUtil.isNotEmpty(parentAreas)){
|
|
|
+ // 设置 楼栋
|
|
|
+ parentAreas.stream().filter(ptAreaVo -> ptAreaVo.getAreaId().equals(floor.getParentId())).findAny().ifPresent(floorDataVo::setBuilding);
|
|
|
+ // 设置 校区
|
|
|
+ if(floorDataVo.getBuilding() != null){
|
|
|
+ parentAreas.stream().filter(ptAreaVo -> ptAreaVo.getAreaId().equals(floorDataVo.getBuilding().getParentId())).findAny().ifPresent(floorDataVo::setCampus);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ rs.add(floorDataVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 排除总房间数 为 0 的数据
|
|
|
+ rs = rs.stream().filter(floorDataVo -> floorDataVo.getAllCount() > 0).toList();
|
|
|
+
|
|
|
+ //排序 校区名称 楼栋名称 楼层名称
|
|
|
+ if(CollectionUtil.isNotEmpty(rs)){
|
|
|
+ // 使用 Optional 处理可能为 null 的情况
|
|
|
+ // 确保 rs 是可变集合
|
|
|
+ List<FloorDataVo> mutableRs = new ArrayList<>(rs);
|
|
|
+// Collator instance = Collator.getInstance(Locale.CHINA);
|
|
|
+ mutableRs.sort(Comparator.comparing((FloorDataVo e) -> Optional.ofNullable(e.getCampus()).map(PtAreaVo::getAreaName).orElse(""))
|
|
|
+ .thenComparing(e -> Optional.ofNullable(e.getBuilding()).map(PtAreaVo::getAreaName).orElse(""))
|
|
|
+ .thenComparing((e -> Optional.ofNullable(e.getFloor()).map(PtAreaVo::getAreaId).orElse(0L))));
|
|
|
+ return mutableRs;
|
|
|
+ }
|
|
|
+
|
|
|
+ return rs;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据楼层查询房间订单数据 用于房态
|
|
|
+ *
|
|
|
+ * @param param 楼层等参数
|
|
|
+ * @return 房间订单数据
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<FloorRoomsVo> getRoomOrderData(QueryFloorRoomBo param) {
|
|
|
+ List<FloorRoomsVo> rs = new ArrayList<>();
|
|
|
+ List<String> checkStatus =
|
|
|
+ List.of(HotelRoomStatusEnum.YZ.code(), HotelRoomStatusEnum.CS.code(), HotelRoomStatusEnum.SF.code(), HotelRoomStatusEnum.YD.code());
|
|
|
+ if(StringUtils.isEmpty(param.getMultiParams())){
|
|
|
+// 1.基础平台的房间数据:根据楼层、房型、房间状态、房间号 查询房间数据
|
|
|
+ // 1.1.先查询所有房间数据
|
|
|
+ List<PtRoomVo> guestRooms = ptRoomMapper.selectVoList(Wrappers.lambdaQuery(PtRoom.class)
|
|
|
+ // 客房
|
|
|
+ .eq(PtRoom::getRoomType, FJLXEnum.KF.code())
|
|
|
+ //楼层
|
|
|
+ .eq(PtRoom::getAreaId, param.getFloorId())
|
|
|
+ // 2.查询 房态
|
|
|
+ .in(CollectionUtil.isNotEmpty(param.getRoomStatus()),PtRoom::getStatus, param.getRoomStatus())
|
|
|
+ .in(CollectionUtil.isNotEmpty(param.getRoomTypes()),PtRoom::getGuestRoomType, param.getRoomTypes())
|
|
|
+ );
|
|
|
+
|
|
|
+ if(CollectionUtil.isNotEmpty(guestRooms)){
|
|
|
+ // 2.查询 房型数据
|
|
|
+ List<PtRoomTypeVo> roomTypes = roomTypeMapper.selectVoList();
|
|
|
+ //转成map
|
|
|
+ Map<Long, PtRoomTypeVo> roomTypeMap = roomTypes.stream().collect(Collectors.toMap(PtRoomTypeVo::getRoomTypeId, e -> e));
|
|
|
+
|
|
|
+// 2.锁定、预定、住房、超时的房间 还需要通过调用客户系统接口查询 订单信息、客户信息
|
|
|
+ List<PtRoomVo> needCheckRooms = guestRooms.stream().filter(e -> StringUtils.isNotBlank(e.getStatus()) && checkStatus.contains(e.getStatus())).toList();
|
|
|
+ List<RemoteOrderVo> orders = remoteOrderService.getOrderAndGuestByRoomCodes(needCheckRooms.stream().map(PtRoomVo::getRoomCode).toList());
|
|
|
+
|
|
|
+ //一个房间可能有多个订单
|
|
|
+ Map<String, List<RemoteOrderVo>> ordersMap = orders.stream().collect(Collectors.groupingBy(RemoteOrderVo::getRoomCode));
|
|
|
+
|
|
|
+ //组装数据返回
|
|
|
+ setFloorRoomsResult(rs, guestRooms, roomTypeMap, ordersMap);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ String multiParams = param.getMultiParams();
|
|
|
+ // 先根据房间号查询房间数据 房间号
|
|
|
+ PtRoom ptRoom = ptRoomMapper.selectOne(Wrappers.lambdaQuery(PtRoom.class).eq(PtRoom::getRoomCode, multiParams));
|
|
|
+ if(ptRoom != null){
|
|
|
+ // 有数据
|
|
|
+ PtRoomTypeBo ptRoomTypeBo = new PtRoomTypeBo();
|
|
|
+ ptRoomTypeBo.setRoomTypeId(ptRoom.getGuestRoomType());
|
|
|
+ List<PtRoomTypeVo> roomTypes = roomTypeMapper.selectVoList(Wrappers.lambdaQuery(PtRoomType.class).eq(PtRoomType::getRoomTypeId, ptRoomTypeBo.getRoomTypeId()));
|
|
|
+
|
|
|
+ List<RemoteOrderVo> orders = remoteOrderService.getOrderAndGuestByRoomCodes(List.of(ptRoom.getRoomCode()));
|
|
|
+ FloorRoomsVo floorRoomsVo = new FloorRoomsVo();
|
|
|
+ floorRoomsVo.setRoom(MapstructUtils.convert(ptRoom, PtRoomVo.class));
|
|
|
+ floorRoomsVo.setRoomType(CollectionUtil.isNotEmpty(roomTypes)?roomTypes.get(0):null);
|
|
|
+ floorRoomsVo.setOrderList(orders);
|
|
|
+ rs.add(floorRoomsVo);
|
|
|
+ }else{
|
|
|
+ // 没有数据
|
|
|
+ // 查询这个楼层下的所有房间
|
|
|
+ List<PtRoomVo> allRooms = ptRoomMapper.selectVoList(Wrappers.lambdaQuery(PtRoom.class)
|
|
|
+ // 客房
|
|
|
+ .eq(PtRoom::getRoomType, FJLXEnum.KF.code())
|
|
|
+ // 楼层
|
|
|
+ .eq(PtRoom::getAreaId, param.getFloorId())
|
|
|
+ );
|
|
|
+
|
|
|
+ List<PtRoomVo> needCheckRooms = allRooms.stream().filter(e -> StringUtils.isNotBlank(e.getStatus()) && checkStatus.contains(e.getStatus())).toList();
|
|
|
+ if(CollectionUtil.isEmpty(needCheckRooms)){
|
|
|
+ return rs;
|
|
|
+ }
|
|
|
+ List<RemoteOrderVo> orders = remoteOrderService.getOrderAndGuestByRoomCodes(needCheckRooms.stream().map(PtRoomVo::getRoomCode).toList());
|
|
|
+
|
|
|
+ // 找出符合条件的订单 姓名 / 手机号
|
|
|
+ List<RemoteOrderVo> filterOrders = orders.stream().filter(e -> multiParams.equals(e.getPhone()) || e.getName().contains(multiParams)).toList();
|
|
|
+
|
|
|
+ if(CollectionUtil.isEmpty(filterOrders)) {
|
|
|
+ return rs;
|
|
|
+ }
|
|
|
+
|
|
|
+ //找出房间
|
|
|
+ List<PtRoomVo> filterRooms = allRooms.stream().filter(e -> filterOrders.stream().anyMatch(o -> o.getRoomCode().equals(e.getRoomCode()))).toList();
|
|
|
+
|
|
|
+ Map<String, List<RemoteOrderVo>> ordersMap = filterOrders.stream().collect(Collectors.groupingBy(RemoteOrderVo::getRoomCode));
|
|
|
+
|
|
|
+ // 2.查询 房型数据
|
|
|
+ List<PtRoomTypeVo> roomTypes = roomTypeMapper.selectVoList();
|
|
|
+ //转成map
|
|
|
+ Map<Long, PtRoomTypeVo> roomTypeMap = roomTypes.stream().collect(Collectors.toMap(PtRoomTypeVo::getRoomTypeId, e -> e));
|
|
|
+
|
|
|
+ //组装数据返回
|
|
|
+ setFloorRoomsResult(rs, filterRooms, roomTypeMap, ordersMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return rs;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setFloorRoomsResult(List<FloorRoomsVo> rs, List<PtRoomVo> guestRooms,
|
|
|
+ Map<Long, PtRoomTypeVo> roomTypeMap, Map<String, List<RemoteOrderVo>> ordersMap) {
|
|
|
+ for (PtRoomVo guestRoom : guestRooms) {
|
|
|
+ FloorRoomsVo floorRoomsVo = new FloorRoomsVo();
|
|
|
+ floorRoomsVo.setRoom(guestRoom);
|
|
|
+ floorRoomsVo.setRoomType(roomTypeMap.get(guestRoom.getGuestRoomType()));
|
|
|
+ floorRoomsVo.setOrderList(ordersMap.get(guestRoom.getRoomCode()));
|
|
|
+ rs.add(floorRoomsVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|