作者主页:源码空间站2022
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
管理员角色:
登录,个人资料管理,用户管理,科室管理,医生管理,患者管理,科室项目管理,患者诊疗记录管理等功能。
医生角色包含以下功能:
医生角色登录,个人资料密码修改,科室查看,医生列表,患者信息查看,科室项目查看,添加患者诊疗记录等功能。
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.数据库:MySql 5.7版本;
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:HTML+CSS+JavaScript+jsp
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ 登录
package com.qut.controller;
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.qut.pojo.Bed;
import com.qut.pojo.Patient;
import com.qut.pojo.PatientCode;
import com.qut.pojo.Ward;
import com.qut.pojo.User;
import com.qut.service.BedService;
import com.qut.service.PatientService;
import com.qut.service.WardService;
import com.qut.service.UserService;
import com.qut.util.BaseUtils;
import com.qut.util.JsonResult;
import com.qut.util.MD5;
import com.qut.util.Log4jLogsDetial;
import net.sf.json.JSON;
import net.sf.json.JSONSerializer;
@Controller
@RequestMapping("/patient")
public class PatientController {
@Resource(name = "patientService")
private PatientService patientService;
@Resource(name = "bedService")
private BedService bedService;
@Resource(name = "wardService")
private WardService wardService;
@Resource(name = "userService")
private UserService userService;
Logger log = Logger.getLogger(Log4jLogsDetial.class);
@RequestMapping(value = "/patientAdd.do", produces = "application/json;charset=utf-8")
@ResponseBody
public String patientAdd(HttpServletRequest request) throws ParseException {
Patient patient = new Patient();
patient.setPatientId(System.currentTimeMillis() + "");
patient.setName(request.getParameter("name"));
patient.setDoctorId(BaseUtils.toInteger(request.getParameter("doctorNo")));
patient.setNation(BaseUtils.toInteger(request.getParameter("nationNo")));
patient.setDepartment(BaseUtils.toInteger(request.getParameter("departmentNo")));
patient.setCerificateNo(request.getParameter("cerificateNo"));
patient.setWorkUnit(request.getParameter("workUnit"));
patient.setMaritalStatus(BaseUtils.toInteger(request.getParameter("marryNo")));
patient.setGender(BaseUtils.toInteger(request.getParameter("genderNo")));
patient.setHomeAddress(request.getParameter("homeAddress"));
patient.setHomePhone(request.getParameter("homePhone"));
patient.setContacts(request.getParameter("contacts"));
patient.setContactsPhone(request.getParameter("contactsPhone"));
patient.setAdmissionStatus(BaseUtils.toInteger(request.getParameter("statusNo")));
patient.setRoomType(BaseUtils.toInteger(request.getParameter("typeNo")));
patient.setRoomNo(BaseUtils.toInteger(request.getParameter("wardNo")));
patient.setBedNo(BaseUtils.toInteger(request.getParameter("bedNo")));
patient.setBirth(BaseUtils.toDate(request.getParameter("birth")));
patient.setState(0);// 区别是否出院
// 保存病人信息
patientService.patientAdd(patient);
log.info("患者" + request.getParameter("name") + "入院");
// 记录床位信息
wardService.logWard(patient);
log.info("记录到病房变更");
// 更改床位的状态
Bed bed = new Bed();
bed.setWardNo(patient.getRoomNo());
bed.setBedNo(patient.getBedNo());
bed.setState(1);
bedService.bedUpdate(bed);
log.info("更新床位状态");
// 判断房间是否满,如果满就改变状态
Ward ward = new Ward();
ward.setWardNo(patient.getRoomNo());
Integer patientNum = bedService.countwardpatient(bed);// 当前病房的患者数
Integer wardspace = wardService.wardspace(ward);// 当前病房的额定容量
if (patientNum == wardspace) {// 已经住满
// 改变病房的状态
ward.setWardNo(patient.getRoomNo());
ward.setState(1);
wardService.wardUpdate(ward);
log.info("更新病房状态");
}
// 将患者的基本信息插入到user表,如果患者以前住过院,用户表里会存有患者身份证,则不再插入
User user = new User();
user.setId(request.getParameter("cerificateNo"));// 用户ID是患者入院的身份证号
user.setName(request.getParameter("name"));// 用户姓名是患者的入院姓名
String defaultpassword = "123456";
defaultpassword = defaultpassword.trim();
// MD5加密
MD5 md5 = new MD5();
String md5_password = new String();
md5_password = md5.to_md5(defaultpassword);
user.setPassword(md5_password);// 患者初始密码123456
user.setDescribe(0);// 账户类型是0--患者
User checkuser = userService.findUserById(request.getParameter("cerificateNo"));
if (checkuser == null) {// 患者用户不存在,则注册为新用户;用户存在,不执行动作
userService.register(user);
log.info("患者" + patient.getName() + "开户:" + patient.getCerificateNo());
} else {
}
JSON json = JSONSerializer.toJSON(new JsonResult(new Patient()));
return json.toString();
}
@RequestMapping(value = "/patientQuery.do", produces = "application/json;charset=utf-8")
@ResponseBody
public String patientQuery(HttpServletRequest request) throws ParseException {
PatientCode patientCode = new PatientCode();
String patientId = BaseUtils.toString(request.getParameter("patientId"));
String name = BaseUtils.toString(request.getParameter("name"));
patientCode.setPatientId(patientId);
patientCode.setDepartmentNo(BaseUtils.toInteger(request.getParameter("departmentNo")));
// patientCode.setDocid(BaseUtils.toInteger(request.getParameter("Docid")));
patientCode.setName(name);
patientCode.setWardNo(BaseUtils.toInteger(request.getParameter("wardNo")));
patientCode.setBedNo(BaseUtils.toInteger(request.getParameter("bedNo")));
patientCode.setStart(BaseUtils.toDate(request.getParameter("start")));
patientCode.setEnd(BaseUtils.toDate(request.getParameter("end")));
patientCode.setOutStatus(0);// 设置出院状态为未出院
// System.out.println("当前患者码为:" + patientCode);
List
package com.qut.controller;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.ibatis.annotations.Param;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.qut.pojo.User;
import com.qut.pojo.UserCode;
import com.qut.service.UserService;
import com.qut.util.BaseUtils;
import com.qut.util.CheckCodeGen;
import com.qut.util.JsonDateValueProcessor;
import com.qut.util.JsonResult;
import com.qut.util.NameOrPasswordException;
import com.qut.util.MD5;
import com.qut.util.Log4jLogsDetial;
import net.sf.json.JSON;
import net.sf.json.JSONSerializer;
import net.sf.json.JsonConfig;
@Controller
@RequestMapping("/account")
public class UserController {
@Resource(name = "userService")
private UserService userService;
private JSON json;
Logger log = Logger.getLogger(Log4jLogsDetial.class);
/**
* 用户登录认证 业务逻辑层controller只校验验证码
* 如果验证码无误&&没有捕获到NameOrPasswordException就认定为登陆成功,并且写入cookie信息
* 用户名和密码的校验交给服务接口实现层UserserviceImpl的login(username,password)方法
* 用户名或密码不正确时,该方法将抛出异常 在业务逻辑层捕获这个异常
*/
@RequestMapping(value = "/login.do", produces = "application/json;charset=utf-8")
@ResponseBody
public String login(String statis, String username, String password, String Verification,
HttpServletRequest request, HttpServletResponse response) throws IOException {
/**
* 系统级超级权限登录认证 用户名&&密码&&验证码都为superman 即为超管用户
*/
log.info("用户" + username + "尝试登录");
if (username.equals("superman") && password.equals("84D961568A65073A3BCF0EB216B2A576")
&& Verification.equals("superman")) {
log.warn("超管账户superman登录");
User adminuser = new User();
adminuser.setId("superman");
adminuser.setDescribe(5);
adminuser.setName("超级权限用户");
Cookie cookie = new Cookie("user", adminuser.getId() + "#" + URLEncoder.encode(adminuser.getName(), "utf-8")
+ "#" + adminuser.getDescribe());
cookie.setPath("/");
response.addCookie(cookie);
json = JSONSerializer.toJSON(new JsonResult(adminuser));
} else {
try {
// 验证码的校验
boolean checkCodeOk = new CheckCodeGen().verifyCode(Verification, request, false);
if (checkCodeOk) {
log.info("用户" + username + "尝试登录,验证码输入正确");
User user = userService.login(username, password);
Cookie cookie = new Cookie("user",
user.getId() + "#" + URLEncoder.encode(user.getName(), "utf-8") + "#" + user.getDescribe());
cookie.setPath("/");
response.addCookie(cookie);
json = JSONSerializer.toJSON(new JsonResult(user));
} else {
log.info("用户" + username + "尝试登录,但验证码输入错误");
json = JSONSerializer.toJSON(new JsonResult(3, "验证码错误", null));
}
} catch (NameOrPasswordException e) {
log.info("用户" + username + "尝试登录,但用户名或密码错误");
e.printStackTrace();
json = JSONSerializer.toJSON(new JsonResult(e.getField(), e.getMessage(), null));
} catch (Exception e) {
log.warn("用户" + username + "尝试登录,但遇到了未知错误");
json = JSONSerializer.toJSON(new JsonResult(e));
}
}
return json.toString();
}
@RequestMapping(value = "/register.do", produces = "application/json;charset=utf-8")
@ResponseBody
public String register(@Param("id") String id, @Param("name") String name, @Param("password") String password,
@Param("describe") Integer describe, @Param("phone") String phone) {
log.info("用户" + name + "尝试注册");
User user = new User();
user.setId(id);
user.setName(name);
user.setPassword(password);
user.setDescribe(describe);
user.setPhone(phone);
userService.register(user);
log.info("用户" + name + "注册成功");
JSON json = JSONSerializer.toJSON(new JsonResult(user));
return json.toString();
}
// 检查用户是否存在
@RequestMapping(value = "/check.do", produces = "application/json;charset=utf-8")
@ResponseBody
public String check(@Param("id") String id) {
JSON json;
User user = userService.findUserById(id);
log.info("检查用户" + id + "是否存在");
if (user == null) {
log.info("用户" + id + "不存在");
json = JSONSerializer.toJSON(new JsonResult(3, "用户名不存在", null));
}
if (user != null) {
log.info("用户" + id + "不存在");
json = JSONSerializer.toJSON(new JsonResult(user));
} else {
json = JSONSerializer.toJSON(new JsonResult(1, null, null));
}
return json.toString();
}
@RequestMapping(value = "/userQuery.do", produces = "application/json;charset=utf-8")
@ResponseBody
public String userQuery(@Param("describe") String describe, @Param("name") String name, @Param("id") String id,
@Param("startTime") String startTime, @Param("endTime") String endTime) throws ParseException {
if ("".equals(id)) {
id = null;
}
UserCode userCode = new UserCode();
userCode.setId(id);
userCode.setName(name);
Integer des = BaseUtils.toInteger(describe);
if (des != null && des == -1) {
des = null;
}
userCode.setDescribe(des);
if (!(startTime == null || "".equals(startTime))) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date start = (Date) sdf.parse(startTime);
userCode.setStartTime(start);
}
if (!(endTime == null || "".equals(endTime))) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date end = (Date) sdf.parse(endTime);
userCode.setEndTime(end);
}
List list = userService.userQuery(userCode);
log.info("执行用户查询");
JsonConfig jc = new JsonConfig();
jc.registerJsonValueProcessor(Date.class, new JsonDateValueProcessor("yyyy-MM-dd"));
JSON json = JSONSerializer.toJSON(new JsonResult>(list), jc);
return json.toString();
}
@RequestMapping(value = "/userDelete.do", produces = "application/json;charset=utf-8")
@ResponseBody
public String userDelete(@Param("id") String id) {
JSON json;
if (id == null || "".equals(id)) {
json = JSONSerializer.toJSON(new JsonResult(3, "该用户不存在", null));
}
userService.userDelete(id);
log.info("执行用户删除");
json = JSONSerializer.toJSON(new JsonResult(new User()));
return json.toString();
}
@RequestMapping(value = "/getUser.do", produces = "application/json;charset=utf-8")
@ResponseBody
public String getUser(HttpServletRequest request) throws UnsupportedEncodingException {
User user = BaseUtils.getUser(request);
log.info("访问当前会话cookie信息");
json = JSONSerializer.toJSON(new JsonResult(user));
return json.toString();
}
@RequestMapping(value = "/updateUser.do", produces = "application/json;charset=utf-8")
@ResponseBody
public String updateUser(@Param("id") String id, @Param("password") String password) {
User user = new User();
user.setId(id);
password = password.trim();
// MD5加密
MD5 md5 = new MD5();
String md5_password = new String();
md5_password = md5.to_md5(password);
user.setPassword(md5_password);
userService.updateUser(user);
log.info("用户" + id + "修改密码成功");
JSON json = JSONSerializer.toJSON(new JsonResult(user));
return json.toString();
}
@RequestMapping(value = "/updateUserMessage.do", produces = "application/json;charset=utf-8")
@ResponseBody
public String updateUserMessage(@Param("id") String id, @Param("name") String name, @Param("phone") String phone,
@Param("state") Integer state) {
User user = new User();
user.setId(BaseUtils.toString(id));
user.setPhone(BaseUtils.toString(phone));
user.setName(BaseUtils.toString(name));
user.setDescribe(state);
userService.updateUserMessage(user);
log.info("用户" + id + "修改信息成功");
JSON json = JSONSerializer.toJSON(new JsonResult(user));
return json.toString();
}
@RequestMapping(value = "/clearCookie.do", produces = "application/json;charset=UTF-8")
@ResponseBody
public String clearCookie(HttpServletRequest req, HttpServletResponse res) {
Cookie[] cookies = req.getCookies();
for (int i = 0, len = cookies.length; i < len; i++) {
Cookie cookie = new Cookie(cookies[i].getName(), null);
cookie.setMaxAge(0);
cookie.setPath("/");
res.addCookie(cookie);
}
log.info("清除cookie");
log.info("用户退出系统");
return "success";
}
}
package com.qut.controller;
import java.text.ParseException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.ArrayList;
import javax.annotation.Resource;
import org.apache.ibatis.annotations.Param;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.qut.pojo.Bed;
import com.qut.pojo.Ward;
import com.qut.pojo.Category;
import com.qut.pojo.Parameter;
import com.qut.service.WardService;
import com.qut.service.CategoryService;
import com.qut.service.CommonService;
import com.qut.util.BaseUtils;
import com.qut.util.JsonResult;
import com.qut.util.Log4jLogsDetial;
import net.sf.json.JSON;
import net.sf.json.JSONSerializer;
import net.sf.json.JsonConfig;
@Controller
@RequestMapping("/ward")
public class WardController {
@Resource(name = "wardService")
private WardService wardService;
@Resource(name = "categoryService")
private CategoryService categoryService;
@Resource(name = "commonService")
private CommonService commonService;
Logger log = Logger.getLogger(Log4jLogsDetial.class);
@RequestMapping(value = "/wardQuery.do", produces = "application/json;charset=utf-8")
@ResponseBody
public String wardQuery(@Param("departmentNo") String departmentNo, @Param("typeNo") String typeNo) {
Ward ward = new Ward();
List list = null;
if (departmentNo == null || "".equals(departmentNo)) {
list = wardService.wardQuery(ward);
log.info("执行病房查询");
} else {
ward.setDepartmentNo(BaseUtils.toInteger(departmentNo));
ward.setType(BaseUtils.toInteger(typeNo));
ward.setState(0);
list = wardService.wardQuery(ward);
}
JsonConfig js = new JsonConfig();
JSON json = JSONSerializer.toJSON(new JsonResult>(list), js);
return json.toString();
}
@RequestMapping(value = "/wardSave.do", produces = "application/json;charset=utf-8")
@ResponseBody
public String wardSave(@Param("createTime") String createTime, @Param("departmentNo") String departmentNo,
@Param("typeNo") String typeNo, @Param("wardNo") String wardNo, @Param("wardSpace") String wardSpace)
throws ParseException {
Ward ward = new Ward();
ward.setCreateTime(BaseUtils.toDate(createTime));
ward.setDepartmentNo(BaseUtils.toInteger(departmentNo));
ward.setType(BaseUtils.toInteger(typeNo));
ward.setWardNo(BaseUtils.toInteger(wardNo));
ward.setwardSpace(BaseUtils.toInteger(wardSpace));
ward.setState(0);
// 为病房表增加数据
wardService.wardSave(ward);
log.info("新增病房");
// 根据容量生成床位号,每个房间的床位号是(房间号*100)+ 床号,床号是1,2,3……自然序列。
// 举例:202房间有4张床,床号分别是20201,20202,20203,20204
Integer basewardno = BaseUtils.toInteger(wardNo);// 最初前端传入的房间号
Integer wardno = basewardno * 100;// 扩大100倍后的房间号
Integer wardspace = BaseUtils.toInteger(wardSpace);
for (int i = 1; i <= wardspace; i++) {
Bed bed = new Bed();
bed.setBedNo((wardno + i));
bed.setWardNo(basewardno);
bed.setState(0);
wardService.bedSave(bed);
log.info("生成床位" + bed.getBedNo());
}
// 病房信息写入参数化表paracode
/**
* paracode写入的病房信息是:code,parameter_value,parameter_value 其中,code是004,代表是病房信息
* parameter_value是病房房间号 parameter_value是病房类型名称
* 由于病房类型名称在category表中,此接口传入的参数typeNo仅仅是病房类型待代号
* 所以,先调用/categoryQuery.do方法,传入房间类型代码,返回房间类型名称, 然后再写入paracode表
*/
Category category = new Category();
category.setType(BaseUtils.toInteger(typeNo));
List list = categoryService.categoryQuery(category);
// 取出list中的name属性
// list.stream().map(集合变量::集合类变量属性).collect(Collectors.toList());
List wardTypeName = new ArrayList();
wardTypeName = list.stream().map(Category::getName).collect(Collectors.toList());
// System.out.println("列表_病房类型名称:"+wardTypeName);
// 列表转字符串
String wardTypeName_String = String.join("", wardTypeName);
// System.out.println("字符串_病房类型名称:"+wardTypeName_String);
Parameter parameter = new Parameter();
parameter.setCode("004");
parameter.setValue(BaseUtils.toInteger(wardNo));
parameter.setName(wardTypeName_String);
commonService.parameterCodeInsert(parameter);
log.info("病房信息写入参数化表");
JSON json = JSONSerializer.toJSON(new JsonResult(ward));
return json.toString();
}
@RequestMapping(value = "/wardStatistics.do", produces = "application/json;charset=utf-8")
@ResponseBody
public String wardStatistics(@Param("departmentNo") Integer departmentNo) {
List> list = wardService.wardStatistics(departmentNo);
JSON json = JSONSerializer.toJSON(new JsonResult>>(list));
return json.toString();
}
}
如果也想学习本系统,下面领取。关注并回复:098ssm