当前位置:   article > 正文

基于javaweb+mysql的ssm医院住院管理系统(java+ssm+jsp+bootstrap+mysql)

基于javaweb+mysql的ssm医院住院管理系统(java+ssm+jsp+bootstrap+mysql)

基于javaweb+mysql的ssm医院住院管理系统(java+ssm+jsp+bootstrap+mysql)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb的SSM医院住院管理系统(java+ssm+jsp+bootstrap+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.数据库:MySql 5.7版本; 6.是否Maven项目:否;

技术栈

  1. 后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+CSS+JavaScript+jquery+bootstrap

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ 登录
	/**
	 * 获取随机的字
	 */
	class CheckCode implements Serializable {
		private static final long serialVersionUID = 1L;
		String code;
		long createTime;
		boolean enable;
	}
}

@Controller
@RequestMapping("/sign")
public class SignController {
	@Resource(name = "signService")
	private SignService signService;
	Logger log = Logger.getLogger(Log4jLogsDetial.class);

	@RequestMapping(value = "/signSave.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String signSave(@Param("patientId") String patientId, @Param("measureTime") String measureTime,
			@Param("temperature") String temperature, @Param("pulse") String pulse, @Param("wardNo") String breathing,
			@Param("bloodSugar") String bloodSugar, @Param("bloodPressure") String bloodPressure,
			@Param("vein") String vein, @Param("remarks") String remarks, HttpServletRequest request)
			throws ParseException, UnsupportedEncodingException {
		Sign sign = new Sign();
		sign.setPatientId(BaseUtils.toString(patientId));// 患者ID
		sign.setMeasureTime(BaseUtils.toDates(measureTime));// 护理时间
		sign.setTemperature(BaseUtils.toFloat(temperature));// 体温
		sign.setPulse(BaseUtils.toInteger(pulse));// 心率
		sign.setBreathing(BaseUtils.toInteger(breathing));// 呼吸
		sign.setBloodSugar(BaseUtils.toFloat(bloodSugar));// 血糖
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
			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")));
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
		 * 由于病房类型名称在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();
	}
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
	private CostService costService;
	Logger log = Logger.getLogger(Log4jLogsDetial.class);

	@RequestMapping(value = "/costAdd.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String costAdd(@Param("patientId") String patientId, @Param("types") String types,
			@Param("account") Float account, @Param("userId") String userId) {
		Cost cost = new Cost();
		cost.setAccount(account);
		cost.setPatientId(patientId);
		cost.setType(types);
		cost.setUserId(userId);
		String id = System.currentTimeMillis() + "";
		cost.setId(id);
		costService.costAdd(cost);
		log.info("患者" + patientId + "预交费" + cost.getAccount() + "元,收款方为" + cost.getUserId());
		JSON json = JSONSerializer.toJSON(new JsonResult<Cost>(cost));
		return json.toString();
	}

	@RequestMapping(value = "/costQuery.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String costQuery(@Param("id") String id, @Param("patientId") String patientId, @Param("types") String types,
			@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime,
			@Param("patientName") String patientName) throws ParseException {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("patientId", BaseUtils.toString(patientId));
		map.put("startTime", BaseUtils.toDate(startTime));
		map.put("endTime", BaseUtils.toDate(endTime));
		map.put("patientName", BaseUtils.toString(patientName));
		List<Map<String, Object>> list = costService.costQuery(map);
		log.info("患者" + id + "查询消费明细");
		for (Map<String, Object> mapp : list) {
			String costTime = mapp.get("costTime").toString();
			mapp.put("costTime", costTime);
		}
		JSON json = JSONSerializer.toJSON(new JsonResult<List<Map<String, Object>>>(list));
		return json.toString();
	}

