基于Servlet的超市订单管理系统【含源码+数据库】
2023-12-21 11:21:57
🍓前言:我是天码编程,从事计算机开发行业数年,专注Java程序设计开发、源码分享、技术指导和毕业设计
🍓🍓厚台获取源码🍓🍓
项目名
基于Servlet的超市订单管理系统
技术栈
Servlet+JSP+MySQL
一、环境介绍
1.1 运行环境
开发语言:Java
数据库:MySQL
系统架构:B/S
后端:Servlet
前端:JSP
工具:IDEA,JDK1.8
二、系统介绍
超市订单管理系统是一种用于优化和简化超市日常运营的重要工具。它是一个综合性的软件解决方案,旨在帮助超市管理订单、库存、销售数据和供应商信息。这个系统的背景源于超市行业的高度竞争和不断增长的市场需求,需要高效的管理和数据分析。
这个系统的意义不仅体现在提高了超市的运营效率,还有助于提供更好的客户服务。通过实时跟踪库存情况,超市可以确保货架始终充足,减少了断货的情况,提高了客户满意度。订单管理系统还使超市能够更好地了解客户购买习惯,为促销活动和库存采购提供了宝贵的数据支持。
当前,随着技术的不断进步,超市订单管理系统已经成为现代超市不可或缺的一部分。它不仅可以自动化订单处理过程,还能够生成详尽的销售报告和分析,协助超市管理层制定更明智的经营策略。此外,系统还能够提高超市的数据安全性,确保敏感信息得到保护。
总之,超市订单管理系统在提高超市效率、优化库存控制、提供更好的客户服务和数据分析等方面发挥着关键作用,有助于超市在竞争激烈的市场中取得成功。这个系统不仅令超市更具竞争力,还为其提供了未来可持续发展的机会。
2.1 功能模块
- 系统角色:管理员、经理、普通员工
- 管理员:登录、订单管理、供应商管理、用户管理、密码修改
- 经理:登录、订单管理、供应商管理、用户管理、密码修改
- 普通员工:登录、订单管理、供应商管理、用户管理、密码修改
2.2 系统架构
B/S架构
三、系统展示
3.1部分功能图文展示
四、部分代码设计
4.1.部分代码如下:
public class BillServlet extends HttpServlet {
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/*String totalPrice = request.getParameter("totalPrice");
//23.234 45
BigDecimal totalPriceBigDecimal =
//设置规则,小数点保留两位,多出部分,ROUND_DOWN 舍弃
//ROUND_HALF_UP 四舍五入(5入) ROUND_UP 进位
//ROUND_HALF_DOWN 四舍五入(5不入)
new BigDecimal(totalPrice).setScale(2,BigDecimal.ROUND_DOWN);*/
String method = request.getParameter("method");
if(method != null && method.equals("query")){
this.query(request,response);
}else if(method != null && method.equals("add")){
this.add(request,response);
}else if(method != null && method.equals("view")){
this.getBillById(request,response,"billview.jsp");
}else if(method != null && method.equals("modify")){
this.getBillById(request,response,"billmodify.jsp");
}else if(method != null && method.equals("modifysave")){
this.modify(request,response);
}else if(method != null && method.equals("delbill")){
this.delBill(request,response);
}else if(method != null && method.equals("getproviderlist")){
this.getProviderlist(request,response);
}
}
private void getProviderlist(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("getproviderlist ========================= ");
List<Provider> providerList = new ArrayList<Provider>();
ProviderService providerService = new ProviderServiceImpl();
providerList = providerService.getProviderList("","");
//把providerList转换成json对象输出
response.setContentType("application/json");
PrintWriter outPrintWriter = response.getWriter();
outPrintWriter.write(JSONArray.toJSONString(providerList));
outPrintWriter.flush();
outPrintWriter.close();
}
private void getBillById(HttpServletRequest request, HttpServletResponse response,String url)
throws ServletException, IOException {
String id = request.getParameter("billid");
if(!StringUtils.isNullOrEmpty(id)){
BillService billService = new BillServiceImpl();
Bill bill = null;
bill = billService.getBillById(id);
request.setAttribute("bill", bill);
request.getRequestDispatcher(url).forward(request, response);
}
}
private void modify(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("modify===============");
String id = request.getParameter("id");
String productName = request.getParameter("productName");
String productDesc = request.getParameter("productDesc");
String productUnit = request.getParameter("productUnit");
String productCount = request.getParameter("productCount");
String totalPrice = request.getParameter("totalPrice");
String providerId = request.getParameter("providerId");
String isPayment = request.getParameter("isPayment");
Bill bill = new Bill();
bill.setId(Integer.valueOf(id));
bill.setProductName(productName);
bill.setProductDesc(productDesc);
bill.setProductUnit(productUnit);
bill.setProductCount(new BigDecimal(productCount).setScale(2,BigDecimal.ROUND_DOWN));
bill.setIsPayment(Integer.parseInt(isPayment));
bill.setTotalPrice(new BigDecimal(totalPrice).setScale(2,BigDecimal.ROUND_DOWN));
bill.setProviderId(Integer.parseInt(providerId));
bill.setModifyBy(((User)request.getSession().getAttribute(Constants.USER_SESSION)).getId());
bill.setModifyDate(new Date());
boolean flag = false;
BillService billService = new BillServiceImpl();
flag = billService.modify(bill);
if(flag){
response.sendRedirect(request.getContextPath()+"/jsp/bill.do?method=query");
}else{
request.getRequestDispatcher("billmodify.jsp").forward(request, response);
}
}
private void delBill(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String id = request.getParameter("billid");
HashMap<String, String> resultMap = new HashMap<String, String>();
if(!StringUtils.isNullOrEmpty(id)){
BillService billService = new BillServiceImpl();
boolean flag = billService.deleteBillById(id);
if(flag){//删除成功
resultMap.put("delResult", "true");
}else{//删除失败
resultMap.put("delResult", "false");
}
}else{
resultMap.put("delResult", "notexit");
}
//把resultMap转换成json对象输出
response.setContentType("application/json");
PrintWriter outPrintWriter = response.getWriter();
outPrintWriter.write(JSONArray.toJSONString(resultMap));
outPrintWriter.flush();
outPrintWriter.close();
}
private void add(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String billCode = request.getParameter("billCode");
String productName = request.getParameter("productName");
String productDesc = request.getParameter("productDesc");
String productUnit = request.getParameter("productUnit");
String productCount = request.getParameter("productCount");
String totalPrice = request.getParameter("totalPrice");
String providerId = request.getParameter("providerId");
String isPayment = request.getParameter("isPayment");
Bill bill = new Bill();
bill.setBillCode(billCode);
bill.setProductName(productName);
bill.setProductDesc(productDesc);
bill.setProductUnit(productUnit);
bill.setProductCount(new BigDecimal(productCount).setScale(2,BigDecimal.ROUND_DOWN));
bill.setIsPayment(Integer.parseInt(isPayment));
bill.setTotalPrice(new BigDecimal(totalPrice).setScale(2,BigDecimal.ROUND_DOWN));
bill.setProviderId(Integer.parseInt(providerId));
bill.setCreatedBy(((User)request.getSession().getAttribute(Constants.USER_SESSION)).getId());
bill.setCreationDate(new Date());
boolean flag = false;
BillService billService = new BillServiceImpl();
flag = billService.add(bill);
System.out.println("add flag -- > " + flag);
if(flag){
response.sendRedirect(request.getContextPath()+"/jsp/bill.do?method=query");
}else{
request.getRequestDispatcher("billadd.jsp").forward(request, response);
}
}
private void query(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
List<Provider> providerList = new ArrayList<Provider>();
ProviderService providerService = new ProviderServiceImpl();
providerList = providerService.getProviderList("","");
request.setAttribute("providerList", providerList);
String queryProductName = request.getParameter("queryProductName");
String queryProviderId = request.getParameter("queryProviderId");
String queryIsPayment = request.getParameter("queryIsPayment");
if(StringUtils.isNullOrEmpty(queryProductName)){
queryProductName = "";
}
List<Bill> billList = new ArrayList<Bill>();
BillService billService = new BillServiceImpl();
Bill bill = new Bill();
if(StringUtils.isNullOrEmpty(queryIsPayment)){
bill.setIsPayment(0);
}else{
bill.setIsPayment(Integer.parseInt(queryIsPayment));
}
if(StringUtils.isNullOrEmpty(queryProviderId)){
bill.setProviderId(0);
}else{
bill.setProviderId(Integer.parseInt(queryProviderId));
}
bill.setProductName(queryProductName);
billList = billService.getBillList(bill);
request.setAttribute("billList", billList);
request.setAttribute("queryProductName", queryProductName);
request.setAttribute("queryProviderId", queryProviderId);
request.setAttribute("queryIsPayment", queryIsPayment);
request.getRequestDispatcher("billlist.jsp").forward(request, response);
}
public static void main(String[] args) {
System.out.println(new BigDecimal("23.235").setScale(2,BigDecimal.ROUND_HALF_DOWN));
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
🍓🍓厚台获取源码🍓🍓
🍓🍓麻烦大家帮忙点赞、收藏、关注、评论啦 🍓🍓
文章来源:https://blog.csdn.net/2301_79452142/article/details/132775590
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!