Java项目:ssh酒店管理系统

该系统采用SSH框架,实现酒店管理功能,包括客房预订、入住、换房等操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

作者主页:夜未央5788

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

ssh酒店管理系统。分管理员与普通员工两种角色;

管理员主要功能有:
员工管理:员工列表;
客户基本信息:客户基本信息
客房基本信息:楼层设置、客房设置、客房信息、客房维护;
客房预定信息:客房预定信息
客户入住信息:办理入住、客户入住;
客户换房信息:客户换房;
客户退房信息:客户退房信息
酒店商品信息:商品分类设置、商品基本信息、已售商品信息;
结账管理信息:结账管理列表;

普通员工主要功能有:
客户基本信息:客户基本信息
客房基本信息:客房维护;
客房预定信息:客房预定信息
客户入住信息:办理入住、客户入住;
客户换房信息:客户换房;
客户退房信息:客户退房信息
酒店商品信息:已售商品信息;

结账管理信息:结账管理列表;

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 

6.数据库:MySql 5.7版本;

技术栈

1. 后端:Spring+Structs2+Hibernate

2. 前端:JSP+bootstrap+jQuery+easyUI

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置;
3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;

4. 运行项目,输入登录页面 http://localhost:8085/login_login.do 登录

运行截图

 

 

 

 

 

 

 

 

 

相关代码 

BuyCartAction

package com.xznu.edu.leave.action;

/**
 * 用户新增
 */

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.xznu.edu.leave.model.*;
import com.xznu.edu.leave.service.*;
import com.xznu.edu.leave.utils.JsonUtils;
import com.xznu.edu.leave.utils.Pager;
import com.xznu.edu.leave.utils.UserUtils;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import java.io.IOException;
import java.util.List;

@Controller("buycartAction")
@Scope("prototype")
public class BuyCartAction extends ActionSupport implements ModelDriven<BuyCart> {

    @Autowired
    private BuyCartService service;
    @Autowired
    private GoodsService goodsService;
    @Autowired
    private RoomLogService roomlogs;
    @Autowired
    private GoodsTypeService goodstypeService;
    private BuyCart buyCart;
    private Integer roomlogId;


    /**
     * list
     *
     * @return
     */
    public String list() throws IOException {
        User user1 = UserUtils.getUser();
        if (user1 == null || user1.getId() == null) {
            ActionContext.getContext().put("login", 1);
            return SUCCESS;
        }
        buyCart.setUser(user1);
        Pager<BuyCart> pagers = service.getList(buyCart);
        Pager<GoodsType> list = goodstypeService.getList(null);
        ActionContext.getContext().put("list", list);
        ActionContext.getContext().put("pagers", pagers);
        ActionContext.getContext().put("user", user1);
        return SUCCESS;
    }

    /**
     * 后台客户购买商品列表
     * @return
     * @throws IOException
     */
    public String khlist() throws IOException {
        User user1 = UserUtils.getUser();
        if (user1 == null || user1.getId() == null) {
            ActionContext.getContext().put("login", 1);
            return SUCCESS;
        }
        Pager<BuyCart> pagers = service.getList2(buyCart);
        Pager<GoodsType> list = goodstypeService.getList(null);
        ActionContext.getContext().put("list", list);
        ActionContext.getContext().put("pagers", pagers);
        ActionContext.getContext().put("user", user1);
        ActionContext.getContext().put("bean", buyCart);
        return SUCCESS;
    }

    /**
     * 跳转add
     *
     * @return
     */
    public String add() {
        return SUCCESS;
    }

    /**
     * 查询修改
     *
     * @return
     */
    public void edit() throws IOException {
        BuyCart bean = service.findById(buyCart.getId());
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("bean", bean);
        jsonObject.put("flag", true);
        JsonUtils.jsonObject(jsonObject);
    }

    public String updatesl() throws IOException {
        BuyCart bean = service.findById(buyCart.getId());
        bean.setSl(buyCart.getSl());
        service.update(bean);
        ActionContext.getContext().put("url", "buycart_khlist.do");
        return "redirect";
    }

    /**
     * 更新
     *
     * @return
     */
    public void update() throws IOException {
        service.updates(buyCart);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("flag", true);
        jsonObject.put("message", "更新成功");
        JsonUtils.jsonObject(jsonObject);
    }

