基于javaweb的SSH医药管理系统药品管理药品库存进销存(java+ssh+mysql+jsp+tomcat)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

212124172208

222124172208

232124172208

242124172208

262124172208

272124172208

282124172208

292124172208

基于javaweb的SSH医药管理系统药品管理药品库存进销存(java+ssh+mysql+jsp+tomcat)

Java医药管理系统源码

源码描述:
一、源码介绍
医药系统的后台管理功能,医药管理,类别管理,购买药物等
二、主要功能
实现了添加药品,查看药品,高级查询,查看库存,添加类别,查看类别,类别统计,购买药品,销售管理,进货需求管理,系统管理。
三、注意事项
开发环境为jdk1.8,数据库为mysql

登录:
admin 123456

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
		throws Exception {
UserDao dao = new UserDao();
List list = dao.findByHQL("from User");
if (list != null) {
request.setAttribute("list", list);
}
return mapping.findForward("findAllSuccess");
}

// 删除用户
public ActionForward userDelete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
UserForm uf = (UserForm) form;
if (uf.getId() > 0) {
//从session之中获取User对象
User u = (User) request.getSession().getAttribute("user");
if (u != null) {
//用户不能删除自身账号
if (uf.getId() != u.getId()) {
UserDao dao = new UserDao();
dao.deleteByHQL("delete from User u where u.id = " + uf.getId());
}else{
//删除自身返回错误信息
ActionMessages errors = new ActionMessages();
errors.add("",new ActionMessage("user.delete.error"));
this.saveErrors(request, errors);
return mapping.findForward("error");
}
}
}
return mapping.findForward("userFind");
}

// 编辑用户
public ActionForward userEdit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

UserForm uf = (UserForm) form;
if (uf.getId() > 0) {
UserDao dao = new UserDao();
User user = dao.loadUser(uf.getId());
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
			// 将文件名称保存到数据库
med.setPhotoPath(fname);
} catch (Exception e) {
e.printStackTrace();
}
}
dao.saveOrUpdate(med);
return mapping.findForward("addSuccess");
}
// 添加药品
public ActionForward update(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// 获取MedicineForm
MedicineForm df = (MedicineForm) form;
MedicineDao dao = new MedicineDao();
// 药品已存在,更新药品数量
Medicine med = dao.loadMedicine(df.getId());
int medCount = med.getMedCount();
med.setMedCount(medCount + df.getMedCount());
return mapping.findForward("addSuccess");
}
// 根据medNo查询药品
public ActionForward findMedicineByMedNo(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
// 获取MedicineForm
MedicineForm df = (MedicineForm) form;
Medicine med = null;
// 查询药品
if (df != null && df.getMedNo() != null) {
MedicineDao dao = new MedicineDao();
med = dao.findMedicineByMedNo(df.getMedNo());
}
// 如果药品存在,更新数量,否则添加新药
if (med != null) {
BeanUtils.copyProperties(df, med);
request.setAttribute("med", "med");
return mapping.findForward("medUpdate");
} else {
CategoryDao cd = new CategoryDao();
List list = cd.findByHQL("from Category");
request.setAttribute("cs", list);
return mapping.findForward("medSave");
}
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
		throws Exception {
ActionForward forword = new ActionForward("/login.jsp", true);
return forword;
}

// 用户退出
public ActionForward userExit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
request.getSession().removeAttribute("user");
return mapping.findForward("login");
}

// 添加用户
public ActionForward userAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
UserForm uf = (UserForm) form;
if (uf != null) {
//密码是否与确认密码相等则添加用户信息
if(uf.getPassword().equals(uf.getRePassword())){
User user = new User(); // 实例化一个User对象
BeanUtils.copyProperties(user, uf); // 对user属性赋值
user.setCreateTime(new Date()); // 对创建时间属性赋值
UserDao dao = new UserDao(); // 实例化UserDao对象
dao.save(user); // 保存user对象
}
}
return mapping.findForward("userFind");
}

