Java项目:ssm库存管理系统

作者主页:夜未央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+spring mvc+mybatis

2. 前端:bootstrap+jQuery

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;

3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;

4. 运行项目,地址:http://localhost:8080/tologin.do

运行截图

 

 

 

 

  

相关代码

出库控制器

package org.shop.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.shop.pojo.ChuKu;
import org.shop.pojo.KuCun;
import org.shop.service.ChuKuService;
import org.shop.utils.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Controller
@RequestMapping("/chuku")
public class ChuKuController {

	@Autowired
	ChuKuService chukuService;
	
	@RequestMapping("/main.do")
	public String main() {
		return "/chuku/main";
	}
	
	//²é³öµ±Ç°¿â´æÊýÁ¿
	@ResponseBody
	@RequestMapping("/selectByName.do")
	public Msg selectByName(String shopName) {
		System.out.println("----------------------->:"+shopName);
		KuCun kucun = chukuService.selectByName(shopName);
		String fenlei = kucun.getShopFenlei();
		String shuliang = kucun.getShopShuliang()+"";
		System.out.println("----------------------->:"+fenlei+"||"+shuliang);
		Map<String,String> map = new HashMap<String,String>();
		map.put("fenlei", fenlei);
		map.put("shuliang", shuliang);
		return Msg.success().add("map", map);
	}
	
	@ResponseBody
	@RequestMapping("/insert.do")
	public Msg insert(ChuKu chuku) {
		System.out.println(chuku);
		
		int deptId = chukuService.selectByIdKey(chuku);
		if(deptId!=0) {
			return Msg.idCFfile();
		}
	     int i = chukuService.insert(chuku);
	     if(i==1) {
	    	 return Msg.success();
	     }else {
	    	 return Msg.file();
	     }
	}
	
	@ResponseBody
	@RequestMapping("/select.do")
	public Msg select(int pn) {
		
		PageHelper.startPage(pn, 5);
		List<ChuKu> list = chukuService.select();
		PageInfo pageInfo = new PageInfo(list,5);
		return Msg.success().add("pageInfo", pageInfo);
	}
	
	@ResponseBody
	@RequestMapping("/selectOne.do")
	public Msg selectOne(ChuKu chuku) {
		System.out.println("----------------->:"+chuku);
		PageHelper.startPage(1, 5);
		List<ChuKu> list = chukuService.selectOne(chuku);
		PageInfo pageInfo = new PageInfo(list,5);
		return Msg.success().add("pageInfo", pageInfo);
	}
}

分类控制器

package org.shop.controller;

import java.util.List;

import org.shop.pojo.FenLei;
import org.shop.service.FenLeiService;
import org.shop.utils.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Controller
@RequestMapping("/fenlei")
public class FenLeiController {
	
	@Autowired
	FenLeiService fenLeiService;

	@RequestMapping("/top.do")
	public String top() {
		return "/fenlei/top";
	}
	
	@RequestMapping("/base.do")
	public String base() {
		return "/fenlei/base";
	}
	
	@RequestMapping("/seebase.do")
	public String seebase() {
		return "/fenlei/seebase";
	}
	
	@RequestMapping("/addbase.do")
	public String addbase() {
		return "/fenlei/addbase";
	}
	
	@ResponseBody
	@RequestMapping("/getFenleiXinXi.do")
	public Msg getFenleiXinXi(int pn) {
		//¿ªÆô·ÖÒ³
		PageHelper.startPage(pn, 5);
		List<FenLei> list = fenLeiService.selectAll();
		PageInfo pageInfo = new PageInfo(list,5);
		return Msg.success().add("pageInfo", pageInfo);
	}
	
	@ResponseBody
	@RequestMapping("/select.do")
	public Msg getselect(FenLei fenlei) {
		System.out.println("---------------------------------->:"+fenlei);
		PageHelper.startPage(1, 5);
		List<FenLei> list = fenLeiService.selectOne(fenlei);
		System.out.println(list.size());
		PageInfo pageInfo = new PageInfo(list,5);
		if(list.size()!=0) {
			return Msg.success().add("pageInfo", pageInfo);
		}else {
			return Msg.file();
		}
	//	PageInfo pageInfo = new PageInfo(list,5);
	//	return Msg.success().add("pageInfo", pageInfo);
	}
	
