1.概述
中国的经济日益增长,人们的生活水平也在不断地提高,旅游成了人们享受生活的一种方式,从而带动旅游业的蓬勃生长,旅游业和宾馆行业本就相辅相成,所以对于宾馆的要求也随之提高。在宾馆行业里竞争愈发激烈,想要不与时代脱节,就必须紧跟时代高新技术的脚步。基础设施落后、管理水平低下、服务质量堪忧的宾馆管理将被湮没在时代前进车轮的尘埃后。以往的纯手工或简单的宾馆管理方式,早已不适合当代经济高速发展和信息快速增长的要求,因此必须运用现代化管理技术,以及完善的的酒店设备,运用完善的互联网技术和宾馆管理系统,从而提升宾馆自身的服务水平与质量,发挥出精确收集信息,快速提供相应服务,更好地进行管理的等效能,从竞争激烈的宾馆行业中脱颖而出。

2.需求分析
2.1用户工作流
入住或预定客房时,用户要对客房管理模块或预定管理模块进行核对审查,并进行登记;用户要获得换房时,要对换房情况进行查询和更新;顾客结束住宿时,要对其进行结算。
2.2 用户业务需求
1.该管理系统将对客房信息进行管理和登计,对已入住客房、已订购客房、未入住且已订购客房进行录入管理和统计等等。
2.该管理软件将根据用户的需求对客户情况进行资料管理和统计,对已入住客户、预定客房客户进行数据录入、信息检索、修改和删除,并能打印详细信息。
3.完善的结账报表,管理员可对报表信息进行修改。
4.管理系统具有一定的维护手段,有一定权利的操作人员在密码支持下才可以更改房价,增减房型。
5.管理者可以准确的了解到客房状态,以便于进行决策。

3.系统设计
3.1系统功能设计
1.酒店数据处理功能:实现录入、修改、删除、存储功能,如客房信息,客户信息,入住信息、换房信息,订房信息、结算信息等的数据处理等。
2.酒店信息检索功能:实现按不同要求分类进行查询,组合查询功能,根据查询方式的不同,选择输出检索信息。如订房信息的查询,结算信息的查询,新增房型,新增房间管理等。
3.管理系统系统维护功能:实现用户,管理员不同权限的限制等。

3.2 系统流程图
在这里插入图片描述

3.2.2 客房查询
在这里插入图片描述

3.3.3 客房管理

在这里插入图片描述

3.3 数据库设计
3.3.1物理模型设计
(1) 房间(room):房间号(主键),房间类型,房间价格。
(2) 客户(customer): 客户姓名,客户入住房间号(主键),客户联系方式(外键)。
(3) 管理员(manager):管理员编号(主键),管理员姓名,管理员密码。
(4) 入住记录(in history):入住编号(主键),客户姓名,入住时间,应退房时间。
(5)退房记录(out history):房间号(外键),客户姓名(主键),入住时间,退房时间。
(6) 客房类型: 房间号(外键键),客房图片编码格式,客房类型名称(主键)。
(7) 账单: 账单号(主键),盈亏信息,账单类型,入账日期。
3.3.2 概念模型设计

在这里插入图片描述

3.3.3 逻辑模型设计

-账单表:
在这里插入图片描述

-客户表:
在这里插入图片描述

-客房信息表:
在这里插入图片描述

-管理员表:
在这里插入图片描述

-客房类型表:
在这里插入图片描述

4.系统实现
4.1系统主要功能的实现
系统功能设计是使酒店管理系统能基本实现宾馆的工呢,包括以下:
客房管理,顾客入住、顾客订房、顾客更换房间、结算管理、系统用户管理等功能,能让宾馆管理者更直观的了解宾馆的经营状况,以做出相应的经营决策。宾馆管理系统要对这些资源建立正确的数据表,并进行信息的存储管理,编制成各种票据、报表、台帐等信息,同时对这些信息进行维护,通过实测宾馆的各种运行情况,并利用过去的历史数据预测未来的发展,从宾馆全局角度出发进行决策,利用信息控制宾馆的行为,辅助宾馆管理者更好的运维。

