当前位置:文档之家› Java网上订餐系统与分析大型实验报告

Java网上订餐系统与分析大型实验报告

Java系统与分析大型实验报告设计题目:基于JavaEE的网上订餐系统班级:软件801姓名:***学号:***指导老师:***2011年12月1、需求分析网上订餐系统需要提供客户快捷、方便的订餐服务,开发本系统的具体要求如下:(1)在系统首页需要提供推荐菜单、热门菜单已经菜单搜索功能,方便用户快速选购自己喜欢的菜单。

(2)系统要求用户进行注册和登录。

(3)在用户订餐完毕后,需要能够自动计算菜单价格。

同时在用户提交订单时,需要用户确定订单无误,同时还将自动生成订单号,并保存到系统的剪贴板中,方便用户保存订单号。

(4)系统还需要提供会员服务功能,会员每消费一块钱将增加一积分。

同时在系统首页将显示积分榜,鼓励会员消费。

(5)系统需要提供菜单分类查看功能,从而方便用户选购。

2、功能分析模块:餐店简介模块:用来介绍餐店信息,例如餐店名称、联系人、地址、电话等。

美食分类模块:用来分类显示美食信息,可以通过单击菜单来查看菜单详细信息,可以发表评论信息。

订餐模块:点击菜单的订餐按钮,进入购物车,提供订餐功能。

会员中心模块:用来显示会员身份信息,并提供会员信息更新功能。

订单查询模块:负责订单的查询功能,提供订单时间、订单号查询功能。