	//Ìí¼ÓÊý¾Ý
	@ResponseBody
	@RequestMapping("/insert.do")
	public Msg getinsert(FenLei fenlei) {
		System.out.println("---------------------------->:"+fenlei);
		//Ê×ÏÈÒª²éѯÊý¾Ý¿âÖÐÊÇ·ñÒѾ­ÓиıàºÅµÄÊý¾ÝÁË
		int deptId = fenLeiService.selectByKey(fenlei);
	//	System.out.println("++++++++++++++++"+deptest);
		if(deptId!=0) {
			return Msg.idCFfile();
		}
		int deptName = fenLeiService.selectByNameKey(fenlei);
		if(deptName!=0) {
			return Msg.nameCFfile();
		}
		int dept = fenLeiService.insert(fenlei);
		if(dept==1) {
			return Msg.success();
		}else {
			return Msg.file();
		}
	}
	//ÐÞ¸ÄÊý¾Ý
	@ResponseBody
	@RequestMapping("/update.do")
	public Msg getupdate(FenLei fenlei) {
		System.out.println("------------------------->:"+fenlei);
		int dept = fenLeiService.update(fenlei);
		if(dept==1) {
			return Msg.success();
		}else {
			return Msg.file();
		}
	}
	//ɾ³ýÊý¾Ý
	@ResponseBody
	@RequestMapping("/delete.do")
	public Msg getdelete(int sortId) {
		System.out.println("-------------------------->:"+sortId);
		int dept = fenLeiService.delete(sortId);
		if(dept==1) {
			return Msg.success();
		}else {
			return Msg.file();
		}
	}
}

库存控制器

package org.shop.controller;

import java.util.List;

import org.shop.pojo.KuCun;
import org.shop.pojo.YuJin;
import org.shop.service.KuCunService;
import org.shop.service.YuJinService;
import org.shop.utils.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException;
@RequestMapping("/kucun")
@Controller
public class KuCunController {

	@Autowired
	KuCunService kucunService;
	
	@Autowired
	YuJinService yujinService;
	
	@RequestMapping("/main.do")
	public String kucun() {
		return "kucun/main";
	}
	
	@ResponseBody
	@RequestMapping("/selectAll.do")
	public Msg selectAll(int pn) {
		List<YuJin> listYujin = yujinService.selectAll();
		PageHelper.startPage(pn, 5);
		List<KuCun> list = kucunService.selectAll();
		//System.out.println("---------------------->:"+list.size());
		PageInfo pageInfo = new PageInfo(list,5);
	//	List<YuJin> listYujin = yujinService.selectAll();
		return Msg.success().add("pageInfo", pageInfo).add("listYujin", listYujin);
	}
	
	@ResponseBody
	@RequestMapping("/selectOne.do")
	public Msg selectOne(KuCun kucun) {
		System.out.println("---------------------------->:"+kucun);
		PageHelper.startPage(1, 5);
		List<KuCun> list = kucunService.selectOne(kucun);
		PageInfo pageInfo = new PageInfo(list,5);
		return Msg.success().add("pageInfo", pageInfo);
	}
	
	@ResponseBody
	@RequestMapping("/insert.do")
	public Msg insert(KuCun kucun) {
		System.out.println("---------------------------->:"+kucun);
		int deptId = kucunService.selectByKey(kucun);
		if(deptId!=0) {
			return Msg.idCFfile();
		}
		int deptName = kucunService.selectByNameKey(kucun);
		if(deptName!=0) {
			return Msg.nameCFfile();
		}
		int dept = kucunService.insert(kucun);
		if(dept==1) {
			return Msg.success();
		}else {
			return Msg.file();
		}
	}
	
	@ResponseBody
	@RequestMapping("/update.do")
	public Msg update(KuCun kucun) {
		int dept = kucunService.update(kucun);
		if(dept==1) {
			return Msg.success();
		}else {
			return Msg.file();
		}
	}
	
	@ResponseBody
	@RequestMapping("/delete.do")
	public Msg delete(int kucunId) {
		int dept = kucunService.delete(kucunId);
		if(dept==1) {
			return Msg.success();
		}else {
			return Msg.file();
		}
	}
	
	/*@ResponseBody
	@RequestMapping("/ddd")
	public Msg ddd() {
		List<String> list = kucunService.selectAllNamess();
		return Msg.success().add("list", list);
	}*/
	
	@ResponseBody
	@RequestMapping("/selectFenlei.do")
	public Msg selectFenlei(String shopName) {
		List<String> list = kucunService.selectFenlei(shopName);
		return Msg.success().add("list", list);
	}
}

入库控制器

package org.shop.controller;

