完整的醫(yī)院就診掛號(hào)系統(tǒng)基于Spring MVC + Spring + MyBatis實(shí)現(xiàn)
資源下載:點(diǎn)此下載
一、語(yǔ)言和環(huán)境
1.實(shí)現(xiàn)語(yǔ)言: JAVA語(yǔ)言。
2.環(huán)境要求: MyEclipse/Eclipse + Tomcat + MySQL。
3.使用技術(shù): Spring MVC + Spring + MyBatis 或 JSP + Servlet + JavaBean + JDBC。
二、實(shí)現(xiàn)效果
實(shí)現(xiàn)能夠?qū)颊咝彰?,醫(yī)師類別、科室的模糊查詢,用戶點(diǎn)擊核銷以后狀態(tài)變?yōu)橐丫驮\。
點(diǎn)擊掛號(hào)實(shí)現(xiàn)基本信息的添加
三、實(shí)現(xiàn)代碼
數(shù)據(jù)庫(kù):
SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for tb_patient -- ---------------------------- DROP TABLE IF EXISTS `tb_patient`; CREATE TABLE `tb_patient` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL, `sex` varchar(10) DEFAULT NULL, `age` int(11) DEFAULT NULL, `phone` varchar(20) DEFAULT NULL, `department` varchar(50) DEFAULT NULL, `type` varchar(50) DEFAULT NULL, `price` decimal(9,2) DEFAULT NULL, `state` int(11) DEFAULT NULL, `register_time` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of tb_patient -- ---------------------------- INSERT INTO `tb_patient` VALUES ('1', '張蕾', '女', '12', '13895463212', '兒科', '專家醫(yī)師', '25.00', '1', '2021-07-18 12:23:00'); INSERT INTO `tb_patient` VALUES ('2', '劉德明', '男', '28', '13345623215', '骨科', '普通醫(yī)師', '8.00', '0', '2021-07-18 12:23:00'); INSERT INTO `tb_patient` VALUES ('3', '李將軍', '男', '38', '13578064788', '內(nèi)科', '專家醫(yī)師', '25.00', '1', '2021-07-17 12:23:00'); INSERT INTO `tb_patient` VALUES ('4', '張佩佩', '女', '44', '18214217246', '外科', '副主任醫(yī)師', '17.00', '0', '2021-07-16 12:23:00'); INSERT INTO `tb_patient` VALUES ('5', '程聰明', '男', '29', '13652645964', '骨科', '副主任醫(yī)師', '17.00', '0', '2021-08-08 16:21:52');
項(xiàng)目Java代碼:
目錄結(jié)構(gòu)
JAR包:
代碼:
=src
> com.mhys.crm.controller
HospitalContrller.java
package com.mhys.crm.controller; import java.util.List; import javax.annotation.Resource; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import com.mhys.crm.dao.TbPatientMapper; import com.mhys.crm.entity.TbPatient; @Controller public class HospitalContrller { @Resource private TbPatientMapper tbPatientMapper; @RequestMapping("/select") public String getList(Model model) { List<TbPatient> selctAll = tbPatientMapper.selectAlls(); System.out.println(selctAll); model.addAttribute("selctAll", selctAll); return "info"; } @RequestMapping("/list") public String getAll(Model model, String name, String type, String dep) { List<TbPatient> selctAll = tbPatientMapper.selectAll(name, type, dep); System.out.println(name+"==="+type+"==="+dep); model.addAttribute("selctAll", selctAll); return "info"; } @RequestMapping("/upd") public String upDev(Model model,int id) { int update = tbPatientMapper.update(id); return "redirect:/select.do"; } @RequestMapping("/adds") public String adds(Model model) { return "addInfo"; } @RequestMapping("/insert") public String toaddDev(Model model,TbPatient tb) { tbPatientMapper.insert(tb); return "redirect:/select.do"; } }
> com.mhys.crm.dao
TbPatientMapper.java
package com.mhys.crm.dao; import com.mhys.crm.entity.TbPatient; import java.util.List; import org.apache.ibatis.annotations.Param; public interface TbPatientMapper { int deleteByPrimaryKey(Integer id); int insert(TbPatient record); TbPatient selectByPrimaryKey(Integer id); List<TbPatient> selectAlls(); int updateByPrimaryKey(TbPatient record); int update(Integer id); List<TbPatient> selectAll(@Param("name")String name,@Param("type")String type,@Param("dep")String dap); }
TbPatientMapper.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.mhys.crm.dao.TbPatientMapper" > <resultMap id="BaseResultMap" type="com.mhys.crm.entity.TbPatient" > <id column="id" property="id" jdbcType="INTEGER" /> <result column="name" property="name" jdbcType="VARCHAR" /> <result column="sex" property="sex" jdbcType="VARCHAR" /> <result column="age" property="age" jdbcType="INTEGER" /> <result column="phone" property="phone" jdbcType="VARCHAR" /> <result column="department" property="department" jdbcType="VARCHAR" /> <result column="type" property="type" jdbcType="VARCHAR" /> <result column="price" property="price" jdbcType="DECIMAL" /> <result column="state" property="state" jdbcType="INTEGER" /> <result column="register_time" property="registerTime" jdbcType="TIMESTAMP" /> </resultMap> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > delete from tb_patient where id = #{id,jdbcType=INTEGER} </delete> <insert id="insert" parameterType="com.mhys.crm.entity.TbPatient" > insert into tb_patient (id, name, sex, age, phone, department, type, price, state, register_time) values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{sex,jdbcType=VARCHAR}, #{age,jdbcType=INTEGER}, #{phone,jdbcType=VARCHAR}, #{department,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, #{state,jdbcType=INTEGER}, #{registerTime,jdbcType=TIMESTAMP}) </insert> <update id="updateByPrimaryKey" parameterType="com.mhys.crm.entity.TbPatient" > update tb_patient set name = #{name,jdbcType=VARCHAR}, sex = #{sex,jdbcType=VARCHAR}, age = #{age,jdbcType=INTEGER}, phone = #{phone,jdbcType=VARCHAR}, department = #{department,jdbcType=VARCHAR}, type = #{type,jdbcType=VARCHAR}, price = #{price,jdbcType=DECIMAL}, state = #{state,jdbcType=INTEGER}, register_time = #{registerTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=INTEGER} </update> <select id="selectAlls" resultMap="BaseResultMap" > select id, name, sex, age, phone, department, type, price, state, register_time from tb_patient </select> <select id="selectAll" resultMap="BaseResultMap" > select id, name, sex, age, phone, department, type, price, state, register_time from tb_patient <where> <if test="name!=null and name!=''"> and name = #{name} </if> <if test="type!=null and type!=''"> and type = #{type} </if> <if test="dep!=null and dep!=''"> and department = #{dep} </if> </where> </select> <update id="update" parameterType="com.mhys.crm.entity.TbPatient" > update tb_patient set state=1 where id = #{id,jdbcType=INTEGER} </update> </mapper>
> com.mhys.crm.entity
TbPatient.java
package com.mhys.crm.entity; import java.math.BigDecimal; import java.util.Date; public class TbPatient { private Integer id; private String name; private String sex; private Integer age; private String phone; private String department; private String type; private BigDecimal price; private Integer state; private Date registerTime; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name == null ? null : name.trim(); } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex == null ? null : sex.trim(); } public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone == null ? null : phone.trim(); } public String getDepartment() { return department; } public void setDepartment(String department) { this.department = department == null ? null : department.trim(); } public String getType() { return type; } public void setType(String type) { this.type = type == null ? null : type.trim(); } public BigDecimal getPrice() { return price; } public void setPrice(BigDecimal price) { this.price = price; } public Integer getState() { return state; } public void setState(Integer state) { this.state = state; } public Date getRegisterTime() { return registerTime; } public void setRegisterTime(Date registerTime) { this.registerTime = registerTime; } @Override public String toString() { return "TbPatient [id=" + id + ", name=" + name + ", sex=" + sex + ", age=" + age + ", phone=" + phone + ", department=" + department + ", type=" + type + ", price=" + price + ", state=" + state + ", registerTime=" + registerTime + "]"; } }
> com.mhys.crm.service.impl
HospitalService.java
package com.mhys.crm.service.impl; import java.util.List; import javax.annotation.Resource; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import com.mhys.crm.dao.TbPatientMapper; import com.mhys.crm.entity.TbPatient; public class HospitalService { @Resource private TbPatientMapper tbPatientMapper; @RequestMapping("/select") public String getList(Model model) { List<TbPatient> selctAll = tbPatientMapper.selectAlls(); System.out.println(selctAll); model.addAttribute("selctAll", selctAll); return "info"; } @RequestMapping("/list") public String getAll(Model model, String name, String type, String dep) { List<TbPatient> selctAll = tbPatientMapper.selectAll(name, type, dep); System.out.println(name+"==="+type+"==="+dep); model.addAttribute("selctAll", selctAll); return "info"; } @RequestMapping("/upd") public String upDev(Model model,int id) { int update = tbPatientMapper.update(id); return "redirect:/select.do"; } @RequestMapping("/adds") public String adds(Model model) { return "addInfo"; } @RequestMapping("/insert") public String toaddDev(Model model,TbPatient tb) { tbPatientMapper.insert(tb); return "redirect:/select.do"; } }
=resource
> mybatis
SqlMapConfig.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <typeAliases> <package name="com.mhys.crm.entity"/> </typeAliases> </configuration>
> spring
applicationContext-dao.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd"> <context:property-placeholder location="classpath:database.properties"></context:property-placeholder> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"> <property name="driverClassName" value="${jdbc.driver}"></property> <property name="Url" value="${jdbc.url}"></property> <property name="username" value="${jdbc.username}"></property> <property name="password" value="${jdbc.password}"></property> </bean> <!-- 配置SqlSessionFactory --> <bean class="org.mybatis.spring.SqlSessionFactoryBean"> <!-- 設(shè)置MyBatis核心配置文件 --> <property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml" /> <!-- 設(shè)置數(shù)據(jù)源 --> <property name="dataSource" ref="dataSource" /> </bean> <!-- 配置Mapper掃描 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <!-- 設(shè)置Mapper掃描包 --> <property name="basePackage" value="com.mhys.crm.dao" /> </bean> <!-- 配置事務(wù)管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"></property> </bean> <!-- 開(kāi)啟注解方式管理AOP事務(wù) --> <tx:annotation-driven transaction-manager="transactionManager" /> </beans>
applicationContext-service.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd"> <!-- 配置Service掃描 --> <context:component-scan base-package="com" /> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"></property> </bean> <tx:annotation-driven transaction-manager="transactionManager" /> </beans>
spring-mvc.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <!-- 配置Controller掃描 --> <context:component-scan base-package="com.mhys.crm.controller" /> <mvc:annotation-driven /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> </beans>
> database.properties
jdbc.url=jdbc:mysql://localhost:3306/hospital_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false jdbc.username=root jdbc.password=123456 jdbc.driver=com.mysql.jdbc.Driver
=JSP頁(yè)面
> /WEB-INF/jsp/
addInfo.jsp
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>掛號(hào)</title> </head> <body> <form action="insert.do" method="post"> <table border="" cellspacing="" cellpadding=""> <tr> <td>姓名</td> <td><input type="text" name="name" value="" /></td> </tr> <tr> <td>性別</td> <td><input type="text" name="sex" value=""/></td> </tr> <tr> <td>年齡</td> <td><input type="text" name="age" value=""/></td> </tr> <tr> <td>電話</td> <td><input type="text" name="phone" value=""/></td> </tr> <tr> <td>醫(yī)師類別</td> <td><input type="text" name="department" value=""/></td> </tr> <tr> <td>價(jià)格</td> <td><input type="text" name="price" value=""/></td> </tr> <tr> <td>掛號(hào)時(shí)間</td> <td><input type="text" name="registerTime" value=""/></td> </tr> </table> <input type="submit" value="確定" /> </form> </body> </html>
info.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>醫(yī)院就診掛號(hào)系統(tǒng)</title> <style type="text/css"> form{ padding: 20px; } #warp{ margin:0 auto; width: 60% } </style> </head> <body> <h1 align="center">醫(yī)院就診掛號(hào)系統(tǒng)</h1> <div id="warp"> <form action="list.do"> 患者姓名:<input type="text" name="name"> 醫(yī)師類別: <select name="type"> <option value="" >=不限=</option> <option value="專家醫(yī)師" >專家醫(yī)師</option> <option value="普通醫(yī)師" >普通醫(yī)師</option> <option value="副主任醫(yī)師" >副主任醫(yī)師</option> </select> 科室:<input type="text" name="dep"> <input type="submit" value="查詢"> <input type="button" value="掛號(hào)" onclick="add()"> </form> <table style="margin-bottom: 30px;" width="100%" border="1px" cellpadding="11" cellspacing="0"> <tr> <th>編號(hào)</th> <th>姓名</th> <th>性別</th> <th>年齡</th> <th>電話</th> <th>科室</th> <th>醫(yī)師類別</th> <th>價(jià)格</th> <th>掛號(hào)時(shí)間</th> <th>狀態(tài)</th> <th>操作</th> </tr> <c:forEach var="list" items="${selctAll }"> <tr> <td>${list.id }</td> <td>${list.name }</td> <td>${list.sex }</td> <td>${list.age }</td> <td>${list.phone }</td> <td>${list.department }</td> <td>${list.type }</td> <td>${list.price }</td> <td><fmt:formatDate value="${list.registerTime }" pattern="yyyy-MM-dd"/></td> <td> <c:if test="${list.state==0}"> 未就診 </c:if> <c:if test="${list.state==1}"> 已就診 </c:if> </td> <td> <c:if test="${list.state==0}"> <a href="javascript:if(confirm('確實(shí)要核銷該掛號(hào)信息嗎?'))location='upd.do?id=${list.id }'">核銷</a> </c:if> <%-- <c:if test="${list.state==1}"> 已就診 </c:if> --%> </td> </tr> </c:forEach> </table> </div> <script type="text/javascript"> function add() { location.href="adds.do"; } </script> </body> </html>
index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE html> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path; %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>XXX系統(tǒng)</title> </head> <body> <script> window.location.href="<%=basePath%>/select.do"; </script> </body> </html>
到此這篇關(guān)于完整的醫(yī)院就診掛號(hào)系統(tǒng)基于Spring MVC + Spring + MyBatis的文章就介紹到這了,更多相關(guān)醫(yī)院掛號(hào)系統(tǒng)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- 基于java springboot + mybatis實(shí)現(xiàn)電影售票管理系統(tǒng)
- 基于Java Springboot + Vue + MyBatis實(shí)現(xiàn)音樂(lè)播放系統(tǒng)
- 基于JavaSwing+mysql開(kāi)發(fā)一個(gè)學(xué)生社團(tuán)管理系統(tǒng)設(shè)計(jì)和實(shí)現(xiàn)
- 基于java ssm springboot+mybatis酒莊內(nèi)部管理系統(tǒng)設(shè)計(jì)和實(shí)現(xiàn)
- 基于java Springboot實(shí)現(xiàn)教務(wù)管理系統(tǒng)詳解
- 基于java ssm springboot實(shí)現(xiàn)選課推薦交流平臺(tái)系統(tǒng)
- 基于java SSM springboot實(shí)現(xiàn)景區(qū)行李寄存管理系統(tǒng)
- 基于java SSM springboot實(shí)現(xiàn)抗疫物質(zhì)信息管理系統(tǒng)
- 前端?el-table?本地搜索的實(shí)現(xiàn)代碼
- 基于java+springboot+mybatis+laiyu實(shí)現(xiàn)學(xué)科競(jìng)賽管理系統(tǒng)
相關(guān)文章
Java并發(fā)之synchronized實(shí)現(xiàn)原理深入理解
這篇文章主要介紹了Java中synchronized實(shí)現(xiàn)原理詳解,涉及synchronized實(shí)現(xiàn)同步的基礎(chǔ),Java對(duì)象頭,Monitor,Mark Word,鎖優(yōu)化,自旋鎖等相關(guān)內(nèi)容,具有一定借鑒價(jià)值,需要的朋友可以參考下2021-08-08Java開(kāi)發(fā)深入分析講解二叉樹(shù)的遞歸和非遞歸遍歷方法
樹(shù)是一種重要的非線性數(shù)據(jù)結(jié)構(gòu),直觀地看,它是數(shù)據(jù)元素(在樹(shù)中稱為結(jié)點(diǎn))按分支關(guān)系組織起來(lái)的結(jié)構(gòu),很象自然界中的樹(shù)那樣。樹(shù)結(jié)構(gòu)在客觀世界中廣泛存在,如人類社會(huì)的族譜和各種社會(huì)組織機(jī)構(gòu)都可用樹(shù)形象表示,本篇介紹二叉樹(shù)的遞歸與非遞歸遍歷的方法2022-05-05聊聊Spring循環(huán)依賴三級(jí)緩存是否可以減少為二級(jí)緩存的情況
這篇文章主要介紹了聊聊Spring循環(huán)依賴三級(jí)緩存是否可以減少為二級(jí)緩存的情況,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2021-02-02SpringBoot整合Ldap的實(shí)現(xiàn)示例
本文主要介紹了SpringBoot整合Ldap的實(shí)現(xiàn)示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-11-11Java selenium處理極驗(yàn)滑動(dòng)驗(yàn)證碼示例
本篇文章主要介紹了Java selenium處理極驗(yàn)滑動(dòng)驗(yàn)證碼示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-10-10