• 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

    运行截图

     

     

     

     

      

    相关代码

    出库控制器

    1. package org.shop.controller;
    2. import java.util.HashMap;
    3. import java.util.List;
    4. import java.util.Map;
    5. import org.shop.pojo.ChuKu;
    6. import org.shop.pojo.KuCun;
    7. import org.shop.service.ChuKuService;
    8. import org.shop.utils.Msg;
    9. import org.springframework.beans.factory.annotation.Autowired;
    10. import org.springframework.stereotype.Controller;
    11. import org.springframework.web.bind.annotation.RequestMapping;
    12. import org.springframework.web.bind.annotation.ResponseBody;
    13. import com.github.pagehelper.PageHelper;
    14. import com.github.pagehelper.PageInfo;
    15. @Controller
    16. @RequestMapping("/chuku")
    17. public class ChuKuController {
    18. @Autowired
    19. ChuKuService chukuService;
    20. @RequestMapping("/main.do")
    21. public String main() {
    22. return "/chuku/main";
    23. }
    24. //²é³öµ±Ç°¿â´æÊýÁ¿
    25. @ResponseBody
    26. @RequestMapping("/selectByName.do")
    27. public Msg selectByName(String shopName) {
    28. System.out.println("----------------------->:"+shopName);
    29. KuCun kucun = chukuService.selectByName(shopName);
    30. String fenlei = kucun.getShopFenlei();
    31. String shuliang = kucun.getShopShuliang()+"";
    32. System.out.println("----------------------->:"+fenlei+"||"+shuliang);
    33. Map map = new HashMap();
    34. map.put("fenlei", fenlei);
    35. map.put("shuliang", shuliang);
    36. return Msg.success().add("map", map);
    37. }
    38. @ResponseBody
    39. @RequestMapping("/insert.do")
    40. public Msg insert(ChuKu chuku) {
    41. System.out.println(chuku);
    42. int deptId = chukuService.selectByIdKey(chuku);
    43. if(deptId!=0) {
    44. return Msg.idCFfile();
    45. }
    46. int i = chukuService.insert(chuku);
    47. if(i==1) {
    48. return Msg.success();
    49. }else {
    50. return Msg.file();
    51. }
    52. }
    53. @ResponseBody
    54. @RequestMapping("/select.do")
    55. public Msg select(int pn) {
    56. PageHelper.startPage(pn, 5);
    57. List list = chukuService.select();
    58. PageInfo pageInfo = new PageInfo(list,5);
    59. return Msg.success().add("pageInfo", pageInfo);
    60. }
    61. @ResponseBody
    62. @RequestMapping("/selectOne.do")
    63. public Msg selectOne(ChuKu chuku) {
    64. System.out.println("----------------->:"+chuku);
    65. PageHelper.startPage(1, 5);
    66. List list = chukuService.selectOne(chuku);
    67. PageInfo pageInfo = new PageInfo(list,5);
    68. return Msg.success().add("pageInfo", pageInfo);
    69. }
    70. }

    分类控制器

    1. package org.shop.controller;
    2. import java.util.List;
    3. import org.shop.pojo.FenLei;
    4. import org.shop.service.FenLeiService;
    5. import org.shop.utils.Msg;
    6. import org.springframework.beans.factory.annotation.Autowired;
    7. import org.springframework.stereotype.Controller;
    8. import org.springframework.web.bind.annotation.RequestMapping;
    9. import org.springframework.web.bind.annotation.ResponseBody;
    10. import com.github.pagehelper.PageHelper;
    11. import com.github.pagehelper.PageInfo;
    12. @Controller
    13. @RequestMapping("/fenlei")
    14. public class FenLeiController {
    15. @Autowired
    16. FenLeiService fenLeiService;
    17. @RequestMapping("/top.do")
    18. public String top() {
    19. return "/fenlei/top";
    20. }
    21. @RequestMapping("/base.do")
    22. public String base() {
    23. return "/fenlei/base";
    24. }
    25. @RequestMapping("/seebase.do")
    26. public String seebase() {
    27. return "/fenlei/seebase";
    28. }
    29. @RequestMapping("/addbase.do")
    30. public String addbase() {
    31. return "/fenlei/addbase";
    32. }
    33. @ResponseBody
    34. @RequestMapping("/getFenleiXinXi.do")
    35. public Msg getFenleiXinXi(int pn) {
    36. //¿ªÆô·ÖÒ³
    37. PageHelper.startPage(pn, 5);
    38. List list = fenLeiService.selectAll();
    39. PageInfo pageInfo = new PageInfo(list,5);
    40. return Msg.success().add("pageInfo", pageInfo);
    41. }
    42. @ResponseBody
    43. @RequestMapping("/select.do")
    44. public Msg getselect(FenLei fenlei) {
    45. System.out.println("---------------------------------->:"+fenlei);
    46. PageHelper.startPage(1, 5);
    47. List list = fenLeiService.selectOne(fenlei);
    48. System.out.println(list.size());
    49. PageInfo pageInfo = new PageInfo(list,5);
    50. if(list.size()!=0) {
    51. return Msg.success().add("pageInfo", pageInfo);
    52. }else {
    53. return Msg.file();
    54. }
    55. // PageInfo pageInfo = new PageInfo(list,5);
    56. // return Msg.success().add("pageInfo", pageInfo);
    57. }
    58. //Ìí¼ÓÊý¾Ý
    59. @ResponseBody
    60. @RequestMapping("/insert.do")
    61. public Msg getinsert(FenLei fenlei) {
    62. System.out.println("---------------------------->:"+fenlei);
    63. //Ê×ÏÈÒª²éѯÊý¾Ý¿âÖÐÊÇ·ñÒѾ­ÓиıàºÅµÄÊý¾ÝÁË
    64. int deptId = fenLeiService.selectByKey(fenlei);
    65. // System.out.println("++++++++++++++++"+deptest);
    66. if(deptId!=0) {
    67. return Msg.idCFfile();
    68. }
    69. int deptName = fenLeiService.selectByNameKey(fenlei);
    70. if(deptName!=0) {
    71. return Msg.nameCFfile();
    72. }
    73. int dept = fenLeiService.insert(fenlei);
    74. if(dept==1) {
    75. return Msg.success();
    76. }else {
    77. return Msg.file();
    78. }
    79. }
    80. //ÐÞ¸ÄÊý¾Ý
    81. @ResponseBody
    82. @RequestMapping("/update.do")
    83. public Msg getupdate(FenLei fenlei) {
    84. System.out.println("------------------------->:"+fenlei);
    85. int dept = fenLeiService.update(fenlei);
    86. if(dept==1) {
    87. return Msg.success();
    88. }else {
    89. return Msg.file();
    90. }
    91. }
    92. //ɾ³ýÊý¾Ý
    93. @ResponseBody
    94. @RequestMapping("/delete.do")
    95. public Msg getdelete(int sortId) {
    96. System.out.println("-------------------------->:"+sortId);
    97. int dept = fenLeiService.delete(sortId);
    98. if(dept==1) {
    99. return Msg.success();
    100. }else {
    101. return Msg.file();
    102. }
    103. }
    104. }

    库存控制器

    1. package org.shop.controller;
    2. import java.util.List;
    3. import org.shop.pojo.KuCun;
    4. import org.shop.pojo.YuJin;
    5. import org.shop.service.KuCunService;
    6. import org.shop.service.YuJinService;
    7. import org.shop.utils.Msg;
    8. import org.springframework.beans.factory.annotation.Autowired;
    9. import org.springframework.stereotype.Controller;
    10. import org.springframework.web.bind.annotation.RequestMapping;
    11. import org.springframework.web.bind.annotation.ResponseBody;
    12. import com.github.pagehelper.PageHelper;
    13. import com.github.pagehelper.PageInfo;
    14. import com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException;
    15. @RequestMapping("/kucun")
    16. @Controller
    17. public class KuCunController {
    18. @Autowired
    19. KuCunService kucunService;
    20. @Autowired
    21. YuJinService yujinService;
    22. @RequestMapping("/main.do")
    23. public String kucun() {
    24. return "kucun/main";
    25. }
    26. @ResponseBody
    27. @RequestMapping("/selectAll.do")
    28. public Msg selectAll(int pn) {
    29. List listYujin = yujinService.selectAll();
    30. PageHelper.startPage(pn, 5);
    31. List list = kucunService.selectAll();
    32. //System.out.println("---------------------->:"+list.size());
    33. PageInfo pageInfo = new PageInfo(list,5);
    34. // List listYujin = yujinService.selectAll();
    35. return Msg.success().add("pageInfo", pageInfo).add("listYujin", listYujin);
    36. }
    37. @ResponseBody
    38. @RequestMapping("/selectOne.do")
    39. public Msg selectOne(KuCun kucun) {
    40. System.out.println("---------------------------->:"+kucun);
    41. PageHelper.startPage(1, 5);
    42. List list = kucunService.selectOne(kucun);
    43. PageInfo pageInfo = new PageInfo(list,5);
    44. return Msg.success().add("pageInfo", pageInfo);
    45. }
    46. @ResponseBody
    47. @RequestMapping("/insert.do")
    48. public Msg insert(KuCun kucun) {
    49. System.out.println("---------------------------->:"+kucun);
    50. int deptId = kucunService.selectByKey(kucun);
    51. if(deptId!=0) {
    52. return Msg.idCFfile();
    53. }
    54. int deptName = kucunService.selectByNameKey(kucun);
    55. if(deptName!=0) {
    56. return Msg.nameCFfile();
    57. }
    58. int dept = kucunService.insert(kucun);
    59. if(dept==1) {
    60. return Msg.success();
    61. }else {
    62. return Msg.file();
    63. }
    64. }
    65. @ResponseBody
    66. @RequestMapping("/update.do")
    67. public Msg update(KuCun kucun) {
    68. int dept = kucunService.update(kucun);
    69. if(dept==1) {
    70. return Msg.success();
    71. }else {
    72. return Msg.file();
    73. }
    74. }
    75. @ResponseBody
    76. @RequestMapping("/delete.do")
    77. public Msg delete(int kucunId) {
    78. int dept = kucunService.delete(kucunId);
    79. if(dept==1) {
    80. return Msg.success();
    81. }else {
    82. return Msg.file();
    83. }
    84. }
    85. /*@ResponseBody
    86. @RequestMapping("/ddd")
    87. public Msg ddd() {
    88. List list = kucunService.selectAllNamess();
    89. return Msg.success().add("list", list);
    90. }*/
    91. @ResponseBody
    92. @RequestMapping("/selectFenlei.do")
    93. public Msg selectFenlei(String shopName) {
    94. List list = kucunService.selectFenlei(shopName);
    95. return Msg.success().add("list", list);
    96. }
    97. }

    入库控制器

    1. package org.shop.controller;
    2. import java.util.List;
    3. import org.shop.pojo.RuKu;
    4. import org.shop.service.RuKuService;
    5. import org.shop.utils.Msg;
    6. import org.springframework.beans.factory.annotation.Autowired;
    7. import org.springframework.stereotype.Controller;
    8. import org.springframework.web.bind.annotation.RequestMapping;
    9. import org.springframework.web.bind.annotation.ResponseBody;
    10. import com.github.pagehelper.PageHelper;
    11. import com.github.pagehelper.PageInfo;
    12. @Controller
    13. @RequestMapping("/ruku")
    14. public class RuKuController {
    15. @Autowired
    16. RuKuService rukuService;
    17. @RequestMapping("/main.do")
    18. public String main() {
    19. return "ruku/main";
    20. }
    21. @ResponseBody
    22. @RequestMapping("/insert.do")
    23. public Msg insert(RuKu ruku) {
    24. int deptId = rukuService.selectByIdKey(ruku);
    25. if(deptId!=0) {
    26. return Msg.idCFfile();
    27. }
    28. int dept = rukuService.insert(ruku);
    29. if(dept==1) {
    30. return Msg.success();
    31. }else {
    32. return Msg.file();
    33. }
    34. }
    35. @ResponseBody
    36. @RequestMapping("/select.do")
    37. public Msg select(int pn) {
    38. PageHelper.startPage(pn, 5);
    39. List list = rukuService.select();
    40. PageInfo pageInfo = new PageInfo(list,5);
    41. return Msg.success().add("pageInfo",pageInfo);
    42. }
    43. @ResponseBody
    44. @RequestMapping("/selectByKey.do")
    45. public Msg selectByKey(RuKu ruku) {
    46. System.out.println("--------------------->:"+ruku);
    47. PageHelper.startPage(1, 5);
    48. List list = rukuService.selectByKey(ruku);
    49. PageInfo pageInfo = new PageInfo(list,5);
    50. return Msg.success().add("pageInfo", pageInfo);
    51. }
    52. }

    用户控制器

    1. package org.shop.controller;
    2. import java.io.IOException;
    3. import javax.servlet.ServletException;
    4. import javax.servlet.http.HttpServletRequest;
    5. import javax.servlet.http.HttpServletResponse;
    6. import javax.servlet.http.HttpSession;
    7. import org.shop.pojo.User;
    8. import org.shop.service.UserService;
    9. import org.shop.utils.Msg;
    10. import org.shop.utils.RandomValidateCode;
    11. import org.springframework.beans.factory.annotation.Autowired;
    12. import org.springframework.stereotype.Controller;
    13. import org.springframework.web.bind.annotation.RequestMapping;
    14. import org.springframework.web.bind.annotation.ResponseBody;
    15. @Controller
    16. public class UserController {
    17. @Autowired
    18. UserService userService;
    19. @RequestMapping("/tologin.do")
    20. public String tologin() {
    21. return "login";
    22. }
    23. @ResponseBody
    24. @RequestMapping("/login.do")
    25. public Msg login(User user,String yanzen,HttpServletRequest request) {
    26. /*System.out.println(user); OK
    27. System.out.println(yanzen);*/
    28. Msg msg = new Msg();
    29. HttpSession session = request.getSession();
    30. String str = (String)session.getAttribute(RandomValidateCode.RANDOMCODEKEY);
    31. if(!yanzen.equals(str)) {
    32. return msg.yanZhenFile();
    33. }
    34. int dept = userService.selectLogin(user);
    35. if(dept==1) {
    36. session.setAttribute("user", user);
    37. return msg.success();
    38. }else {
    39. return msg.UnPsFile();
    40. }
    41. }
    42. @RequestMapping("/index.do")
    43. public String index() {
    44. return "index";
    45. }
    46. @RequestMapping("/top.do")
    47. public String top() {
    48. return "fenlei/top";
    49. }
    50. @RequestMapping("/type.do")
    51. public String type() {
    52. return "type";
    53. }
    54. @RequestMapping("/updatePwd.do")
    55. public String updatePwd() {
    56. return "updatePwd";
    57. }
    58. @RequestMapping("/user.do")
    59. public String user() {
    60. return "user";
    61. }
    62. /**
    63. * »ñÈ¡Éú³ÉÑéÖ¤ÂëÏÔʾµ½ UI ½çÃæ
    64. * @param request
    65. * @param response
    66. * @throws ServletException
    67. * @throws IOException
    68. */
    69. @RequestMapping(value="/checkCode.do")
    70. public void checkCode(HttpServletRequest request, HttpServletResponse response)
    71. throws ServletException, IOException {
    72. //ÉèÖÃÏàÓ¦ÀàÐÍ,¸æËßä¯ÀÀÆ÷Êä³öµÄÄÚÈÝΪͼƬ
    73. response.setContentType("image/jpeg");
    74. //ÉèÖÃÏìӦͷÐÅÏ¢£¬¸æËßä¯ÀÀÆ÷²»Òª»º´æ´ËÄÚÈÝ
    75. response.setHeader("pragma", "no-cache");
    76. response.setHeader("Cache-Control", "no-cache");
    77. response.setDateHeader("Expire", 0);
    78. RandomValidateCode randomValidateCode = new RandomValidateCode();
    79. try {
    80. randomValidateCode.getRandcode(request, response);//Êä³öͼƬ·½·¨
    81. HttpSession session = request.getSession();
    82. String str = (String)session.getAttribute(RandomValidateCode.RANDOMCODEKEY);
    83. System.out.println("--------------------------->:"+str);
    84. } catch (Exception e) {
    85. e.printStackTrace();
    86. }
    87. }
    88. @ResponseBody
    89. @RequestMapping("/update.do")
    90. public Msg update(String username,String password) {
    91. User user = new User();
    92. user.setUsername(username);
    93. user.setPassword(password);
    94. System.out.println("------------------------->:"+user);
    95. int dept = userService.update(user);
    96. if(dept==1) {
    97. return Msg.success();
    98. }else {
    99. return Msg.file();
    100. }
    101. }
    102. }

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

  • 相关阅读:
    【PostgreSQL17新特性之-explain命令新增选项】
    C#中DataGridView设置行高
    Java的三个接口Comparable,Comparator,Cloneable(浅拷贝与深拷贝)
    格物云设备接入-MQTT方式
    关于HBuilder X鼠标变为_ 替换字符的问题
    电脑重装系统u盘文件被隐藏要怎么找出来
    【YOLO系列】YOLO.v2算法原理详解
    sql:SQL优化知识点记录(九)
    前端的规范
    错误监控——sentry源码
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/126397838