作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
该超市订单管理毕业设计基于jdk8版本开发,在部署时需要使用jdk8以上的版本。使用了目前流行的框架组合spring+springMVC+mybatis的框架技术, 实现了供应商管理对供应商实现增删改查、订单管理对超市订单实现增删改查、用户管理等功能,适用于小型超市的使用,通过学习该超市订单管理 的毕业设计,对于SSM框架的组合能够有更深层次的理解。
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.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 5.7版本;
1. 后端:Spring SpringMVC MyBatis
2. 前端:JSP+jQuery
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 将项目中applicationContext.xml配置文件中的数据库配置改为自己的配置;
3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
4. 运行成功后,访问http://localhost:8080/supermarket/login.htm到登录页面
- package com.bjpowernode.controller;
-
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
-
- import javax.servlet.http.HttpSession;
-
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Qualifier;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
-
- import com.alibaba.fastjson.JSONArray;
- import com.bjpowernode.bizImpl.SmbmsBillBizImpl;
- import com.bjpowernode.bizImpl.SmbmsProviderBizImpl;
- import com.bjpowernode.entity.SmbmsBill;
- import com.bjpowernode.entity.SmbmsBillExample;
- import com.bjpowernode.entity.SmbmsProvider;
- import com.bjpowernode.entity.SmbmsUser;
-
- @Controller
- public class BillController {
-
- @Autowired
- @Qualifier("bBiz")
- private SmbmsBillBizImpl bBiz;
-
- @Autowired
- @Qualifier("pBiz")
- private SmbmsProviderBizImpl pBiz;
-
-
- public void setpBiz(SmbmsProviderBizImpl pBiz) {
- this.pBiz = pBiz;
- }
-
- public void setbBiz(SmbmsBillBizImpl bBiz) {
- this.bBiz = bBiz;
- }
-
- /*进入billlist页面 modify页面 view页面*/
- @RequestMapping("/bill.do")
- public String tobilllist(Model model,String method,String billid,String queryProductName,String queryProviderId,String queryIsPayment,String pageIndex){
- if("view".equals(method)){
- SmbmsBill bill=bBiz.selectByPrimaryKey(Long.parseLong(billid));
-
- bill.setProvidername(pBiz.selectByPrimaryKey(bill.getProviderid()).getProname());/*根据供应商id,获得供应商名字*/
- model.addAttribute("bill", bill);
- return "billview";
- }else if("modify".equals(method)){
- model.addAttribute("bill", bBiz.selectByPrimaryKey(Long.parseLong(billid)));
- return "billmodify";
- }else{
- Map map=bBiz.selectByExample(null,queryProductName,queryProviderId,queryIsPayment,pageIndex);/*按照分页获取list 、和分页信息param*/
- Map map2=pBiz.selectByExample(null, null, null, null);/*获取供应商列表*/
- List
list2=new ArrayList<>(); - for (SmbmsBill bill : (List
)map.get("listuser")) { - bill.setProvidername(pBiz.selectByPrimaryKey(bill.getProviderid()).getProname());/*根据供应商id,获得供应商名字*/
- list2.add(bill);
- }
-
- model.addAttribute("billList", list2);
- model.addAttribute("providerList", map2.get("listuser"));
- model.addAttribute("page", map.get("param"));
- model.addAttribute("queryProductName",queryProductName);
- model.addAttribute("queryProviderId", queryProviderId);
- model.addAttribute("queryIsPayment", queryIsPayment);
- return "billlist";
- }
- }
-
- /*删除bill页面 获取供应商列表*/
- @ResponseBody
- @RequestMapping("/delbill.do")
- public Object delbill(String billid,String method){
- Map map=new HashMap<>();
- if("delbill".equals(method)){
- if(bBiz.selectByPrimaryKey(Long.parseLong(billid))==null){
- map.put("delResult", "notexist");
- }
- int flag=bBiz.deleteByPrimaryKey(Long.parseLong(billid));
- if(flag>0){
- map.put("delResult", "true");
- }else{
- map.put("delResult", "false");
- }
- }else if("getproviderlist".equals(method)){
- Map map2=pBiz.selectByExample(null,null,null,null);
- map.put("list", map2.get("listuser"));
- }
- return JSONArray.toJSONString(map);
- }
-
- /*跳到添加bill页面*/
- @RequestMapping("/billadd.do")
- public String billadd(){
-
- return "billadd";
- }
-
- /*bill 各种save*/
- @RequestMapping("/billsave.do")
- public String billsave(String method,SmbmsBill bill,HttpSession session){
- if("add".equals(method)){
- SmbmsUser user=(SmbmsUser)session.getAttribute("userSession");
- bill.setCreatedby(user.getId());
- bill.setCreationdate(new Date());
- int flag=bBiz.insertSelective(bill);
- if(flag>0){
- return "redirect:/bill.do";
- }else{
- return "redirect:/billadd.do";
- }
- }else{
- SmbmsBillExample example=new SmbmsBillExample();
- SmbmsBillExample.Criteria criteria=example.createCriteria();
- int flag=bBiz.updateByExampleSelective(bill, example);
- if(flag>0){
- return "redirect:/bill.do";
- }else{
- return "redirect:/bill.do?method=modify&billid="+bill.getId();
- }
- }
- }
- }
- package com.bjpowernode.controller;
-
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
-
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Qualifier;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.filter.DelegatingFilterProxy;
-
- import com.alibaba.fastjson.JSONArray;
- import com.bjpowernode.bizImpl.SmbmsProviderBizImpl;
- import com.bjpowernode.entity.SmbmsProvider;
-
- @Controller
- public class ProviderController {
-
- @Autowired
- @Qualifier("pBiz")
- private SmbmsProviderBizImpl pBiz;
-
-
- public void setpBiz(SmbmsProviderBizImpl pBiz) {
- this.pBiz = pBiz;
- }
-
- /*进入供应商list*/
- @RequestMapping("/provider.do")
- public String topro(Model model,String queryProCode,String queryProName,String pageIndex){
- Map map=pBiz.selectByExample(null,queryProCode,queryProName,pageIndex);
- model.addAttribute("providerList", map.get("listuser"));
- model.addAttribute("page", map.get("param"));
- model.addAttribute("queryProCode",queryProCode);
- model.addAttribute("queryProName", queryProName);
- return "providerlist";
- }
-
- /*根据method跳转到不同字段*/
- @RequestMapping("/providerALL.do")
- public String bymethod(String method,String proid,Model model){
-
- /*转到查看页面*/
- if("view".equals(method)){
- SmbmsProvider provider=pBiz.selectByPrimaryKey(Long.parseLong(proid));
- model.addAttribute("provider", provider);
- return "providerview";
- }
- /*转到更新页面*/
- else if("modify".equals(method)){
- SmbmsProvider provider=pBiz.selectByPrimaryKey(Long.parseLong(proid));
- model.addAttribute("provider", provider);
- return "providermodify";
- }
- /*转到添加页面*/
- else if("add".equals(method)){
- return "provideradd";
- }
- return "";
- }
-
- /*转到删除*/
- @ResponseBody
- @RequestMapping("/delpro")
- public String DelegatingFilterProxy(String proid){
- Map map=new HashMap<>();
- SmbmsProvider provider=pBiz.selectByPrimaryKey(Long.parseLong(proid));
- if(provider==null){
- map.put("delResult", "notexist");
- }
- int flag=pBiz.deleteByPrimaryKey(Long.parseLong(proid));
- if(flag>0){
- map.put("delResult", "true");
- }else{
- map.put("delResult", "false");
- }
-
- return JSONArray.toJSONString(map);
-
- }
-
- /*提交添加 或修改的请求*/
- @RequestMapping("providersave.do")
- public String tosave(String method,SmbmsProvider provider){
- if("add".equals(method)){
- int flag=pBiz.insertSelective(provider);
- if(flag>0){
- return "redirect:/provider.do";
- }else{
- return "provideradd";
- }
- }
- else{
- int flag=pBiz.updateByPrimaryKeySelective(provider);
- if(flag>0){
- return "redirect:/provider.do";
- }else{
- return "providermodify";
- }
- }
- }
- }
- package com.bjpowernode.controller;
-
- import java.io.File;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.*;
-
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpSession;
-
- import org.apache.commons.io.FilenameUtils;
- import org.apache.commons.lang.math.RandomUtils;
- import org.apache.log4j.Logger;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Qualifier;
- import org.springframework.beans.propertyeditors.CustomDateEditor;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.WebDataBinder;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.context.request.WebRequest;
- import org.springframework.web.multipart.MultipartFile;
-
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.annotation.JSONField;
- import com.bjpowernode.biz.SmbmsRoleBiz;
- import com.bjpowernode.biz.SmbmsUserBiz;
- import com.bjpowernode.entity.Param;
- import com.bjpowernode.entity.SmbmsRole;
- import com.bjpowernode.entity.SmbmsUser;
-
- @Controller
- public class UserController {
- private Logger logger=Logger.getLogger(UserController.class);
-
- @Autowired
- @Qualifier("uBiz")
- private SmbmsUserBiz uBiz;
-
- @Autowired
- @Qualifier("rBiz")
- private SmbmsRoleBiz rBiz;
-
-
- public void setrBiz(SmbmsRoleBiz rBiz) {
- this.rBiz = rBiz;
- }
-
- public void setuBiz(SmbmsUserBiz uBiz) {
- this.uBiz = uBiz;
- }
-
- /*登陆判断*/
- @RequestMapping("/login.do")
- public String login(SmbmsUser user,HttpSession session){
- Map map2=uBiz.selectByExample(user,null,null,null,null);
- List
list=(List)map2.get("listuser"); - if(list.size()>0){
- session.setAttribute("userSession", list.get(0));
- return "frame";
- }else{
- return "redirect:login.htm";
- }
- }
-
- /*转到登陆页面*/
- @RequestMapping("/login.htm")
- public String tologin(){
- return "login";
- }
-
- /*进入list前先查找数据*/
- @RequestMapping(value="/tolist.do")
- public String list(Model model,String queryname,String queryUserRole,String pageIndex){
- List
list=rBiz.selectByExample(null);/*获取角色列表*/ - Map map=uBiz.selectByExample(null,null,queryname,queryUserRole,pageIndex);/*按条件获取list*/
- model.addAttribute("roleList", list);
- List
listuser=(List)map.get("listuser"); - model.addAttribute("userList", listuser);
- Param param=(Param)map.get("param");
- model.addAttribute("page", param);
- model.addAttribute("queryname",queryname);
- model.addAttribute("queryUserRole", queryUserRole);
- return "userlist";
- }
-
- /*跳到添加用户页面*/
- @RequestMapping("/useradd.do")
- public String adduser(){
-
- return "useradd";
- }
-
- /*Ajax查询方法*/
- /*第一种解决乱码方式
- * @RequestMapping(value="/isuser",produces={"application/json;charset=UTF-8"})*/
- @ResponseBody
- @JSONField(format="yyyy-MM-dd")
- @RequestMapping("/isuser")
- public Object isuser(String method,String usercode,String uid,String oldpassword,HttpSession session){
- Map map=new HashMap<>();
- List listMap=new ArrayList<>();
- /*获取角色列表*/
- if("getrolelist".equals(method)){
- List
list=rBiz.selectByExample(null); - for (SmbmsRole smbmsRole : list) {
- Map map2=new HashMap<>();
- map2.put("id", smbmsRole.getId());
- map2.put("rolename", smbmsRole.getRolename());
- listMap.add(map2);
- }
- map.put("rows", listMap);
-
- }
- /*判断code是否存在*/
- else if("ucexist".equals(method)){
- if(""==usercode){
- map.put("usercode", "kong");
- }else{
- Map map2=uBiz.selectByExample(null, usercode,null,null,null);
- List
list=(List)map2.get("listuser"); - if(list.size()>0){
- map.put("usercode", "exist");
- }else{
- map.put("usercode", "true");
- }
- }
- }
- /*删除账号*/
- else if("deluser".equals(method)){
- if(uid==null){
- map.put("delResult", "notexist");
- }else{
- Integer flag=uBiz.deleteByPrimaryKey(Long.parseLong(uid));
- if(flag>0){
- map.put("delResult", "true");
- }else{
- map.put("delResult", "false");
- }
- }
- }
- /*判断密码是否正确*/
- else if("pwdmodify".equals(method)){
- SmbmsUser user=(SmbmsUser)session.getAttribute("userSession");
- if(user==null){
- map.put("result", "sessionerror");
- }
- if("".equals(oldpassword)){
- map.put("result", "error");
- }else{
- if(oldpassword.equals(user.getUserpassword())){
- map.put("result", "true");
- }else{
- map.put("result", "false");
- }
- }
-
- }
- return JSONArray.toJSONString(map);
- }
- /*添加用户,多文件上传*/
- @RequestMapping(value="/usersave.do",method=RequestMethod.POST)
- public String usersave(SmbmsUser user,HttpSession session,HttpServletRequest request,
- @RequestParam(value ="attachs", required = false) MultipartFile[] pics){
-
- String idPicPath = null;
- String workPicPath = null;
- String errorInfo = null;
- boolean flag = true;
- String path = request.getSession().getServletContext().getRealPath("statics"+File.separator+"uploadfiles");
- logger.info("uploadFile path ============== > "+path);
- for(int i = 0;i < pics.length ;i++){
- MultipartFile pic = pics[i];
- if(!pic.isEmpty()){
- if(i == 0){
- errorInfo = "uploadFileError";
- }else if(i == 1){
- errorInfo = "uploadWpError";
- }
- String oldFileName = pic.getOriginalFilename();//原文件名
- logger.info("uploadFile oldFileName ============== > "+oldFileName);
- String prefix=FilenameUtils.getExtension(oldFileName);//原文件后缀
- logger.debug("uploadFile prefix============> " + prefix);
- int filesize = 500000;
- logger.debug("uploadFile size============> " + pic.getSize());
- if(pic.getSize() > filesize){//上传大小不得超过 500k
- request.setAttribute(errorInfo, " * 上传大小不得超过 500k");
- flag = false;
- }else if(prefix.equalsIgnoreCase("jpg") || prefix.equalsIgnoreCase("png")
- || prefix.equalsIgnoreCase("jpeg") || prefix.equalsIgnoreCase("pneg")){//上传图片格式不正确
- //定义上传文件名:当前系统时间+随机数+“_Personal.jpg”
- String fileName = System.currentTimeMillis()+RandomUtils.nextInt(1000000)+"_Personal.jpg";
- logger.debug("new fileName======== " + pic.getName());
- File targetFile = new File(path, fileName);
- if(!targetFile.exists()){
- targetFile.mkdirs();
- }
- //保存
- try {
- pic.transferTo(targetFile);
- } catch (Exception e) {
- e.printStackTrace();
- request.setAttribute(errorInfo, " * 上传失败!");
- flag = false;
- }
- if(i == 0){
- idPicPath = path+File.separator+fileName;
- }else if(i == 1){
- workPicPath = path+File.separator+fileName;
- }
- logger.debug("idPicPath: " + idPicPath);
- logger.debug("workPicPath: " + workPicPath);
-
- }else{
- request.setAttribute(errorInfo, " * 上传图片格式不正确");
- flag = false;
- }
- }
- }
- if(flag){
- user.setCreatedby(((SmbmsUser)session.getAttribute("userSession")).getId());
- user.setCreationdate(new Date());
- user.setIdpicpath(idPicPath);
- user.setWorkpicpath(workPicPath);
- if(uBiz.insertSelective(user)>0){
- return "redirect:/tolist.do";
- }
- }
- return "useradd";
- }
-
- @InitBinder
- public void initBinder(WebDataBinder binder, WebRequest request) {
- //转换日期 注意这里的转化要和传进来的字符串的格式一直 如2015-9-9 就应该为yyyy-MM-dd
- DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd");
- binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));// CustomDateEditor为自定义日期编辑器
- }
-
- /*进入查看个人信息页面*/
- @RequestMapping(value="/view")
- public String view(String id,Model model){
- model.addAttribute("user", uBiz.selectByPrimaryKey(Long.parseLong(id)));
- return "userview";
- }
-
- /*进入修改个人信息页面*/
- @RequestMapping(value="/modify")
- public String modify(String id,Model model){
- model.addAttribute("user", uBiz.selectByPrimaryKey(Long.parseLong(id)));
- return "usermodify";
- }
-
- /*修改信息提交,成功则跳到list*/
- @RequestMapping("/modifysave.do")
- public String modifysave(SmbmsUser user){
- int flag=uBiz.updateByPrimaryKeySelective(user);
- if(flag>0){
- return "redirect:/tolist.do";
- }else{
- return "usermodify";
- }
- }
-
- /*进入密码修改页面*/
- @RequestMapping("/pwdmodify.do")
- public String pwdmodify(HttpSession session,Model model){
- Long id=((SmbmsUser)session.getAttribute("userSession")).getId();
- if(id==null){
- return "login";
- }
- model.addAttribute("user", uBiz.selectByPrimaryKey(id));
- return "pwdmodify";
- }
-
- /*提交密码修改,成功则跳到登陆页面*/
- @RequestMapping("/pwdmodifysave.do")
- public String pwdmodifysave(String newpassword,HttpSession session){
- SmbmsUser user=(SmbmsUser)session.getAttribute("userSession");
- user.setUserpassword(newpassword);
- int flag=uBiz.updateByPrimaryKeySelective(user);
- if(flag>0){
- return "redirect:logout.do";
- }else{
- return "pwdmodify.do";
- }
- }
-
- /*注销*/
- @RequestMapping("/logout.do")
- public String loginout(HttpSession session){
- session.removeAttribute("userSession");
- return "syserror";
- }
- }
如果也想学习本系统,下面领取。关注并回复:023ssm