import java.util.List;

import org.shop.pojo.RuKu;
import org.shop.service.RuKuService;
import org.shop.utils.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Controller
@RequestMapping("/ruku")
public class RuKuController {

	@Autowired
	RuKuService rukuService;
	
	@RequestMapping("/main.do")
	public String main() {
		return "ruku/main";
	}
	
	@ResponseBody
	@RequestMapping("/insert.do")
	public Msg insert(RuKu ruku) {
		
		int deptId = rukuService.selectByIdKey(ruku);
		if(deptId!=0) {
			return Msg.idCFfile();
		}
		int dept = rukuService.insert(ruku);
		if(dept==1) {
			return Msg.success();
		}else {
			return Msg.file();
		}
	}
	
	@ResponseBody
	@RequestMapping("/select.do")
	public Msg select(int pn) {
		PageHelper.startPage(pn, 5);
		List<RuKu> list = rukuService.select();
		PageInfo pageInfo = new PageInfo(list,5);
		return Msg.success().add("pageInfo",pageInfo);
	}
	
	@ResponseBody
	@RequestMapping("/selectByKey.do")
	public Msg selectByKey(RuKu ruku) {
		System.out.println("--------------------->:"+ruku);
		PageHelper.startPage(1, 5);
		List<RuKu> list = rukuService.selectByKey(ruku);
		PageInfo pageInfo = new PageInfo(list,5);
		return Msg.success().add("pageInfo", pageInfo);
	}
}

用户控制器

package org.shop.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.shop.pojo.User;
import org.shop.service.UserService;
import org.shop.utils.Msg;
import org.shop.utils.RandomValidateCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class UserController {

	@Autowired
	UserService userService;
	
	@RequestMapping("/tologin.do")
	public String tologin() {
		return "login";
	}
	
	@ResponseBody
	@RequestMapping("/login.do")
	public Msg login(User user,String yanzen,HttpServletRequest request) {
		/*System.out.println(user);    OK
		System.out.println(yanzen);*/
		Msg msg = new Msg();
		HttpSession session = request.getSession();
		String str = (String)session.getAttribute(RandomValidateCode.RANDOMCODEKEY);
		if(!yanzen.equals(str)) {
			return msg.yanZhenFile();
		}
		int dept = userService.selectLogin(user);
		if(dept==1) {
			session.setAttribute("user", user);
			return msg.success();
		}else {
			return msg.UnPsFile();
		}
	}
	
	@RequestMapping("/index.do")
	public String index() {
		return "index";
	}
	
	@RequestMapping("/top.do")
	public String top() {
		return "fenlei/top";
	}
	
	@RequestMapping("/type.do")
	public String type() {
		return "type";
	}
	
	@RequestMapping("/updatePwd.do")
	public String updatePwd() {
		return "updatePwd";
	}
	
	@RequestMapping("/user.do")
	public String user() {
		return "user";
	}
	
	
	/**
	 * »ñÈ¡Éú³ÉÑéÖ¤ÂëÏÔʾµ½ UI ½çÃæ
	 * @param request
	 * @param response
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/checkCode.do")
	public void checkCode(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
		//ÉèÖÃÏàÓ¦ÀàÐÍ,¸æËßä¯ÀÀÆ÷Êä³öµÄÄÚÈÝΪͼƬ
        response.setContentType("image/jpeg");
        
        //ÉèÖÃÏìӦͷÐÅÏ¢£¬¸æËßä¯ÀÀÆ÷²»Òª»º´æ´ËÄÚÈÝ
        response.setHeader("pragma", "no-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expire", 0);
        
        RandomValidateCode randomValidateCode = new RandomValidateCode();
        try {
            randomValidateCode.getRandcode(request, response);//Êä³öͼƬ·½·¨
            HttpSession session = request.getSession();
            String str = (String)session.getAttribute(RandomValidateCode.RANDOMCODEKEY);
            System.out.println("--------------------------->:"+str);
        } catch (Exception e) {
            e.printStackTrace();
        }
	}
	
	@ResponseBody
	@RequestMapping("/update.do")
	public Msg update(String username,String password) {
		User user = new User();
		user.setUsername(username);
		user.setPassword(password);
		System.out.println("------------------------->:"+user);
		int dept = userService.update(user);
		if(dept==1) {
			return Msg.success();
		}else {
			return Msg.file();
		}
	}
}

如果也想学习本系统,下面领取。回复:183ssm 

  • 0
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 15
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 15
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜未央5788

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值