Java project: SSM online Chinese medicine prescription management system based on jsp+mysql+Spring+mybatis

Author home page: Night Weiyang 5788

Introduction: high quality creators in Java field, Java projects, learning materials, technical assistance

Get the source code at the end of the article

Project introduction

This project is divided into three roles: pharmacy staff, administrator and doctor;
The pharmacy personnel role includes the following functions:
Pharmacy staff login, guide sheet management, purchase management and other functions.

The administrator role includes the following functions:
Administrator login, pharmacy personnel management, doctor management, medicinal materials information management, prescription management and other functions.

The doctor role includes the following functions:
Doctor login, herbal information query, prescription query, guide list management and other functions.

Environmental needs

1. Running environment: the best is java jdk 1.8, which we run on this platform. Other versions are theoretically OK.
2.IDE environment: IDEA, eclipse and MyEclipse are all OK. Recommend IDEA;
3.tomcat environment: Tomcat versions 7.x, 8.x, and 9.x are acceptable
4. Hardware environment: windows 7/8/10 1G memory or more; Or Mac OS;  

5. Database: MySQL version 5.7/8.0 can be used;
6. Maven project: Yes;

Technology stack

1. Back end: Spring+SpringMVC+Mbytes

2. Front end: JSP+css+javascript+bootstrap+jQuery

instructions

1. Use Navicat or other tools to create a database with the corresponding name in mysql and import the sql file of the project;
2. Use IDEA/Eclipse/MyEclipse to import the project. When importing Eclipse/MyEclipse, if it is a maven project, please select Maven;
If it is a maven project, please execute Maven clean after successful import; Maven install command, and then run;
3. Change the database configuration in the db.properties configuration file in the project to your own configuration;

4. Run the project and enter localhost:8080/ssm in the browser_ yaofangsys/
Doctor account / password: doctor/123456
Pharmacy staff account / password: yaofang/123456
Administrator account / password: admin/admin

Screenshot of operation
Administrator role

 

 

 

 

Doctor role

 

 

 

 

Pharmacy personnel management

 

 

 

Related codes

 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 July 16, 2013 13:19:16
 */


@Controller
@RequestMapping("/cmsOrder")
public class CmsOrderController extends BaseController {
	
	
	/**
	 * Dependency injection start dao/service/===
	 */
	@Autowired
	private CmsOrderService cmsOrderService;
	
	
	
	
	
	@RequestMapping(value = "/findBySql")
	public String findBySql(CmsOrder cmsOrder, Model model, HttpServletRequest request, HttpServletResponse response) {
		
		//Paging query
		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);
		//Store query criteria
		model.addAttribute("obj", cmsOrder);
		return "cmsOrder/cmsOrder";
	}
	
	/**
	 * Skip to the add page
	 * @return
	 */
	@RequestMapping(value = "/add")
	public String add() {
		return "cmsOrder/add";
	}

	
	/**
	 * Add execution
	 * @return
	 */
	@RequestMapping(value = "/exAdd")
	public String exAdd(CmsOrder cmsOrder, Model model, HttpServletRequest request, HttpServletResponse response) {
		cmsOrderService.insert(cmsOrder);
		return "redirect:/cmsOrder/findBySql";
	}
	
	
	/**
	 * Skip to the modification page
	 * @return
	 */
	@RequestMapping(value = "/update")
	public String update(Integer id,Model model) {
		CmsOrder obj = cmsOrderService.load(id);
		model.addAttribute("obj",obj);
		return "cmsOrder/update";
	}
	
	/**
	 * Add modification
	 * @return
	 */
	@RequestMapping(value = "/exUpdate")
	public String exUpdate(CmsOrder cmsOrder, Model model, HttpServletRequest request, HttpServletResponse response) {
		//1. You can transfer multiple modification conditions through entity class modification
		//2. Modify by primary key id
		cmsOrderService.updateById(cmsOrder);
		return "redirect:/cmsOrder/findBySql";
	}
	
	/**
	 * Delete through primary key
	 * @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 July 16, 2013 13:19:17
 */


@Controller
@RequestMapping("/doctor")
public class DoctorController extends BaseController {
	
	
	/**
	 * Dependency injection start dao/service/===
	 */
	@Autowired
	private DoctorService doctorService;
	
	
	
	
	
