Java项目:医院管理系统(java+SpringBoot+Layui+Freemaker+maven+mysql)

源码获取:博客首页 "资源" 里下载!

 

项目介绍

医院管理系统,分为管理员、医生、病人三种角色;

管理员主要功能包括:
首页、系统管理:医生管理、患者管理、药品管理;预约管理;病史管理;住院信息管理;管理员用户管理;
医生主要功能包括:首页、就医/查看病史;

病人主要功能包括:首页、病史、住院信息、挂号;

环境需要

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版本;

技术栈

1. 后端:SpringBoot

2. 前端:Layui+Freemaker

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

若为maven项目,导入成功后请执行maven clean;maven install命令

3. 将项目中application.yml配置文件中的数据库配置改为自己的配置,配置tomcat,然后运行;
4. 运行项目,输入http://localhost:8088 登录

 

 

 

 

 

 

用户管理控制层:

@RestController
@RequestMapping(value = "/user")
@Api(tags = "用户管理API")
public class UserController {

    @Autowired
    private IUserService iUserService;


    /**
     * 登录验证
     *
     * @param reqVO
     * @param model
     * @return
     */
    @RequestMapping(value = "/dologin", method = RequestMethod.POST)
    public BaseResponse doLogin(@RequestBody @Validated UserLoginReqVO reqVO, Model model) {

        return iUserService.doLogin(reqVO);
    }

    /**
     * 保存用户注册信息,向用户发送激活链接
     *
     * @param reqVO
     * @return
     */
    @RequestMapping(value = "/doregister", method = RequestMethod.POST)
    public BaseResponse registered(@RequestBody @Validated UserRegisterReqVO reqVO, Model model) {

        return iUserService.saveUserAndSendEmail(reqVO);
    }


    /**
     * 获取登录日志
     *
     * @param reqVO
     * @return
     */
    @RequestMapping(value = "/getLoginfor",method = RequestMethod.GET)
    public PageRspVO getLoginfor(BasePageReqVO reqVO) {

        return iUserService.getLoginfor(reqVO);
    }

    /**
     * 修改密码
     *
     * @param reqVO
     * @return
     */
    @PostMapping(value = "/changePassword")
    public BaseResponse changePassword(@RequestBody @Validated ChangePasswordReqVO reqVO) {

        return iUserService.changePassword(reqVO);
    }

    /**
     * 个人资料设置
     *
     * @return
     */
    @PostMapping(value = "/getUserInfo")
    public List getUserInfo() {

        return iUserService.getUserInfo();
    }

    @PostMapping(value = "/changeUserInfo")
    public BaseResponse changeUserInfo(@RequestBody @Validated UserInfoVO reqVO) {

        return  iUserService.changeUserInfo(reqVO);
    }

    @PostMapping(value = "/getAnnContent")
    public AnnRspVO getAnnContent(@RequestParam String id) {

        return iUserService.getAnnContent(id);
    }

    @PostMapping(value = "/addAnotherRole")
    public BaseResponse addAnotherRole(@RequestBody @Validated AccountRoleVO reqVO) {

        return iUserService.addAnotherRole(reqVO);
    }


    /**
     * 获取所有角色
     * @param
     * @return
     */
    @PostMapping(value = "/getAllRole")
    public List getAllRole() {
        return iUserService.getAllRole();
    }

}
@Controller
public class DeptController {
    @Autowired
    private DeptService deptService;

    /**
     * 分页查询
     */
    @RequestMapping("/findDept")
    public String findDept(String deptNo, String deptName,Integer pageIndex
            , Integer pageSize, Model model,HttpSession session){
        PageInfo de = deptService.findPageInfo(deptNo,deptName, pageIndex,pageSize);
        model.addAttribute("de",de);
        session.setAttribute("u",deptNo);
        session.setAttribute("t",deptName);
        return "Dept_list";
    }

    /**
     * 添加管理员信息
     */
    @RequestMapping(value = "/addDept" ,method = RequestMethod.POST)
    @ResponseBody
    public String addDept(@RequestBody Dept dept) {
        int a = deptService.addDept(dept);
        return "Dept_list";
    }


    /**
     * 修改信息
     */
    @RequestMapping( value = "/updateDept", method = RequestMethod.POST)
    public String updateDept(Dept dept) {
        int a = deptService.updateDept(dept);
        return "redirect:/findDept";
    }

    /**
     * 根据Id搜索;
     */
    @RequestMapping("/findDeptById")
    public String findDeptById(Integer deptId, HttpSession session) {
        Dept de2= deptService.findDeptById(deptId);
        session.setAttribute("de2",de2);
        return "Dept_edit";
    }



    /**
     * 导出Excel
     */
    @RequestMapping(value = "/exportDeptlist" , method = RequestMethod.POST)
    @ResponseBody
    public List exportDept(){
        List depts = deptService.getAll();
        return depts;
    }