5.界面样式及其功能
5.1主界面:
在这里插入图片描述

5.2订房界面:

在这里插入图片描述


5.2.1刷新用户信息
    public void RoomInfos(HttpServletRequest request ,HttpServletResponse response) throws IOException, ServletException {
//        获取所有客房剩余数量
        List<RoomQuantityInfo> RIS= new ArrayList<>();
       RIS =  roomAmountMapper.GetAllRoomType();
//        将对象数组转为JSON
        JSONObject  JB = new JSONObject();
        String RISLists = JSONObject.toJSONString(RIS);
        response.getWriter().println(RISLists);
    }

    //处理订房用户列表信息
    public void EnsureCustomersInfo(HttpServletRequest request ,HttpServletResponse response){
        JSONArray infosList =  JSON.parseArray(request.getParameter("InfosList"));  //接收json字符串格式的对象数组
        ArrayList<CustomerBookInfosList> CBILists = new ArrayList<>();    //对象数组,存储反序列化后的对象

        //提供相应的类,获取序列化后的对象数组,逐个对象反序列化解析,并存储起来
        for(Object jsonObject : infosList){
            //导入了 fastjson依赖,解析前端序列化的对象数组
            CBI = JSONObject.parseObject(jsonObject.toString(), CustomerBookInfosList.class);
            CBILists.add(CBI);
        }

        //连接Dao层,存入订房数据
        for(int index = 0 ; index < CBILists.size(); ++index){
            //若用户填写的信息完整
             if(DeducedCustomer(CBILists.get(index)).equals("All attribute if full fill!")){
                 CBI = CBILists.get(index);
                 String CheckInDateTime = myUtility.IntegrateDateAndTime(CBI.getCheckInDate(),CBI.getCheckInTime());  //整合订房
                 String CheckOutDateTime = myUtility.IntegrateDateAndTime(CBI.getCheckOutDate(),CBI.getCheckOutTime()); //退房时间
                 String EmptyRoomNum = null;
                 Long RoomAmount = null;
                List<RoomInfo> EmptyRoomLists = roomMapper.SearchEmptyRoom();  //空房间列表
                 if(!DistributeRoomNum(EmptyRoomLists,CBI.getRoomType()).equals("null")){
                     //若客户必要信息不为空,则分配相应房间类型的空房间给客户,并则存进数据库,并更新相应类型房间数
                      EmptyRoomNum = DistributeRoomNum(EmptyRoomLists,CBI.getRoomType());   // 分配相应类型的空房间号
                     RoomInfo RI = new RoomInfo(CBI.getMobilePhone() ,EmptyRoomNum ,CBI.getRoomType() ,"-1", MyUtility.ConvertStringToDate(CheckInDateTime) , MyUtility.ConvertStringToDate(CheckOutDateTime));
                     CustomerInfo CI = new CustomerInfo(CBI.getCustomer(), CBI.getMobilePhone(),EmptyRoomNum, "0");
                     System.out.println("--------------------------------------------");
                     System.out.println("RoomInfo:"+RI);
                     System.out.println("CustomerInfo:"+CI);
                     RoomAmount = roomAmountMapper.GetOneRoomType(CBI.getRoomType()).getAmount();
                     RoomAmount--;
                     System.out.println(CBI.getRoomType()+" : "+RoomAmount.toString());
                     roomAmountMapper.UpdateRoomAmountByType(CBI.getRoomType(),RoomAmount.toString());  //更新相应房间类型的数量
                     customerMapper.InsertCustomer(CI); //向用户表存储数据
                     roomMapper.BookRoom(RI);    //向客房信息表存储数据
                     ss.commit();   //向数据库提交代码
                     request.getSession().setAttribute("Save Success!","用户信息登记成功");

                 }else{
//                     //设置信息提示前端
                     request.getSession().setAttribute("EmptyRoomNum","该系列的房间紧缺!请选择其他类型!");
                 }
             }else{
                 //若有用户信息填写不完整
                 int num = index + 1;
                 //用户信息录入失败
                 request.getSession().setAttribute("Save Failed!","The " + num +" Customer: \n "+ DeducedCustomer(CBILists.get(index)));
             }
        }
    }


