互锁门开关-酒店管理系统API接口
互锁门开关功能
该功能用于处理互锁门的退房操作,实现房间状态更新和通知客户端。
if (room.getRoomLockType() == RoomLockType.MUTUAL_LOCK) {
// 互锁门,根据roomId查询一下此房间关联的所有房间号
List<Integer> relatedRoomIds = roomService.queryRelatedRoomIdsByRoomId(roomId);
// 再次循环这些关联的房间
for (Integer relatedRoomId : relatedRoomIds) {
if (relatedRoomId != null) {
// 根据roomId查询对应的房间
Room relatedRoom = roomService.selectByPrimaryKey(relatedRoomId);
// 如果这个房间不是空的,即有人住在这个房间
if (relatedRoom.getGuestId() != null) {
// 则把这个房间的状态改为未入住
relatedRoom.setRoomStatus(RoomStatus.UNOCCUPIED);
roomService.updateByPrimaryKeySelective(relatedRoom);
}
}
}
}
/**
* 退房结束,把房间的状态改为未入住
*/
room.setRoomStatus(RoomStatus.UNOCCUPIED);
roomService.updateByPrimaryKeySelective(room);
// 向客户端发送退房消息
sendMessageToClient(room, MessageType.CHECK_OUT);
}
return true;
}
/**
* 根据房间号,查询入住人
*
* @param roomId
* 房间号
* @return
*/
public Guest queryGuestByRoomId(Integer roomId) {
return guestService.queryGuestByRoomId(roomId);
}
/**
* 根据房间号查询房间
*
* @param roomId
* 房间号
* @return
*/
public Room queryRoomByRoomId(Integer roomId) {
return roomService.selectByPrimaryKey(roomId);
}
/**
* 根据房号查询该房间的信息
*
* @param roomId
* 房号
* @return
*/
public RoomInfo queryRoomInfoByRoomId(Integer roomId) {
return roomService.queryRoomInfoByRoomId(roomId);
}
/**
* 根据房号查询房间的消费记录
*
* @param roomId
* 房号
* @return
*/
public List<Consumption> queryConsumptionsByRoomId(Integer roomId) {
return consumptionService.queryConsumptionsByRoomId(roomId);
}
/**
* 根据房号查询房间的入住记录
*
* @param roomId
* 房号
* @return
*/
public List<CheckInRecord> queryCheckInRecordsByRoomId(Integer roomId) {
return checkInRecordService.queryCheckInRecordsByRoomId(roomId);
}
/**
* 根据房号查询房间的退房记录
*
* @param roomId
* 房号
* @return
*/
public List<CheckOutRecord> queryCheckOutRecordsByRoomId(Integer roomId) {
return checkOutRecordService.queryCheckOutRecordsByRoomId(roomId);
}
/**
* 根据房号查询房间的订单
*
* @param roomId
* 房号
* @return
*/
public List<Order> queryOrdersByRoomId(Integer roomId) {
return orderService.queryOrdersByRoomId(roomId);
}
/**
* 查询所有房间的信息
*
* @return
*/
public List<RoomInfo> queryAllRoomInfos() {
return roomService.queryAllRoomInfos();
}
/**
* 查询所有的订单
*
* @return
*/
public List<Order> queryAllOrders() {
return orderService.queryAllOrders();
}
/**
* 查询所有的入住记录
*
* @return
*/
public List<CheckInRecord> queryAllCheckInRecords() {
return checkInRecordService.queryAllCheckInRecords();
}
/**
* 查询所有的退房记录
*
* @return
*/
public List<CheckOutRecord> queryAllCheckOutRecords() {
return checkOutRecordService.queryAllCheckOutRecords();
}
/**
* 查询所有的消费记录
*
* @return
*/
public List<Consumption> queryAllConsumptions() {
return consumptionService.queryAllConsumptions();
}
/**
* 查询所有的入住人
*
* @return
*/
public List<Guest> queryAllGuests() {
return guestService.queryAllGuests();
}
/**
* 向客户端发送消息
*
* @param room
* 房间
* @param type
* 消息类型
*/
private void sendMessageToClient(Room room, MessageType type) {
// 创建消息
Message message = new Message(room.getRoomId(), type);
// 将消息转换为json字符串
String json = JSON.toJSONString(message);
// 将消息发送到客户端
WebSocketServer.sendInfo(json);
}
}```
**接口说明:**
* **RoomLockType.MUTUAL_LOCK**: 表示互锁门类型
* **RoomStatus.UNOCCUPIED**: 表示房间状态为未入住
* **MessageType.CHECK_OUT**: 表示退房消息类型
**代码示例:**
```java
// 假设roomId为1
Integer roomId = 1;
// 退房操作
boolean checkOutResult = checkOut(roomId);
// 打印退房结果
System.out.println(checkOutResult);
注意:
- 该代码示例仅供参考,具体实现需要根据实际情况进行调整。
- 该代码示例使用的是Java语言,您需要根据实际项目所使用的语言进行修改。
- 请确保您的酒店管理系统已经配置了WebSocketServer,才能实现消息的发送。
联系方式:
如果您有任何问题或需要帮助,请随时联系我们。
邮箱: your_email@example.com
电话: 123-456-7890
原文地址: https://www.cveoy.top/t/topic/likH 著作权归作者所有。请勿转载和采集!