Java项目:SSM简单医院信息管理系统

作者主页:夜未央5788

 简介: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/ 登录

运行截图

管理员角色

 

 

 

 

 

 

 

医生角色

 

 

 

 

 

 

 相关代码

PatientController

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<Patient>(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<Map<String, Object>> list = patientService.patientQuery(patientCode);
		log.info("患者查询");
		for (Map<String, Object> map : list) {// 此处不对从库中取出的时间做toString转化会报java.lang.IllegalArgumentException
			String admissionTime = map.get("admissionTime").toString();
			map.put("admissionTime", admissionTime);
			String birth = map.get("birth").toString();
			map.put("birth", birth);
		}
		JSON json = JSONSerializer.toJSON(new JsonResult<List<Map<String, Object>>>(list));
		return json.toString();
	}

	@RequestMapping(value = "/patientQueryBycerificateNo.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String patientQueryBycerificateNo(HttpServletRequest request) throws ParseException {
		String patientcerificateNo = BaseUtils.toString(request.getParameter("cerificateNo"));
		List<Map<String, Object>> list = patientService.patientQueryBycerificateNo(patientcerificateNo);
		log.info("身份证" + patientcerificateNo + "患者查询信息");
		for (Map<String, Object> map : list) {// 此处不对从库中取出的时间做toString转化会报java.lang.IllegalArgumentException
			String admissionTime = map.get("admissionTime").toString();
			map.put("admissionTime", admissionTime);
			String birth = map.get("birth").toString();
			map.put("birth", birth);
			if (map.get("leaveTime") != null) {
				String leaveTime = map.get("leaveTime").toString();
				map.put("leaveTime", leaveTime);
			} else {
				String leaveTime = "未出院";
				map.put("leaveTime", leaveTime);
			}
		}
		JSON json = JSONSerializer.toJSON(new JsonResult<List<Map<String, Object>>>(list));
		// System.out.println("返回的json是:"+json.toString());
		return json.toString();
	}

	/**
	 * 检查新住院的这个患者是否有未出院的记录
	 */
	@RequestMapping(value = "/patientcheck.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String patientcheck(@Param("cerificateNo") String cerificateNo) throws ParseException {
		JSON json = null;
		PatientCode patientCode = new PatientCode();
		String patientCerificateNo = BaseUtils.toString(cerificateNo);
		patientCode.setCerificateNo(patientCerificateNo);
		patientCode.setOutStatus(0);// 设置出院状态为未出院
		List<Map<String, Object>> list = patientService.patientQuery(patientCode);
		log.info("执行患者检查");
		if (list.size() == 0) {
			json = JSONSerializer.toJSON(new JsonResult<User>(1, "可以住院", null));
			log.info("患者" + cerificateNo + "可以住院");
		} else if (list.size() > 0) {
			json = JSONSerializer.toJSON(new JsonResult<User>(2, "当前患者还未出院", null));
			log.info("患者" + cerificateNo + "未出院");
		}
		return json.toString();
	}

	@RequestMapping(value = "/patientUpdate.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String patientUpdate(HttpServletRequest request) {
		String patientId = BaseUtils.toString(request.getParameter("patientId"));
		Integer departmentNo = BaseUtils.toInteger(request.getParameter("departmentNo"));
		Integer typeNo = BaseUtils.toInteger(request.getParameter("typeNo"));
		Integer new_ward_No = BaseUtils.toInteger(request.getParameter("wardNo"));
		Integer new_bed_No = BaseUtils.toInteger(request.getParameter("bedNo"));
		Integer doctorNo = BaseUtils.toInteger(request.getParameter("doctorNo"));
		Integer old_bed_Num = BaseUtils.toInteger(request.getParameter("ybed"));
		Integer old_ward_Num = BaseUtils.toInteger(request.getParameter("yroom"));
		Patient patient = new Patient();
		patient.setPatientId(patientId);
		patient.setDepartment(departmentNo);
		patient.setRoomType(typeNo);
		patient.setBedNo(new_bed_No);
		patient.setRoomNo(new_ward_No);
		patient.setDoctorId(doctorNo);

		// 更新病人信息到病人信息表(patient)
		patientService.patientUpdate(patient);
		log.info("患者" + patient.getName() + "转病房:更新患者信息");
		// 记录改变床位记录到病房变更表(wardupdate)
		wardService.logWard(patient);
		log.info("患者" + patient.getName() + "转病房:记录到病房转移");
		// 改变原床位的状态为可住到床位表(bed)
		Bed old_bed = new Bed();
		old_bed.setWardNo(old_ward_Num);
		old_bed.setBedNo(old_bed_Num);
		old_bed.setState(0);
		bedService.bedUpdate(old_bed);
		log.info("患者" + patient.getName() + "转病房:更新旧床位状态");
		// 改变新床位的状态为已住
		Bed new_bed = new Bed();
		new_bed.setWardNo(new_ward_No);
		new_bed.setBedNo(new_bed_No);
		new_bed.setState(1);
		bedService.bedUpdate(new_bed);
		log.info("患者" + patient.getName() + "转病房:更新新床位状态");
		/**
		 * 改变原病房状态,如果之前为已满,则改为未满
		 */
		Ward ward1 = wardService.wardQueryById(old_ward_Num);
		if (ward1.getState() == 1) {
			ward1.setWardNo(old_ward_Num);
			ward1.setState(0);
			wardService.wardUpdate(ward1);
			log.info("患者" + patient.getName() + "转病房:更新旧病房状态");
		}

		/**
		 * 改变新病房状态,如果满了,就把状态改为已满
		 */
		Ward ward2 = new Ward();
		ward2.setWardNo(new_ward_No);
		Integer patientNum = bedService.countwardpatient(new_bed);// 当前病房的患者数
		Integer wardspace = wardService.wardspace(ward2);// 当前病房的额定容量
		if (patientNum == wardspace) {// 已经住满
			// 改变病房的状态
			ward2.setState(1);
			wardService.wardUpdate(ward2);
			log.info("患者" + patient.getName() + "转病房:更新新病房状态");
		}

		JSON json = JSONSerializer.toJSON(new JsonResult<Patient>(patient));
		return json.toString();
	}

	@RequestMapping(value = "/patientLeave.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String patientLeave(String patientId, Integer bedNo, Integer roomNo) {
		// 标记patient表中的leaveState状态为1,标记为出院
		patientService.patientLeave(patientId);
		log.info("患者" + patientId + "出院");
		// 改变原床位的状态为可住
		Bed bed = new Bed();
		bed.setWardNo(roomNo);
		bed.setBedNo(bedNo);
		bed.setState(0);
		bedService.bedUpdate(bed);// 将bed表中的roomNum&&bedNo行的State标记为0,床位设置为未使用
		log.info("患者" + patientId + "出院:更新床位状态");
		// 判断原病房是否已满
		Ward ward = wardService.wardQueryById(roomNo);
		if (ward.getState() == 1) {// 如果之前已经住满了,则把新状态置为未住满,state=0
			ward.setState(0);
			wardService.wardUpdate(ward);
			log.info("患者" + patientId + "出院:更新病房状态");
		}

		JSON json = JSONSerializer.toJSON(new JsonResult<Patient>(new Patient()));
		return json.toString();
	}

	@RequestMapping(value = "/jiesuan.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String jiesuan(String patientId) {
		patientService.jiesuan(patientId);
		log.info("患者" + patientId + "结算");
		JSON json = JSONSerializer.toJSON(new JsonResult<Patient>(new Patient()));
		return json.toString();
	}

	@RequestMapping(value = "/leftFind.do", produces = "application/json;charset=utf-8")
	@ResponseBody // 出院记录查询
	public String leftFind(String patientId, String patientName, String inStart, String inEnd, String outStart,
			String outEnd) throws ParseException {
		PatientCode patientCode = new PatientCode();
		patientCode.setPatientId(BaseUtils.toString(patientId));
		patientCode.setName(BaseUtils.toString(patientName));
		patientCode.setStart(BaseUtils.toDate(inStart));
		patientCode.setEnd(BaseUtils.toDate(inEnd));
		patientCode.setOutStart(BaseUtils.toDate(outStart));
		patientCode.setOutEnd(BaseUtils.toDate(outEnd));
		patientCode.setOutStatus(1);
		List<Map<String, Object>> list = patientService.patientQuery(patientCode);
		log.info("患者查询");
		for (Map<String, Object> map : list) {
			String leaveTime = map.get("leaveTime").toString();
			map.put("leaveTime", leaveTime);
			String admissionTime = map.get("admissionTime").toString();
			map.put("admissionTime", admissionTime);
			String birth = map.get("birth").toString();
			map.put("birth", birth);
		}
		JSON json = JSONSerializer.toJSON(new JsonResult<List<Map<String, Object>>>(list));
		return json.toString();
	}

	@RequestMapping(value = "/patientStatistics.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String patientStatistics(String startTime, String endTime) throws ParseException {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startTime", BaseUtils.toDate(startTime));
		map.put("endTime", BaseUtils.toDate(endTime));
		List<Map<String, Object>> list = patientService.patientStatistics(map);
		JSON json = JSONSerializer.toJSON(new JsonResult<List<Map<String, Object>>>(list));
		return json.toString();
	}

}

