IDEA+Java+SSM+JSP+Mysql+Tomcat实现Web药品信息管理系统
Posted 水坚石青
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IDEA+Java+SSM+JSP+Mysql+Tomcat实现Web药品信息管理系统相关的知识,希望对你有一定的参考价值。
目录
一、系统介绍
1.开发环境
开发工具:IDEA2018
JDK版本:Jdk1.8
mysql版本:8.0.13
2.技术选型
Java+Jsp+Mysql
3.系统功能
1.登录系统;
2.管理员对人员的增删改查,管理员对进药信息的增删改查,管理员对售药信息的增删改查,管理员对库存信息的管理;
3.销售人员对售药信息的增删改查,对库存信息的管理;
4.仓库人员对进药信息的增删改查,对库存信息的管理;
4.数据库文件
/*
Navicat Premium Data Transfer
Source Server : MySQL
Source Server Type : MySQL
Source Server Version : 80013
Source Host : 127.0.0.1:3306
Source Schema : ssm_medicine_management
Target Server Type : MySQL
Target Server Version : 80013
File Encoding : 65001
Date: 19/02/2022 19:55:57
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for log4
-- ----------------------------
DROP TABLE IF EXISTS `log4`;
CREATE TABLE `log4` (
`date` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`category` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`message` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of log4
-- ----------------------------
-- ----------------------------
-- Table structure for saledrug
-- ----------------------------
DROP TABLE IF EXISTS `saledrug`;
CREATE TABLE `saledrug` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`customer_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`drug_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`sale_number` int(11) NULL DEFAULT NULL,
`date` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`price` double NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of saledrug
-- ----------------------------
INSERT INTO `saledrug` VALUES (7, '1', '1003', 10, '2022-02-19', 20);
INSERT INTO `saledrug` VALUES (8, '2', '1004', 20, '2022-02-19', 10);
-- ----------------------------
-- Table structure for stockdrug
-- ----------------------------
DROP TABLE IF EXISTS `stockdrug`;
CREATE TABLE `stockdrug` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`bill_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`drug_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`price` double NULL DEFAULT NULL,
`buy_num` int(11) NULL DEFAULT NULL,
`date` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`supplier` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 42 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of stockdrug
-- ----------------------------
INSERT INTO `stockdrug` VALUES (42, '2', '1003', 10, 200, '2022-02-19', '北京医药厂');
INSERT INTO `stockdrug` VALUES (43, '1', '1002', 30, 300, '2022-02-19', '武汉医药厂');
INSERT INTO `stockdrug` VALUES (44, '3', '1004', 5, 500, '2022-02-19', '长沙医药厂');
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`usertype` int(11) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 28 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES (1, 'admin', 'admin', 0);
INSERT INTO `user` VALUES (11, 'saler', '123456', 1);
INSERT INTO `user` VALUES (28, 'warehouser', '123456', 2);
-- ----------------------------
-- Table structure for warehouse
-- ----------------------------
DROP TABLE IF EXISTS `warehouse`;
CREATE TABLE `warehouse` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`drug_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`stock_number` int(11) NULL DEFAULT NULL,
`manufacturer` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`standard` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`sale_price` double NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 31 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of warehouse
-- ----------------------------
INSERT INTO `warehouse` VALUES (31, '1003', 190, '北京医药厂', '30粒/瓶', 20);
INSERT INTO `warehouse` VALUES (32, '1002', 300, '武汉医药厂', '30粒/瓶', 50);
INSERT INTO `warehouse` VALUES (33, '1004', 480, '长沙医药厂', '20粒/瓶', 10);
SET FOREIGN_KEY_CHECKS = 1;
二、系统展示
1.登录系统
2.管理员-主页
3.管理员-人员信息管理
4.管理员-进药信息管理
5.管理员-售药信息管理
6.管理员-库存信息管理
7.销售员-主页
8.仓库员-主页
三、部分代码
LoginController
package com.sjsq.controller;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.sjsq.bean.Login;
import com.sjsq.service.LoginService;
@Controller
@RequestMapping("/user")
public class LoginController
@Autowired
private LoginService LoginService;
@RequestMapping("/login")
public String login(HttpServletRequest request, HttpServletResponse response)
Login user = LoginService.findByName(request.getParameter("username"));
if (null == user || "".equals(user))
return "/index";
else
if ((user.getPassword()).equals(request.getParameter("password")))
System.out.println();
Cookie cookie;
try
cookie = new Cookie("username", URLEncoder.encode(
user.getUsername(), "utf-8"));
Cookie cookie1 = new Cookie("usertype", String.valueOf(user
.getUsertype()));
response.addCookie(cookie1);
response.addCookie(cookie);
catch (UnsupportedEncodingException e)
// TODO Auto-generated catch block
e.printStackTrace();
return "/adminList";
else
return "/index";
@RequestMapping("/userList")
public String userList()
return "redirect:/user/queryAll.do";
@RequestMapping("/exitAll")
public String exitAll()
return "/index";
SaledrugController
package com.sjsq.controller;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.sjsq.bean.Saledrug;
import com.sjsq.bean.Warehouse;
import com.sjsq.service.SaledrugService;
import com.sjsq.service.WarehouseService;
@Controller
@RequestMapping("/user")
public class SaledrugController
@Autowired
private SaledrugService saledrugService;
@Autowired
private WarehouseService warehouseService;
@RequestMapping("/querysaledrugAll")
public String querysaledrugAll(HttpServletRequest request)
List<Warehouse> list = saledrugService.querysaledrugAll();
request.setAttribute("saledrugList", list);
return "saledrugList";
@RequestMapping("/presaledrugadd")
public String presaledrugadd()
return "saledrugadd";
@RequestMapping("/saledrugadd")
public String saledrugadd(Saledrug Saledrug, Warehouse warehouse,
HttpServletRequest request)
warehouse.setDrug_id(Saledrug.getDrug_id());
if (warehouseService.queryWarehouseBydrug_id(warehouse) == null)
request.setAttribute("errorMessage", "库存不足");
return "saledrugadd";
else
if (warehouseService.queryWarehouseBydrug_id(warehouse)
.getStock_number() > Saledrug.getSale_number())
saledrugService.saledrugadd(Saledrug);
warehouse.setStock_number(warehouseService
.queryWarehouseBydrug_id(warehouse).getStock_number()
- Saledrug.getSale_number());
warehouseService.updateWarehouseBydrug_id(warehouse);
return "redirect:/user/querysaledrugAll.do";
else
request.setAttribute("errorMessage", "库存不足");
return "saledrugadd";
@RequestMapping("/saledrugdelete")
public String saledrugdelete(Saledrug saledrug, Warehouse warehouse)
warehouse.setDrug_id(saledrugService
.querysaledrugById(saledrug.getId()).getDrug_id());
warehouse.setStock_number(warehouseService.queryWarehouseBydrug_id(
warehouse).getStock_number()
+ saledrugService.querysaledrugById(saledrug.getId())
.getSale_number());
warehouseService.updateWarehouseBydrug_id(warehouse);
saledrugService.saledrugdelete(saledrug.getId());
return "redirect:/user/querysaledrugAll.do";
@RequestMapping("/querysaledrug")
public String querysaledrug(Saledrug saledrug, HttpServletRequest request)
List<Saledrug> list = saledrugService.querysaledrug(saledrug);
request.setAttribute("saledrugList", list);
return "saledrugList";
@RequestMapping("/presaledrugupdate")
public String presaledrugupdate(Saledrug saledrug,
HttpServletRequest request)
List<Saledrug> list = new ArrayList<Saledrug>();
list.add(saledrugService.querysaledrugById(saledrug.getId()));
request.setAttribute("saledrugList", list);
return "saledrugupdate";
@RequestMapping("/saledrugupdate")
public String saledrugupdate(Saledrug saledrug, Warehouse warehouse,
HttpServletRequest request)
if ((saledrug.getDrug_id()).equals(saledrugService.querysaledrugById(
saledrug.getId()).getDrug_id()))
warehouse.setDrug_id(saledrug.getDrug_id());
warehouse.setStock_number(warehouseService.queryWarehouseBydrug_id(
warehouse).getStock_number()
+ saledrugService.querysaledrugById(saledrug.getId())
.getSale_number() - saledrug.getSale_number());
warehouseService.updateWarehouseBydrug_id(warehouse);
saledrugService.saledrugupdate(saledrug);
else
warehouse.setDrug_id(saledrugService.querysaledrugById(
saledrug.getId()).getDrug_id());
warehouse.setStock_number(warehouseService.queryWarehouseBydrug_id(
warehouse).getStock_number()
+ saledrugService.querysaledrugById(saledrug.getId())
.getSale_number());
warehouseService.updateWarehouseBydrug_id(warehouse);
warehouse.setDrug_id(saledrug.getDrug_id());
if (warehouseService.queryWarehouseBydrug_id(warehouse) == null)
request.setAttribute("errorMessage", "库存不足");
return querysaledrugAll(request);
else
if (warehouseService.queryWarehouseBydrug_id(warehouse)
.getStock_number() > saledrug.getSale_number())
warehouse.setStock_number(warehouseService
.queryWarehouseBydrug_id(warehouse)
.getStock_number()
- saledrug.getSale_number());
warehouseService.updateWarehouseBydrug_id(warehouse);
saledrugService.saledrugupdate(saledrug);
else
request.setAttribute("errorMessage", "库存不足");
return querysaledrugAll(request);
return "redirect:/user/querysaledrugAll.do";
public WarehouseService getWarehouseService()
return warehouseService;
public void setWarehouseService(WarehouseService warehouseService)
this.warehouseService = warehouseService;
public SaledrugService getSaledrugService()
return saledrugService;
public void setSaledrugService(SaledrugService saledrugService)
this.saledrugService = saledrugService;
StockdrugController
package com.sjsq.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.sjsq.bean.Stockdrug;
import com.sjsq.bean.Warehouse;
import com.sjsq.service.StockdrugService;
import com.sjsq.service.WarehouseService;
@Controller
@RequestMapping("/user")
public class StockdrugController
@Autowired
private StockdrugService stockdrugService;
@Autowired
private WarehouseService warehouseService;
@RequestMapping("/stockdrugList")
public String stockdrugList(HttpServletRequest request)
return querystockdrugAll(request);
@RequestMapping("/querystockdrugAll")
public String querystockdrugAll(HttpServletRequest request)
List<Stockdrug> list = stockdrugService.querystockdrugAll();
request.setAttribute("stokdrugList", list);
return "stockdrugList";
@RequestMapping("/prestockdrugadd")
public String prestockdrugadd()
return "stockdrugadd";
@RequestMapping("/stockdrugadd")
public String stockdrugadd(Stockdrug stockdrug, Warehouse warehouse)
warehouse.setDrug_id(stockdrug.getDrug_id());
warehouse.setStock_number(stockdrug.getBuy_num());
if (warehouseService.queryWarehouseBydrug_id(warehouse) != null)
warehouse.setStock_number((warehouse.getStock_number()) + ((warehouseService.queryWarehouseBydrug_id(warehouse)).getStock_number()));
warehouseService.updateWarehouseBydrug_id(warehouse);
stockdrugService.addStockdrugBydrug_id(stockdrug);
else
stockdrugService.addStockdrugBydrug_id(stockdrug);
warehouseService.addWarehouseBydrug_id(warehouse);
return "redirect:/user/querystockdrugAll.do";
@RequestMapping("/stockdrugdelete")
public String stockdrugdelete(Stockdrug stockdrug)
stockdrugService.stockdrugdelete(stockdrug.getId());
return "redirect:/user/querystockdrugAll.do";
@RequestMapping("/prestockdrugupdate")
public String prestockdrugupdate(Stockdrug stockdrug, HttpServletRequest request)
List<Stockdrug> list = stockdrugService.stockdrugQueryById(stockdrug.getId());
request.setAttribute("stokdrugList", list);
return "stockdrugupdate";
@RequestMapping("/stockdrugupdate")
public String stockdrugupdate(Stockdrug stockdrug, Warehouse warehouse)
String temp = "";
int te = 0;
List<Stockdrug> list = stockdrugService.stockdrugQueryById(stockdrug.getId());
for (Stockdrug stockdrug2 : list)
temp = stockdrug2.getDrug_id();
te = stockdrug2.getBuy_num();
if ((stockdrug.getDrug_id()).equals(temp))
warehouse.setDrug_id(stockdrug.getDrug_id());
int a = warehouseService.queryWarehouseBydrug_id(warehouse).getStock_number();
a = a - te + stockdrug.getBuy_num();
warehouse.setStock_number(a);
warehouseService.updateWarehouseBydrug_id(warehouse);
else
warehouse.setDrug_id(temp);
int a = warehouseService.queryWarehouseBydrug_id(warehouse).getStock_number();
warehouse.setStock_number(a - te);
warehouseService.updateWarehouseBydrug_id(warehouse);
warehouse.setDrug_id(stockdrug.getDrug_id());
if (warehouseService.queryWarehouseBydrug_id(warehouse) != null)
warehouse.setStock_number(warehouseService.queryWarehouseBydrug_id(warehouse).getStock_number() + stockdrug.getBuy_num());
warehouseService.updateWarehouseBydrug_id(warehouse);
else
warehouse.setStock_number(stockdrug.getBuy_num());
warehouseService.addWarehouseBydrug_id(warehouse);
stockdrugService.stockdrugupdate(stockdrug);
return "redirect:/user/querystockdrugAll.do";
@RequestMapping("/querystockdrug")
public String querystockdrug(Stockdrug stockdrug, HttpServletRequest request)
List<Stockdrug> list = stockdrugService.querystockdrug(stockdrug);
request.setAttribute("stokdrugList", list);
return "stockdrugList";
UserController
package com.sjsq.controller;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.sjsq.bean.User;
import com.sjsq.service.UserService;
@Controller
@RequestMapping("/user")
public class UserController
@Autowired
private UserService userService;
@RequestMapping("/queryAll")
public String queryAll(HttpServletRequest request)
List<User> list = userService.queryAll();
request.setAttribute("userList", list);
return "userList";
@RequestMapping("/preadd")
public String preadd()
return "useradd";
@RequestMapping("/add")
public String add(User user, HttpServletRequest request)
if (userService.queryByName(user.getUsername()) == null)
userService.add(user);
else
request.setAttribute("errorMessage", "用户已存在");
return queryAll(request);
@RequestMapping("/delete")
public String delete(User user)
userService.delete(user.getId());
return "redirect:/user/queryAll.do";
@RequestMapping("/preupdate")
public String update(User user, HttpServletRequest request)
user = userService.queryById(user.getId());
List<User> list = new ArrayList<User>();
list.add(user);
request.setAttribute("userList", list);
return "userupdate";
@RequestMapping("/update")
public String update(User user)
userService.update(user);
return "redirect:/user/queryAll.do";
@RequestMapping("/queryByUsernameUserType")
public String queryByUsernameUserType(User user, HttpServletRequest request)
List<User> list = userService.queryByUsernameUserType(user);
request.setAttribute("userList", list);
return "userList";
public UserService getUserService()
return userService;
public void setUserService(UserService userService)
this.userService = userService;
WarehouseController
package com.sjsq.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.sjsq.bean.Warehouse;
import com.sjsq.service.WarehouseService;
@Controller
@RequestMapping("/user")
public class WarehouseController
@Autowired
private WarehouseService warehouseService;
public WarehouseService getWarehouseService()
return warehouseService;
public void setWarehouseService(WarehouseService warehouseService)
this.warehouseService = warehouseService;
@RequestMapping("/querywarehouseAll")
public String querywarehouseAll(HttpServletRequest request)
List<Warehouse> list = warehouseService.querywarehouseAll();
request.setAttribute("warehoustList", list);
return "warehouseList";
@RequestMapping("/querywarehouse")
public String querywarehouse(Warehouse warehouse, HttpServletRequest request)
List<Warehouse> list = warehouseService.querywarehouse(warehouse);
request.setAttribute("warehoustList", list);
return "warehouseList";
@RequestMapping("/prewarehouseupdate")
public String prewarehouseupdate(Warehouse warehouse, HttpServletRequest request)
List<Warehouse> list = warehouseService.queryWarehouseById(warehouse.getId());
request.setAttribute("warehoustList", list);
return "warehouseupdate";
@RequestMapping("/warehouseupdate")
public String warehouseupdate(Warehouse warehouse)
warehouseService.updateWarehouseById(warehouse);
return "redirect:/user/querywarehouseAll.do";
四、其他
1.更多系统
Java+JSP系统系列实现
Java+Servlet系统系列实现
Java+SSM系统系列实现
Java+SSH系统系列实现
Java+Springboot系统系列实现
Java+Springboot+H-ui+Maven实现营销管理系统
Java+Springboot+Bootstrap+Maven实现网上商城系统
Java+Springboot+Bootstrap+Maven实现景区旅游管理系统
1.更多JavaWeb系统请关注专栏。
https://blog.csdn.net/helongqiang/category_10020130.htmlhttps://blog.csdn.net/helongqiang/category_10020130.html
2.更多JavaSwing系统请关注专栏。
2.源码下载
sql在sql文件夹下面
3.运行项目
4.备注
如有侵权请联系我删除。
5.支持博主
如果您觉得此文对您有帮助,请点赞加关注加收藏。祝您生活愉快!想要获取其他资源可关注左侧微信公众号获取!
以上是关于IDEA+Java+SSM+JSP+Mysql+Tomcat实现Web药品信息管理系统的主要内容,如果未能解决你的问题,请参考以下文章
IDEA+Java+SSM+JSP+Mysql实现Web图书管理系统
IDEA+Java+SSM+Mysql+JSP实现Web宠物商城系统
IDEA+Java+SSM+JSP+Mysql+Tomcat实现Web药品信息管理系统