5.2.2 判断客户对象信息是否齐全,并且返回缺失的信息
    public String DeducedCustomer(CustomerBookInfosList CBI ){
        String MSG = "";
        if(CBI.getMobilePhone().isEmpty()) {
            MSG += "MobilePhone is empty!\n";
        }
        if(CBI.getCustomer().isEmpty()) {
            MSG += "Customer is empty!\n";
        }
        if(CBI.getRoomStatus().isEmpty()) {
            MSG += "RoomStatus is empty!\n";
        }
        if(CBI.getRoomType().isEmpty()) {
            MSG += "RoomType is empty!\n";
        }
        if(CBI.getCheckInTime().isEmpty()) {
            MSG += "CheckInTime is empty!\n";
        }
        if(CBI.getCheckOutTime().isEmpty()) {
            MSG += "CheckOutTime is empty!\n";
        }
        if(CBI.getCheckInDate().isEmpty()) {
            MSG += "CheckInDate is empty!\n";
        }
        if(CBI.getCheckOutDate().isEmpty()) {
            MSG += "CheckInDate is empty!\n";
        }
        if(MSG.isEmpty()) {
            return  "All attribute if full fill!";
        }
        return MSG;
    }

5.2.3.根据客户选择的房间类型,分配房间号
    public String DistributeRoomNum(List<RoomInfo> lists , String CustomerSelectedType){
        String RoomNum = "null";
        for (RoomInfo list : lists) {
            if (list.getRoomType().equals(CustomerSelectedType)) {
                RoomNum = list.getRoomNum();
                break;
            }
        }
        return RoomNum;
    }

5.3退房界面:
在这里插入图片描述

