作者主页:夜未央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/8.0版本均可;
6.是否Maven项目:是;
技术栈
1. 后端:Spring+SpringMVC+Mbytes
2. 前端:JSP+css+javascript+bootstrap+jQuery
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入localhost:8080/ssm_yaofangsys/
医生账号/密码: doctor/123456
药房人员账号/密码:yaofang/123456
管理员账号/密码:admin/admin
运行截图
管理员角色
医生角色
药房人员管理
相关代码
CmsOrderController
package com.kewen.cms.controller;
import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import com.alibaba.fastjson.JSONObject;
import com.kewen.cms.base.BaseController;
import com.kewen.cms.po.*;
import com.kewen.cms.utils.Pager;
import java.util.*;
import com.kewen.cms.po.*;
import com.kewen.cms.mapper.*;
import com.kewen.cms.service.*;
/**
* @ClassName:
* @Description:
* @author - - admin
* @date - 2021年07月16日 13时19分16秒
*/
@Controller
@RequestMapping("/cmsOrder")
public class CmsOrderController extends BaseController {
/**
* 依赖注入 start dao/service/===
*/
@Autowired
private CmsOrderService cmsOrderService;
@RequestMapping(value = "/findBySql")
public String findBySql(CmsOrder cmsOrder, Model model, HttpServletRequest request, HttpServletResponse response) {
//分页查询
String sql = "SELECT * FROM cms_order WHERE 1=1 ";//and isDelete = 0
if(!isEmpty(cmsOrder.getCode())){
sql += " and code like '%"+cmsOrder.getCode()+"%'";
}
if(!isEmpty(cmsOrder.getName())){
sql += " and name like '%"+cmsOrder.getName()+"%'";
}
if(!isEmpty(cmsOrder.getNum())){
sql += " and num like '%"+cmsOrder.getNum()+"%'";
}
sql += " ORDER BY ID DESC ";
Pager<CmsOrder> pagers = cmsOrderService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers", pagers);
//存储查询条件
model.addAttribute("obj", cmsOrder);
return "cmsOrder/cmsOrder";
}
/**
* 跳至添加页面
* @return
*/
@RequestMapping(value = "/add")
public String add() {
return "cmsOrder/add";
}
/**
* 添加执行
* @return
*/
@RequestMapping(value = "/exAdd")
public String exAdd(CmsOrder cmsOrder, Model model, HttpServletRequest request, HttpServletResponse response) {
cmsOrderService.insert(cmsOrder);
return "redirect:/cmsOrder/findBySql";
}
/**
* 跳至修改页面
* @return
*/
@RequestMapping(value = "/update")
public String update(Integer id,Model model) {
CmsOrder obj = cmsOrderService.load(id);
model.addAttribute("obj",obj);
return "cmsOrder/update";
}
/**
* 添加修改
* @return
*/
@RequestMapping(value = "/exUpdate")
public String exUpdate(CmsOrder cmsOrder, Model model, HttpServletRequest request, HttpServletResponse response) {
//1.通过实体类修改,可以多传修改条件
//2.通过主键id修改
cmsOrderService.updateById(cmsOrder);
return "redirect:/cmsOrder/findBySql";
}
/**
* 删除通过主键
* @return
*/
@RequestMapping(value = "/delete")
public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
cmsOrderService.deleteById(id);
return "redirect:/cmsOrder/findBySql";
}
}
DoctorController
package com.kewen.cms.controller;
import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import com.alibaba.fastjson.JSONObject;
import com.kewen.cms.base.BaseController;
import com.kewen.cms.po.*;
import com.kewen.cms.utils.Pager;
import java.util.*;
import com.kewen.cms.po.*;
import com.kewen.cms.mapper.*;
import com.kewen.cms.service.*;
/**
* @ClassName:
* @Description:
* @author - - admin
* @date - 2021年07月16日 13时19分17秒
*/
@Controller
@RequestMapping("/doctor")
public class DoctorController extends BaseController {
/**
* 依赖注入 start dao/service/===
*/
@Autowired
private DoctorService doctorService;
@RequestMapping(value = "/findBySql")
public String findBySql(Doctor doctor, Model model, HttpServletRequest request, HttpServletResponse response) {
//分页查询
String sql = "SELECT * FROM doctor WHERE 1=1 and isDelete = 0 ";//and isDelete = 0
if(!isEmpty(doctor.getUserName())){
sql += " and userName like '%"+doctor.getUserName()+"%'";
}
if(!isEmpty(doctor.getPassword())){
sql += " and password like '%"+doctor.getPassword()+"%'";
}
if(!isEmpty(doctor.getRealName())){
sql += " and realName like '%"+doctor.getRealName()+"%'";
}
if(!isEmpty(doctor.getIdCard())){
sql += " and idCard like '%"+doctor.getIdCard()+"%'";
}
if(!isEmpty(doctor.getPhone())){
sql += " and phone like '%"+doctor.getPhone()+"%'";
}
if(!isEmpty(doctor.getSex())){
sql += " and sex like '%"+doctor.getSex()+"%'";
}
if(!isEmpty(doctor.getIsDelete())){
sql += " and isDelete like '%"+doctor.getIsDelete()+"%'";
}
sql += " ORDER BY ID DESC ";
Pager<Doctor> pagers = doctorService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers", pagers);
//存储查询条件
model.addAttribute("obj", doctor);
return "doctor/doctor";
}
/**
* 跳至添加页面
* @return
*/
@RequestMapping(value = "/add")
public String add() {
return "doctor/add";
}
/**
* 添加执行
* @return
*/
@RequestMapping(value = "/exAdd")
public String exAdd(Doctor doctor, Model model, HttpServletRequest request, HttpServletResponse response) {
doctor.setIsDelete(0);
doctorService.insert(doctor);
return "redirect:/doctor/findBySql";
}
/**
* 跳至修改页面
* @return
*/
@RequestMapping(value = "/update")
public String update(Integer id,Model model) {
Doctor obj = doctorService.load(id);
model.addAttribute("obj",obj);
return "doctor/update";
}
/**
* 添加修改
* @return
*/
@RequestMapping(value = "/exUpdate")
public String exUpdate(Doctor doctor, Model model, HttpServletRequest request, HttpServletResponse response) {
//1.通过实体类修改,可以多传修改条件
doctorService.updateById(doctor);
//2.通过主键id修改
//doctorService.updateById(doctor);
return "redirect:/doctor/findBySql";
}
/**
* 删除通过主键
* @return
*/
@RequestMapping(value = "/delete")
public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
Doctor load = doctorService.load(id);
load.setIsDelete(1);
doctorService.update(load);
doctorService.updateById(load);
return "redirect:/doctor/findBySql";
}
}
登录控制器
package com.kewen.cms.controller;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
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.JSONObject;
import com.kewen.cms.base.BaseController;
import com.kewen.cms.po.Doctor;
import com.kewen.cms.po.Manage;
import com.kewen.cms.po.MedicineUser;
import com.kewen.cms.service.DoctorService;
import com.kewen.cms.service.ManageService;
import com.kewen.cms.service.MedicineUserService;
@Controller
@RequestMapping("/login")
public class LoginController extends BaseController{
@Autowired
private ManageService manageService;
@Autowired
private MedicineUserService medicineUserService;
@Autowired
private DoctorService doctorService;
/**
* 跳转登陆
* @return
*/
@RequestMapping("/login")
public String login(){
return "login/mLogin";
}
@RequestMapping("/index")
public String index(){
return "login/mIndex";
}
@RequestMapping("/uIndex")
public String uIndex(Model model){
return "login/uIndex";
}
@RequestMapping("/welcome")
public String welcome(){
return "login/welcome";
}
@RequestMapping("/mup")
public String mpass(){
return "login/mup";
}
/**
* 管理员登陆
* @param manage
* @param request
* @param response
* @return
*/
@RequestMapping("/toLogin")
public String toLogin(Manage manage,Integer role, HttpServletRequest request, HttpServletResponse response){
if (role == null){
return "redirect:/login/login.action";
}
//超级管理员
if (role== 1){
Manage byEntity = manageService.getByEntity(manage);
if(byEntity != null){
request.getSession().setAttribute("role", role);
request.getSession().setAttribute("name", byEntity.getRealName());
return "redirect:/login/index.action";
}else{
return "redirect:/login/login.action";
}
}
//1 超级管理员2 医生 3 药房人员
if (role== 2){
Doctor d = new Doctor();
d.setPassword(manage.getPassword());
d.setUserName(manage.getUserName());
Doctor byEntity = doctorService.getByEntity(d);
if(byEntity != null){
request.getSession().setAttribute("role", role);
request.getSession().setAttribute("name", byEntity.getRealName());
request.getSession().setAttribute("userId", byEntity.getId());
return "redirect:/login/index.action";
}else{
return "redirect:/login/login.action";
}
}
//药房人员
if (role== 3){
MedicineUser d = new MedicineUser();
d.setPassword(manage.getPassword());
d.setUserName(manage.getUserName());
MedicineUser byEntity = medicineUserService.getByEntity(d);
if(byEntity != null){
request.getSession().setAttribute("role", role);
request.getSession().setAttribute("name", byEntity.getRealName());
request.getSession().setAttribute("userId", byEntity.getId());
return "redirect:/login/index.action";
}else{
return "redirect:/login/login.action";
}
}
return null;
}
/**
* 退出
* @param request
* @param response
* @return
*/
@RequestMapping("/tuichu")
public String tuichu( HttpServletRequest request, HttpServletResponse response){
HttpSession session = request.getSession();
session.invalidate();
return "redirect:/login/login.action";
}
@RequestMapping("/uTui")
public String uTui( HttpServletRequest request, HttpServletResponse response){
HttpSession session = request.getSession();
session.invalidate();
return "redirect:/login/uLogin.action";
}
@RequestMapping("/head")
private String head(){
return "inc/head";
}
@RequestMapping("/left")
private String left(){
return "inc/left";
}
}
管理控制器
package com.kewen.cms.controller;
import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import com.alibaba.fastjson.JSONObject;
import com.kewen.cms.base.BaseController;
import com.kewen.cms.po.*;
import com.kewen.cms.utils.Pager;
import java.util.*;
import com.kewen.cms.po.*;
import com.kewen.cms.mapper.*;
import com.kewen.cms.service.*;
/**
* @ClassName:
* @Description:
* @author - - admin
* @date - 2021年07月16日 13时19分17秒
*/
@Controller
@RequestMapping("/manage")
public class ManageController extends BaseController {
/**
* 依赖注入 start dao/service/===
*/
@Autowired
private ManageService manageService;
}
药品管理控制器
package com.kewen.cms.controller;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import com.alibaba.fastjson.JSONObject;
import com.kewen.cms.base.BaseController;
import com.kewen.cms.po.*;
import com.kewen.cms.utils.Pager;
import java.util.*;
import com.kewen.cms.po.*;
import com.kewen.cms.mapper.*;
import com.kewen.cms.service.*;
/**
* @ClassName:
* @Description:
* @author - - admin
* @date - 2021年07月16日 13时19分17秒
*/
@Controller
@RequestMapping("/medicinalMaterials")
public class MedicinalMaterialsController extends BaseController {
/**
* 依赖注入 start dao/service/===
*/
@Autowired
private MedicinalMaterialsService medicinalMaterialsService;
@RequestMapping(value = "/findBySql")
public String findBySql(MedicinalMaterials medicinalMaterials, Model model, HttpServletRequest request, HttpServletResponse response) {
//分页查询
String sql = "SELECT * FROM medicinal_materials WHERE 1=1 and isDelete = 0 ";//
if(!isEmpty(medicinalMaterials.getCode())){
sql += " and code like '%"+medicinalMaterials.getCode()+"%'";
}
if(!isEmpty(medicinalMaterials.getName())){
sql += " and name like '%"+medicinalMaterials.getName()+"%'";
}
if(!isEmpty(medicinalMaterials.getType())){
sql += " and type like '%"+medicinalMaterials.getType()+"%'";
}
if(!isEmpty(medicinalMaterials.getTaste())){
sql += " and taste like '%"+medicinalMaterials.getTaste()+"%'";
}
if(!isEmpty(medicinalMaterials.getEffect())){
sql += " and effect like '%"+medicinalMaterials.getEffect()+"%'";
}
if(!isEmpty(medicinalMaterials.getUseAmount())){
sql += " and useAmount like '%"+medicinalMaterials.getUseAmount()+"%'";
}
if(!isEmpty(medicinalMaterials.getAlias())){
sql += " and alias like '%"+medicinalMaterials.getAlias()+"%'";
}
if(!isEmpty(medicinalMaterials.getUsages())){
sql += " and usage like '%"+medicinalMaterials.getUsages()+"%'";
}
if(!isEmpty(medicinalMaterials.getIsDelete())){
sql += " and isDelete like '%"+medicinalMaterials.getIsDelete()+"%'";
}
sql += " ORDER BY ID DESC ";
Pager<MedicinalMaterials> pagers = medicinalMaterialsService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers", pagers);
//存储查询条件
model.addAttribute("obj", medicinalMaterials);
return "medicinalMaterials/medicinalMaterials";
}
@RequestMapping(value = "/findBySqlUser")
public String findBySqlUser(MedicinalMaterials medicinalMaterials, Model model, HttpServletRequest request, HttpServletResponse response) {
//分页查询
String sql = "SELECT * FROM medicinal_materials WHERE 1=1 and isDelete = 0 ";//
if(!isEmpty(medicinalMaterials.getCode())){
sql += " and code like '%"+medicinalMaterials.getCode()+"%'";
}
if(!isEmpty(medicinalMaterials.getName())){
sql += " and name like '%"+medicinalMaterials.getName()+"%'";
}
if(!isEmpty(medicinalMaterials.getType())){
sql += " and type like '%"+medicinalMaterials.getType()+"%'";
}
if(!isEmpty(medicinalMaterials.getTaste())){
sql += " and taste like '%"+medicinalMaterials.getTaste()+"%'";
}
if(!isEmpty(medicinalMaterials.getEffect())){
sql += " and effect like '%"+medicinalMaterials.getEffect()+"%'";
}
if(!isEmpty(medicinalMaterials.getUseAmount())){
sql += " and useAmount like '%"+medicinalMaterials.getUseAmount()+"%'";
}
if(!isEmpty(medicinalMaterials.getAlias())){
sql += " and alias like '%"+medicinalMaterials.getAlias()+"%'";
}
if(!isEmpty(medicinalMaterials.getUsages())){
sql += " and usage like '%"+medicinalMaterials.getUsages()+"%'";
}
if(!isEmpty(medicinalMaterials.getIsDelete())){
sql += " and isDelete like '%"+medicinalMaterials.getIsDelete()+"%'";
}
sql += " ORDER BY ID DESC ";
Pager<MedicinalMaterials> pagers = medicinalMaterialsService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers", pagers);
//存储查询条件
model.addAttribute("obj", medicinalMaterials);
return "medicinalMaterials/medicinalMaterialsUser";
}
/**
* 跳至添加页面
* @return
*/
@RequestMapping(value = "/add")
public String add() {
return "medicinalMaterials/add";
}
/**
* 添加执行
* @return
*/
@RequestMapping(value = "/exAdd")
public String exAdd(MedicinalMaterials medicinalMaterials, Model model, HttpServletRequest request, HttpServletResponse response) {
medicinalMaterials.setIsDelete(0);
//medicinalMaterials.setCode(getOrderNo());
medicinalMaterialsService.insert(medicinalMaterials);
return "redirect:/medicinalMaterials/findBySql";
}
/**
* 跳至修改页面
* @return
*/
@RequestMapping(value = "/update")
public String update(Integer id,Model model) {
MedicinalMaterials obj = medicinalMaterialsService.load(id);
model.addAttribute("obj",obj);
return "medicinalMaterials/update";
}
/**
* 添加修改
* @return
*/
@RequestMapping(value = "/exUpdate")
public String exUpdate(MedicinalMaterials medicinalMaterials, Model model, HttpServletRequest request, HttpServletResponse response) {
//1.通过实体类修改,可以多传修改条件
medicinalMaterialsService.updateById(medicinalMaterials);
return "redirect:/medicinalMaterials/findBySql";
}
/**
* 删除通过主键
* @return
*/
@RequestMapping(value = "/delete")
public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
//5.状态删除
MedicinalMaterials load = medicinalMaterialsService.load(id);
load.setIsDelete(1);
medicinalMaterialsService.updateById(load);
return "redirect:/medicinalMaterials/findBySql";
}
}
如果也想学习本系统,下面领取。回复:223ssm