	@RequestMapping(value = "/costTotal.do", produces = "application/json;charset=utf-8")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
		return json.toString();
	}

	@RequestMapping(value = "/grantAdd.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String grantAdd(HttpServletRequest request) throws UnsupportedEncodingException {
		Grant grant = new Grant();
		grant.setDrugId(BaseUtils.toString(request.getParameter("drugsId")));
		grant.setDrugName(BaseUtils.toString(request.getParameter("drugsName")));
		grant.setDrugPrice(BaseUtils.toFloat(request.getParameter("price")));
		grant.setDrugCount(BaseUtils.toInteger(request.getParameter("num")));
		grant.setPatientId(BaseUtils.toString(request.getParameter("patientId")));
		grant.setPatientName(BaseUtils.toString(request.getParameter("patientName")));
		grant.setGrantUserId(BaseUtils.getUser(request).getId());
		grant.setGrantUserName(BaseUtils.getUser(request).getName());
		// 存入发放表grantDrug
		drugsService.grantAdd(grant);
		log.info("医生" + grant.getGrantUserName() + "为患者" + grant.getPatientName() + "发放了" + grant.getDrugName() + ",数量为"
				+ grant.getDrugCount());
		// 减少库存的量
		drugsService.stockUpdate(grant);
		log.info("更新库存");
		JSON json = JSONSerializer.toJSON(new JsonResult<Grant>(grant));
		return json.toString();
	}

	@RequestMapping(value = "/grantQuery.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String grantQuery(@Param("patientId") String patientId) {
		List<Stock> list = drugsService.grantQuery(patientId);
		log.info("患者" + patientId + "查询了用药历史");
		JSON json = JSONSerializer.toJSON(new JsonResult<List<Stock>>(list));
		return json.toString();
	}

	@RequestMapping(value = "/grantDrugsFindByPatienId.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String grantDrugsFindByPatienId(HttpServletRequest request) throws ParseException {
		String patientId = BaseUtils.toString(request.getParameter("patientId"));
		List<grantDrugs> list = grantdrugsService.grantDrugsFindByPatienId(patientId);
		System.out.println("返回结果:" + list);
		JSON json = JSONSerializer.toJSON(new JsonResult<List<grantDrugs>>(list));
		return json.toString();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
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();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42

@Controller
@RequestMapping("/common")
public class CommonController {
	@Resource(name = "commonService")
	private CommonService commonService;
	@Resource(name = "doctorService")
	private DoctorService doctorService;
	@Resource(name = "patientService")
	private PatientService patientService;
	@Resource(name = "wardService")
	private WardService wardService;
	Logger log = Logger.getLogger(Log4jLogsDetial.class);

	@RequestMapping(value = "/list.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String titleQuery(@Param("name") String name) {
		List<Common> list = commonService.titleQuery(name);
		log.info("职称查询");
		JSON json = JSONSerializer.toJSON(new JsonResult<List<Common>>(list));
		return json.toString();
	}

	@RequestMapping(value = "/parameterQuery.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String parameterQuery() {
		List<Parameter> list = commonService.parameterQuery();
		log.info("一级参数查询");
		JSON json = JSONSerializer.toJSON(new JsonResult<List<Parameter>>(list));
		return json.toString();
	}

	@RequestMapping(value = "/parameterCodeQuery.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String parameterCodeQuery(@Param("code") String code) {
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
	@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);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
		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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
		}
		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();
	}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49