5.3.1退房界面核心代码:
//处理退房信息,客户表删除相应的客户,房间表根据房间号修改房间状态,流水表记录流水 ,房间数量表根据房型修改房间数量
    public void CheckOutInfos(HttpServletRequest request,HttpServletResponse response){
        String COI =  request.getParameter("CheckOutInfos"); // 获取前端传来序列化的退房客户数据
        List<String[]> JSONCheckoutList = JSON.parseArray(COI,String[].class);   //将序列化的数组,反序列化成字符串数组的数组
        JSONArray COIList = JSON.parseArray(Arrays.toString(JSONCheckoutList.get(0)));  //取一个数组,再将其反序列化
        String CheckOutRoomNum = String.valueOf(COIList.get(0));  //获取退房号码
        String CheckOutMobilePhone = String.valueOf(COIList.get(1));  //获取退房客户的号码
//        退房信息不为空,再进行以下操作
        if(!CheckOutMobilePhone.isEmpty() && !CheckOutRoomNum.isEmpty()){
            RoomInfo RI = roomMapper.GetRoomInfoByMobilePhone(CheckOutMobilePhone);  //根据电话获取用户的房间信息
            if(RI != null){
                String ThisRoomType = RI.getRoomType();   //退房类型
                System.out.println(RI);
                RoomQuantityInfo ThisRoomQuantity = roomAmountMapper.GetOneRoomType(ThisRoomType);  //获取具体某种房型的信息
                long roomPrice = ThisRoomQuantity.getRoomPrice();   //当前房型的价格
                long roomNum = ThisRoomQuantity.getAmount()+1;   //当前房型加一
                String RoomNum  = String.valueOf(roomNum);   //房号
                Timestamp NowTime = timeUtility.GetNowTime(); //获取当前时间
                Timestamp UsedTime = RI.getCheckOutTime(); //获取订房初始时间
                int DeltaTime = timeUtility.CalculateDays(UsedTime,NowTime); //订房退房时间差
                roomPrice *= DeltaTime;  //计算在时间差内,住房金额
                AccountBookInfo ABI = new AccountBookInfo("",ThisRoomType,roomPrice,RI.getCheckOutTime()); //建立账单
                roomMapper.CheckOut(CheckOutRoomNum);      //客房表退房
                customerMapper.DeleteCustomerByMobilePhone(CheckOutMobilePhone);  //客户表删除客户
                roomAmountMapper.UpdateRoomAmountByType(ThisRoomType,RoomNum);  //增加相应房型的数量
                accountBookMapper.AddAccount(ABI);   //账单表入账
                ss.commit();   //向数据库提交事务
                try {
                    response.getWriter().println(JSONObject.toJSONString("退房成功!"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }else{
                try {
                    response.getWriter().println(JSONObject.toJSONString("没有相应房间信息!"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

        }
    }

5.4单间查询:
在这里插入图片描述

5.4.1查询单间用户
   public void QuerySingleRoom(HttpServletRequest request,HttpServletResponse response){
          String RoomNum = request.getParameter("RoomNum");
       DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd hh:mm:ss");
          RoomInfo roomInfo = roomMapper.GetRoomInfoByRoomNum(RoomNum);  //通过房间号获取信息
          System.out.println(roomInfo);
          Object JSONRoomInfo = JSONObject.toJSONStringWithDateFormat(roomInfo,JSON.DEFFAULT_DATE_FORMAT);   //带上日期格式,序列化数据方便传输
          System.out.println(JSONRoomInfo);
       try {
           response.getWriter().println(JSONRoomInfo);   //响应数据
       } catch (IOException e) {
           e.printStackTrace();
       }
   }

5.4.1查询单间用户
   public void QuerySingleRoom(HttpServletRequest request,HttpServletResponse response){
          String RoomNum = request.getParameter("RoomNum");
       DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd hh:mm:ss");
          RoomInfo roomInfo = roomMapper.GetRoomInfoByRoomNum(RoomNum);  //通过房间号获取信息
          System.out.println(roomInfo);
          Object JSONRoomInfo = JSONObject.toJSONStringWithDateFormat(roomInfo,JSON.DEFFAULT_DATE_FORMAT);   //带上日期格式,序列化数据方便传输
          System.out.println(JSONRoomInfo);
       try {
           response.getWriter().println(JSONRoomInfo);   //响应数据
       } catch (IOException e) {
           e.printStackTrace();
       }
   }

5.5查询所有房间:
在这里插入图片描述


5.5.1 查询所有房间信息
    public void QueryAllRoom(HttpServletRequest request,HttpServletResponse response){
          String AdminName = request.getParameter("AdminName");  //获取管理员信息
          String AdminId = request.getParameter("AdminId");
        AdministratorInfo administratorInfo = administratorMapper.GetOneAdminiPrivilege(AdminId); //获取权限
     if(administratorInfo.getAdminiPrivilege().equals("1") || administratorInfo.getAdminiPrivilege().equals("2")){
              List<RoomInfo> allRoom = roomMapper.getAllRoom(); //获取所有房间数据
              Object AllRoomList = JSONObject.toJSONStringWithDateFormat(allRoom,JSON.DEFFAULT_DATE_FORMAT);        //将房间信息对象数组序列化,传输到前端
              System.out.println(AllRoomList);
              try {
                  response.getWriter().println(AllRoomList);
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
    }



5.6结账页面:
在这里插入图片描述

5.6.1支付功能:
    public void Pay(HttpServletRequest request,HttpServletResponse response){
        String IDNum = (String) JSONObject.parse(request.getParameter("IDNum"));  //获取房号或电话号码
        System.out.println(IDNum);
        RoomInfo roomInfo = null;
        RoomQuantityInfo roomQuantityInfo = null;
        int DeltaTime = 1;
        int Price = 0;
        if (IDNum.length()!=0){
            if( IDNum.length() <= 3){
                 roomInfo = roomMapper.GetRoomInfoByRoomNum(IDNum); //获取客房信息
                System.out.println(roomInfo);
                //若没有相应信息
                if(roomInfo == null) {
                    try {
                        response.getWriter().println(JSONObject.toJSONString("0"));
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    return;
                }
                else{
                    roomQuantityInfo = roomAmountMapper.GetOneRoomType(roomInfo.getRoomType());  //获取房型
                    try {
                        if(roomInfo.getRoomStatus().equals("0")){
                            Price = 0 ;
                        }else{
                            Price = roomQuantityInfo.getRoomPrice() * timeUtility.CalculateDays(roomInfo.getCheckInTime(),roomInfo.getCheckOutTime());
                        }

                        //加入账单
                        AccountBookInfo accountBookInfo = new AccountBookInfo("",roomInfo.getRoomType(), (long) Price,timeUtility.GetNowTime());
                        accountBookMapper.AddAccount(accountBookInfo);  //添加新账单
                        ss.commit();  //提交到数据库
                        String JSONRoomInfo = JSONObject.toJSONStringWithDateFormat(roomInfo,JSON.DEFFAULT_DATE_FORMAT);
                        String JSONRoomQuantityInfo = JSONObject.toJSONString(roomQuantityInfo);
                        List<String> Arr =  new ArrayList<>();
                        Arr.add(JSONRoomInfo);
                        Arr.add(JSONRoomQuantityInfo);
                        Arr.add(String.valueOf(Price));
                        response.getWriter().println(JSON.toJSONStringWithDateFormat(Arr,JSON.DEFFAULT_DATE_FORMAT));   //响应前端的请求
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }

            }else if(IDNum.length()>4 &&IDNum.length() <=11){
                  roomInfo = roomMapper.GetRoomInfoByRoomNum(IDNum); //获取客房信息
                //若没有相应信息
                if(roomInfo == null) {
                    try {
                        response.getWriter().println(JSONObject.toJSONString("0"));
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    return;
                }
                else{
                    roomQuantityInfo = roomAmountMapper.GetOneRoomType(roomInfo.getRoomType());  //获取房型
                    try {
                        if(roomInfo.getRoomStatus().equals("0")){
                            Price = 0 ;
                        }else{
                            Price = roomQuantityInfo.getRoomPrice() * timeUtility.CalculateDays(roomInfo.getCheckInTime(),roomInfo.getCheckOutTime());
                        }

                        //加入账单
                        AccountBookInfo accountBookInfo = new AccountBookInfo("",roomInfo.getRoomType(), (long) Price,timeUtility.GetNowTime());
                        accountBookMapper.AddAccount(accountBookInfo);  //添加新账单
                        ss.commit();  //提交到数据库
                        String JSONRoomInfo = JSONObject.toJSONStringWithDateFormat(roomInfo,JSON.DEFFAULT_DATE_FORMAT);
                        String JSONRoomQuantityInfo = JSONObject.toJSONString(roomQuantityInfo);
                        List<String> Arr =  new ArrayList<>();
                        Arr.add(JSONRoomInfo);
                        Arr.add(JSONRoomQuantityInfo);
                        Arr.add(String.valueOf(Price));
                        response.getWriter().println(JSON.toJSONStringWithDateFormat(Arr,JSON.DEFFAULT_DATE_FORMAT));   //响应前端的请求
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }

        }
        else{
            try {
                response.getWriter().println("没有相应信息!");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
}

5.7 客户信息查询
在这里插入图片描述

5.7.1通过房间号查询某个客户信息
    public void QueryCustomer(HttpServletRequest request,HttpServletResponse response){
        String IDNum = request.getParameter("IDNum");  //获取房间号或身份证号
        CustomerInfo customerInfo = new CustomerInfo();
//        根据房间号查询
        if(IDNum.length()>0&&IDNum.length()<=4){
            customerInfo = customerMapper.GetCustomerByRoomNum(IDNum);
        }
//        根据电话号码查询
        if(IDNum.length()>4 && IDNum.length()<=11){
            customerInfo = customerMapper.GetCustomerByPhone(IDNum);
        }
        System.out.println("CustomerInfo: " +customerInfo);
        String JsonCIO = JSONObject.toJSONString(customerInfo);
        try {
            response.getWriter().println(JsonCIO);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

5.8管理员界面:
在这里插入图片描述

5.8.1客房管理,管理员登录
    public  void ManageGetRoot(HttpServletRequest request, HttpServletResponse response){
        AdministratorInfo Administrator =  JSONObject.parseObject(request.getParameter("Administrator"),AdministratorInfo.class);
        //管理员验证
        AdministratorInfo tempAdmini = administratorMapper.GetOneAdministrator(Administrator);
//        如果没有这个管理员,返回false
        if(tempAdmini == null){
            try {
                response.getWriter().println(JSONObject.toJSONString("false"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
//        如果有则返回true
        if(tempAdmini != null){
            try {
                response.getWriter().println(JSONObject.toJSONString("true"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }


5.9房型管理界面:
在这里插入图片描述

5.9.1 客房管理,某种房型的删除一行信息
    public  void DeleteRoomInfoRow(HttpServletRequest request ,HttpServletResponse response){
        RoomInfo roomInfo = JSONObject.parseObject(request.getParameter("RoomInfo"),RoomInfo.class);  //接收并转换
        if(roomInfo!=null){
            RoomQuantityInfo roomQuantityInfo = roomAmountMapper.GetOneRoomType(roomInfo.getRoomType());
            if(!roomInfo.getRoomStatus().equals("0")){
                try {
                    response.getWriter().println(JSONObject.toJSONString("false"));   //有人住,不能删
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }else{
                roomMapper.DeleteRoomByRoomNum(roomInfo.getRoomNum());   //删除房间
                customerMapper.DeleteUserByRoomNum(roomInfo.getRoomNum());  //删除客户
                roomAmountMapper.UpdateRoomAmountByType(roomInfo.getRoomType(),String.valueOf(roomQuantityInfo.getAmount()-1));  //相应房型减一
                ss.commit();
                try {
                    response.getWriter().println(JSONObject.toJSONString("true"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

5.9.2客房管理,获取某类客房的所有信息
    public void GetOneRoomTypeInfo(HttpServletRequest request, HttpServletResponse response){
           //根据房型,获取该房型的所有数据
          String RoomType = request.getParameter("RoomType");
          List<RoomInfo> roomTypeList =  roomMapper.GetRoomInfoByRoomType(RoomType);
          String JSONRoomTypeList = JSONObject.toJSONStringWithDateFormat(roomTypeList,JSON.DEFFAULT_DATE_FORMAT);
        try {
            response.getWriter().println(JSONRoomTypeList);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

5.9.3客房管理,为某种客房类型添加房间
    public  void AddOrUpdateRoomOfOneType(HttpServletRequest request,HttpServletResponse response){
          String Info = request.getParameter("RoomTypeInfo");  //接收前台信息
          RoomInfo roomInfo= JSONObject.parseObject(Info,RoomInfo.class);
          RoomInfo ExistRoom = roomMapper.GetRoomInfoByRoomNum(roomInfo.getRoomNum());   //判断该房间是否已存在,已存在则修改,不存在则增添

        if(ExistRoom!=null){
              if(!ExistRoom.getRoomStatus().equals("0")&&roomInfo.getRoomStatus().equals("0")){
                  //如果要修改为空的房间已经被入住,则相应的表信息也需要修改
                  roomMapper.CheckOut(roomInfo.getRoomNum());   //修改房间表
                  customerMapper.DeleteUserByRoomNum(roomInfo.getRoomNum());  //修改客户表
                  ss.commit();
              }
              else{
                  roomMapper.UpdateRoomInfo(roomInfo); //更新客房状态
                  ss.commit();
              }
          }else{
              roomMapper.AddRoom(roomInfo);   //新增房间
            ss.commit();
          }
        try {
            response.getWriter().println("修改成功!");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    5.9.4保存房间类型的信息(包括新添加的类型)
    public void  UpdateRoomType(HttpServletRequest request,HttpServletResponse response){
        String  ManageRoomPrice = request.getParameter("ManageRoomPrice");
        String  ManageRoomType = request.getParameter("ManageRoomType");
        System.out.println(ManageRoomPrice);
        System.out.println(ManageRoomType);
        String LoadPath = "D:\\vodkaItem\\MyHotel\\src\\main\\webapp\\img\\";   //图片在服务器中的位置
        RoomQuantityInfo TempRQI = null;
        //查询该房间类型是否已存在,存在则修改类型信息 ; 不存在,则增添,并保存图片
        RoomQuantityInfo RQI = roomAmountMapper.GetOneRoomType(ManageRoomType);
        int index = 0;
        if(RQI == null){
            //构造新客房类型对象,并添加到数据库
             TempRQI = new RoomQuantityInfo();
             TempRQI.setAmount((long) 20);
                 //判断图片资源是否为空
                 while (index < Base64PhotoList.size()){
                     String TempUrl =  Base64PhotoList.get(index);
                     if(TempUrl !=null){
                         TempRQI.setRoomImgUrl(ManageRoomType+".jpg");
                         myUtility.TransformBase64DataToPhoto(LoadPath,ManageRoomType,Base64PhotoList.get(index));  //将图片存进服务器
                         Base64PhotoList.set(index,null); //如果当前图片已加载完成,则在图片资源队列销毁
                     }
                     index++;   //当前图片检索完毕后,移动到下一张
                 }
             TempRQI.setRoomPrice(Integer.parseInt(ManageRoomPrice));
             TempRQI.setRoomType(ManageRoomType);
             roomAmountMapper.AddRoomType(TempRQI);
             ss.commit(); //提交到数据库
        }
        else{
            //若该房型已经存在,则只能修改价格
            roomAmountMapper.UpdateRoomPrice(ManageRoomType,ManageRoomPrice);
            ss.commit();  //提交到数据库
        }
    }

    5.9.5客房管理界面初始化所需的数据,已有的房型信息
    public void RoomType(HttpServletRequest request,HttpServletResponse response){
        List<RoomQuantityInfo> allRoomType =  roomAmountMapper.GetAllRoomType();  //获取现有的房间类型
        String LoadPath = "D:\\vodkaItem\\MyHotel\\src\\main\\webapp\\img\\";   //图片在服务器中的位置
        String Base64ImgHead = "data:image/jpg;base64,";     //传给前端时,需加上base64编码格式的说明
        Map<String,String>  Base64ImgMap = new HashMap<>();             //哈希表用于接收对应房间类型的图片数据
        List<String> RoomTypeInfo = new ArrayList<>();
        String ImgUrl = null;
        for(RoomQuantityInfo roomQuantityInfo: allRoomType){
            ImgUrl = roomQuantityInfo.getRoomImgUrl();
            //将相应房间类型及其图片数据存进哈希表
        }
        try {
            RoomTypeInfo.add(JSONObject.toJSONString(allRoomType));
            response.getWriter().println(JSONObject.toJSONString(RoomTypeInfo));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    5.9.6接收添加房型的图片,并保存到服务器
    public void SavePhoto(HttpServletRequest request ,HttpServletResponse response){
//            UploadPath = request.getServletContext().getRealPath("/"); //获取项目真实路径
           UploadPath = "D:\\vodkaItem\\MyHotel\\src\\main\\webapp\\img\\";
            String Base64Photo = (String) JSONObject.parse(request.getParameter("Base64Photo"));  //解析并接收前端传输的数据
            Base64PhotoList.add(Base64Photo);
//           myUtility.TransformBase64DataToPhoto(UploadPath,"MyNewImg",Base64Photo);   //转换存储图片

}


5.10客房流水界面:
在这里插入图片描述

5.10.1删除某条账单信息
    public void DeleteAccount(HttpServletRequest request, HttpServletResponse response){
        List<String> AccountInfo = (List<String>) JSONObject.parse(request.getParameter("AccountInfo"));  //获取并解析序列化的账单信息
        AccountBookInfo accountBookInfo = new AccountBookInfo(AccountInfo.get(0),AccountInfo.get(1),Long.valueOf(AccountInfo.get(2)),timeUtility.ConvertStringToDate(AccountInfo.get(3)));  //转换为账单对象
        System.out.println(accountBookInfo);   //获取账单信息后,数据库进行删除
        accountBookMapper.DeleteAccount(Long.valueOf(accountBookInfo.getFlowId()));
        ss.commit();    //提交事务
        try {
            response.getWriter().println("删除成功!");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    5.10.2修改账单信息
    public void UpdateAccount(HttpServletRequest request, HttpServletResponse response){
       List<String> AccountInfo = (List<String>) JSONObject.parse(request.getParameter("AccountInfo"));  //获取并解析序列化的账单信息
       AccountBookInfo accountBookInfo = new AccountBookInfo(AccountInfo.get(0),AccountInfo.get(1),Long.valueOf(AccountInfo.get(2)),timeUtility.ConvertStringToDate(AccountInfo.get(3)));  //转换为账单对象
       System.out.println(accountBookInfo);   //获取账单信息后,数据库进行相应更改
        accountBookMapper.UpdateOneAccount(accountBookInfo);
        ss.commit();    //提交事务
        try {
            response.getWriter().println("保存成功!");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

   5.10.3获取账单信息,发送到前端
   public void GetAccount(HttpServletRequest request,HttpServletResponse response){
      //  从数据库获取账单,并序列化
      List<AccountBookInfo> ABILists  =  accountBookMapper.ShowAllAccount();
      String JSONABILists  = JSONObject.toJSONStringWithDateFormat(ABILists,JSON.DEFFAULT_DATE_FORMAT);
       try {
           response.getWriter().println(JSONABILists);
       } catch (IOException e) {
           e.printStackTrace();
       }
   }

5.11客服热线界面:

在这里插入图片描述

6.系统使用说明书
皓月酒店管理系统分几个模块:
-登记模块:支持单人或者团体登记入住,根据电话号码分配客户相应选择类型的房间。支持根据客户房号或电话号码进行退房。支持在线展示当前可选择的房型所剩的房间数量。
-查询模块:支持客户根据电话号码,查询自己的所登记的信息。 用户可根据自己房间号或电话号码,查询相应房间状态,管理员可以查询所有房间状态。
-结账模块:支持根据用户电话号码,或房间号,进行结账,并且将账单信息录入数据库。
-管理模块: 支持管理员对房间类型,房间数量,进行增删改查。
-资讯模块: 提供客服服务热线。

7.设计总结
皓月酒店管理系统基于web技术进行设计,界面样式采用了js+jsp+css 模式,使用了jQuery库的传统前端技术,后端采用了java的Servlet 网络编程技术处理数据,数据存储采用了Mysql数据库,并在原生JDBC的基础上使用了Mybatis数据库管理框架,使数据库连接和数据处理更规范化。


版权声明:本文为Vodka688原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/Vodka688/article/details/122369740