首页>代码>基于ssh(spring+spring mvc+hibernate)+layui的医院分诊后台管理系统(多种角色)>/src/controller/AppointMentController.java
package controller; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import entity.AppointMent; import entity.Doctor; import entity.Patient; import exception.ServiceException; import service.AppointMentService; import service.DoctorService; import service.PatientService; import tools.Pager; @Controller public class AppointMentController { @Autowired private AppointMentService appointMentService; @Autowired private DoctorService doctorService; @Autowired private PatientService patientService; @RequestMapping("/findAppiontByPageByDoctor.do") public @ResponseBody HashMap<String, Object> findAppiontByPageByDoctor(Integer page,Integer limit, HttpServletRequest request) { Doctor doctor = (Doctor) request.getSession().getAttribute("doctor"); Pager<AppointMent> pager = null; try { pager = appointMentService.findAppointMentByDoctorAndPage(doctor.getDid(), page, limit); } catch (ServiceException e) { e.printStackTrace(); } HashMap<String, Object> map = new HashMap<String, Object>(); map.put("code", 0); map.put("msg", ""); map.put("count", pager.getPageCount()); map.put("data", pager.getContent()); return map; } @RequestMapping("/findAppiontByPageByPatient.do") public @ResponseBody HashMap<String, Object> findAppiontByPageByPatient(Integer page,Integer limit, HttpServletRequest request) { Patient patient = (Patient) request.getSession().getAttribute("patient"); Pager<AppointMent> pager = null; try { pager = appointMentService.findAppointMentByPatientAndPage(patient.getPid(), page, limit); } catch (ServiceException e) { e.printStackTrace(); } HashMap<String, Object> map = new HashMap<String, Object>(); map.put("code", 0); map.put("msg", ""); map.put("count", pager.getPageCount()); map.put("data", pager.getContent()); return map; } @RequestMapping("showOrderView") public String showOrderView(Integer aid,HttpServletRequest request){ try { AppointMent appointMent = appointMentService.findAppointMentById(aid); request.setAttribute("appointMent", appointMent); } catch (ServiceException e) { e.printStackTrace(); } return "order/orderView"; } @RequestMapping("confirmOrder") public String confirmOrder(Integer aid){ try { AppointMent appointMent = appointMentService.findAppointMentById(aid); appointMent.setFlag(2); appointMentService.modifyAppointMent(appointMent); } catch (Exception e) { e.printStackTrace(); } return "redirect:/showOrderView.do?aid="+aid; } @RequestMapping("toAppointMentAdd") public String toAppointMentAdd(Integer aid,HttpServletRequest request){ try { if(aid!=null){ AppointMent appointMent = appointMentService.findAppointMentById(aid); request.setAttribute("appointMent", appointMent); } } catch (Exception e) { e.printStackTrace(); } return "order/orderAdd"; } @RequestMapping("addOrModifyAppointMent") public String addOrModifyAppointMent(Integer aid,Integer pid,Integer did, String pname,String dname,String description,String effectDate){ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); System.out.println("aid = "+aid); try { if(aid!=null){ System.out.println("修改"); AppointMent appointMent = appointMentService.findAppointMentById(aid); appointMent.setEffectDate(effectDate); appointMent.setDescription(description); Doctor doctor = doctorService.findDoctorByDname(dname); if(doctor==null){ throw new Exception("医生姓名无效"); } appointMent.setDoctor(doctor); Patient patient = patientService.findPatientByPname(pname); if(patient==null){ throw new Exception("病人姓名无效"); } appointMent.setPatient(patient); appointMent.setCreateDate(sdf.format(new Date())); Calendar c = Calendar.getInstance(); c.setTime(sdf.parse(effectDate)); c.add(Calendar.HOUR, 1); appointMent.setExpireDate(sdf.format(c.getTime())); appointMent.setFlag(1); appointMentService.modifyAppointMent(appointMent); }else{ System.out.println("添加"); AppointMent appointMent = new AppointMent(); appointMent.setEffectDate(effectDate); appointMent.setDescription(description); Doctor doctor = doctorService.findDoctorByDname(dname); if(doctor==null){ throw new Exception("医生姓名无效"); } appointMent.setDoctor(doctor); Patient patient = patientService.findPatientByPname(pname); if(patient==null){ throw new Exception("病人姓名无效"); } appointMent.setPatient(patient); appointMent.setCreateDate(sdf.format(new Date())); Calendar c = Calendar.getInstance(); c.setTime(sdf.parse(effectDate)); c.add(Calendar.HOUR, 1); appointMent.setExpireDate(sdf.format(c.getTime())); appointMent.setFlag(1); appointMentService.addAppointMent(appointMent); } } catch (Exception e) { e.printStackTrace(); } return "order/orderAdd"; } @RequestMapping("removeAppointMentById") public @ResponseBody String removeAppointMent(Integer aid){ try { appointMentService.removeAppointMent(aid); } catch (ServiceException e) { e.printStackTrace(); } return ""; } public AppointMentService getAppointMentService() { return appointMentService; } public void setAppointMentService(AppointMentService appointMentService) { this.appointMentService = appointMentService; } public DoctorService getDoctorService() { return doctorService; } public void setDoctorService(DoctorService doctorService) { this.doctorService = doctorService; } public PatientService getPatientService() { return patientService; } public void setPatientService(PatientService patientService) { this.patientService = patientService; } }
最近下载更多
hx0204 LV2
11月2日
haozhilang LV9
7月4日
Mr_VVcat LV9
4月16日
FF加菲猫 LV4
2月15日
fengyezi1205 LV1
2023年11月8日
xxu0219 LV2
2023年3月22日
1355862436 LV9
2022年11月3日
wanghsm LV4
2022年6月9日
yinxunyu12138 LV11
2022年5月6日
wangxin199804 LV9
2022年4月18日