作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
本项目主要分为服务员、厨师、收银员、经理四种角色;
主要功能包括:
客户可以根据自己的要求去选择菜品,厨师部会收到你点的菜单。你可以看到菜单的时时状况。
工作人员之间可以互相进行内部通讯,及时得到最新信息。经理可以群发通知、消息给每位员工。
系统会对所有菜品进行监视,当有菜品库存缺乏时,系统会自动提醒管理员。
管理员可以查看到餐厅的近期运营状况。包括最近的营业额,各个菜品的销售情况等。
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.数据库:MySql 5.7版本;
6.是否Maven项目:是;
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+CSS+JavaScript+bootstrap
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8080/DiningRoom 登录
服务员账号/密码: 20144206169/123456
厨师账号/密码:20144206170/123456
经理账号/密码:20144206171/123456
收银账号/密码:20144206172/123456

- @Controller
- public class LoginController {
-
-
- @Autowired
- IUserService userService;
-
- @Autowired
- IDishService dishService;
-
- @Autowired
- ITradeService tradeService;
-
- @RequestMapping("/loginCheck")
- public void loginCheck(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
-
- String idStr = request.getParameter("id");
- String password = request.getParameter("password");
- String validation = request.getParameter("validation");
- HttpSession session = request.getSession();
-
- if (idStr == null || password == null || validation == null) {
- response.sendRedirect("index.jsp?message=error");
- return;
- }
- Long id = 1l;
- try {
- id = Long.parseLong(idStr);
- } catch (NumberFormatException e) {
- }
- String result = "0";
- PrintWriter out = response.getWriter();
-
- User tempUser = userService.getUserById(id);
-
-
- String imgStr = (String) session.getAttribute("imgStr");
- if (!imgStr.equalsIgnoreCase(validation)) {
- result = "1";
- }
-
- if (tempUser!=null && result.equals("0")) {
-
- if(tempUser.getPassword().equals(MD5Util.string2MD5(password))){
-
- }
- session.setAttribute("user", tempUser);
- result = "2";
- }
-
- out.write(result);
- out.close();
- }
-
- @RequestMapping("/login")
- public ModelAndView login(HttpServletRequest request){
-
- HttpSession session = request.getSession();
- if (session.getAttribute("user") != null) {
- return new ModelAndView("redirect:toIndexUI.do");
- //response.sendRedirect("mianServlet?method=toIndexUI");
- } else {
- return new ModelAndView("index");
- }
- }
-
- @RequestMapping("/toIndexUI")
- public ModelAndView toIndexUI(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- ModelAndView view = new ModelAndView();
- HttpSession session = request.getSession();
- User user = (User) session.getAttribute("user");
- if (user == null) {
- view.setViewName("index");
- return view;
- }
- List
page = dishService.getPageBySaleDesc(1,10); - request.setAttribute("top_sale", page);
- List
pageTrade = tradeService.getPageList(1, 10); -
- request.setAttribute("pageTrade", pageTrade);
- view.setViewName("jsp/main/index");
- return view;
- }
-
- /**
- * 功能描述:生成验证码
- * @param request
- * @param response
- * @throws IOException
- */
- @RequestMapping("/getRadomPic")
- public void getRadomPic(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
- HttpSession session = request.getSession();
- // 千万注意,像此类图片一定禁止浏览器缓存
- response.setIntHeader("expires", 0);
- response.setHeader("Cache-Control", "no-cache");
- response.setHeader("Pragma", "no-cache");
-
- response.setHeader("content-type", "image/jpeg");
-
- Captcha captcha = new ImageUtils(120, 26, 4);// png格式验证码
-
- captcha.out(response.getOutputStream());
-
- String imgStr = captcha.getStr();
- session.setAttribute("imgStr", imgStr);
-
- }
-
- /**
- * 功能描述:后台公共跳转页面
- * @param page
- * @return
- */
- @RequestMapping(value = "/{page}.do", method = RequestMethod.GET)
- public ModelAndView toPage(@PathVariable String page) {
- ModelAndView view = new ModelAndView("/manage/"+page+"");
- return view;
- }
-
- }
- @Controller
- @RequestMapping("/user")
- public class UserController {
-
-
- @Resource
- private IUserService userService;
-
-
-
- @Value("${img_dir}")
- private String imgDir;
-
- /**
- * 查询所有 and 模糊搜索
- * @param request
- * @param response
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/getList")
- @ResponseBody
- public String getList(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- String p = request.getParameter("page"); //需求页码
- String rows = request.getParameter("rows"); //每页多少条
- String sel = request.getParameter("s_userName"); //如果是查询这不为空
- System.out.println("收到请求:"+p+" "+rows+" "+sel);
- Map
map = new HashMap(); - ObjectMapper mapper = new ObjectMapper();
- String json = null;
- if(sel==null){
- /*List
list = userService.getPageList(new User(),Integer.parseInt(p), Integer.parseInt(rows)); - PageInfo
pageInfo = new PageInfo(list);*/ - /*map.put("rows", pageInfo.getList());
- map.put("total", pageInfo.getTotal());*/
- }
-
- json = mapper.writeValueAsString(map);
- return json;
- }
-
- /**
- * 功能描述:个人中心
- * @param request
- * @param response
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/toUserIndexUI")
- public ModelAndView toUserIndexUI(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- ModelAndView view = new ModelAndView();
- view.setViewName("jsp/user/userIndex");
- return view;
- }
-
- /**
- * 跳转到修改密码页面
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/toUserPasswordEditUI")
- public ModelAndView toUserPasswordEditUI(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- ModelAndView view = new ModelAndView();
- view.setViewName("jsp/user/editPassword");
- return view;
- }
-
- /**
- * 功能描述:退出系统
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/quit")
- public ModelAndView quit(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- HttpSession session = request.getSession();
- session.invalidate();
-
- ModelAndView view = new ModelAndView();
- view.setViewName("../index");
- return view;
- }
-
- /**
- * 功能描述:用户管理
- * @param request
- * @param response
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/toUserManageUI")
- public ModelAndView toUserManageUI(User tempUser,HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- String pageStr = request.getParameter("pageNum");
- ModelAndView view = new ModelAndView();
- int pageNum = 1;
- int pageSize = 15;
- try {
- pageNum = Integer.parseInt(pageStr);
- } catch (NumberFormatException e) {
- }
- List
userList = userService.getPageList(tempUser,pageNum,pageSize); - PageInfo
pageInfo = new PageInfo(userList); - request.setAttribute("page", pageInfo);
-
- view.setViewName("jsp/user/userManage");
- return view;
- }
-
- /**
- * 功能描述:跳转到新增用户页面
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/userAddUI")
- public ModelAndView userAddUI(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- ModelAndView view = new ModelAndView();
- List
roles = userService.getRoleList(); - request.setAttribute("roles", roles);
-
- view.setViewName("jsp/user/user-add");
- return view;
- }
-
- /**
- * 功能描述:保存用户信息
- * @param request
- * @param response
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/addUser")
- public ModelAndView addUser(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- ModelAndView view = new ModelAndView();
- String name = request.getParameter("name");
- String typeStr = request.getParameter("type");
- String tell = request.getParameter("tell");
- Integer type = 2;
- try {
- type = Integer.parseInt(typeStr);
- } catch (NumberFormatException e) {
- }
- userService.addUser(name, type, tell);
-
- view.setViewName("redirect:toUserManageUI.do");
- return view;
- }
-
- /**
- * 功能描述:跳转到修改页面
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/toModifyUI")
- public ModelAndView toModifyUI(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- ModelAndView view = new ModelAndView();
- String idStr = request.getParameter("id");
- Long id = null;
- try {
- id = Long.parseLong(idStr);
- } catch (NumberFormatException e) {
- }
- List
roles = userService.getRoleList(); - User user = userService.getUserById(id);
- request.setAttribute("roles", roles);
- request.setAttribute("account", user);
-
- view.setViewName("jsp/user/user-add");
- return view;
- }
-
- @RequestMapping("/editUser")
- public ModelAndView editUser(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- ModelAndView view = new ModelAndView();
- String name = request.getParameter("name");
- String typeStr = request.getParameter("type");
- String tell = request.getParameter("tell");
- String pageNum = request.getParameter("pageNum");
- Integer type = 2;
- String idStr = request.getParameter("id");
- Long id = null;
- try {
- id = Long.parseLong(idStr);
- } catch (NumberFormatException e) {
- }
- try {
- type = Integer.parseInt(typeStr);
- } catch (NumberFormatException e) {
- }
- userService.editUser(id, name, type, tell);
-
-
- view.setViewName("redirect:toUserManageUI.do?pageNum"+pageNum);
- return view;
-
- }
-
-
- /**
- * 功能描述:删除用户
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/delUser")
- public ModelAndView delUser(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- ModelAndView view = new ModelAndView();
- String pageStr = request.getParameter("pageNum");
- String idStr = request.getParameter("id");
- Long id = null;
- try {
- id = Long.parseLong(idStr);
- } catch (NumberFormatException e) {
- }
- userService.delUser(id);
-
- view.setViewName("redirect:toUserManageUI.do?pageNum"+pageStr);
- return view;
-
- }
-
-
- /**
- * 功能描述:得到某个用户某月的业绩
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/toSalaryUI")
- public ModelAndView toSalaryUI(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- String date = request.getParameter("date");
- String pageNoStr = request.getParameter("pageNo");
- ModelAndView view = new ModelAndView();
- int pageNo = 1;
- try {
- pageNo = Integer.parseInt(pageNoStr);
- } catch (NumberFormatException e) {
- }
-
- HttpSession session = request.getSession();
- if (date != null && date.trim().length()>0) {
- session.setAttribute("salary_date", date);
- }
-
- date = (String) session.getAttribute("salary_date");
- if (date != null && date.trim().length()>0) {
- session.setAttribute("salary_date_f", date.substring(0, 4) + "年"
- + date.substring(5, 7) + "月");
- SalaryOpe salaryOpe = userService.getSalaryOpe(date, pageNo);
- request.setAttribute("salaryOpe", salaryOpe);
- }
-
- view.setViewName("jsp/user/salary");
- return view;
- }
-
- /**
- * 功能描述:跳转到运营分析
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/toFinanceUI")
- public ModelAndView toFinanceUI(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- ModelAndView view = new ModelAndView();
- view.setViewName("jsp/user/salaryAnalysis");
- return view;
- }
-
- }
- @Controller
- @RequestMapping("/book")
- public class BookController {
-
-
- @Autowired
- private IDishService dishService;
-
-
- @Value("${img_dir}")
- private String imgDir;
-
-
-
- /**
- * 功能描述:点餐本首页
- * @param request
- * @param response
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/index")
- public ModelAndView toIndexUI(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- ModelAndView view = new ModelAndView();
- int pageNo = 1;
- int pageSize = 10;
- String condition = null;
- String likeStr = null;
- HttpSession session = request.getSession();
-
- try {
- condition = (String) session.getAttribute("bookCondition");
- likeStr = (String) session.getAttribute("bookLikeStr");
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (condition == null || ("".trim()).equals(condition)) {
- condition = "u.id";
- }
- if (likeStr == null) {
- likeStr = "";
- }
-
- Dish tempDish = new Dish();
- tempDish.setOrderByCondition(condition);
- tempDish.setSearchKeyWord(likeStr);
- List
dishList = dishService.getPageList(pageNo,pageSize ,tempDish); - PageInfo
pageInfo = new PageInfo(dishList); - request.setAttribute("dishType", dishService.getDishTypeList());
- view.addObject("page",pageInfo);
- view.setViewName("jsp/book/book");
- return view;
- }
-
- /**
- * 功能描述:搜索菜单
- * @param request
- * @param response
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/searchDish")
- public ModelAndView searchDish(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- ModelAndView view = new ModelAndView();
- String likeStr = request.getParameter("likeStr");
- // likeStr = new String(likeStr.getBytes("iso-8859-1"), "utf-8");
- likeStr = likeStr.trim();
- HttpSession session = request.getSession();
- if (likeStr != null) {
- session.setAttribute("bookLikeStr", likeStr);
- } else {
- session.removeAttribute("bookLikeStr");
- }
- view.setViewName("redirect:index.do");
- return view;
- }
-
- /**
- * 功能描述:查看更多
- * @param request
- * @param response
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/getMoreList")
- @ResponseBody
- public String getMoreList(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- Map
map = new HashMap(); - ObjectMapper mapper = new ObjectMapper();
- String json = null;
- try {
- Thread.sleep(500);
- } catch (InterruptedException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
-
-
- String pageNumStr = request.getParameter("pageNum");
- int pageNum = 1;
- int pageSize = 10;
- try {
- pageNum = Integer.parseInt(pageNumStr);
- } catch (NumberFormatException e) {
-
- }
-
- String condition = null;
- String likeStr = null;
- HttpSession session = request.getSession();
-
- try {
- condition = (String) session.getAttribute("bookCondition");
- likeStr = (String) session.getAttribute("bookLikeStr");
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- if (condition == null || ("".trim()).equals(condition)) {
- condition = "u.id";
- }
- if (likeStr == null) {
- likeStr = "";
- }
-
- Dish tempDish = new Dish();
- tempDish.setOrderByCondition(condition);
- List
dishList = dishService.getPageList(pageNum,pageSize ,tempDish); - PageInfo
pageInfo = new PageInfo(dishList); -
- json = mapper.writeValueAsString(pageInfo);
- return json;
-
- }
-
- /**
- * 根据条件获取菜单列表
- * @param request
- * @param response
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/setSortAttr")
- public ModelAndView setSortAttr(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- ModelAndView view = new ModelAndView();
- HttpSession session = request.getSession();
- String conditionStr = request.getParameter("bookCondition");
- String condition = null;
- if ("2".equals(conditionStr)) {
- condition = "sale";
-
- } else if ("3".equals(conditionStr)) {
- condition = "price";
-
- } else {
- condition = "";
-
- }
-
- session.setAttribute("bookCondition", condition);
- view.setViewName("redirect:index.do");
- return view;
- }
-
- /**
- * 功能描述:菜单管理
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/itemManageUI")
- public ModelAndView itemManageUI(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- ModelAndView view = new ModelAndView();
- String pageNumStr = request.getParameter("pageNum");
- int pageNum = 1;
- int pageSize = 10;
- try {
- pageNum = Integer.parseInt(pageNumStr);
- } catch (NumberFormatException e) {
-
- }
- Dish tempDish = new Dish();
- tempDish.setOrderByCondition("u.id");
- List
dishList = dishService.getPageList(pageNum, pageSize,tempDish); - PageInfo
pageInfo = new PageInfo(dishList); - request.setAttribute("dishType", dishService.getDishTypeList());
- request.setAttribute("page", pageInfo);
-
- view.setViewName("jsp/book/itemManege");
- return view;
- }
-
- /**
- * 功能描述:跳转到添加菜单页面
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/itemAddUI")
- public ModelAndView itemAddUI(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- ModelAndView view = new ModelAndView();
- request.setAttribute("dishType", dishService.getDishTypeList());
- request.setAttribute("UUID", UUIDUtil.getUUID());
- view.setViewName("jsp/book/book-add");
- return view;
- }
-
- /**
- * 功能描述:新增菜单
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/addDish")
- public ModelAndView addDish(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- ModelAndView view = new ModelAndView();
- String name = request.getParameter("name");
- Integer type_id = 1;
- String typeIdStr = request.getParameter("type_id");
- Float price = 10.5F;
- String priceStr = request.getParameter("price");
- String picture = request.getParameter("picture");
- Long sale = 0l;
- Integer stock = 10;
- String description = request.getParameter("description");
- try {
- type_id = Integer.parseInt(typeIdStr);
- price = Float.parseFloat(priceStr);
- } catch (NumberFormatException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- dishService.addBook(name, type_id, price, picture, sale, stock,
- description);
- view.setViewName("redirect:itemManageUI.do");
- return view;
- }
-
- /**
- * 功能描述:跳转到修改页面
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/itemEditUI")
- public ModelAndView itemEditUI(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- String idStr = request.getParameter("id");
- ModelAndView view = new ModelAndView();
- Long id = 1l;
- try {
- id = Long.parseLong(idStr);
- } catch (NumberFormatException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Dish dish = dishService.getDishById(id);
- request.setAttribute("dishType", dishService.getDishTypeList());
- request.setAttribute("dish", dish);
- view.setViewName("jsp/book/book-add");
- return view;
- }
-
- /**
- * 功能描述:保存修改信息
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/itemEdit")
- public ModelAndView itemEdit(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- String idStr = request.getParameter("id");
- String pageNum = request.getParameter("pageNum");
- ModelAndView view = new ModelAndView();
- Long id = 1l;
- try {
- id = Long.parseLong(idStr);
- } catch (NumberFormatException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- String name = request.getParameter("name");
- Integer type_id = 1;
- String typeIdStr = request.getParameter("type_id");
- Float price = 10.5F;
- String priceStr = request.getParameter("price");
- String picture = request.getParameter("picture");
-
- Long sale = 0l;
- Integer stock = 10;
- String description = request.getParameter("description");
- try {
- type_id = Integer.parseInt(typeIdStr);
- price = Float.parseFloat(priceStr);
- } catch (NumberFormatException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Dish dish = dishService.getDishById(id);
- sale = dish.getSale();
- stock =dish.getStock();
- dishService.eidtBook(id, name, type_id, price, picture, sale, stock,
- description);
- view.setViewName("redirect:itemManageUI.do?pageNum="+pageNum);
- return view;
- }
-
- /**
- * 功能描述:删除菜单
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/itemDelete")
- public ModelAndView itemDelete(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- String idStr = request.getParameter("id");
- String pageNum = request.getParameter("pageNum");
- Long id = null;
- ModelAndView view = new ModelAndView();
- try {
- id = Long.parseLong(idStr);
- } catch (NumberFormatException e) {
- e.printStackTrace();
- }
- try {
- dishService.deleteBook(id);
- } catch (Exception e) {
- }
-
- view.setViewName("redirect:itemManageUI.do?pageNum="+pageNum);
- return view;
-
- }
-
- /**
- * 功能描述:销售排行榜
- * @param request
- * @param response
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/getTopSaleDish")
- @ResponseBody
- public String getTopSaleDish(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- Map
map = new HashMap(); - ObjectMapper mapper = new ObjectMapper();
- String json = null;
- List
dishList = dishService.getPageBySaleDesc(1,15); - json = mapper.writeValueAsString(dishList);
- return json;
- }
-
-
- /**
- * 功能描述:各大菜式销量
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/getSaleDishType")
- @ResponseBody
- public String getSaleDishType(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- Map
map = new HashMap(); - ObjectMapper mapper = new ObjectMapper();
- String json = null;
- List
list =dishService.getDishTypeSales(); - json = mapper.writeValueAsString(list);
- return json;
- }
-
- }
如果也想学习本系统,下面领取。回复:217ssm