基于javaweb+mysql的ssm+maven智能餐厅管理系统(java+ssm+jsp+bootstrap+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM+Maven智能餐厅管理系统(java+ssm+jsp+bootstrap+mysql)
项目介绍
本项目主要分为服务员、厨师、收银员、经理四种角色; 主要功能包括: 客户可以根据自己的要求去选择菜品,厨师部会收到你点的菜单。你可以看到菜单的时时状况。 工作人员之间可以互相进行内部通讯,及时得到最新信息。经理可以群发通知、消息给每位员工。 系统会对所有菜品进行监视,当有菜品库存缺乏时,系统会自动提醒管理员。 管理员可以查看到餐厅的近期运营状况。包括最近的营业额,各个菜品的销售情况等。
环境需要
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项目:是;
技术栈
- 后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+CSS+JavaScript+bootstrap
使用说明
- 使用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
cart.addDish(dish);
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
if (result.equals("true")) {
//result = cart.getTotalNumber() + "";
map.put("totalnumber",cart.getTotalNumber());
}
json = mapper.writeValueAsString(map);
return json;
}
/**
* 功能描述:更改购物车菜单数量
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/cartItemChange")
@ResponseBody
public String cartItemChange(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
Map<String, Object> map = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
String json = null;
HttpSession session = request.getSession();
Cart cart = (Cart) session.getAttribute("cart");
ServletContext servletContext = request.getSession()
.getServletContext();
Cart cartStock = (Cart) servletContext.getAttribute("cartStock");
String idStr = request.getParameter("id");
String value = request.getParameter("value");
Long id = null;
String result = "";
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) {
}
}
/**
* 功能描述:销售排行榜
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/getTopSaleDish")
@ResponseBody
public String getTopSaleDish(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Map<String, Object> map = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
String json = null;
List<Dish> 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<String, Object> map = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
String json = null;
List<DishTypeSale> list =dishService.getDishTypeSales();
json = mapper.writeValueAsString(list);
return json;
}
}
@Controller
@RequestMapping("/cart")
public class CartController {
@Autowired
private IDishService dishService;
/**
* 跳转到购物车
* @param request
* @param response
* @return
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/toCartUI")
public ModelAndView toCartUI(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
ModelAndView view = new ModelAndView();
view.setViewName("jsp/cart/cart");
return view;
}
/**
* 功能描述:添加到购物车
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/addToCart")
@ResponseBody
public String addToCart(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
ServletContext servletContext = request.getSession()
.getServletContext();
Map<String, Object> map = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
String json = null;
HttpSession session = request.getSession();
String idStr = request.getParameter("id");
Long id = null;
Cart cart = (Cart) session.getAttribute("cart");
Cart cartStock = (Cart) servletContext.getAttribute("cartStock");
if (cart == null) {
cart = new Cart();
/**
* 功能描述:生成验证码
* @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;
}
}
public class LoginFilter implements Filter {
public void init(FilterConfig filterConfig) throws ServletException {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// 获得在下面代码中要用的request,response,session对象
HttpServletRequest servletRequest = (HttpServletRequest) request;
HttpServletResponse servletResponse = (HttpServletResponse) response;
HttpSession session = servletRequest.getSession();
// 获得用户请求的URI
String path = servletRequest.getRequestURI();
// System.out.println(path);
// 从session里取员信息
User admin = (User) session.getAttribute("user");
//创建类Constants.java,里面写的是无需过滤的页面
for (int i = 0; i < Constant.NoFilter_Pages.length; i++) {
if (path.indexOf(Constant.NoFilter_Pages[i]) > -1) {
chain.doFilter(servletRequest, servletResponse);
return;
}
}
// 登陆页面无需过滤
if (path.indexOf("/login.do") > -1) {
chain.doFilter(servletRequest, servletResponse);
return;
}
if (path.indexOf("/login.do.do") > -1) {
chain.doFilter(servletRequest, servletResponse);
return;
}
// 判断如果没有取到员工信息,就跳转到登陆页面
if (admin == null || "".equals(admin)) {
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<Role> 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) {
} else {
result = "0";
}
map.put("result",result);
json = mapper.writeValueAsString(map);
return json;
}
/**
* 删除购物车
* @param request
* @param response
* @return
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/cartItemDelete")
public ModelAndView cartItemDelete(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
ModelAndView view = new ModelAndView();
HttpSession session = request.getSession();
Cart cart = (Cart) session.getAttribute("cart");
ServletContext servletContext = request.getSession()
.getServletContext();
Cart cartStock = (Cart) servletContext.getAttribute("cartStock");
String idStr = request.getParameter("id");
Long id = null;
try {
id = Long.parseLong(idStr);
} catch (NumberFormatException e) {
}
Integer quantity = cart.getItemNum(id);
cart.removeItem(id);
Integer applocationQuantity = cartStock.getItemNum(id);
cartStock.updateItemQuantity(id, applocationQuantity - quantity);
//response.sendRedirect("cartServlet?method=toCartUI");
view.setViewName("redirect:toCartUI.do");
return view;
}
/**
* 取消购物车
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/cancel")
public ModelAndView cancel(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
ModelAndView view = new ModelAndView();
/**
* 功能描述:用户模块控制层
*
* {@link http://www.goodym.cn/}
*/
@Controller
@RequestMapping("/user")
public class UserController {
@Resource
private IUserService userService;
/**
* 查询所有 and 模糊搜索
* @param request
* @param response
* @throws ServletException
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;
}
}
/**
* 功能描述:文件上传控制层
*
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<Dish> dishList = dishService.getPageList(pageNum, pageSize,tempDish);
PageInfo<Dish> pageInfo = new PageInfo<Dish>(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;
/**
* 功能描述:用户模块控制层
*
* {@link http://www.goodym.cn/}
*/
@Controller
@RequestMapping("/user")
public class UserController {
@Resource
private IUserService userService;
/**
* 查询所有 and 模糊搜索
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/getList")
@ResponseBody
public String getList(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/**
*/
public class LoginFilter implements Filter {
public void init(FilterConfig filterConfig) throws ServletException {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// 获得在下面代码中要用的request,response,session对象
HttpServletRequest servletRequest = (HttpServletRequest) request;
HttpServletResponse servletResponse = (HttpServletResponse) response;
HttpSession session = servletRequest.getSession();
// 获得用户请求的URI
String path = servletRequest.getRequestURI();
// System.out.println(path);
// 从session里取员信息
User admin = (User) session.getAttribute("user");
//创建类Constants.java,里面写的是无需过滤的页面
for (int i = 0; i < Constant.NoFilter_Pages.length; i++) {
if (path.indexOf(Constant.NoFilter_Pages[i]) > -1) {
chain.doFilter(servletRequest, servletResponse);
return;
}
}
// 登陆页面无需过滤
if (likeStr == null) {
likeStr = "";
}
Dish tempDish = new Dish();
tempDish.setOrderByCondition(condition);
List<Dish> dishList = dishService.getPageList(pageNum,pageSize ,tempDish);
PageInfo<Dish> pageInfo = new PageInfo<Dish>(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
view.setViewName("jsp/trade/tradeAll");
return view;
}
}
/**
* 功能描述:交易模块控制层
*
* http://www.goodym.cn
*/
@Controller
@RequestMapping("/cart")
public class CartController {
@Autowired
private IDishService dishService;
/**
* 跳转到购物车
* @param request
* @param response
* @return
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/toCartUI")
public ModelAndView toCartUI(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
* http://www.goodym.cn
*/
@Controller
@RequestMapping("/book")
public class BookController {
@Autowired
private IDishService dishService;
/**
* 功能描述:点餐本首页
* @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<Dish> dishList = dishService.getPageList(pageNo,pageSize ,tempDish);
PageInfo<Dish> pageInfo = new PageInfo<Dish>(dishList);
request.setAttribute("dishType", dishService.getDishTypeList());
view.addObject("page",pageInfo);
* @param request
* @param response
* @return
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/toCartUI")
public ModelAndView toCartUI(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
ModelAndView view = new ModelAndView();
view.setViewName("jsp/cart/cart");
return view;
}
/**
* 功能描述:添加到购物车
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/addToCart")
@ResponseBody
public String addToCart(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
ServletContext servletContext = request.getSession()
.getServletContext();
Map<String, Object> map = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
String json = null;
HttpSession session = request.getSession();
String idStr = request.getParameter("id");
Long id = null;
Cart cart = (Cart) session.getAttribute("cart");
Cart cartStock = (Cart) servletContext.getAttribute("cartStock");
if (cart == null) {
cart = new Cart();
session.setAttribute("cart", cart);
}
String result = "false";
try {
id = Long.parseLong(idStr);
Dish dish = dishService.getDishById(id);