基于javaweb的社区养老医疗综合服务系统(java+springboot+bootstrap+html+mysql)
以JavaWeb为基础构建社区养老医疗综合服务系统,并采用Java + Spring Boot + Bootstrap + HTML + MySQL的技术架构
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明






以Java Web + Spring Boot为基础构建的社区养老医疗综合服务系统(java + Spring Boot + Bootstrap + HTML + MySQL)
项目介绍
本项目设置了管理员、医生和病人的三种角色。 管理员的主要职责包括: 个人信息管理与安全措施 系统层面涉及用户操作、权限分配以及部门设置等环节 药物信息管理方面则涵盖了药品调拨记录与使用情况追踪 健康数据记录涵盖以下内容: 居民的基本信息存档 医疗服务记录 医疗费用统计 存储患者往次就诊记录 系统设计还支持以下功能模块: 用户操作权限分配 权限更新机制 部门间数据交互功能 菜单配置参数设置 字典信息维护等环节
医生的职责包括: 个人信息管理与安全措施 药物信息调用与配发记录 患者病情动态更新 基础医疗数据统计 健康检查报告生成
病患的记录涵盖以下内容: 个人信息存档 医保支付记录 健康状况更新 过去就医清单
我的预约信息
环境需要
运行环境:建议基于Java JDK 1.8搭建该平台进行运行,并非唯一配置要求(其他JDK版本亦可正常运行)。
IDE环境:多种开发工具均可支持该平台(包括但不限于IDEA、Eclipse及Myeclipse),其中IDEA强烈推荐使用。
Tomcat环境:适用于Tomcat 7.x及以上版本。
硬件环境:兼容Windows系统中的7、8、10版本(需至少1GB内存)及Mac OS平台。
数据库:支持MySQL数据库5.7及更高版本。
6.是否Maven项目:是;
技术栈
后端:SpringBoot+mybatis-plus
前端:HTML+CSS+javascriipt+jQuery+bootstrap+ztree
使用说明
建议采用Navicat或其他工具来在MySQL中创建指定名称的数据库并导入相关SQL文件以完成数据初始化工作
医生管理控制层:
/**
- 医生管理控制层
*/
@Controller
@RequestMapping(“/doctor”)
public class DoctorController {
@Autowired
private DoctorService doctorService;
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@Autowired
private OperaterLogService operaterLogService;
@Autowired
private DepartmentService departmentService;
@Autowired
private OrderReceivingService orderReceivingService;
@Autowired
private BedAllotService bedAllotService;
/**
跳转医生列表页面
@param model
@param doctor
@param pageBean
@return
*/
@RequestMapping(value = “/list”)
public String list(Model model, Doctor doctor, PageBean pageBean) {
model.addAttribute(“title”, “医生列表”);
if (doctor.getUser() != null) {
model.addAttribute(“name”, doctor.getUser().getName());
model.addAttribute(“pageBean”, doctorService.findList(doctor, pageBean));
return “admin/doctor/list”;
/**
医生添加页面
@param model
@return
*/
@RequestMapping(value = “/add”, method = RequestMethod.GET)
public String add(Model model) {
$ departments = model.addAttribute("departments", departmentService.findAllDepartment());
return “admin/doctor/add”;
/**
医生添加提交
@param doctor
@return
*/
@RequestMapping(value = “/add”, method = RequestMethod.POST)
@ResponseBody
public Result add(Doctor doctor) {
CodeMsg validate = ValidateEntityUtil.validate(doctor);
if (validate.getCode() != CodeMsg.SUCCESS.getCode()) {
return Result.error(validate);
if(Objects.isNull(doctor.getUser().getEmail())){
return Result.error(CodeMsg.ADMIN_PUBLIC_NO_ISEXIST_EMAIL);
if(Objects.isNull(doctor.getUser().getMobile())){
return Result.error(CodeMsg.ADMIN_PUBLIC_NO_ISEXIST_MOBILE);
if (!StringUtil.emailFormat(doctor.getUser().getEmail())) {
return Result.error(CodeMsg.ADMIN_PUBLIC_EMAIL);
if (!StringUtil.isMobile(doctor.getUser().getMobile())) {
return Result.error(CodeMsg.ADMIN_PUBLIC_MOBILE);
Role role = roleService.find(Doctor.DOCTOR_ROLE_ID);
String dNo = StringUtil.generateSn(Doctor.PATIENT_ROLE_DNO);
int age = DateUtil.getAge(doctor.getUser().getBirthDay());
if (age < 0) {
return Result.error(CodeMsg.ADMIN_PUBLIC_AGE);
doctor.setDoctorDno(dNo);
doctor.getUser().setPassword(dNo);
doctor.getUser().setUsername(dNo);
doctor.getUser().setRole(role);
User user = doctor.getUser();
user.setAge(age);
User save = userService.save(user);
if (userService.save(user) == null) {
return Result.error(CodeMsg.ADMIN_USE_ADD_ERROR);
operaterLogService.add(“添加用户,用户名:” + user.getUsername());
doctor.setUser(save);
if (doctorService.save(doctor) == null) {
return Result.error(CodeMsg.ADMIN_DOCTOR_ADD_EXIST);
return Result.success(true);
/**
医生修改页面
@param model
@param id
@return
*/
@RequestMapping(value = “/edit”, method = RequestMethod.GET)
public String edit(Model model, @RequestParam(name = “id”) Long id) {
model.addAttribute(“doctor”, doctorService.find(id));
model.setAttribute("departments", departmentService.findAllDepartment());
return “admin/doctor/edit”;
/**
医生修改提交
@param doctor
@return
*/
@RequestMapping(value = “/edit”, method = RequestMethod.POST)
@ResponseBody
public Result edit(Doctor doctor) {
Doctor findDoctor = doctorService.find(doctor.getId());
List doctors = doctorService.retrieveDoctorsByDNo(findDoctor.getDoctorDno());
if (doctors.size() > 1 || doctors.size() <= 0) {
return Result.error(CodeMsg.ADMIN_PATIENT_PNO_ERROR);
if (doctors.get(0).getId() != doctor.getId()) {
return Result.error(CodeMsg.ADMIN_PATIENT_PNO_ERROR);
if(Objects.isNull(doctor.getUser().getEmail())){
return Result.error(CodeMsg.ADMIN_PUBLIC_NO_ISEXIST_EMAIL);
if(Objects.isNull(doctor.getUser().getMobile())){
return Result.error(CodeMsg.ADMIN_PUBLIC_NO_ISEXIST_MOBILE);
if (!StringUtil.emailFormat(doctor.getUser().getEmail())) {
return Result.error(CodeMsg.ADMIN_PUBLIC_EMAIL);
if (!StringUtil.isMobile(doctor.getUser().getMobile())) {
return Result.error(CodeMsg.ADMIN_PUBLIC_MOBILE);
int age = DateUtil.getAge(doctor.getUser().getBirthDay());
if (age < 0) {
return Result.error(CodeMsg.ADMIN_PUBLIC_AGE);
findDoctor.setDepartment(doctor.getDepartment());
findDoctor.setDescriiption(doctor.getDescriiption());
findDoctor.setExperience(doctor.getExperience());
User user = doctor.getUser();
user.setAge(age);
BeanUtils.copyProperties(user, get the user from findDoctor.getUser(), "ID字段", "创建时间字段", "更新时间字段", "密码字段", "用户名字段", "角色字段");
userService.save(findDoctor.getUser());
doctorService.save(findDoctor);
return Result.success(true);
/**
删除医生用户
@param id
@return
*/
@RequestMapping(value = “/delete”, method = RequestMethod.POST)
@ResponseBody
public Result delete(@RequestParam(name = “id”, required = true) Long id) {
try {
Doctor doctor = doctorService.find(id);
doctorService.deleteById(id);
userService.delete(doctor.getUser().getId());
} catch (Exception e) {
return Result.error(CodeMsg.ADMIN_DOCTOR_DELETE_ERROR);
operaterLogService.add(“添加用户,用户ID:” + id);
return Result.success(true);
/**
修改个人出诊状态页面
@param model
@return
*/
@RequestMapping(value = “/updateStatus”, method = RequestMethod.GET)
public String updateDoctorStatus(Model model) {
Doctor doctor = doctorService.findByLoginDoctorUser();
model.addAttribute(“title”,“个人出诊信息修改”);
model.addAttribute(“doctor”, doctor);
return “admin/doctor/visitingStatus”;
/**
提交修改个人出诊状态
@param doctor
@return
*/
@RequestMapping(value = “/updateStatus”, method = RequestMethod.POST)
@ResponseBody
public Result editStatus(Doctor doctor) {
Doctor doc = doctorService.findByLoginDoctorUser();
if(Objects.isNull(doctor.getUser().getEmail())){
return Result.error(CodeMsg.ADMIN_PUBLIC_NO_ISEXIST_EMAIL);
if(Objects.isNull(doctor.getUser().getMobile())){
return Result.error(CodeMsg.ADMIN_PUBLIC_NO_ISEXIST_MOBILE);
if (!StringUtil.isMobile(doctor.getUser().getMobile())) {
return Result.error(CodeMsg.ADMIN_PUBLIC_MOBILE);
if (!StringUtil.emailFormat(doctor.getUser().getEmail())) {
return Result.error(CodeMsg.ADMIN_PUBLIC_EMAIL);
User user = doc.getUser();
user.setEmail(doctor.getUser().getEmail());
user.setMobile(doctor.getUser().getMobile());
user.setStatus(doctor.getStatus());
doc.setStatus(doctor.getStatus());
doc.setDescriiption(doctor.getDescriiption());
doc.setExperience(doctor.getExperience());
$BeanUtils.copyProperties(患者信息, 医生获取患者信息, -id-, -createTime-, -updateTime-, -password-, -username-, -role-, -sex-, -age-, -birthday-)
doctorService.save(doc);
return Result.success(true);
/**
医生查询接单记录
@param model
@param pageBean
@return
*/
@RequestMapping(value = “/orderRecord”,method = RequestMethod.GET)
public String doctorOrderRecords(Model model, PageBean pageBean) {
//获取医生登录的信息
Doctor loginDoctorUser = doctorService.findByLoginDoctorUser();
model.addAttribute(“title”, “出诊信息”);
模型将"pageBean"设为其属性值,并基于loginDoctorUser的医生ID获取订单收据。
return “admin/doctor/orderRecord”;
/**
查看自己科室所有医生信息
@param model
@param pageBean
@return
*/
@RequestMapping(value = “/findByDepartment”, method = RequestMethod.GET)
public String AllDoctorByDepartment(Model model,PageBean pageBean) {
Doctor loginDoctorUser = doctorService.findByLoginDoctorUser();
model.addAttribute(“title”, “本科室所有医生列表”);
通过model对象设置属性'pageBean'为doctorService.findAllByDepartment(pageBean, loginDoctorUser.getDepartment().getId())的结果。
return “admin/doctor/doctorInformation”;
/**
医生完成出诊订单
@param id
@return
*/
@RequestMapping(value = “/orderRecord”,method = RequestMethod.POST)
@ResponseBody
public ResultmodifyVisitStatus(Long id){
boolean flag = doctorService.modifyVisitStatus(id);
if (flag){
return Result.success(true);
return Result.error(CodeMsg.ADMIN_DOCTOR_CANNOT_REPEATED);
/**
管理员查看所有订单信息
@param model
@param orderReceiving
@param pageBean
@return
*/
@RequestMapping(value=“/allOrderInformation”,method = RequestMethod.GET)
public String getInstance(Model instance, OrderReceiving instance, PageBean instance){
model.addAttribute(“title”,“出诊信息”);
model.addAttribute("PageBean", orderReceivingService.findList(orderReceiving, PageBean));
return “admin/doctor/allOrderInformation”;
/**
- 医生查询负责的住院信息
*/
@RequestMapping(value=“/bedAllot”)
public String bedAllotSelf(Model model,PageBean pageBean){
Doctor loginDoctorUser = doctorService.findByLoginDoctorUser();
Long doctorId = loginDoctorUser.getId();
model.addAttribute(“title”,“住院信息”);
该模型通过设置属性名为"PAGEBEAN"并将其值赋值为bedAllotService.findDoctor(pageBean, doctorId)的方法实现了资源分配。
return “admin/doctor/bedAllot”;
病人信息管理控制层:
/**
- 病人信息管理控制层
*/
@Controller
@RequestMapping(“/patient”)
public class PatientController {
@Autowired
private PatientService patientService;
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@Autowired
private OperaterLogService operaterLogService;
@Autowired
private BedAllotService bedAllotService;
/**
- 病人登录展示病人个人的信息页面
*/
@RequestMapping(value = “/self”)
public String patient(Model model){
model.addAttribute(“title”, “病人个人信息”);
Patient loginPatientUser = patientService.findByLoginPatientUser();
model.addAttribute(“patient”,loginPatientUser);
return “admin/patient/self”;
/**
跳转病人列表页面
@param model
@param patient
@param pageBean
@return
*/
@RequestMapping(value = “/list”)
public String list(Model model, Patient patient, PageBean pageBean) {
model.addAttribute(“title”, “病人列表”);
if (patient.getUser() != null) {
model.addAttribute(“name”, patient.getUser().getName());
模型将属性附加到'pageBean'变量上,并通过调用'patientServiceToList'的方法获取患者列表
return “admin/patient/list”;
/**
跳转病人添加页面
@return
*/
@RequestMapping(value = “/add”, method = RequestMethod.GET)
public String add() {
return “admin/patient/add”;
/**
病人添加
@param patient
@return
*/
@RequestMapping(value = “/add”, method = RequestMethod.POST)
@ResponseBody
public Result add(Patient patient){
CodeMsg validate = ValidateEntityUtil.validate(patient);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
if(Objects.isNull(patient.getUser().getEmail())){
return Result.error(CodeMsg.ADMIN_PUBLIC_NO_ISEXIST_EMAIL);
if(Objects.isNull(patient.getUser().getMobile())){
return Result.error(CodeMsg.ADMIN_PUBLIC_NO_ISEXIST_MOBILE);
if (!StringUtil.emailFormat(patient.getUser().getEmail())){
return Result.error(CodeMsg.ADMIN_PUBLIC_EMAIL);
if (!StringUtil.isMobile(patient.getUser().getMobile())){
return Result.error(CodeMsg.ADMIN_PUBLIC_MOBILE);
Role role = roleService.find(Patient.PATIENT_ROLE_ID);
String pNo = StringUtil.generateSn(Patient.PATIENT_ROLE_PNO);
int age = DateUtil.getAge(patient.getUser().getBirthDay());
if (age < 0) {
return Result.error(CodeMsg.ADMIN_PUBLIC_AGE);
patient.getUser().setAge(age);
patient.setPatientPno(pNo);
patient.getUser().setPassword(pNo);
patient.getUser().setUsername(pNo);
patient.getUser().setRole(role);
User user = patient.getUser();
User save = userService.save(user);
if(userService.save(user) == null){
return Result.error(CodeMsg.ADMIN_USE_ADD_ERROR);
operaterLogService.add(“添加用户,用户名:” + user.getUsername());
patient.setUser(save);
if (patientService.save(patient) == null) {
return Result.error(CodeMsg.ADMIN_PATIENT_ADD_EXIST);
return Result.success(true);
/**
跳转到修改病人页面
@param model
@param id
@return
*/
@RequestMapping(value=“/edit”,method=RequestMethod.GET)
public String edit(Model model,@RequestParam(name=“id”)Long id){
model.addAttribute(“patient”, patientService.find(id));
return “admin/patient/edit”;
/**
修改病人
@param patient
@return
*/
@RequestMapping(value = “/edit”, method = RequestMethod.POST)
@ResponseBody
public Result edit(Patient patient) {
Patient findPatient = patientService.find(patient.getId());
ArrayList patients = patientService.getPatientsByFindByPatientPno(findPatient.getPatientPno());
if (patients.size() > 1 || patients.size() <= 0) {
return Result.error(CodeMsg.ADMIN_PATIENT_PNO_ERROR);
if (patients.get(0).getId() != patient.getId()) {
return Result.error(CodeMsg.ADMIN_PATIENT_PNO_ERROR);
if(Objects.isNull(patient.getUser().getEmail())){
return Result.error(CodeMsg.ADMIN_PUBLIC_NO_ISEXIST_EMAIL);
if(Objects.isNull(patient.getUser().getMobile())){
return Result.error(CodeMsg.ADMIN_PUBLIC_NO_ISEXIST_MOBILE);
if (!StringUtil.emailFormat(patient.getUser().getEmail())){
return Result.error(CodeMsg.ADMIN_PUBLIC_EMAIL);
if (!StringUtil.isMobile(patient.getUser().getMobile())){
return Result.error(CodeMsg.ADMIN_PUBLIC_MOBILE);
int age = DateUtil.getAge(patient.getUser().getBirthDay());
if (age < 0) {
return Result.error(CodeMsg.ADMIN_PUBLIC_AGE);
User user = patient.getUser();
user.setAge(age);
该类调用copiedProperties方法将指定用户的属性值复制至目标用户对象中
userService.save(findPatient.getUser());
patientService.save(findPatient);
return Result.success(true);
/**
跳转到病人修改个人信息页面
@param model
@param id
@return
*/
@RequestMapping(value=“/editSelf”,method=RequestMethod.GET)
public String editSelf(Model model,@RequestParam(name=“id”)Long id){
model.addAttribute(“patient”, patientService.find(id));
return “admin/patient/editSelf”;
/**
病人修改个人信息
@param patient
@return
*/
@RequestMapping(value = “/editSelf”, method = RequestMethod.POST)
@ResponseBody
public Result editSelf(Patient patient){
Patient findPatient = patientService.find(patient.getId());
从患者服务中查找所有患者号码,并将结果存储到patients列表中
if (patients.size() > 1 || patients.size() <= 0) {
return Result.error(CodeMsg.ADMIN_PATIENT_PNO_ERROR);
if (patients.get(0).getId() != patient.getId()) {
return Result.error(CodeMsg.ADMIN_PATIENT_PNO_ERROR);
if(Objects.isNull(patient.getUser().getEmail())){
return Result.error(CodeMsg.ADMIN_PUBLIC_NO_ISEXIST_EMAIL);
if(Objects.isNull(patient.getUser().getMobile())){
return Result.error(CodeMsg.ADMIN_PUBLIC_NO_ISEXIST_MOBILE);
if (!StringUtil.emailFormat(patient.getUser().getEmail())){
return Result.error(CodeMsg.ADMIN_PUBLIC_EMAIL);
if (!StringUtil.isMobile(patient.getUser().getMobile())){
return Result.error(CodeMsg.ADMIN_PUBLIC_MOBILE);
int age = DateUtil.getAge(patient.getUser().getBirthDay());
if (age < 0) {
return Result.error(CodeMsg.ADMIN_PUBLIC_AGE);
User user = patient.getUser();
user.setAge(age);
BeanUtils.copyProperties(user, findPatient.getUser(), "userId", "createdAt", "updatedAt", "password", "username", "roleId");
userService.save(findPatient.getUser());
patientService.save(findPatient);
return Result.success(true);
/**
删除病人用户
@param id
@return
*/
@RequestMapping(value=“/delete”,method=RequestMethod.POST)
@ResponseBody
public Result delete(@RequestParam(name=“id”,required=true)Long id){
try {
Patient patient = patientService.find(id);
patientService.deleteById(id);
userService.delete(patient.getUser().getId());
} catch (Exception e) {
return Result.error(CodeMsg.ADMIN_UPATIENT_ERROR);
operaterLogService.add(“添加病人用户,病人用户ID:” + id);
return Result.success(true);
/**
- 病人查询个人住院信息
*/
@RequestMapping(value=“/bedAllot”)
public String bedAllotSelf(Model model,PageBean pageBean){
Patient loginPatientUser = patientService.findByLoginPatientUser();
Long patientId = loginPatientUser.getId();
model.addAttribute(“title”,“住院信息”);
模型将属性pageBean赋值为bedAllotService通过查找患者页Bean获取的结果
return “admin/patient/bedAllot”;
后台用户管理控制器:
/**
后台用户管理控制器
@author yy
*/
@RequestMapping(“/user”)
@Controller
public class UserController {
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@Autowired
private OperaterLogService operaterLogService;
/**
用户列表页面
@param model
@param user
@param pageBean
@return
*/
@RequestMapping(value=“/list”)
public String list(Model model,User user,PageBean pageBean){
model.addAttribute(“title”, “用户列表”);
model.addAttribute(“username”, user.getUsername());
model.addAttribute(“pageBean”, userService.findList(user, pageBean));
return “admin/user/list”;
/**
新增用户页面
@param model
@return
*/
@RequestMapping(value=“/add”,method=RequestMethod.GET)
public String add(Model model){
model.addAttribute(“roles”, roleService.findSome());
return “admin/user/add”;
/**
用户添加表单提交处理
@param user
@return
*/
@RequestMapping(value=“/add”,method=RequestMethod.POST)
@ResponseBody
public Result add(User user){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(user);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
if(user.getRole() == null || user.getRole().getId() == null){
return Result.error(CodeMsg.ADMIN_USER_ROLE_EMPTY);
//判断用户名是否存在
if(userService.isExistUsername(user.getUsername(), 0l)){
return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
int age = DateUtil.getAge(user.getBirthDay());
if (age < 0) {
return Result.error(CodeMsg.ADMIN_PUBLIC_AGE);
user.setAge(age);
//到这说明一切符合条件,进行数据库新增
if(userService.save(user) == null){
return Result.error(CodeMsg.ADMIN_USE_ADD_ERROR);
operaterLogService.add(“添加用户,用户名:” + user.getUsername());
return Result.success(true);
/**
用户编辑页面
@param model
@return
*/
@RequestMapping(value=“/edit”,method=RequestMethod.GET)
public String edit(Model model, @RequestParam(name: "id", required: true) Long id){}
model.addAttribute(“roles”, roleService.findSome());
model.addAttribute(“user”, userService.find(id));
return “admin/user/edit”;
/**
编辑用户信息表单提交处理
@param user
@return
*/
@RequestMapping(value=“/edit”,method=RequestMethod.POST)
@ResponseBody
public Result edit(User user){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(user);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
if(user.getRole() == null || user.getRole().getId() == null){
return Result.error(CodeMsg.ADMIN_USER_ROLE_EMPTY_EDIT);
当用户的角色ID等于Dr.角色ID或P.角色ID时{
return Result.error(CodeMsg.ADMIN_USER_ROLE_CANNOT_CHANGE);
if(user.getId() == null || user.getId().longValue() <= 0){
return Result.error(CodeMsg.ADMIN_USE_NO_EXIST);
if(userService.isExistUsername(user.getUsername(), user.getId())){
return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
//到这说明一切符合条件,进行数据库保存
User findById = userService.find(user.getId());
int age = DateUtil.getAge(user.getBirthDay());
if (age < 0) {
return Result.error(CodeMsg.ADMIN_PUBLIC_AGE);
user.setAge(age);
//说明:将提交的用户数据中的特定字段复制到现有的user对象中,并且该方法会将新字段的内容覆盖到现有对象中
BeanUtils.copyProperties(user, findById, “id”,“createTime”,“updateTime”);
if(userService.save(findById) == null){
return Result.error(CodeMsg.ADMIN_USE_EDIT_ERROR);
operaterLogService.add(“编辑用户,用户名:” + user.getUsername());
return Result.success(true);
/**
删除用户
@param id
@return
*/
@RequestMapping(value=“/delete”,method=RequestMethod.POST)
@ResponseBody
public Result delete(@RequestParam(name=“id”,required=true)Long id){
try {
userService.delete(id);
} catch (Exception e) {
return Result.error(CodeMsg.ADMIN_USE_DELETE_ERROR);
operaterLogService.add(“添加用户,用户ID:” + id);
return Result.success(true);
创作打卡挑战赛
赢取流量/现金/周边激励大奖



