项目编号:BS--XX-091
一,环境介绍
语言环境:Java: jdk1.8
数据库:Mysql: mysql5.7
应用服务器:Tomcat: tomcat8.5.31
开发工具:IDEA或eclipse
开发技术:spring+spring mvc+mybatis+bootstrap+jquery
二,项目简介
本项目基于SSM实现用于餐厅的收银管理系统,包含了四个模块
1.桌位模块
桌位模块主要是用于管理桌位的模块,包括点菜到结账的流程
将桌位人数设置为0可以滞空当前桌位
2.账单模块
账单模块记录了每一天的帐单汇总,同时提供了年月日账单的统计,在日账单内可以查看当日的所有消费详情,还提供了按日期或日期区间搜索账单的功能
3.日常维护模块
提供了桌位菜单用户供应商的配置功能,也就是增删改查
添加菜品时,添加酒水类时,可以选择进货内的酒水,这样的话在结账后若客人点了该酒水,会将销售信息记录在酒水库存内的销售信息里
4.酒水库存模块
查看添加酒水的进销存信息
三,系统展示
下面展示系统的运行模块:
用户登陆
数据维护—菜品维护
桌位维护
账户维护
账户维护
开桌就餐
点菜
结账
查看账单
查看单桌消费
四,核心代码展示
package controller; import com.alibaba.fastjson.JSON; import dao.user.UserMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import pojo.Pager; import pojo.Provider; import pojo.User; import service.user.UserService; import tools.PagerTools; import java.util.HashMap; import java.util.Map; @Controller public class UserController { @Autowired private UserService userService; @ResponseBody @RequestMapping("/addUser.do") public Object addUser(User user){ return JSON.toJSONString(userService.addUser(user)); } @RequestMapping("/showUserList.do") public ModelAndView showUserList(ModelAndView modelAndView, Pager pager){ pager.setPageSize(PagerTools.deskBillPagerSize); pager.setTotalCount(userService.getTotalCount(pager)); pager.count(); pager.setList(userService.showUserList(pager)); modelAndView.addObject("pager",pager); modelAndView.setViewName("/daily/user/userList"); return modelAndView; } @RequestMapping("/delUserById.do") @ResponseBody public Object delUserById(User user){ return JSON.toJSONString(userService.delUserById(user)); } @RequestMapping("/updateUser.do") @ResponseBody public Object updateUser(User user){ return JSON.toJSONString(userService.updateUser(user)); } @RequestMapping("/loadUserInfoById.do") public ModelAndView loadUserInfoById(ModelAndView modelAndView,Pager pager){ pager.setPageSize(1); pager.setTotalCount(userService.getTotalCount(pager)); pager.count(); modelAndView.addObject("user",userService.showUserList(pager).get(0)); modelAndView.setViewName("/daily/user/updateUser"); return modelAndView; } @ResponseBody @RequestMapping("/userIsExist.do") public Object userIsExist(User user){ System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println(user.getIdentity()+user.getUserCode()+user.getPhone()); System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~"); int phoneFlag=-1; int identityFlag=-1; int userCodeFlag=-1; if(user.getUserCode()!=null && !user.getUserCode().equals("")){ userCodeFlag=userService.userIsExist(user); } if(user.getIdentity()!=null && !"".equals(user.getIdentity())){ identityFlag=userService.userIsExist(user); } if(user.getPhone()!=null && !"".equals(user.getPhone())){ phoneFlag=userService.userIsExist(user); } return "{\"userCodeFlag\":\""+userCodeFlag+"\",\"phoneFlag\":\""+phoneFlag+"\",\"identityFlag\":\""+identityFlag+"\"}"; } }
package controller; import com.alibaba.fastjson.JSON; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import pojo.*; import service.drink.ProviderService; import tools.BillCodeUtil; import tools.PagerTools; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import javax.sound.midi.Soundbank; import java.util.List; @Controller public class DrinkController { @Autowired private ProviderService providerService; @RequestMapping("/drink.html") public String drink(HttpSession session) { if(session.getAttribute("user")==null){//权限控制 return "redirect:login.html"; } return "/drink/drink"; } ; //加载供应下拉列表 @RequestMapping("/loadProviderSelect.do") @ResponseBody public Object loadProviderSelect() { return JSON.toJSONString(providerService.getProvider()); } ; //加载进货信息 @RequestMapping("/loadDrinkBill.do") @ResponseBody public ModelAndView loadDrinkBill(ModelAndView modelAndView, DrinkBillPager pager) { int totalCount = providerService.getDrinkBillCount(pager); if (totalCount != 0) { pager.setTotalCount(totalCount); } else { pager.setTotalCount(1); } pager.setPageSize(PagerTools.drinkBillPagerSize); pager.count(); pager.setList(providerService.getDrinkBill(pager)); modelAndView.addObject("pager", pager); modelAndView.setViewName("/drink/ajaxJinhuoList"); return modelAndView; } //加载进货信息 @RequestMapping("/loadDrinkBillCode.do") @ResponseBody public Object loadDrinkBillCode(DrinkBillPager pager) { int totalCount = providerService.getDrinkBillCount(pager); if (totalCount != 0) { pager.setTotalCount(totalCount); } else { pager.setTotalCount(1); } pager.setPageSize(100); pager.count(); List<Drinkbill> drinkBills=providerService.getDrinkBill(pager); return JSON.toJSONString(drinkBills); } //del删除进货信息 @RequestMapping("/delDrinkBill.do") @ResponseBody public Object delDrinkBill(@RequestParam(required = false) String id) { providerService.delDrinkSellBill(id); return JSON.toJSONString(providerService.delDrinkBill(id)); } //del删除销售信息 @RequestMapping("/delDrinkSellBill.do") @ResponseBody public Object delDrinkSellBill(@RequestParam(required = false) String id) { return JSON.toJSONString(providerService.delDrinkSellBill(id)); } //更新进货信息 @RequestMapping("/updateDrinkBill.do") @ResponseBody public Object delDrinkBill(Drinkbill drinkbill) { drinkbill.setIsPay(2); return JSON.toJSONString(providerService.updateDrinkBill(drinkbill)); } ; //添加进货信息 @RequestMapping("/addDrinkBill.do") @ResponseBody public Object addDrinkBill(Drinkbill drinkbill, DrinkSellBill drinkSellBill) { String drinkBillCode = BillCodeUtil.getBillCode(); drinkbill.setDrinbillCode(drinkBillCode); int addDrinkBillFlag = providerService.addDrinkBill(drinkbill); drinkSellBill.setDrinkbillId(drinkbill.getId()); drinkSellBill.setDrinkBillCode(drinkBillCode); int addDrinkSellBillFlag = providerService.addDrinkSellBill(drinkSellBill); return "{\"addDrinkBillFlag\":\"" + addDrinkBillFlag + "\",\"addDrinkSellBillFlag\":\"" + addDrinkSellBillFlag + "\"}"; } //加载销售信息 @RequestMapping("/loadDrinkSellBill.do") @ResponseBody public ModelAndView loadDrinkSellBill(ModelAndView modelAndView, DrinkBillPager pager) { int totalCount = providerService.getDrinkSellBillCount(pager); if (totalCount != 0) { pager.setTotalCount(totalCount); } else { pager.setTotalCount(1); } pager.setPageSize(PagerTools.drinkBillPagerSize); pager.count(); pager.setList(providerService.getDrinkSellBill(pager)); modelAndView.addObject("pager", pager); modelAndView.setViewName("/drink/sellList"); return modelAndView; } //加载销售信息 @RequestMapping("/loadSuplusDrinkBill.do") @ResponseBody public ModelAndView loadSuplusDrinkBill(ModelAndView modelAndView, DrinkBillPager pager) { int totalCount = providerService.getDrinkSellBillCount(pager); if (totalCount != 0) { pager.setTotalCount(totalCount); } else { pager.setTotalCount(1); } pager.setPageSize(PagerTools.drinkBillPagerSize); pager.count(); pager.setList(providerService.getSuplusDrinkBill(pager)); modelAndView.addObject("pager", pager); modelAndView.setViewName("/drink/suplusDrinkBillList"); return modelAndView; } //添加供应商 @RequestMapping("/addProvider.do") @ResponseBody public Object addProvider(Provider provider){ return JSON.toJSONString(providerService.addProvider(provider)); } //验证供应商是否存在 @RequestMapping("/isProExist.do") @ResponseBody public Object isProExist(@RequestParam(required = false) String proName){ return JSON.toJSONString(providerService.isProExist(proName)); } //加载供应商列表 @RequestMapping("/showProviderList.do") public ModelAndView showProviderList(ModelAndView modelAndView,Pager pager){ pager.setTotalCount(providerService.getTotalCount(pager)); pager.setPageSize(3); pager.count(); if("".equals(pager.getOpr()) || pager.getOpr()==null){ modelAndView.addObject("provider",providerService.getProviderList(pager).get(0)); modelAndView.setViewName("daily/provider/updateProvider"); }else{ pager.setList(providerService.getProviderList(pager)); modelAndView.setViewName("daily/provider/providerList"); modelAndView.addObject("pager",pager); } return modelAndView; } //删除供应商 @RequestMapping("/delProviderById.do") @ResponseBody public Object delProviderById(Pager pager){ return JSON.toJSONString(providerService.delProviderById(pager)); } //更改供应商 @RequestMapping("/updateProvider.do") @ResponseBody public Object updateProvider(Provider provider){ return JSON.toJSONString(providerService.updateProvider(provider)); } }
package controller; import com.alibaba.fastjson.JSON; import org.apache.commons.io.FilenameUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import pojo.Dish; import pojo.Pager; import pojo.dish.Dishes; import service.dish.DishService; import tools.BillCodeUtil; import tools.PagerTools; import tools.RedisUtil; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; @Controller public class DishController { @Autowired private DishService dishService; @Resource(name = "redisUtil") private RedisUtil redisUtil; @ResponseBody @RequestMapping(value = "/addDish.do", produces = "application/json;charset=utf-8") public Object addDish(Dish dish, @RequestParam(required = false) MultipartFile file, HttpServletRequest request) { boolean addFlag = false;//添加标记 String fifleFlag = null;//文件上传状态标记 System.out.println("addDish~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println("~~~~~~~~~~~~~~~~~~~dishName:" + dish.getDishName()); if (!file.isEmpty()) { String path = request.getSession().getServletContext().getRealPath("assets" + File.separator + "img");//获取/statics/upload的地址 System.out.println("存储地址:" + path); String oldFileName = file.getOriginalFilename();//获取原文件名 System.out.println("原文件名:" + oldFileName); String newFileName = BillCodeUtil.getBillCode() + "_"+oldFileName;//新文件名 String prefix = FilenameUtils.getExtension(oldFileName);//获取文件后缀,对后缀进行判断,过滤不符合条件的文件 System.out.println("~~~文件类型:" + prefix + "~~~"); System.out.println("~~~文件大小:" + file.getSize() + "~~~"); if (file.getSize() < PagerTools.maxFileSize) { System.out.println("~~~~~~~~~文件大小验证通过~~~~~~~~~~~"); try { file.transferTo(new File(path + File.separator +newFileName)); System.out.println("上传成功"); dish.setFileName(newFileName);//将新文件名保存在对象中 addFlag = dishService.addDish(dish);//添加至数据库 System.out.println("菜品" + dish.getDishName() + "添加成功"); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else { fifleFlag = "图片不能大于500KB"; } } if (addFlag) {//添加成功时 //刷新缓存 redisUtil.del("allDishes"); return JSON.toJSONString("OK"); } else { return "{'fifleFlag':'" + fifleFlag + "'}"; } } //ajax验证菜品名是否存在 @ResponseBody @RequestMapping("/dishNameIsExist.do") public Object dishNameIsExist(@RequestParam(required = false) String dishName) { boolean existFlag = false; if (dishName != "" && dishName != null) { existFlag = dishService.isExist(dishName); } if (existFlag) { return JSON.toJSONString("0");//存在该菜品 } return JSON.toJSONString("1");//不存在该菜品 } //加载菜品列表 @ResponseBody @RequestMapping("/dishList.do") public ModelAndView dishList(Pager pager, ModelAndView modelAndView, @RequestParam(required = false) String dishName) { if (dishName == null || "".equals(dishName)) {//如果没有输入查询名字则当作opr=allDish pager.setOpr("allDish"); } modelAndView.setViewName("/daily/dish/dishList"); Dishes dishes = Dishes.getDishes(); pager.setPageSize(PagerTools.delDishListPagerSize); if (dishes.getAllDishCount() == 0) { if(redisUtil.getList("allDishes")==null){ redisUtil.addList("allDishes",dishService.getDish()); } dishes.setAllDish(redisUtil.getList("allDishes")); } pager.setTotalCount(dishes.getAllDishCount()); if ("serchDish".equals(pager.getOpr())) {//优先查询 pager.setPageSize(dishes.getAllDishCount());//搜索时把所有菜品全部查出 System.out.println("~~~~~~~~~~~~~~~~~~~~~~" + dishName); } pager.count(); List<Dish> list = dishes.getAllDish(pager); if ("serchDish".equals(pager.getOpr())) {//优先查询 List<Dish> serchList = new ArrayList<Dish>(); if (dishName != null && !"".equals(dishName)) { System.out.println("~~~~~~~~查找相同菜品的数据~~~~~~~~~~"); for (Dish dish : list) { if(dish.getDishName().contains(dishName)){ System.out.println("~~~~~~~~~~~找到与"+dishName+"相似的菜品~~~~~~~~~~~"); serchList.add(dish); } } pager.setList(serchList); } } else { pager.setList(list); } modelAndView.addObject("pager", pager); return modelAndView; } //ajax删除菜品 @ResponseBody @RequestMapping("/delDishFromMenu.do") public Object delDish(@RequestParam(required = false)String id){ System.out.println("~~~~~~~~~~~~~~开始删除Dish~~~~~~~~~~~~~~~"); boolean delFlag=false; System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~id="+id); if(id!=null && !"".equals(id)){ System.out.println("~~~~~~~~~~~~~~~进入删除~~~~~~~~~~~~~~~~"); delFlag=dishService.delDishById(id); } if(delFlag){//删除成功 System.out.println("~~~~~~~~~~~~~~删除Dish成功~~~~~~~~~~~~~~~"); redisUtil.del("allDishes");//刷新redis Dishes.getDishes().setAllDish(null);//刷新单例 return JSON.toJSONString(0);//删除成功 } return JSON.toJSONString(1);//删除失败 } }
五,项目总结
项目功能完整,运行无误,适合做毕业设计使用