UserController

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<User>(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>(user));
				} else {
					log.info("用户" + username + "尝试登录,但验证码输入错误");
					json = JSONSerializer.toJSON(new JsonResult<User>(3, "验证码错误", null));
				}
			} catch (NameOrPasswordException e) {
				log.info("用户" + username + "尝试登录,但用户名或密码错误");
				e.printStackTrace();
				json = JSONSerializer.toJSON(new JsonResult<User>(e.getField(), e.getMessage(), null));
			} catch (Exception e) {
				log.warn("用户" + username + "尝试登录,但遇到了未知错误");
				json = JSONSerializer.toJSON(new JsonResult<User>(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>(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<User>(3, "用户名不存在", null));
		}
		if (user != null) {
			log.info("用户" + id + "不存在");
			json = JSONSerializer.toJSON(new JsonResult<User>(user));
		} else {
			json = JSONSerializer.toJSON(new JsonResult<User>(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<User> 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<User>>(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<User>(3, "该用户不存在", null));
		}
		userService.userDelete(id);
		log.info("执行用户删除");
		json = JSONSerializer.toJSON(new JsonResult<User>(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>(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>(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>(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";
	}
}

WardController

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<Ward> 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<Ward>>(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<Category> list = categoryService.categoryQuery(category);
		// 取出list中的name属性
		// list.stream().map(集合变量::集合类变量属性).collect(Collectors.toList());
		List<String> wardTypeName = new ArrayList<String>();
		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>(ward));
		return json.toString();
	}

	@RequestMapping(value = "/wardStatistics.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String wardStatistics(@Param("departmentNo") Integer departmentNo) {
		List<Map<String, Object>> list = wardService.wardStatistics(departmentNo);
		JSON json = JSONSerializer.toJSON(new JsonResult<List<Map<String, Object>>>(list));
		return json.toString();
	}
}

如果也想学习本系统,下面领取。关注并回复:098ssm 

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
 《Java web医院分诊挂号管理系统》该项目采用技术jsp、SpringMVC、spring,hibernate,tomcat服务器、mysql数据库 开发工具eclipse,项目含有源码、论文、配套开发软件、软件安装教程、项目发布教程分诊管理主要实现患者信息录入,分诊,排队等功能。    具体实现以下功能:   1 患者查询功能:为了方便医生查找患者等信息,将所有患者信息按照需要进行分类。这样医生就能很方便的找到自己需要的信息。   2 添加功能:管理员可以通过填写表格的形式输入患者姓名,联系电话等相关信息。系统可以自动避免重复信息。   3 修改功能:管理员可以对数据库中的信息进行修改。系统能够通过管理员给出的条件查找出所要修改的信息,对修改后的信息进行保存,并自动查找是否是重复信息。   4 删除功能:管理员可以对数据进行删除操作。系统能够通过管理员给出的条件查找出要删除的信息,并提示是否确定删除,如果确定删除,则把相关信息从数据库中删除掉。   5 管理员查询功能:管理员可以通过条件选择查询所有信息,并进行排序。 课程目标:    1、学会各类开发软件安装、项目导入以及项目发布,含项目源码,需求文档,配套软件等    2、该项目主要功能完善,主要用于简历项目经验丰富,以及毕业设计或者二次开发    3、提供项目源码,设计文档、数据库sql文件以及所有配套软件,按照教程即可轻松实现项目安装部署  本课程为素材版,需要实战版代码讲解教程的同学可以点击如下链接:java项目实战之电商系统全套(前台和后台)(java毕业设计ssm框架项目)https://edu.csdn.net/course/detail/25771java项目之oa办公管理系统(java毕业设计)https://edu.csdn.net/course/detail/23008java项目之hrm人事管理项目java毕业设计)https://edu.csdn.net/course/detail/23007JavaWeb项目实战之点餐系统前台https://edu.csdn.net/course/detail/20543JavaWeb项目实战之点餐系统后台https://edu.csdn.net/course/detail/19572JavaWeb项目实战之宿舍管理系统https://edu.csdn.net/course/detail/26721JavaWeb项目实战之点餐系统全套(前台和后台)https://edu.csdn.net/course/detail/20610java项目实战之电子商城后台(java毕业设计SSM框架项目)https://edu.csdn.net/course/detail/25770java美妆商城项目|在线购书系统java毕业设计项目ssm版)https://edu.csdn.net/course/detail/23989系统学习课程:JavaSE基础全套视频(环境搭建 面向对象 正则表达式 IO流 多线程 网络编程 java10https://edu.csdn.net/course/detail/26941Java Web从入门到电商项目实战挑战万元高薪(javaweb教程)https://edu.csdn.net/course/detail/25976其他素材版(毕业设计或课程设计)项目:点击老师头像进行相关课程学习

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜未央5788

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值