	@RequestMapping(value = "/findBySql")
	public String findBySql(Doctor doctor, Model model, HttpServletRequest request, HttpServletResponse response) {
		//Paging query
		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);
		//Store query criteria
		model.addAttribute("obj", doctor);
		return "doctor/doctor";
	}
	
	/**
	 * Skip to the add page
	 * @return
	 */
	@RequestMapping(value = "/add")
	public String add() {
		return "doctor/add";
	}

	
	/**
	 * Add execution
	 * @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";
	}
	
	
	/**
	 * Skip to the modification page
	 * @return
	 */
	@RequestMapping(value = "/update")
	public String update(Integer id,Model model) {
		Doctor obj = doctorService.load(id);
		model.addAttribute("obj",obj);
		return "doctor/update";
	}
	
	/**
	 * Add modification
	 * @return
	 */
	@RequestMapping(value = "/exUpdate")
	public String exUpdate(Doctor doctor, Model model, HttpServletRequest request, HttpServletResponse response) {
		//1. You can transfer multiple modification conditions through entity class modification
		doctorService.updateById(doctor);
		//2. Modify by primary key id
		//doctorService.updateById(doctor);
		return "redirect:/doctor/findBySql";
	}
	
	/**
	 * Delete through primary key
	 * @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";
	}
	
	
}

Login controller

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;
	
	/**
	 * Jump login
	 * @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";
	}
	
	/**
	 * Administrator login
	 * @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";
		}
		
		//Super administrator
		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 super administrator 2 doctor 3 pharmacy staff 
		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";
			}
		}
		 //Pharmacy staff
		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;
		
	}
	
	/**
	 * sign out
	 * @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";
	}
	
}

Management controller

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 July 16, 2013 13:19:17
 */


@Controller
@RequestMapping("/manage")
public class ManageController extends BaseController {
	
	
	/**
	 * Dependency injection start dao/service/===
	 */
	@Autowired
	private ManageService manageService;
	
	
	
	
}

Drug management controller

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 July 16, 2013 13:19:17
 */


@Controller
@RequestMapping("/medicinalMaterials")
public class MedicinalMaterialsController extends BaseController {
	
	
	/**
	 * Dependency injection start dao/service/===
	 */
	@Autowired
	private MedicinalMaterialsService medicinalMaterialsService;
	
	
	
	
	
	@RequestMapping(value = "/findBySql")
	public String findBySql(MedicinalMaterials medicinalMaterials, Model model, HttpServletRequest request, HttpServletResponse response) {
		
		//Paging query
		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);
		//Store query criteria
		model.addAttribute("obj", medicinalMaterials);
		return "medicinalMaterials/medicinalMaterials";
	}
	
	
	@RequestMapping(value = "/findBySqlUser")
	public String findBySqlUser(MedicinalMaterials medicinalMaterials, Model model, HttpServletRequest request, HttpServletResponse response) {
		
		//Paging query
		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);
		//Store query criteria
		model.addAttribute("obj", medicinalMaterials);
		return "medicinalMaterials/medicinalMaterialsUser";
	}
	
	/**
	 * Skip to the add page
	 * @return
	 */
	@RequestMapping(value = "/add")
	public String add() {
		return "medicinalMaterials/add";
	}

	
	/**
	 * Add execution
	 * @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";
	}
	
	
	/**
	 * Skip to the modification page
	 * @return
	 */
	@RequestMapping(value = "/update")
	public String update(Integer id,Model model) {
		MedicinalMaterials obj = medicinalMaterialsService.load(id);
		model.addAttribute("obj",obj);
		return "medicinalMaterials/update";
	}
	
	/**
	 * Add modification
	 * @return
	 */
	@RequestMapping(value = "/exUpdate")
	public String exUpdate(MedicinalMaterials medicinalMaterials, Model model, HttpServletRequest request, HttpServletResponse response) {
		//1. You can transfer multiple modification conditions through entity class modification
		medicinalMaterialsService.updateById(medicinalMaterials);
		return "redirect:/medicinalMaterials/findBySql";
	}
	
	/**
	 * Delete through primary key
	 * @return
	 */
	@RequestMapping(value = "/delete")
	public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
		//5. Status deletion
		MedicinalMaterials load = medicinalMaterialsService.load(id);
		load.setIsDelete(1);
		medicinalMaterialsService.updateById(load);
		return "redirect:/medicinalMaterials/findBySql";
	}
}

If you want to learn this system, please get it below. Reply: 223ssm

Tags: Java Spring Mybatis

Posted by petitduc on Wed, 03 Aug 2022 01:57:50 +0930