    /**
     * 保存
     *
     * @return
     */
    public void save() throws IOException {
        User user = UserUtils.getUser();
        Integer id = roomlogId;
        if (id == null || id.equals("")){
            id = user.getRoomlogId();
        }
        JSONObject jsonObject = new JSONObject();
        BuyCart buyCart1 = new BuyCart();
        if (user == null) {
            jsonObject.put("flag", false);
            JsonUtils.jsonObject(jsonObject);
        } else {
            Goods goods = goodsService.findById(buyCart.getId());
            buyCart1.setUser(UserUtils.getUser());
            buyCart1.setGoods(goods);
            RoomLog r = roomlogs.findById(id);
            buyCart1.setRoomLog(r);
            List<BuyCart> list = service.getList(id).getDatas();
            if (list.size() == 0) {
                buyCart1.setSl(1);
                service.save(buyCart1);
                jsonObject.put("flag", true);
                jsonObject.put("roomlogId", id);
                JsonUtils.jsonObject(jsonObject);
            } else {
                boolean flag = true;
                for (int i = 0; i < list.size(); i++) {
                    if (goods.getId() == list.get(i).getGoods().getId()){
                        flag = false;
                        list.get(i).setSl(list.get(i).getSl() + buyCart.getSl());
                        service.updates(list.get(i));
                        jsonObject.put("flag", true);
                        jsonObject.put("roomlogId", id);
                        JsonUtils.jsonObject(jsonObject);
                    }
                }
                if (flag){
                    buyCart1.setSl(1);
                    service.save(buyCart1);
                    jsonObject.put("flag", true);
                    jsonObject.put("roomlogId", id);
                    JsonUtils.jsonObject(jsonObject);
                }
            }
        }
    }

    public void delete() throws IOException {
        service.delete(buyCart.getId());
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("flag", true);
        JsonUtils.jsonObject(jsonObject);
    }

    @Override
    public BuyCart getModel() {
        if (buyCart == null) {
            buyCart = new BuyCart();
        }
        return buyCart;
    }

    public Integer getRoomlogId() {
        return roomlogId;
    }

    public void setRoomlogId(Integer roomlogId) {
        this.roomlogId = roomlogId;
    }
}

GoodsAction

package com.xznu.edu.leave.action;

/**
 * 用户新增
 */

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.xznu.edu.leave.model.Goods;
import com.xznu.edu.leave.model.GoodsType;
import com.xznu.edu.leave.model.ItemTypeSecondary;
import com.xznu.edu.leave.model.User;
import com.xznu.edu.leave.service.*;
import com.xznu.edu.leave.utils.JsonUtils;
import com.xznu.edu.leave.utils.Pager;
import com.xznu.edu.leave.utils.UUIDUtils;
import com.xznu.edu.leave.utils.UserUtils;
import net.sf.json.JSONObject;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.joda.time.DateTime;

import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.util.Date;
import java.util.List;

@Controller("goodsAction")
@Scope("prototype")
public class GoodsAction extends ActionSupport implements ModelDriven<Goods> {
    @Autowired
    private GoodsService service;
    @Autowired
    private UserService userService;
    @Autowired
    private GoodsTypeService goodsTypeService;
    private Goods goods;
    private List<File> file;
    private List<String> fileFileName;
    private List<String> fileContentType;
    private Integer bookLoanId;


    /**
     * list
     *
     * @return
     */
    public String list() throws IOException {
        User user1 = UserUtils.getUser();
        if (user1 == null || user1.getId() == null) {
            ActionContext.getContext().put("login", 1);
            return SUCCESS;
        }
        Pager<Goods> pagers = null;
        if (user1.getRole().getEnName().equals("admin")) {
            pagers = service.getList2(goods);
            ActionContext.getContext().put("pagers", pagers);
            Pager<GoodsType> goodsTypePager = goodsTypeService.getList(null);
            ActionContext.getContext().put("goodsTypePager", goodsTypePager);
            ActionContext.getContext().put("user", user1);
            ActionContext.getContext().put("bean", goods);
            return SUCCESS;
        }
        return null;
    }


    /**
     * 跳转add
     *
     * @return
     */
    public String add() {
        Pager<GoodsType> pagers = goodsTypeService.getList(null);
        ActionContext.getContext().put("pagers", pagers);
        return SUCCESS;
    }