功能说明用例图:图1 用户用例图图2 管理员用例图3、系统设计系统流程图:图3 前台系统流程图图4 后台系统流程图数据库实体表:图5 店铺信息表图6 订单信息表图7 用户信息表图8 菜单信息列表图9 菜单种类表ER图:图10 店铺实体E-R图图11 菜单种类实体E-R图图12 菜单信息实体E-R图图13 用户信息实体E-R图14 订单信息实体E-R图4、模块设计表现层代码如下:<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%@page import="org.shop.model.*" %><%@ taglib uri="/struts-tags" prefix="s" %><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><base href="<%=basePath%>"><BASE target=_self><title>食为天</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><link rel="stylesheet" type="text/css" href="styles.css"><script type="text/javascript">function setImg(img, width, height){var scale_w = img.width / width; //按宽度得到的缩放比例var scale_h = img.height / height;//按高度得到的缩放比例var scale = scale_w > scale_h ? scale_w : scale_h;//得到缩放比例(取最大值)img.width = img.width / scale;//缩放宽度return false;}var allId="";var allPrice=0;function addShopBus(name,price,num,id){var str=name+" 价格"+price+" 数量"+num+" 已加入购物车";var allPrices=document.getElementById("allPrices");var allPricess=document.getElementById("allPricess");var strId=document.getElementById("strId");var table=document.getElementById("shopBusTable");var tr = table.insertRow(2);//在第二行插入一行,并赋值var td1 = tr.insertCell();td1.innerHTML=name;var td = tr.insertCell();var td2 = tr.insertCell();td2.innerHTML=price;var td3 = tr.insertCell();td3.innerHTML=num;allPrice=allPrice+price;if(allId==""){allId=allId+id;}else{allId=allId+","+id;}strId.value=allId;allPrices.innerHTML=allPrice;allPricess.value=allPrice;}function check(){var strId=document.getElementById("strId").value;if(strId!=""){alert("订单生成成功!");return true;}else{alert("您还未点菜!");return false;}}function gotothat(flag){if(flag=="login"){showModalDialog("login.jsp",window, "dialogHeight:20;dialogWidth:29;");}if(flag=="reg"){showModalDialog("reg.jsp",window, "dialogHeight:20;dialogWidth:29;");}}function more(InfoId,TypeId){showModalDialog("more.jsp?InfoId="+InfoId+"&TypeId="+TypeId,window, "dialogHeight:30;dialogWidth:29;");}</script></head><body><%ShopInfo shopInfo=(ShopInfo)session.getAttribute("shopInfo");MemberInfo memberInfo=null;if(session.getAttribute("memberInfo")!=null){memberInfo =(MemberInfo)session.getAttribute("memberInfo");}List<MenuType> menuTypes=(List<MenuType>)session.getAttribute("menuType"); List<OrderInfo>orderInfos =(List<OrderInfo>)session.getAttribute("orderInfo"); MenuType menuType=new MenuType();MenuInfo menuInfo=new MenuInfo();%><%if(memberInfo==null){%><div id="member"><input type="button" value="登录" onclick="javascript:gotothat('login')"><input type="button" value="注册" onclick="javascript:gotothat('reg')"></div><%}else{%><div id="member">欢迎<%=memberInfo.getName()%>在食为天订餐!<br/>您目前的积分为<%=memberInfo.getSource() %><a href="login_out">注销</a> </div><%} %><div id="shopInfo"><table width="250"><tr><td> 店名:</td><td><%=shopInfo.getName() %></td></tr><tr><td>联系人:</td><td><%=shopInfo.getPersonName() %></td></tr><tr><td>联系电话:</td><td><%=shopInfo.getPhone() %></td></tr><tr><td>地址:</td><td><%=shopInfo.getAdress() %></td></tr></table></div><div id="shopBus"><form action="addOrderInfo" method="post" onsubmit="return check()"><table id="shopBusTable"><tr><td colspan="3" align="center">购物车</td></tr><tr><td width="160">菜名<td><td width="40">价格</td><td width="40">数量</td></tr> <tr><td width="160">总价:<font color="red" id="allPrices">0</font><td><td width="40"><input id="strId" type="hidden" name="orderInfo.menuAll" value=""></td><td width="40"><input id="allPricess" type="hidden" name="orderInfo.allPrice"></td></tr> <tr><td colspan="3" align="center"><input type="submit" value="生成订单"/></td></tr> </table></form></div><div id="orderList"><h3>我的订单</h3><table><tr><td>编号</td><td>菜编号</td><td>总价</td><td>时间</td></tr><%if(orderInfos.size()<1){%><tr><td colspan="4">您目前还没有订单!</td></tr><%}else{for(Iterator it3=orderInfos.iterator();it3.hasNext();){OrderInfo orderInfo=(OrderInfo)it3.next();%><tr><td><%=orderInfo.getId() %></td><td><%=orderInfo.getMenuAll() %></td><td><%=orderInfo.getAllPrice() %></td><td><%=orderInfo.getTime() %></td></tr><%} }%></table></div><%for(Iterator it=menuTypes.iterator();it.hasNext();){menuType=(MenuType)it.next();%><div id="menuType"><h3><%=menuType.getName()%></h3><p><%=menuType.getDescription() %></p><table><tr><%int i=0;//标记for(Iterator it2=((MenuType) menuType).getMenuInfo().iterator();it2.hasNext();){menuInfo=(MenuInfo)it2.next();if(menuInfo!=null){%><td><table class="menuInfo"><tr><td> 菜名:</td><td><%=menuInfo.getName() %></td></tr><tr><td> 图样:</td><td><img alt="<%=menuInfo.getName()%>" src="menuPhoto/<%=menuInfo.getPhoto()%>"onload="javascript:setImg(this,120,80)" ></td></tr><tr><td> 单价:</td><td><%=menuInfo.getPrice() %> ¥</td></tr><tr><td> 描述:</td><td><%=menuInfo.getDescription() %></td></tr><tr><td>编号<%=menuInfo.getId() %><td><input type="button" value="详情"onclick="javascript:more('<%=menuInfo.getId()%>',<%=menuType.getId()%>)"/></td></tr> <tr><td></td><td><input type="button" value="购买"onclick="javascript:addShopBus('<%=menuInfo.getName()%>',<%=menuInfo.getPrice()%>,1,< %=menuInfo.getId()%>)"/></td></tr></table></td><%i++;if(i%4==0){i=1; %></tr><tr><%}}}%></tr></table></div><%} %></body></html>控制层代码如下:<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "/dtds/struts-2.1.dtd"><struts><package name="default" extends="struts-default"><action name="index" class="org.shop.action.indexLogin"><result name="success">/shopMain.jsp</result></action><action name="addOrderInfo" class="org.shop.action.orderInfo"><result name="success">/index.jsp</result></action><action name="login_member" class="org.shop.action.loginAction"><result name="success">/login_success.jsp</result><result name="error">/login.jsp</result></action><action name="login_super" class="org.shop.action.loginAction" method="superOn"> <result name="success">/super/super.jsp</result><result name="error">/super/login.jsp</result></action><action name="reg" class="org.shop.action.loginAction" method="reg"><result name="success">/success.jsp</result><result name="error">/reg.jsp</result></action><action name="login_out" class="org.shop.action.loginAction"method="out"><result name="success">/index.jsp</result></action><action name="addMessage" class="org.shop.action.messageAction"><result name="success">/more.jsp</result></action></package></struts>业务逻辑层代码如下:<?xml version="1.0" encoding="UTF-8"?><beans xmlns="/schema/beans"xmlns:xsi="/2001/XMLSchema-instance"xmlns:p="/schema/p"xsi:schemaLocation="/schema/beans/schema/beans/spring-beans-2.5.xsd"><bean id="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><property name="configLocation" value="classpath:hibernate.cfg.xml"></property></bean><bean id="shopInfoDao" class="org.shop.dao.imp.ShopInfoDaoImp"><property name="sessionFactory" ref="sessionFactory"></property> </bean><bean id="shopInfoService" class="org.shop.service.imp.ShopInfoServiceImp"> <property name="shopInfoDao" ref="shopInfoDao"></property> </bean><bean id="menuTypeDao" class="org.shop.dao.imp.MenuTypeDaoImp"><property name="sessionFactory" ref="sessionFactory"></property> </bean><bean id="menuTypeService" class="org.shop.service.imp.MenuTypeServiceImp"> <property name="menuTypeDao" ref="menuTypeDao"></property> </bean><bean id="orderInfoDao" class="org.shop.dao.imp.OrderInfoDaoImp"><property name="sessionFactory" ref="sessionFactory"></property> </bean><bean id="orderInfoService" class="org.shop.service.imp.OrderInfoServiceImp"> <property name="orderInfoDao" ref="orderInfoDao"></property> </bean><bean id="memberInfoDao" class="org.shop.dao.imp.MemberInfoDaoImp"> <property name="sessionFactory" ref="sessionFactory"></property> </bean><bean id="memberInfoService" class="org.shop.service.imp.MemberInfoServiceImp"> <property name="memberInfoDao" ref="memberInfoDao"></property> </bean><bean id="messageInfoDao" class="org.shop.dao.imp.MessageInfoDaoImp"> <property name="sessionFactory" ref="sessionFactory"></property> </bean><bean id="messageInfoService" class="org.shop.service.imp.MessageInfoServiceImp"> <property name="messageInfoDao" ref="messageInfoDao"></property> </bean></beans>持久层代码如下:<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE hibernate-configuration PUBLIC"-//Hibernate/Hibernate Configuration DTD 3.0//EN""/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools. --><hibernate-configuration><session-factory><property name="dialect">org.hibernate.dialect.MySQLDialect</property><property name="connection.url">jdbc:mysql://127.0.0.1:3306/reservation</property><property name="ername">root</property><property name="connection.password">sa</property><property name="connection.driver_class">com.mysql.jdbc.Driver</property><property name="myeclipse.connection.profile">mysql</property><mapping resource="org/shop/model/ShopInfo.hbm.xml" /><mapping resource="org/shop/model/MenuInfo.hbm.xml" /><mapping resource="org/shop/model/MenuType.hbm.xml" /><mapping resource="org/shop/model/OrderInfo.hbm.xml" /><mapping resource="org/shop/model/MemberInfo.hbm.xml" /><mapping resource="org/shop/model/MessageInfo.hbm.xml" /></session-factory></hibernate-configuration>5、总结通过这次实验,加深了对JAEE的框架的理解与应用,也把一学期所学的知识都综合应用到一起,并解决了学习中存在的很多疑惑与难点,对实验中的Struts2,Hibernate和Spring的应用更熟练更透彻。

相关主题