// 查找所有用户
public ActionForward userFind(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
UserDao dao = new UserDao();
List list = dao.findByHQL("from User");
if (list != null) {
request.setAttribute("list", list);
}
return mapping.findForward("findAllSuccess");
}

// 删除用户
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// 查看药品详细信息
public ActionForward view(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String id = request.getParameter("id");
Medicine med = null;
// 根据id查询药品信息
if (id != null && !"".equals(id)) {
MedicineDao dao = new MedicineDao();
med = dao.loadMedicineAndCategory(Integer.parseInt(id));
}
request.setAttribute("med", med);
return mapping.findForward("view");
}

// 编辑药品信息
public ActionForward edit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// 获取MedicineForm
MedicineForm df = (MedicineForm) form;
Medicine med = null;
// 根据id查询药品
if (df.getId() > 0) {
MedicineDao dao = new MedicineDao();
med = dao.loadMedicineAndCategory(df.getId());
BeanUtils.copyProperties(df, med);
df.setCategoryId(med.getCategory().getId());
}
// 获取类别信息
CategoryDao categoryDao = new CategoryDao();
List cs = categoryDao.findByHQL("from Category");
request.setAttribute("cs", cs);
return mapping.findForward("medSave");
}

// 多条件查询,分页显示结果
public ActionForward query(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// 获取MedicineForm
MedicineForm df = (MedicineForm) form;
String currPage = request.getParameter("currPage");
// 构造查询Action
String action = request.getContextPath() + "/baseData/med.do?command=query";
//构造HQL语句及分页条件
Map mapQuery = QueryUtil.queryMedicine(df, currPage, action);
String hql = (String) mapQuery.get("hql");
action = (String) mapQuery.get("action");
Object[] where = (Object[]) mapQuery.get("where");
// 分页查询
Map map = this.getPage(hql, recPerPage, currPage, action, where);
//将结果集放到request中
request.setAttribute("list", map.get("list"));
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
	// 销售排行
public ActionForward sequence(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
SellDao dao = new SellDao();
List list = dao.sellSeq();
if (list != null && list.size() > 0) {
request.setAttribute("list", list);
}
return mapping.findForward("sequence");
}

// 根据销售药品id查询销售信息
public ActionForward findByMedId(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String id = request.getParameter("id");
//获取当前页码
String currPage = request.getParameter("currPage");
String action = request.getContextPath()
+ "/sell/sell.do?command=findByMedId";
String hql = "from SellDetail s";
Object[] where = null;
if (id != null && !id.isEmpty()) {
hql += " where s.med.id = ? order by s.sellTime desc";
action += "&id=" + id;
where = new Object[] { Integer.getInteger(id) };
}
//分布查询
Map map = this.getPage(hql, recPerPage, currPage, action, where);
//将结果集放到request中
request.setAttribute("list", map.get("list"));
//将结果集放到分页条中
request.setAttribute("pagingBar", map.get("bar"));
return mapping.findForward("findAllSuccess");
}
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
			if (user != null && uf.getOldPassword().equals(user.getPassword())) {
if (uf.getPassword().equals(uf.getRePassword())) {
UserDao dao = new UserDao();
user.setPassword(uf.getPassword());
dao.saveOrUpdate(user);
}
}else{
//密码错误
ActionMessages errors = new ActionMessages();
errors.add("",new ActionMessage("user.oldpassword.error"));
this.saveErrors(request, errors);
return mapping.findForward("error");
}
}
return mapping.findForward("userFind");
}
//初始化
public ActionForward initialization(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
UserDao dao = new UserDao();
//初始化数据
dao.initialization();
request.getSession().invalidate();
ActionForward forward = new ActionForward("/login.jsp",true);
return forward;
}


}




项目链接:
https://javayms.github.io?id=202124172208201mi
https://javayms.pages.dev?id=202124172208201mi