    /**
     * 查询修改
     *
     * @return
     */
    public String edit() {
        Goods bean = service.findById(goods.getId());
        Pager<GoodsType> pagers = goodsTypeService.getList(null);
        ActionContext.getContext().put("pagers", pagers);
        ActionContext.getContext().put("bean", bean);
        return SUCCESS;
    }

    /**
     * 详情
     *
     * @return
     */
    public String detail() {
        Goods bean = service.findById(goods.getId());
        Pager<GoodsType> pagers = goodsTypeService.getList(null);
        ActionContext.getContext().put("pagers", pagers);
        ActionContext.getContext().put("bean", bean);
        return SUCCESS;
    }

    /**
     * 更新
     *
     * @return
     */
    public String update() throws IOException {
        ActionContext ac = ActionContext.getContext();
        HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
        String root = request.getRealPath("/upload");
        if (file != null) {
            for (int i = 0; i < file.size(); i++) {
                InputStream is = new FileInputStream(file.get(i));
                String f = UUIDUtils.create() + i;
                OutputStream os = new FileOutputStream(new File(root, f));
                byte[] buffer = new byte[500];
                int length = 0;
                while (-1 != (length = is.read(buffer, 0, buffer.length))) {
                    os.write(buffer);
                }
                os.close();
                is.close();
                if (i == 0) {
                    goods.setFileName1("\\upload\\" + f);
                }
                if (i == 1) {
                    goods.setFileName2("\\upload\\" + f);
                }
                if (i == 2) {
                    goods.setFileName3("\\upload\\" + f);
                }
                if (i == 3) {
                    goods.setFileName4("\\upload\\" + f);
                }
                if (i == 4) {
                    goods.setFileName5("\\upload\\" + f);
                }
            }
        }
        service.updates(goods);
        ActionContext.getContext().put("url", "goods_list.do");
        return "redirect";
    }

    /**
     * 保存
     *
     * @return
     */
    public String save() throws IOException {
        ActionContext ac = ActionContext.getContext();
        HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
        String root = request.getRealPath("/upload");
        if (file != null) {
            for (int i = 0; i < file.size(); i++) {
                InputStream is = new FileInputStream(file.get(i));
                String xx = new DateTime().toString();
                String f = new DateTime().toString("yyyyMMdd");
                f = UUIDUtils.create() + i;
                OutputStream os = new FileOutputStream(new File(root, f));
                byte[] buffer = new byte[500];
                int length = 0;
                while (-1 != (length = is.read(buffer, 0, buffer.length))) {
                    os.write(buffer);
                }
                os.close();
                is.close();
                if (i == 0) {
                    goods.setFileName1("\\upload\\" + f);
                }
                if (i == 1) {
                    goods.setFileName2("\\upload\\" + f);
                }
                if (i == 2) {
                    goods.setFileName3("\\upload\\" + f);
                }
                if (i == 3) {
                    goods.setFileName4("\\upload\\" + f);
                }
                if (i == 4) {
                    goods.setFileName5("\\upload\\" + f);
                }
            }
        }
        goods.setIsDelete(0);
        service.save(goods);
        ActionContext.getContext().put("url", "goods_list.do");
        return "redirect";
    }


    public void delete() throws IOException {
        goods.setIsDelete(1);
        service.updates(goods);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("flag", true);
        jsonObject.put("url", "goods_list.do");
        JsonUtils.jsonObject(jsonObject);
    }

    @Override
    public Goods getModel() {
        if (goods == null) {
            goods = new Goods();
        }
        return goods;
    }

    public List<File> getFile() {
        return file;
    }

    public void setFile(List<File> file) {
        this.file = file;
    }

    public List<String> getFileFileName() {
        return fileFileName;
    }

    public void setFileFileName(List<String> fileFileName) {
        this.fileFileName = fileFileName;
    }

    public List<String> getFileContentType() {
        return fileContentType;
    }

    public void setFileContentType(List<String> fileContentType) {
        this.fileContentType = fileContentType;
    }

    public Integer getBookLoanId() {
        return bookLoanId;
    }

    public void setBookLoanId(Integer bookLoanId) {
        this.bookLoanId = bookLoanId;
    }
}

如果也想学习本系统,下面领取。关注并回复:009ssh

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜未央5788

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值