@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 {
				// 验证码的校验
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38

	public boolean verifyCode(String codeStr, HttpServletRequest request, boolean clear) {
		if (StringUtils.isBlank(codeStr)) {
			return false;
		}
		HttpSession session = request.getSession();
		CheckCode code = (CheckCode) session.getAttribute(RANDOMCODEKEY);
		if (clear) // 清除验证
			cleanCode(session);
		if (code == null || !code.enable || StringUtils.isBlank(code.code)
				|| !code.code.equalsIgnoreCase(codeStr.trim())) {
			return false;
		}
		// 有效
		if ((System.currentTimeMillis() - code.createTime) > NumberUtils.toInt("10", 10) * 60 * 1000) {
			code.enable = false;
			return false;
		}
		return true;
	}

	/**
	 * 生成随机图片
	 */
	public String buildRandcode(HttpServletRequest request, OutputStream outStream) {
		HttpSession session = request.getSession();
		BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
		g.fillRect(0, 0, width, height);
		g.setFont(new Font("Times New Roman", Font.ROMAN_BASELINE, 25));
		g.setColor(getRandColor(110, 133));
		// 绘制干扰
		for (int i = 0; i <= lineSize; i++) {
			drowLine(g);
		}
		// 绘制随机字符
		String randomString = "";
		for (int i = 1; i <= stringNum; i++) {
			randomString = drowString(g, randomString, i);
		}
		cleanCode(session);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
	@Resource(name = "costService")
	private CostService costService;
	Logger log = Logger.getLogger(Log4jLogsDetial.class);

	@RequestMapping(value = "/costAdd.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String costAdd(@Param("patientId") String patientId, @Param("types") String types,
			@Param("account") Float account, @Param("userId") String userId) {
		Cost cost = new Cost();
		cost.setAccount(account);
		cost.setPatientId(patientId);
		cost.setType(types);
		cost.setUserId(userId);
		String id = System.currentTimeMillis() + "";
		cost.setId(id);
		costService.costAdd(cost);
		log.info("患者" + patientId + "预交费" + cost.getAccount() + "元,收款方为" + cost.getUserId());
		JSON json = JSONSerializer.toJSON(new JsonResult<Cost>(cost));
		return json.toString();
	}

	@RequestMapping(value = "/costQuery.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String costQuery(@Param("id") String id, @Param("patientId") String patientId, @Param("types") String types,
			@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime,
			@Param("patientName") String patientName) throws ParseException {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("patientId", BaseUtils.toString(patientId));
		map.put("startTime", BaseUtils.toDate(startTime));
		map.put("endTime", BaseUtils.toDate(endTime));
		map.put("patientName", BaseUtils.toString(patientName));
		List<Map<String, Object>> list = costService.costQuery(map);
		log.info("患者" + id + "查询消费明细");
		for (Map<String, Object> mapp : list) {
			String costTime = mapp.get("costTime").toString();
			mapp.put("costTime", costTime);
		}
		JSON json = JSONSerializer.toJSON(new JsonResult<List<Map<String, Object>>>(list));
		return json.toString();
	}

	@RequestMapping(value = "/costTotal.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String costTotal(@Param("patientId") String patientId) {
		List<Map<String, Object>> list = costService.costTotal(patientId);// 费用计算业务逻辑在CostServiceImpl.java
		log.info("患者" + patientId + "结算");
		JSON json = JSONSerializer.toJSON(new JsonResult<List<Map<String, Object>>>(list));
		return json.toString();
	}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50

	@RequestMapping(value = "/doctorDelete.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String doctorDelete(@Param("id") Integer id) {
		if (id == 0) {
			json = JSONSerializer.toJSON(new JsonResult<Doctor>(3, "该医生不存在", null));
		} else {
			/**
			 * 检查该医生名下是否有未出院的患者
			 */
			PatientCode patientCode = new PatientCode();
			patientCode.setDocid(id);
			patientCode.setOutStatus(0);
			List<Map<String, Object>> list = patientService.patientQuery(patientCode);
			// System.out.println("当前医生名下未出院患者:" + list);
			Doctor doctor = doctorService.doctorById(id);
			log.info("查询医生" + doctor.getId());
			if (doctor.getState() == 0 && list.size() == 0) {// 未离职且无患者
				doctorService.doctorDelete(id);
				log.info("医生" + doctor.getName() + "离职");
				json = JSONSerializer.toJSON(new JsonResult<Doctor>(new Doctor()));
			} else if (list.size() != 0) {// 有患者
				json = JSONSerializer.toJSON(new JsonResult<Doctor>(2, null, new Doctor()));
			} else {// 已离职
				json = JSONSerializer.toJSON(new JsonResult<Doctor>(1, null, new Doctor()));
			}
		}
		return json.toString();
	}

	@RequestMapping(value = "/updateDoctorMessage.do", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String updateDoctorMessage(@Param("id") Integer id, @Param("name") String name,
			@Param("keshi") Integer keshi, @Param("zhicheng") Integer zhicheng, @Param("gender") Integer gender) {
		Doctor doctor = new Doctor();
		doctor.setId(id);
		doctor.setName(name);
		doctor.setDepartment(keshi);
		doctor.setTitle(zhicheng);
		doctor.setGender(gender);
		doctorService.updateDoctorMessage(doctor);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
		// 绘制干扰
		for (int i = 0; i <= lineSize; i++) {
			drowLine(g);
		}
		// 绘制随机字符
		String randomString = "";
		for (int i = 1; i <= stringNum; i++) {
			randomString = drowString(g, randomString, i);
		}
		cleanCode(session);

		// 验证
		CheckCode cc = new CheckCode();
		cc.code = randomString;
		cc.createTime = System.currentTimeMillis();
		cc.enable = true;

		session.setAttribute(RANDOMCODEKEY, cc);
		g.dispose();

		if (outStream != null) {
			try {
				ImageIO.write(image, "png", outStream);
			} catch (Exception e) {
			}
		}
		return randomString;
	}

	/**
	 * 生成随机图片
	 */
	public void getRandcode(HttpServletRequest request, HttpServletResponse response) {
		try {
			// 设置响应的类型格式为图片格式
			response.setContentType("image/png");
			// 禁止图像缓存
			response.setHeader("Pragma", "no-cache");
			response.setHeader("Cache-Control", "no-cache");
			response.setDateHeader("Expires", 0);

			buildRandcode(request, response.getOutputStream());
		} catch (IOException e) {

		}
	}

	/**
	 * 绘制字符
	 */
	private String drowString(Graphics g, String randomString, int i) {
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51

@Controller
public class TestYzmController {
	Logger log = Logger.getLogger(Log4jLogsDetial.class);

	@RequestMapping("test01")
	protected void doPost(HttpServletRequest reqeust, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("image/jpeg");
		response.setHeader("Pragma", "no-cache");
		response.setHeader("Cache-Control", "no-cache");
		response.setDateHeader("Expires", 0);
		ImageYzmUtils instance = new ImageYzmUtils();
		Cookie cookie = new Cookie("scaptcha", instance.getCode());
		cookie.setMaxAge(1800);
		response.addCookie(cookie);
		instance.write(response.getOutputStream());
		log.info("验证码测试类");
	}

	@RequestMapping("image")
	@ResponseBody
	public void validateCodeImg(HttpServletRequest request, HttpServletResponse response) {
		CheckCodeGen code = new CheckCodeGen();
		code.getRandcode(request, response);
		log.info("生成验证码成功");
	}

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

@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));
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
		calendar.add(calendar.DATE, +days);
		// calendar的time转成java.util.Date格式日期
		java.util.Date utilDate = (java.util.Date) calendar.getTime();
		utilDate = (java.util.Date) calendar.getTime();
		// java.util.Date日期转换成转成java.sql.Date格式
		Date newDate = new Date(utilDate.getTime());
		return newDate;
	}

	/**
	 * 对字符串进行处理
	 */
	public static String toString(String str) {
		if (!(str == null || "".equals(str))) {
			return str.trim();
		}
		return null;
	}

	/**
	 * 得到当前用户信息
	 */
	public static User getUser(HttpServletRequest request) throws UnsupportedEncodingException {
		// 解析Cookie中的用户信息
		User user = new User();
		Cookie cookie[] = request.getCookies();
		if (cookie != null) {
			for (Cookie cookie2 : cookie) {
				if (cookie2.getName().equals("user")) {
					String value = cookie2.getValue();
					value = URLDecoder.decode(value, "utf-8");
					String[] userInfo = value.split("#");
					user.setId(userInfo[0]);
					user.setName(userInfo[1]);
				}
			}
		}
		return user;
	}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/311218
推荐阅读
相关标签
  

闽ICP备14008679号