作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
基于SSM的医院预约挂号系统
角色:管理员、医生、用户
管理员登录系统后,可以对主页,个人中心、用户管理、医生管理、门诊信息管理、预约挂号管理、取消预约管理、改约通知管理、留言板管理、系统管理等功能进行相应的操作管理
医生登录进入医院预约挂号系统可以对主页、个人中心、门诊信息管理、预约挂号管理、取消预约管理等功能
用户登录进入医院预约挂号系统可以对主页、个人中心、预约挂号管理、取消预约管理、改约通知管理等功能
环境需要
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.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 5.7/8.0等版本均可;
技术栈
后端:SSM(Spring+SpringMVC+Mybatis)
前端:JSP+CSS+JS+JQUERY+Layui
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目;
3. 将项目中db.xml配置文件中的数据库配置改为自己的配置,然后运行;
运行截图
论文
前台界面
后管界面
相关代码
UtilController
package com.hospital.controller;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.hospital.dao.MessageDao;
import com.hospital.entity.Message;
import com.hospital.entity.Records;
import com.hospital.service.DoctorService;
import com.hospital.service.MessageService;
import com.hospital.service.RecordsService;
import com.hospital.service.UserService;
@Controller
public class UtilController {
@Autowired
MessageService messageService;
@Autowired
RecordsService orderService;
@Autowired
UserService userService;
@Autowired
DoctorService doctorService;
@RequestMapping("toRegister")
public String toRegsiteAct(HttpServletRequest request) {
return "view/register";
}
@RequestMapping("toEcharts")
public String toEcharts(HttpServletRequest request) {
return "view/echarts";
}
@RequestMapping("toLogin")
public String toLogin(HttpSession session) {
session.removeAttribute("admin");
session.removeAttribute("user");
session.removeAttribute("doctor");
return "view/login";
}
@RequestMapping("UserPageAct")
public String UserPageAct() {
return "view/userList";
}
@RequestMapping("toLoginOutAct")
public String toLoginOutAct(HttpSession session) {
session.removeAttribute("admin");
session.removeAttribute("user");
session.removeAttribute("doctor");
return "view/login";
}
@RequestMapping("toMain")
public String toMain(HttpServletRequest request,HttpSession session) {
Map<String,Object> maps = new HashMap<>();
List<Message> messageList = messageService.selectMessageList(maps);
request.setAttribute("messageList", messageList);
List<Records> recordsList = orderService.selectRecordsList(maps);
for(Records record : recordsList) {
record.setUser(userService.selectUserById(record.getUid()));
record.setDoctor(doctorService.selectDoctorById(record.getDid()));
}
request.setAttribute("recordsList", recordsList);
return "view/main";
}
@RequestMapping("toConsoleAct")
public String toWelocmeAct() {
return "view/console";
}
@ResponseBody
@RequestMapping("/upload")
public Map upload(MultipartFile file,HttpServletRequest request){
String prefix="";
String dateStr="";
OutputStream out = null;
InputStream fileInput=null;
try{
if(file!=null){
String originalName = file.getOriginalFilename();
prefix=originalName.substring(originalName.lastIndexOf(".")+1);
Date date = new Date();
String uuid = UUID.randomUUID()+"";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateStr = simpleDateFormat.format(date);
String filepath = "F:\\workspace\\flower_ssm\\WebContent\\img\\" + dateStr+"\\"+uuid+"." + prefix;
File files=new File(filepath);
System.out.println(filepath);
if(!files.getParentFile().exists()){
files.getParentFile().mkdirs();
}
file.transferTo(files);
Map<String,Object> map2=new HashMap<>();
Map<String,Object> map=new HashMap<>();
map.put("code",0);
map.put("msg","");
map.put("data",map2);
map2.put("src","/img/"+ dateStr+"/"+uuid+"." + prefix);
return map;
}
}catch (Exception e){
}finally{
try {
if(out!=null){
out.close();
}
if(fileInput!=null){
fileInput.close();
}
} catch (Exception e) {
}
}
Map<String,Object> map=new HashMap<>();
map.put("code",1);
map.put("msg","");
return map;
}
@ResponseBody
@RequestMapping("/upload2")
public Map upload2(MultipartFile file,HttpServletRequest request){
String prefix="";
String dateStr="";
OutputStream out = null;
InputStream fileInput=null;
try{
if(file!=null){
String originalName = file.getOriginalFilename();
prefix=originalName.substring(originalName.lastIndexOf(".")+1);
Date date = new Date();
String uuid = UUID.randomUUID()+"";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateStr = simpleDateFormat.format(date);
String filepath = "D:\\upload\\" + dateStr+"\\"+uuid+"." + prefix;
File files=new File(filepath);
System.out.println(filepath);
if(!files.getParentFile().exists()){
files.getParentFile().mkdirs();
}
file.transferTo(files);
Map<String,Object> map2=new HashMap<>();
Map<String,Object> map=new HashMap<>();
map.put("code",0);
map.put("msg","");
map.put("data",map2);
map2.put("src",dateStr+"/"+uuid+"." + prefix);
return map;
}
}catch (Exception e){
}finally{
try {
if(out!=null){
out.close();
}
if(fileInput!=null){
fileInput.close();
}
} catch (Exception e) {
}
}
Map<String,Object> map=new HashMap<>();
map.put("code",1);
map.put("msg","");
return map;
}
}
UserController
package com.hospital.controller;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hospital.entity.Admin;
import com.hospital.entity.Doctor;
import com.hospital.entity.User;
import com.hospital.service.UserService;
@RestController
public class UserController {
@Autowired
UserService us;
/**
* ��¼
* @param username
* @param request
* @param password
* @param session
* @param response
* @param mv
* @return
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/login")
@ResponseBody
public boolean login(@RequestParam("username")String username,
HttpServletRequest request,@RequestParam("password")String password,
HttpSession session,HttpServletResponse response,ModelAndView mv) throws ServletException, IOException {
session.removeAttribute("admin");
session.removeAttribute("user");
String type=request.getParameter("type").toString();
User user =new User();
Admin admin = new Admin();
Doctor doctor = new Doctor();
request.getSession().setAttribute("type", type);
boolean re = false;
if(type != null && type.equals("1")){
admin.setUsername(username);
admin.setPassword(password);
Admin admin1 = us.selectAdmin(admin);
if(admin1 != null){
request.getSession().setAttribute("admin", admin1);
session.setAttribute("admin", admin1);
re = true;
}
}else if(type != null && type.equals("2")){
user.setUsername(username);
user.setPassword(password);
User te = us.selectUser(user);
if(te != null){
request.getSession().setAttribute("user", te);
session.setAttribute("user", te);
re = true;
}
}else if(type != null && type.equals("3")) {
doctor.setPhone(username);
doctor.setPwd(password);
Doctor te = us.selectDoctor(doctor);
if(te != null){
request.getSession().setAttribute("doctor", te);
session.setAttribute("doctor", te);
re = true;
}
}
return re;
}
@RequestMapping("/userList")
public ModelAndView UserList(
@RequestParam(defaultValue="1") Integer currentPage,HttpServletRequest request,
Map<String,Object> map){
User user = (User)request.getSession().getAttribute("user");
String userName = request.getParameter("key");
List<User> list = new ArrayList<>();
Map<String,Object> maps = new HashMap<>();
maps.put("username", userName);
maps.put("uid", user!=null?user.getId():null);
PageHelper.startPage(currentPage,10);
list=us.selectUserList(maps);
PageInfo<User> pageInfo=new PageInfo<User>(list,8);
map.put("pageInfo", pageInfo);
map.put("key", userName);
return new ModelAndView("view/user/list");
}
@RequestMapping("/toAddUser")
public ModelAndView toAddUser(HttpServletRequest request,ModelAndView mv){
mv.setViewName("view/user/add");
return mv;
}
@RequestMapping("/addUser")
@ResponseBody
public boolean addUser(User ss){
ss.setTimes(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()));
boolean re = false;
User user = us.selectUserByUserName(ss.getUsername());
if(user == null) {
us.addUser(ss);
re = true;
}
return re;
}
@RequestMapping("/deleteUser")
public boolean deleteUser(HttpServletRequest request,
HttpServletResponse response){
boolean re = false;
String id = request.getParameter("id");
us.deleteUser(Integer.parseInt(id));
re = true;
return re;
}
@RequestMapping("/toUpdateUser")
public ModelAndView toUpdateUser(HttpServletRequest request,ModelAndView mv){
String id=request.getParameter("id");
User ff = us.selectUserById(Integer.parseInt(id));
mv.addObject("userDate", ff);
mv.setViewName("view/user/update");
return mv;
}
@RequestMapping("/toUpdateAdminPassword")
public ModelAndView toUpdateAdminPassword(HttpServletRequest request,ModelAndView mv){
mv.setViewName("view/admin/updatePassword");
return mv;
}
@RequestMapping("/updateAdminPassword")
@ResponseBody
public boolean updateAdminPassword(HttpServletRequest request){
boolean re = false;
Admin admin = (Admin)request.getSession().getAttribute("admin");
String nowpass = request.getParameter("nowpass");
String newpass = request.getParameter("newpass");
if(admin !=null && admin.getPassword().equals(nowpass)) {
us.updateAdminPassword(newpass,admin.getId());
re = true;
}
return re;
}
@RequestMapping("/updateUser")
@ResponseBody
public boolean updateUser(HttpServletRequest request,User ss){
Admin admin = (Admin)request.getSession().getAttribute("admin");
boolean re = false;
us.updateUser(ss);
re = true;
if(admin ==null) {
request.getSession().setAttribute("user", ss);
}
return re;
}
}
如果也想学习本系统,下面领取。关注并回复:318ssm