    /**
     * 部门人员信息查询
     */
    @RequestMapping(value = "/findDeptPersonnel")
    public String findClassStudent(Dept dept,Model model, HttpSession session) {
        List dep = deptService.findDeptPersonnel(dept);
        model.addAttribute("dep",dep);
        return "dept_Personnellist";
    }

}

医生管理控制层:

/**
 * 医生管理控制层
 */

@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) {

        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.addAttribute("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.findByDoctorDno(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.setDescription(doctor.getDescription());
        findDoctor.setExperience(doctor.getExperience());

        User user = doctor.getUser();
        user.setAge(age);

        BeanUtils.copyProperties(user, findDoctor.getUser(), "id", "createTime", "updateTime", "password", "username", "role");

        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.setDescription(doctor.getDescription());
        doc.setExperience(doctor.getExperience());
        BeanUtils.copyProperties(user, doctor.getUser(), "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", "出诊信息");
        model.addAttribute("pageBean", orderReceivingService.findByDoctorId(pageBean,loginDoctorUser.getId()));
        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.addAttribute("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 findAll(Model model,OrderReceiving orderReceiving, PageBean pageBean){
        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","住院信息");
        model.addAttribute("pageBean",bedAllotService.findByDoctor(pageBean,doctorId));
        return "admin/doctor/bedAllot";
    }


}

病房管理控制层:

/***
 * 病房管理控制层
 */
@Controller
@RequestMapping("/room")
public class RoomController {
    @Autowired
    private RoomService roomService;
    @Autowired
    private OperaterLogService operaterLogService;
    @Autowired
    private BedService bedService;
    @Autowired
    private RoomTypeService roomTypeService;


    /***
     * 病房分页查询
     * @param model
     * @param pageBean
     * @param room
     * @return
     */
    @RequestMapping("/list")
    String list(Model model, PageBean pageBean, Room room){
        model.addAttribute("title","病房列表");
        model.addAttribute("roomNo", room.getRoomNo());
        model.addAttribute("pageBean",roomService.findAll(room,pageBean));
        return "admin/room/list";
    }
    /**
     * 新增病房页面
     * @param model
     * @return
     */
    @RequestMapping(value="/add")
    public String add(Model model){
        model.addAttribute("roomType",roomTypeService.findList());
        return "admin/room/add";
    }

    /**
     * 病房添加表单提交处理
     * @param room
     * @return
     */
    @RequestMapping(value="/add",method= RequestMethod.POST)
    @ResponseBody
    public Result add(Room room){
        //用统一验证实体方法验证是否合法
        CodeMsg validate = ValidateEntityUtil.validate(room);
        if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
            return Result.error(validate);
        }
        //设置可用床数
        int total = room.getTotal();
            room.setUsable(total);
        if(Objects.isNull(room.getRoomNo())){
            return Result.error(CodeMsg.ADMIN_ROOM_NO_ISEXIST);
        }
        if(roomService.isExistRoomNo(room.getRoomNo(),0L)){
            return Result.error(CodeMsg.ADMIN_ROOM_EXIST);
        }
        //到这说明一切符合条件,进行数据库新增
        if(roomService.save(room) == null){
            return Result.error(CodeMsg.ADMIN_ROOM_ADD_ERROR);
        }

      /*  //判断是否床位存在
        if(bedService.find(room.getId())!=null){
            return Result.error(CodeMsg.ADMIN_BED_EXIST);
        }*/
        //循环total向床位表添加相应床位
        for (int i = 0 ;i edit(Room room){
        //用统一验证实体方法验证是否合法
        CodeMsg validate = ValidateEntityUtil.validate(room);
        if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
            return Result.error(validate);
        }
        if(room.getId() == null || room.getId().longValue() <= 0){
            return Result.error(CodeMsg.ADMIN_ROOM_NO_EXIST);
        }
        if(roomService.isExistRoomNo(room.getRoomNo(),room.getId())){
            return Result.error(CodeMsg.ADMIN_ROOM_EXIST);
        }
        //到这说明一切符合条件,进行数据库保存
        Room findById = roomService.find(room.getId());
        //将提交的科室信息指定字段复制到已存在的RoomType对象中,该方法会覆盖新字段内容
        BeanUtils.copyProperties(room, findById, "id","createTime","updateTime","total","usable");
        if(roomService.save(findById) == null){
            return Result.error(CodeMsg.ADMIN_ROOM_EDIT_ERROR);
        }
        operaterLogService.add("编辑病房,病房号:" + room.getRoomNo());
        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 {
            roomService.delete(id);
        } catch (Exception e) {
            return Result.error(CodeMsg.ADMIN_ROOM_DELETE_ERROR);
        }
        operaterLogService.add("删除病房,病房ID:" + id);
        return Result.success(true);
    }
}

 源码获取:博客首页 "资源" 里下载!

你可能感兴趣的:(Java毕业设计项目实战篇,java,mysql,springboot,Freemaker,layui)