基于javaweb+mysql的springboot医院预约挂号系统(java+springboot+thymeleaf+html+maven+layui+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot医院预约挂号系统(java+springboot+thymeleaf+html+maven+layui+mysql)
一、项目简述功能包括: 用户分为患者,医生,管理员,患者可进行注册选择医生挂号,选择日期,选择号源,医生可进行接诊,管理员可对用户,医生信息的维护等等功能。
二、项目运行环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP +Spring + SpringBoot + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等
mes.setType(1);
mes.setTime(new Date());
mes.setDid(selectByPrimaryKey.getDid());
List<Messages> list = messagesService.selectMessagesPai(mes);
for (int i = 0; i < list.size(); i++) {
list.get(i).setPai(i+1);
messagesService.updateByPrimaryKeySelective(list.get(i));
}
}
return "ok";
}
/**
*患者信息列表
*/
@RequestMapping("/patientList")
public String messageList(Model model, Patient patient, @RequestParam(value="page",defaultValue="1")Integer page,HttpServletRequest request) {
if(patient == null) {
patient = new Patient();
}
HttpSession session = request.getSession();
Doctor dt = (Doctor) session.getAttribute("DOCTOR");
if(dt == null){
return "redirect:/login/index";
}
/*
* PageInfo<Patient> pageInfo =
* patientService.selectPatientList(patient,1,size); List<Patient> list =
* pageInfo.getList(); List<Patient> list2 = new ArrayList<Patient>(); Messages
* messages = new Messages(); boolean pan = false; SimpleDateFormat sdf = new
* SimpleDateFormat("yyyy-MM-dd"); for (Patient pa : list) { if(pa.getPid() !=
* null && pa.getPid() != 0){ messages.setDid(dt.getId());
* messages.setUid(pa.getPid()); messages.setUsername(pa.getName());
* List<Messages> ml = messagesService.selectMessages(messages); if(ml.size() >
* 0 ){ Date time = ml.get(0).getTime(); pa.setUsername(sdf.format(time));
* pa.setPhone(dt.getName()); pa.setIdentitys(dt.getSname()); list2.add(pa); }
*
* } } if(list2.size() <= 8) { pageInfo.setPages(1); }
*/
Messages messages = new Messages();
// messages.setTime(new Date());
messages.setType(1);
messages.setDid(dt.getId());
PageInfo<Messages> pageInfo = messagesService.selectMessagesList(messages, 1, size);
model.addAttribute("doctorList",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
model.addAttribute("patient",patient);
* @throws ParseException
*/
@RequestMapping(value = "/userLogin")
@ResponseBody
public Patient userLogin(@RequestBody Patient patient) throws ParseException {
List<Patient> list = patientService.selectPatient(patient);
if(patient != null && patient.getUsername() != null && patient.getPassword() != null) {
if(list.size() > 0) {
return list.get(0);
}
}
return patient;
}
/**
*登录
* @throws ParseException
*/
@RequestMapping(value = "/passwordSave")
@ResponseBody
public String passwordSave(@RequestBody Patient patient ) throws ParseException {
if(patient != null && patient.getUsername() != null && patient.getPassword() != null) {
Patient pa = new Patient();
pa.setUsername(patient.getUsername());
List<Patient> list = patientService.selectPatient(pa);
if(list.size() > 0) {
return "err";
}
patientService.insertSelective(patient);
return "ok";
}
return "err";
}
/**
*登录验证
* @throws ParseException
*/
@RequestMapping(value = "/userLoginView")
@ResponseBody
public String userLoginView(HttpServletRequest request) throws ParseException {
HttpSession session = request.getSession();
Patient patient =(Patient) session.getAttribute("USER");
System.out.println("*********登陆验证********");
System.out.println(patient);
if(patient != null) {
return "ok";
}
return "err";
* 修改密码
*//*
@RequestMapping("/mimaUpate")
@ResponseBody
public Map<String,String> passwordUpate(Model model, String mima, String mibao, String zhanghao) {
Map<String, String> map = new HashMap<String, String>();
Merchant me = new Merchant();
me.setZhanghao(zhanghao);
me.setMibao(mibao);
List<Merchant> list = merchantService.selectMerchant(me);
if(list.size() > 0){
Merchant me2 = new Merchant();
me2.setId(list.get(0).getId());
me2.setMima(mima);
merchantService.updateByPrimaryKeySelective(me2);
map.put("pan","ok");
}else{
map.put("pan","err");
}
return map;
}
*//**
* 后台登陆界面
* @return
*//*
@RequestMapping("/afterView")
public String afterLogin(Integer type,Model model) {
if(type == null){
type = 1;
}
model.addAttribute("type",type);
return "behind/login";
}
*//**
* 登陆验证
* @return
*//*
@RequestMapping("/verificatio")
public String signin(String username, String password, Integer type, HttpServletRequest request,Model model) {
HttpSession session = request.getSession();
session.setAttribute("type",type);
//类型为1是商户后台 2是管理员
if(type == 1){
Merchant merchant = new Merchant();
merchant.setZhanghao(username);
return "behind/login";
}
session.setAttribute("ADMIN",adminlist.get(0));
return "redirect:/admin/index";
}
*//**
* 退出登录
* @param request
* @return
*//*
@RequestMapping("/sessionInvalidate")
public String boot(HttpServletRequest request,Model model) {
HttpSession session = request.getSession();
Integer type = (Integer) session.getAttribute("type");
if(type == null){
type=1;
}
model.addAttribute("type",type);
session.invalidate(); //session销毁
return "behind/login";
}
*//**
* 管理员修改密码界面
* @return
*//*
@RequestMapping("/adminUptatePage")
public String adminUptatePage(Model model) {
return "behind/admin/adminUptate";
}
*//**
* 商户修改密码界面
* @return
*//*
@RequestMapping("/merchantUptate")
public String merchantUptate(Model model) {
return "behind/merchant/merchantUptate";
}
*/
}
} catch (IllegalStateException | IOException e) {
e.printStackTrace();
}
Doctor doctor = new Doctor();
if(id != -1){
doctor.setId(id);
doctor.setImg("/files/"+filename);
doctorService.updateByPrimaryKeySelective(doctor);
}else {
//添加图片路径
doctor.setImg("/files/"+filename);
doctorService.insertSelective(doctor);
System.out.println("id:"+doctor.getId());
map.put("id",doctor.getId());
}
return map;
}
/**
* 判断管理员账号
*/
@RequestMapping("/sectionxList")
@ResponseBody
public List<Section> sectionxList(Model model, Integer id) {
List<Section> selectByExample = null;
if(id != null) {
Section section = new Section();
section.setPid(id);
selectByExample = sectionService.selectByExample(section);
}
return selectByExample;
}
/**
* 判断管理员账号
*/
@RequestMapping("/mimaUpate")
@ResponseBody
public Map<String,String> passwordUpate(Model model, String zhanghao) {
Map<String, String> map = new HashMap<String, String>();
Admin ad = new Admin();
ad.setUsername(zhanghao);
List<Admin> selectAdmin = adminService.selectAdmin(ad);
if(selectAdmin.size() > 0){
map.put("pan","err");
}else{
map.put("pan","ok");
for (Section section2 : list) {
sectionService.deleteByPrimaryKey(section2.getId());
}
return "redirect:/admin/sectionList";
}
@RequestMapping("/bannersPageUpdate")
public String bannersAdd(Model model,Integer id) {
Banners banners = null;
String[] imgnames = null;
if(id == 1){
banners = bannersService.selectByPrimaryKey(1);
if(banners == null){
banners = new Banners();
banners.setId(1);
bannersService.insertSelective(banners);
}
}
if(banners.getImg() != null && !"".equals(banners.getImg())){
imgnames = banners.getImg().split(",");
}
model.addAttribute("imgnames",imgnames);
model.addAttribute("banners",banners);
return "admin/bannersUpdate";
}
/**
*轮播图片删除
*/
@RequestMapping(value ="/bannersDel")
@ResponseBody
public Map<String, Object> bannersDel(Integer id,String src) throws IOException{
Map<String, Object> map = new HashMap<String, Object>();
StringBuffer sb = new StringBuffer();
if(id != null && src != null){
Banners banner = bannersService.selectByPrimaryKey(id);
if(banner.getImg() != null){
String[] split = banner.getImg().split(",");
for(int i = 0; i<split.length;i++){
patient.setAge(pa.getAge());
int countByExample = messagesService.countByExample(null);
patient.setBianhao(countByExample+1);
//排序
Messages message = new Messages();
// message.setUid(patient.getUid());
message.setTime(patient.getTime());
message.setDid(patient.getDid());
message.setType(-1);
List<Messages> list = messagesService.selectMessages(message);
if(list.size() <= 0) {
patient.setPai(1);
}else {
patient.setPai(list.size()+1);
}
}
messagesService.insertSelective(patient);
if(patient.getId() != null) {
hui = messagesService.selectByPrimaryKey(patient.getId());
Messages xin = new Messages();
xin.setDid(hui.getDid());
xin.setType(1);
xin.setTime(shijian);
List<Messages> selectMessagesPai = messagesService.selectMessagesPai(xin);
hui.setAge(selectMessagesPai.size());
}
return "redirect:/api/doctorList1";
}
/**
*取消预约
* @throws ParseException
*/
@RequestMapping(value = "/messagesQuXiao")
public String messagesQuXiao(Integer id) throws ParseException {
Messages ma = new Messages();
ma.setId(id);
*/
@RequestMapping("/sectionUptate")
public String sectionUptate(Section section) {
sectionService.updateByPrimaryKeySelective(section);
return "redirect:/admin/sectionList";
}
/**
* 修改科室下级
*/
@RequestMapping("/sectionBelowUptate")
public String sectionBelowUptate(Section section) {
sectionService.updateByPrimaryKeySelective(section);
return "redirect:/admin/sectionBelowList?id="+section.getPid();
}
/**
* 删除科室下级
*/
@RequestMapping("/sectionBelowDelect")
public String sectionBelowUptate(Integer id) {
Section section = sectionService.selectByPrimaryKey(id);
Integer pid = section.getPid();
sectionService.deleteByPrimaryKey(section.getId());
return "redirect:/admin/sectionBelowList?id="+pid;
}
/**
* 删除科室
*/
@RequestMapping("/sectionDelect")
public String sectionDelect(Integer id) {
Section section = new Section();
section.setPid(id);
section.setType(2);
List<Section> list = sectionService.selectByExample(section);
sectionService.deleteByPrimaryKey(id);
for (Section section2 : list) {
sectionService.deleteByPrimaryKey(section2.getId());
}
return "redirect:/admin/sectionList";
}
merchant.setId(id);
merchant.setState(1);
merchantService.updateByPrimaryKeySelective(merchant);
}
return "redirect:/admin/merchantList";
}
*//**
*未通过
* @return
*//*
@RequestMapping("/merchanDel")
public String merchanDel(Model model,Integer id) {
if(id != null){
merchantService.deleteByPrimaryKey(id);
}
return "redirect:/admin/merchantList";
}
*//**
*用户列表
* @return
*//*
@RequestMapping("/userList")
public String userList(Model model) {
List<User> userlist = usertService.selectFull(null);
model.addAttribute("userlist",userlist);
return "behind/admin/userList";
}
*//**
*用户删除
* @return
*//*
@RequestMapping("/userDel")
public String userDel(Model model,Integer id) {
if(id != null){
usertService.deleteByPrimaryKey(id);
}
return "redirect:/admin/userList";
/**
* 坐诊时间设置界面
*/
@RequestMapping("/doctorTimePage")
public String doctorTimePage(Integer id,Model model) {
if(id != null) {
Doctor doctor = doctorService.selectByPrimaryKey(id);
model.addAttribute("doctor",doctor);
}
return "admin/doctorTime";
}
/**
* 坐诊时间设置界面
* @throws ParseException
*/
@RequestMapping("/doctorTimeUpdate")
public String doctorTimeUpdate(Integer id,Model model,String begindate,String enddate,String begintime,String endtime) throws ParseException {
if(id != null) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("HH:mm");
Doctor doctor = new Doctor();
doctor.setId(id);
doctor.setBegindate(simpleDateFormat.parse(begindate));
doctor.setEnddate(simpleDateFormat.parse(enddate));
doctor.setBegintime(simpleDateFormat2.parse(begintime));
doctor.setEndtime(simpleDateFormat2.parse(endtime));
doctorService.updateByPrimaryKeySelective(doctor);
}
return "redirect:/admin/doctorList";
}
/**
* 修改医生信息
*/
@RequestMapping("/admindoctorUptate")
public String adminUptatePassword(Doctor doctor,Model model) {
if(doctor != null && doctor.getId() != null) {
if(doctor.getSid() != null) {
Section section = sectionService.selectByPrimaryKey(doctor.getSid());
doctor.setSid(section.getId());
doctor.setSname(section.getName());
}
doctorService.updateByPrimaryKeySelective(doctor);
}
return "redirect:/admin/doctorList";
}
/**
HttpSession session = request.getSession();
Doctor dt = (Doctor) session.getAttribute("DOCTOR");
if(dt != null) {
Doctor doctor = doctorService.selectByPrimaryKey(dt.getId());
List<Section> sectionlist2 = null;
model.addAttribute("doctor",doctor);
//科室
Section se = new Section();
se.setType(1);
List<Section> sectionlist = sectionService.selectByExample(se);
model.addAttribute("sectionlist", sectionlist);
//科室详情
Section se1 = sectionService.selectByPrimaryKey(doctor.getSid());
if(se1 != null) {
Section section = new Section();
section.setPid(se1.getPid());
section.setType(2);
sectionlist2 = sectionService.selectByExample(section);
model.addAttribute("sectionlist2", sectionlist2);
model.addAttribute("se1", se1);
}
}
return "doctor/doctorUptate";
}
/**
* 修改医生信息
*/
@RequestMapping("/messageTime")
public String messageTime(String name,Model model,HttpServletRequest request) {
HttpSession session = request.getSession();
Doctor dt = (Doctor) session.getAttribute("DOCTOR");
if(name != null) {
Messages mess = new Messages();
mess.setDid(dt.getId());
mess.setUsername(name);
List<Messages> selectMessages = messagesService.selectMessagesTWO(mess);
model.addAttribute("messagesList", selectMessages);
}
return "doctor/messageTime";
}
/**
return "redirect:/admin/personList";
}
*//**
* 管理员
*//*
@RequestMapping("/feiyisList")
public String zuopinList(Model model,Feiyis feiyis,@RequestParam(value="page",defaultValue="1")Integer page,String sou) {
feiyis.setState(0);//0为正常 1是管理员下架的
PageInfo<Feiyis> pageInfo = feiyisService.selectFeiyis(feiyis,page,size);
model.addAttribute("feiyiList",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
model.addAttribute("feiyis",feiyis);
return "behind/admin/feiyisList";
}
*//**
* 非遗视界删除
* @param model
* @return
*//*
@RequestMapping("/feiyisDelete")
public String feiyisDelete(Model model,Integer id,Integer type) {
if (id != null) {
Feiyis feiyis = feiyisService.selectByPrimaryKey(id);
//删除图片
// String fp= filePath.substring(filePath.indexOf("/")+1);//文件的真实路径
if (feiyis.getImg() != null) {
String name = feiyis.getImg().substring(feiyis.getImg().indexOf("s") + 2);//获取文件
File file = new File(filePath + name);
if (file.exists()) {
file.delete();
}
}
feiyisService.deleteByPrimaryKey(id);
}
return "redirect:/admin/feiyisList?type=" + type;
}
@ResponseBody
public List<Doctor> doctortimeSelect(@RequestParam("datetimei")String datetimei,@RequestParam("id")Integer id) throws ParseException {
Doctor doctor = new Doctor();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
doctor.setSid(id);
doctor.setBegindate(simpleDateFormat.parse(datetimei));
List<Doctor> selectDoctor = doctorService.selectTime(doctor);
return selectDoctor;
}
/**
*医生列表查询
* @throws ParseException
*/
@RequestMapping(value = "/doctorGeRenList")
@ResponseBody
public Doctor doctorGeRenList(Integer id) throws ParseException {
Doctor doctor = doctorService.selectByPrimaryKey(id);
return doctor;
}
/**
*时间格式转换
*/
@RequestMapping(value = "/doctorYuyueTime")
@ResponseBody
public Map<String,String> doctorYuyueTime(Integer id) {
Map<String,String> map = new HashMap<String,String>();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
Doctor doctor = doctorService.selectByPrimaryKey(id);
map.put("begin",sdf.format(doctor.getBegintime()));
map.put("end",sdf.format(doctor.getEndtime()));
return map;
}
/**
*时间格式转换
* @throws ParseException
*/
@RequestMapping(value = "/timeZhuan")
@ResponseBody
public String timeZhuan(String time) throws ParseException {
if(patient == null) {
patient = new Patient();
}
HttpSession session = request.getSession();
Doctor dt = (Doctor) session.getAttribute("DOCTOR");
if(dt == null){
return "redirect:/login/index";
}
/*
* PageInfo<Patient> pageInfo =
* patientService.selectPatientList(patient,1,size); List<Patient> list =
* pageInfo.getList(); List<Patient> list2 = new ArrayList<Patient>(); Messages
* messages = new Messages(); boolean pan = false; SimpleDateFormat sdf = new
* SimpleDateFormat("yyyy-MM-dd"); for (Patient pa : list) { if(pa.getPid() !=
* null && pa.getPid() != 0){ messages.setDid(dt.getId());
* messages.setUid(pa.getPid()); messages.setUsername(pa.getName());
* List<Messages> ml = messagesService.selectMessages(messages); if(ml.size() >
* 0 ){ Date time = ml.get(0).getTime(); pa.setUsername(sdf.format(time));
* pa.setPhone(dt.getName()); pa.setIdentitys(dt.getSname()); list2.add(pa); }
*
* } } if(list2.size() <= 8) { pageInfo.setPages(1); }
*/
Messages messages = new Messages();
// messages.setTime(new Date());
messages.setType(1);
messages.setDid(dt.getId());
PageInfo<Messages> pageInfo = messagesService.selectMessagesList(messages, 1, size);
model.addAttribute("doctorList",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
model.addAttribute("patient",patient);
return "doctor/patientList";
}
/**
*预约信息列表
* @throws ParseException
*/
@RequestMapping(value = "/tiaozhuanList")
@ResponseBody
public String messagesList(@RequestParam("xiao")Integer xiao,@RequestParam("da")Integer da) {
Messages message = new Messages();
if(xiao != null & da != null) {
Messages mexiao = messagesService.selectByPrimaryKey(xiao);
Integer px = mexiao.getPai();
Messages meda = messagesService.selectByPrimaryKey(da);
mexiao.setPai(meda.getPai());
meda.setPai(px);
messagesService.updateByPrimaryKeySelective(mexiao);
messagesService.updateByPrimaryKeySelective(meda);
}
return null;
}
/**
int insertSelective = adminService.insertSelective(admin);
model.addAttribute("type",2);
return "login";
}
/**
* 登陆验证
* @return
*/
@RequestMapping("/verificatio")
public String verificatio(String username, String password, Integer type, HttpServletRequest request,Model model) {
HttpSession session = request.getSession();
session.setAttribute("type",type);
//类型为1是医院 2是管理员
if(type == 1){
Doctor doctor = new Doctor();
doctor.setUsername(username);
doctor.setPasswoed(password);
List<Doctor> doctorlist = doctorService.selectDoctor(doctor);
if(doctorlist.size() <= 0){
model.addAttribute("message","密码错误");
model.addAttribute("type",type);
return "login";
}
session.setAttribute("DOCTOR",doctorlist.get(0));
return "redirect:/doctor/index";
}
if(type == 3){
Patient patient = new Patient();
patient.setUsername(username);
patient.setPassword(password);
List<Patient> list = patientService.selectPatient(patient);
if(list.size() <= 0) {
model.addAttribute("message","密码错误");
model.addAttribute("type",type);
return "loginByPatient";
}
session.setAttribute("PATIENT",list.get(0));
return "redirect:/api/doctorList1";
}
Admin admin = new Admin();
admin.setUsername(username);
Section se = new Section();
se.setType(1);
List<Section> sectionlist = sectionService.selectByExample(se);
model.addAttribute("sectionlist", sectionlist);
//科室详情
Section se1 = sectionService.selectByPrimaryKey(doctor.getSid());
Section section = new Section();
if(se1 != null) {
section.setPid(se1.getPid());
section.setType(2);
sectionlist2 = sectionService.selectByExample(section);
}else {
if(sectionlist.size() >0 ) {
section.setPid(sectionlist.get(0).getId());
section.setType(2);
sectionlist2 = sectionService.selectByExample(section);
}
se1 = new Section();
}
model.addAttribute("sectionlist2", sectionlist2);
model.addAttribute("se1", se1);
}
return "admin/doctorUptate";
}
/**
* 科室列表
*/
@RequestMapping("/sectionList")
public String sectionList(Model model, Section section, @RequestParam(value="page",defaultValue="1")Integer page) {
if(section == null) {
section = new Section();
}
section.setType(1);//1 科室
PageInfo<Section> pageInfo = sectionService.selectSectionListt(section,page,size);
List<Section> list = pageInfo.getList();
List<Section> list2 = new ArrayList<Section>();
Section cs = new Section();
for (Section se : list) {
/**
* 修改信息
* @param model
* @return
*/
@RequestMapping("/doctorUptatePage")
public String doctorUptatePage(Model model,HttpServletRequest request) {
HttpSession session = request.getSession();
Doctor dt = (Doctor) session.getAttribute("DOCTOR");
if(dt != null) {
Doctor doctor = doctorService.selectByPrimaryKey(dt.getId());
List<Section> sectionlist2 = null;
model.addAttribute("doctor",doctor);
//科室
Section se = new Section();
se.setType(1);
List<Section> sectionlist = sectionService.selectByExample(se);
model.addAttribute("sectionlist", sectionlist);
//科室详情
Section se1 = sectionService.selectByPrimaryKey(doctor.getSid());
if(se1 != null) {
Section section = new Section();
section.setPid(se1.getPid());
section.setType(2);
sectionlist2 = sectionService.selectByExample(section);
model.addAttribute("sectionlist2", sectionlist2);
model.addAttribute("se1", se1);
}
}
return "doctor/doctorUptate";
}
/**
* 修改医生信息
*/
@RequestMapping("/messageTime")
public String messageTime(String name,Model model,HttpServletRequest request) {
HttpSession session = request.getSession();
Doctor dt = (Doctor) session.getAttribute("DOCTOR");
if(name != null) {
Messages mess = new Messages();
mess.setDid(dt.getId());
mess.setUsername(name);
List<Messages> selectMessages = messagesService.selectMessagesTWO(mess);
model.addAttribute("messagesList", selectMessages);
return "redirect:/doctor/messageList?type=1";
}
/**
* 取消
*/
@RequestMapping("/messagesQuXiao")
public String messagesQuXiao(Integer id) {
if(id != null) {
Messages messages = new Messages();
messages.setId(id);
messages.setType(2); //2取消预约
messagesService.updateByPrimaryKeySelective(messages);
}
return "redirect:/doctor/messageList?type=1";
}
/**
* 退号
*/
@RequestMapping("/messagesTui")
public String messagesTui(Integer id) {
if(id != null) {
Messages messages = new Messages();
messages.setId(id);
messages.setType(4); //4退号失败
messagesService.updateByPrimaryKeySelective(messages);
}
return "redirect:/doctor/messageList?type=3";
}
}