Java實戰寵物醫院預約掛號系統的實現流程

一、項目簡述

功能包括:

用戶分為寵物,醫生,管理員,寵物主人可進行註冊選擇醫生掛號,選擇日期,選擇號源,醫生可進行寵物接診,管理員可對寵物,醫生信息的維護等等功能。

二、項目運行

環境配置:

Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

項目技術:

JSP +Spring + SpringBoot + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等
 

後端管理員控制層:

/**
 * 後端管理員控制層
 */
@Controller
@RequestMapping("/api")
public class PatientController {
	   private Integer size  = 6;//每頁顯示數量
    @Autowired
    private AdminService adminService;
  
    @Autowired
    private SectionService sectionService;
    
    @Autowired
    private BannersService  bannersService;   
    
    @Autowired
    private DoctorService doctorService;
    
    @Autowired
    private   PatientService  patientService;
    
    @Autowired
    private   MessagesService  messagesService;
    
 
    /**
     * 醫生列表
     */
    @RequestMapping("/doctorList1")
    public String doctorList(Model model, Doctor doctor, @RequestParam(value="page",defaultValue="1")Integer page) {
    	if(doctor == null) {
    		doctor = new Doctor();
    	}
    	PageInfo<Doctor> pageInfo  =  doctorService.selectDoctorList(doctor,page,size);
    	
    	List<Doctor> list = pageInfo.getList();
        model.addAttribute("doctorList",pageInfo.getList());
        model.addAttribute("pageInfo",pageInfo);
        model.addAttribute("doctor",doctor);
        return    "patient/doctorList";
    }
       /**
  		 *登錄
        * @throws ParseException 
  		 */
  	    @RequestMapping(value = "/userLogin")
  	    @ResponseBody
  	    public  Patient  userLogin(@RequestBody Patient patient) throws ParseException {
  	    	List<Patient>  list = patientService.selectPatient(patient);
  	    	if(patient != null && patient.getUsername() != null && patient.getPassword() != null) {
	  	    	if(list.size() > 0) {
	  	    	    return  list.get(0);
	  	    	}
  	    	}
  	      return  patient;
  	    } 
       /**
	 	 *登錄
        * @throws ParseException 
		 */
	    @RequestMapping(value = "/passwordSave")
	    @ResponseBody
	    public  String  passwordSave(@RequestBody Patient patient ) throws ParseException {
	    	if(patient != null && patient.getUsername() != null && patient.getPassword() != null) {
	    		Patient  pa = new Patient();
	    	    pa.setUsername(patient.getUsername());
		    	List<Patient>  list = patientService.selectPatient(pa);
	    		if(list.size() > 0) {
	  	    	    return  "err";
	  	    	}
	    		patientService.insertSelective(patient);
	    	    return  "ok";
	    	}
  	    	
	      return  "err";
	    } 
	  
    
    
  	    
       /**
   		 *登錄驗證
         * @throws ParseException 
   		 */
   	    @RequestMapping(value = "/userLoginView")
   	    @ResponseBody
   	    public  String  userLoginView(HttpServletRequest request) throws ParseException {
   	    	   HttpSession session = request.getSession();
   	    	   Patient  patient =(Patient) session.getAttribute("USER");
   	    	   System.out.println("*********登陸驗證********");
		         System.out.println(patient);   
   	            if(patient != null) {
   	             return  "ok";
   	            }
   		        
   	         return  "err";
   	    } 
 
	    /**
	     *banner圖
	     */
	    @RequestMapping(value = "/bannerList")
	    @ResponseBody
	    public String[] formAdd() {
	    	Banners banners = bannersService.selectByPrimaryKey(1);
	    	String[] split  = null;
	    	if(banners != null && banners.getImg() != null) {
	    	  split = banners.getImg().split(",");
	    	}
	        return split;
	    }
    
	    /**
		   *科室查詢
		 */
	    @RequestMapping(value = "/sectionList")
	    @ResponseBody
	    public  Map<String,List<Section>>  sectionList() {
            Map<String,List<Section>> map =  new HashMap<String,List<Section>>();
	    	List<Section> sectionlist2  = null;
	    	Section  se = new  Section();
	    	se.setType(1);
		    List<Section> sectionlist = sectionService.selectByExample(se);
		    if(sectionlist.size() > 0 ) {
		    	//科室詳情
		    	Section  section = new  Section();
		    	section.setPid(sectionlist.get(0).getId());
		    	section.setType(2);
		    	sectionlist2 = sectionService.selectByExample(section);
	        }
		    map.put("sectionlist",sectionlist);
		    map.put("sectionlist2",sectionlist2);  
	        return map;
	    }
    
	    
	
	    
	    /**
		 *科室下級查詢
		 */
	    @RequestMapping(value = "/sectionXiaList")
	    @ResponseBody
	    public  List<Section>  sectionXiaList(Integer id) {
	    	Section  se = new  Section();
	    	se.setPid(id);
	    	se.setType(2);
		    List<Section> sectionlist = sectionService.selectByExample(se);
	        return sectionlist;
	    }
	    
	    /**
		 *科室下級查詢
		 */
	    @RequestMapping(value = "/patientPai")
	    @ResponseBody
	    public Integer  patientPai(Integer id) {
	    	Patient pa = new Patient();
	    	pa.setPid(id);
			  PatientExample se  = new PatientExample();
			  PatientExample.Criteria criteria = se.createCriteria();
		        if(pa != null){
				   if(pa.getPid() != null) {
					   criteria.andPidEqualTo(pa.getPid());
				   }
		        }
	      
		     List<Patient> selectByExample = patientService.selectByExample(se);
	    	if(selectByExample.size() >0 ) {
	    		List<Messages> lmlist = messagesService.selectByExample(null);
	    		int j = 0 ;
	    		for (Messages me : lmlist) {
					if(me.getUid() == id) {
						   return j;
					}
	    			j++;
				}
	    	}
	        return -1;
	    }
	    
	    
	    
	    /**
		 *查詢科室
		 */
	    @RequestMapping(value = "/sectioNameList")
	    @ResponseBody
	    public  List<Section>  sectioNameList(String name) {
	    	Section  se = new  Section();
	    	se.setName(name);
	    	se.setType(2);
		    List<Section> sectionlist = sectionService.selectByExample(se);
		    if(sectionlist.size() > 0) {
		    	//查詢全部科室
		    	se.setName(null);
		    	se.setPid(sectionlist.get(0).getPid());
		    	se.setType(2);
		    	sectionlist = sectionService.selectByExample(se);
		    }
	        return sectionlist;
	    }
	    /**
	     *  坐診時間yuyue
	     */
	    @RequestMapping("/doctorTimePage")
	    public String doctorTimePage(Integer id,Model model) {
	       if(id !=  null) {
	    	   Doctor doctor = doctorService.selectByPrimaryKey(id);
	    	   model.addAttribute("doctor",doctor);
	       }
	        return  "patient/doctorTime";
	    }
 
	    /**
		 *醫生列表查詢
		 */
	    @RequestMapping(value = "/doctorList")
	    @ResponseBody
	    public  List<Doctor>  doctorList(Integer sid) {
	       Doctor doctor = new Doctor();
	       doctor.setSid(sid);
	       List<Doctor> selectDoctor = doctorService.selectDoctor(doctor);
	       return selectDoctor;
	    }  
	    
    
      /**
  		 *醫生列表查詢
  		 */
  	    @RequestMapping(value = "/doctorLike")
  	    @ResponseBody
  	    public  List<Doctor>  doctorLike(String name) {
  	       Doctor doctor = new Doctor();
  	       doctor.setName(name);
  	       
  	       List<Doctor> selectDoctor = doctorService.selectDoctor(doctor);
  	       return selectDoctor;
  	    }  
    
	    
	    /**
		 *科室查詢
		 */
	    @RequestMapping(value = "/doctorIdList")
	    @ResponseBody
	    public  Section  doctorIdList(Integer sid) {
	       Section selectByPrimaryKey = sectionService.selectByPrimaryKey(sid);
	       
	       return selectByPrimaryKey;
	    }  
	    
	    
    
       /**
  		 *醫生列表查詢
     * @throws ParseException 
  		 */
  	    @RequestMapping(value = "/doctortimeSelect")
  	    @ResponseBody
  	    public  List<Doctor>  doctortimeSelect(@RequestParam("datetimei")String datetimei,@RequestParam("id")Integer id) throws ParseException {
  	       Doctor doctor = new Doctor();
  	       SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  	       doctor.setSid(id);
  	       doctor.setBegindate(simpleDateFormat.parse(datetimei));
  	       List<Doctor> selectDoctor = doctorService.selectTime(doctor);
  	       return selectDoctor;
  	    }  
  	  
 
       /**
 		 *醫生列表查詢
         * @throws ParseException 
 	     */
 	    @RequestMapping(value = "/doctorGeRenList")
 	    @ResponseBody
 	    public  Doctor  doctorGeRenList(Integer id) throws ParseException {
 	       Doctor doctor = doctorService.selectByPrimaryKey(id);
 	       return doctor;
 	    }  
  	    
 	    /**
		   *時間格式轉換
		 */
	    @RequestMapping(value = "/doctorYuyueTime")
	    @ResponseBody
	    public  Map<String,String>  doctorYuyueTime(Integer id) {
            Map<String,String> map =  new HashMap<String,String>();
	    	SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); 
	 	    Doctor doctor = doctorService.selectByPrimaryKey(id);
	 	    map.put("begin",sdf.format(doctor.getBegintime()));
		    map.put("end",sdf.format(doctor.getEndtime()));  
	        return  map;
	    }
	    
	    /**
			   *時間格式轉換
	     * @throws ParseException 
			 */
		    @RequestMapping(value = "/timeZhuan")
		    @ResponseBody
		    public  String  timeZhuan(String time) throws ParseException {
		    	
		    	  Date parse = new Date();
		    	  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 
		    	  if(time != null) {
		    		  parse = sdf.parse(time);
		    	  }
		     	 
		          return   sdf.format(parse);
		    }
		    
	    
	    
	     
	    /**
		   *添加患者信息
		 */
	    @RequestMapping(value = "/loginByPatient")
	    public  String  loginByPatient(@RequestBody Patient patient) {
	        return  "loginByPatient";
	    }
	    
	    /**
	     *添加患者信息
	     */
	    @RequestMapping(value = "/patientSave")
	    public  String  patientSave(Patient patient) {
	    	patientService.insertSelective(patient);
	    	return  "loginByPatient";
	    }
	    
	    /**
	     * 判斷患者賬號
	     */
	    @RequestMapping("/panzhanghao")
	    @ResponseBody
	    public Map<String,String> panzhanghao(Model model, String zhanghao) {
	    	 Map<String, String> map =  new HashMap<String, String>();
			  PatientExample se  = new  PatientExample();
			  PatientExample.Criteria criteria = se.createCriteria();
			  criteria.andUsernameEqualTo(zhanghao);
           List<Patient> selectByExample = patientService.selectByExample(se);
           if(selectByExample.size() > 0){
               map.put("pan","err");
           }else{
               map.put("pan","ok");
           }
          return    map;
	    }
	    /**
	     *  患者註冊界面
	    */
	   @RequestMapping("/patientAddPage")
	   public String  patientAddPage(Model model) {
		 	  return    "patientRegister";
	   }
	   
	    /**
		   *患者信息列表
		 */
	    @RequestMapping(value = "/patientList")
	    @ResponseBody
	    public  List<Patient>   patientList(Integer pid,HttpServletRequest request) {
	    	Patient pa = new Patient();
	    	pa.setPid(pid);
	    	List<Patient> selectPatient = patientService.selectPatient(pa);
	    	
	        return  selectPatient;
	    }
	    /**
         *患者信息列表
      */
     @RequestMapping("/patientList2")
     public String messageList2(Model model, Patient patient, @RequestParam(value="page",defaultValue="1")Integer page,HttpServletRequest request) {
     	if(patient == null) {
     		patient = new Patient();
     	}
        HttpSession session = request.getSession();
        Patient       patient1   =  (Patient) session.getAttribute("PATIENT");
         if(patient1 == null){
        	  return  "redirect:/login/font/index";
         }
			/*
			 * PageInfo<Patient> pageInfo =
			 * patientService.selectPatientList(patient,1,size); List<Patient> list =
			 * pageInfo.getList(); List<Patient> list2 = new ArrayList<Patient>(); Messages
			 * messages = new Messages(); boolean pan = false; SimpleDateFormat sdf = new
			 * SimpleDateFormat("yyyy-MM-dd"); for (Patient pa : list) { if(pa.getPid() !=
			 * null && pa.getPid() != 0){ messages.setDid(dt.getId());
			 * messages.setUid(pa.getPid()); messages.setUsername(pa.getName());
			 * List<Messages> ml = messagesService.selectMessages(messages); if(ml.size() >
			 * 0 ){ Date time = ml.get(0).getTime(); pa.setUsername(sdf.format(time));
			 * pa.setPhone(dt.getName()); pa.setIdentitys(dt.getSname()); list2.add(pa); }
			 * 
			 * } } if(list2.size() <= 8) { pageInfo.setPages(1); }
			 */
         Messages messages = new Messages();
//         messages.setTime(new Date());
         messages.setType(1);
         messages.setUid(patient1.getPid());   
         PageInfo<Messages> pageInfo = messagesService.selectMessagesList(messages, 1, size);
         model.addAttribute("doctorList",pageInfo.getList());
         model.addAttribute("pageInfo",pageInfo);
         model.addAttribute("patient",patient);
         return    "patient/patientList";
     }
	    /**
		   *患者信息列表
		 */
	    @RequestMapping(value = "/patienDel")
	    @ResponseBody
	    public  List<Patient>   patienDel(Integer id) {
	    	if(id != null) {
	    		patientService.deleteByPrimaryKey(id);
	    	}
	    	List<Patient> selectByExample = patientService.selectByExample(null);
	        return  selectByExample;
	    }
	    
	    /**
		   *患者信息查看
		 */
	    @RequestMapping(value = "/patientUpatePage")
	    @ResponseBody
	    public  Patient  patientUpatePage(Integer id) {
	    	 Patient patient = null;
	         if(id != null) {
	         patient = patientService.selectByPrimaryKey(id);
	        	 
	         }
	        return  patient;
	    }
	    
	    
	    /**
		   *患者信息修改
		 */
	    @RequestMapping(value = "/patientUpdate")
	    @ResponseBody
	    public  Patient  patientUpdate(@RequestBody Patient patient) {
	    	patientService.updateByPrimaryKeySelective(patient);
	        return  null;
	    }
	    
	    
	    
	    /**
		   *預約信息
	     * @throws ParseException 
		 */
	    @RequestMapping(value = "/messagesSave")
	    public  String  messagesSave(Messages patient,HttpServletRequest request) throws ParseException {
	    	 HttpSession session =  request.getSession();
	         Patient       patient1   =  (Patient) session.getAttribute("PATIENT");
	    	    Messages  hui = null;
	    	    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
	    	    Date shijian = simpleDateFormat.parse(patient.getSname());
	  	        patient.setTime(shijian);
	  	        patient.setType(1);//待預約
	  	       
	  	        Doctor doctor = doctorService.selectByPrimaryKey(patient.getDid());//醫生
	  	        if(doctor != null) {
	  	        	patient.setDname(doctor.getName());
	  	        	if(doctor.getYipeoples() == null) {
	  	        		doctor.setYipeoples(0);
	  	        	}
	  	        	doctor.setYipeoples(doctor.getYipeoples()+1);
	  	        	doctorService.updateByPrimaryKeySelective(doctor);
	  	        	
	  	        }
	  	        Section section = sectionService.selectByPrimaryKey(patient.getSid());//科室
	  	        if(section != null) {
	  	        	patient.setSname(section.getName());
	  	        }
	  	        
	  	        Patient pa = patientService.selectByPrimaryKey(patient1.getId()); //患者
	  	        if(pa != null) {
	  	        	patient.setUid(pa.getPid());
	  	        	patient.setUserid(pa.getId());
	  	        	patient.setPhone(pa.getPhone()); 
	  	        	patient.setUsername(pa.getUsername());
	  	        	patient.setAge(pa.getAge());
	  	        	int countByExample = messagesService.countByExample(null);
	  	        	patient.setBianhao(countByExample+1);
	  	        	//排序
	  	        	Messages message = new Messages();
//	  	        	message.setUid(patient.getUid());
	  		    	message.setTime(patient.getTime());
	  		    	message.setDid(patient.getDid());
	  		    	message.setType(-1);
	  		    	List<Messages>  list  = messagesService.selectMessages(message);
	  		    	if(list.size() <= 0) {
	  		    		patient.setPai(1);
	  		    	}else {
	  		    		patient.setPai(list.size()+1);
	  		    	}
	  	        }
		    	messagesService.insertSelective(patient);
		    	if(patient.getId() != null) {
		    		hui	= messagesService.selectByPrimaryKey(patient.getId());
		    		Messages xin = new Messages();
		    		xin.setDid(hui.getDid());
		    		xin.setType(1);
		    		xin.setTime(shijian);
		    		List<Messages> selectMessagesPai = messagesService.selectMessagesPai(xin);
		    		hui.setAge(selectMessagesPai.size());
		    		
		    	}
		    	 return "redirect:/api/doctorList1";
	    }
	    
	    
	    
	    /**
		   *取消預約
	     * @throws ParseException 
		 */
	    @RequestMapping(value = "/messagesQuXiao")
	    public  String  messagesQuXiao(Integer id) throws ParseException {
	    	Messages ma  = new  Messages();
	    	ma.setId(id);
	    	ma.setType(2); //取消預約
	    	messagesService.updateByPrimaryKeySelective(ma);
	    	Messages mes = messagesService.selectByPrimaryKey(id);
	    	Messages messages  =  new  Messages();
	    	messages.setType(1);
	    	messages.setUid(mes.getUid());
	    	messages.setTime(new Date());
	    	List<Messages>  list  = messagesService.selectMessages(messages);
	    	return "redirect:/api/patientList2";
	    }
	    
	    /**
		   *預約信息列表
	     * @throws ParseException 
		 */
	    @RequestMapping(value = "/messagesUidList")
	    @ResponseBody
	    public  List<Messages>  messagesUidList(@RequestBody Messages message) throws ParseException {
	    	List<Messages>  list = null;
	    	if(message.getType() != null && message.getType() == 1) {
	    			message.setTime(new Date());
	    		    list  = messagesService.selectMessagesPai(message);
	    	}else {
	    		  list  = messagesService.selectMessagesTWO(message);  
	    	}
	    	  Messages me  = new  Messages();
		      me.setType(1);
		      me.setTime(new Date());
			  for (int i = 0; i < list.size(); i++) {
				  me.setDid(list.get(i).getDid());
				  List<Messages> lin = messagesService.selectMessagesPai(me);
				  list.get(i).setAge(lin.size());
				  
	           }
		    return  list;
	    }
	    /**
		   *預約信息列表
	     * @throws ParseException 
		 */
	    @RequestMapping(value = "/messagesList")
	    @ResponseBody
	    public  List<Messages>  messagesList(@RequestParam("type")Integer type,@RequestParam("uid")Integer uid) throws ParseException {
	    	Messages message = new Messages();
	    	List<Messages>  list = null;
	    	message.setType(type);
	    	message.setUid(uid);
	    	if(type != null && type == 1) {
	    		  message.setTime(new Date());
	    		  list  = messagesService.selectMessagesPai(message);  
	    		  Messages me  = new  Messages();
    		      me.setType(1);
    		      me.setTime(new Date());
	    		  for (int i = 0; i < list.size(); i++) {
    				  me.setDid(list.get(i).getDid());
    				  List<Messages> lin = messagesService.selectMessagesPai(me);
    				   list.get(i).setAge(lin.size());
		           }
	    	}else {
	    		  list  = messagesService.selectMessagesTWO(message);  
	    	}
	      
	    	
	    	
		    return  list;
	    }
	    
	    /**
		   *預約信息列表
	     * @throws ParseException 
		 */
	    @RequestMapping(value = "/messagesLists")
	    @ResponseBody
	    public  List<Messages>  messagesLists(Integer uid) throws ParseException {
	    	Messages message = new Messages();
	    	message.setUid(uid);
	    	List<Messages>  list  = messagesService.selectMessagesTWO(message);
	    	  Messages me  = new  Messages();
		      me.setType(1);
		      me.setTime(new Date());
			  for (int i = 0; i < list.size(); i++) {
				  if(list.get(i).getType() == 1) {
					   me.setDid(list.get(i).getDid());
					   List<Messages> lin = messagesService.selectMessagesPai(me);
					   list.get(i).setAge(lin.size()); 
				  }
	           }
	    	return  list;
	    }
	    
	    
	    
	    
	    /** 
	    * @throws ParseException 
		 */
	    @RequestMapping(value = "/doctortouList")
	    @ResponseBody
	    public  List<Doctor>  doctortouList() {
	      	PageInfo<Doctor> pageInfo  =  doctorService.selectDoctorList(null,1,4);
	
		    return   pageInfo.getList();
	    }
	    
	    
	    /** 
	    * @throws ParseException 
		 */
	    @RequestMapping(value = "/datatimeGua")
	    @ResponseBody
	    public  Integer  datatimeGua(@RequestParam("datetime")String datetime,@RequestParam("did")Integer did) throws ParseException {
    	    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    	    Date parse = sdf.parse(datetime);
        	Messages message = new Messages();
	    	message.setTime(parse);
	    	message.setDid(did);
	    	message.setType(-1);
	    	List<Messages>  list  = messagesService.selectMessages(message);
		    return  list.size();
	    }
	    
}

醫生端控制層:

/**
 * 醫生端
 */
@Controller
@RequestMapping("/doctor")
public class DoctorController {
	
     @Autowired
     private AdminService adminService;
 
     @Autowired
     private DoctorService doctorService;
     
     @Autowired
     private SectionService sectionService;
     
     @Autowired
     private  PatientService  patientService;
     
     
     @Autowired
     private   MessagesService  messagesService;
     
     
     private Integer size  = 8;//每頁顯示數量
 
     
     
     
     /**
  	  * 修改信息
      * @param model
      * @return
      */
     @RequestMapping("/tiaomessagelist")
     public String tiaomessagelist(@RequestBody  List<Messages> mlist,Model model) {
 
    	 System.out.println(mlist.size());
    	 
         model.addAttribute("mlist",mlist);
         return    "doctor/messageList";
     }
     
     
     
     @RequestMapping("/index")
     public String index(Model model,HttpServletRequest request) {
    	  HttpSession session = request.getSession();
          Doctor dt = (Doctor) session.getAttribute("DOCTOR");
          if(dt == null) {
        	  return  "redirect:/login/index";  
          }
         int  doctor  = doctorService.countByExample(null); //醫生總數
         int  section = sectionService.count(); //科室總數
         //患者總數
         int patient = 0;
         List<Patient> selectByExample = patientService.selectByExample(null);
         Messages   mess  = new Messages();
         for (Patient pa : selectByExample) {
        	 if(pa.getName() != null) {
        		mess.setDid(dt.getId());
         	 	mess.setUsername(pa.getName());
         	    List<Messages> selectMessages = messagesService.selectMessages(mess);
         	    if(selectMessages.size() > 0 )
         	    {
         	    	patient++;
         	    }
        	 }
		 }
	     //預約總數
	 	 MessagesExample me  = new  MessagesExample();
		 MessagesExample.Criteria mecriteria = me.createCriteria();
		 mecriteria.andDidEqualTo(dt.getId());
         int  messages = messagesService.countByExample(me); 
         model.addAttribute("doctor",doctor);
         model.addAttribute("section",section);
         model.addAttribute("patient",patient);
         model.addAttribute("messages",messages);
         PageInfo<Doctor> pageInfo  =  doctorService.selectDoctorList(null,1,4);
          if(pageInfo.getList() != null && pageInfo.getList().size() >0 ) {
        	    List<Doctor> list = pageInfo.getList();
        	    StringBuffer sb = new StringBuffer();
        	    StringBuffer shu = new StringBuffer();
        	    int v = list.size()-1;
        	    for(int i=0;i<list.size();i++) {
	        		 if(v==i) {
	        			 sb.append(list.get(i).getName());
		        		 shu.append(list.get(i).getYipeoples());
	        		}else {
	        			 sb.append(list.get(i).getName()+",");
		        		 shu.append(list.get(i).getYipeoples()+",");
	        		}
	        	 }
	        	   model.addAttribute("name",sb.toString());
	               model.addAttribute("nu",shu.toString());
          }
         return  "doctor/index";
     }
     
	    
     /**
  	  * 修改信息
      * @param model
      * @return
      */
     @RequestMapping("/doctorUptatePage")
     public String doctorUptatePage(Model model,HttpServletRequest request) {
         HttpSession session = request.getSession();
         Doctor dt = (Doctor) session.getAttribute("DOCTOR");
         if(dt != null) {
        	 Doctor  doctor = doctorService.selectByPrimaryKey(dt.getId());
 			List<Section> sectionlist2  = null;
 			model.addAttribute("doctor",doctor);
 			//科室
 	    	Section  se = new  Section();
 	    	se.setType(1);
 		    List<Section> sectionlist = sectionService.selectByExample(se);
 		    model.addAttribute("sectionlist", sectionlist);
 	    	//科室詳情
 		    Section se1 = sectionService.selectByPrimaryKey(doctor.getSid());
 		    if(se1 != null) {
 		    	Section  section = new  Section();
 		    	section.setPid(se1.getPid());
 		    	section.setType(2);
 		    	sectionlist2 = sectionService.selectByExample(section);
 			    model.addAttribute("sectionlist2", sectionlist2);
 			    model.addAttribute("se1", se1);
 		    } 
         }
         return  "doctor/doctorUptate";
     }
     
     
     
     /**
      *  修改醫生信息
      */
     @RequestMapping("/messageTime")
     public String messageTime(String name,Model model,HttpServletRequest request) {
	   	HttpSession session = request.getSession();
        Doctor dt = (Doctor) session.getAttribute("DOCTOR");
        if(name !=  null) {
        	Messages  mess  = new Messages();
        	mess.setDid(dt.getId());
     	 	mess.setUsername(name);
     	    List<Messages> selectMessages = messagesService.selectMessagesTWO(mess);
     	    model.addAttribute("messagesList", selectMessages);
        }
         return  "doctor/messageTime";
     }
     
     
	     /**
	      *  修改醫生信息
	      */
	     @RequestMapping("/admindoctorUptate")
	     public String adminUptatePassword(Doctor doctor,Model model) {
	        if(doctor !=  null && doctor.getId() != null) {
	     	   if(doctor.getSid() != null) {
	     		   Section section = sectionService.selectByPrimaryKey(doctor.getSid());
	     		   doctor.setSid(section.getId());
	     		   doctor.setSname(section.getName());
	     	   }
	     	   doctorService.updateByPrimaryKeySelective(doctor);
	        }
	         return  "redirect:/doctor/index";
	     }
	     
	     
	     /**
	      * 預約信息列表
	      */
	     @RequestMapping("/messageList")
	     public String doctorList(Model model,  Messages messages, @RequestParam(value="page",defaultValue="1")Integer page,Integer type,HttpServletRequest request) {
	     	if(messages == null) {
	     		messages = new Messages();
	     	}
	         HttpSession session = request.getSession();
	         Doctor dt = (Doctor) session.getAttribute("DOCTOR");
	         if(dt != null){
	        	 messages.setDid(dt.getId());
	         }else{
	        	  return  "redirect:/login/index";
	         }
	     	
	     	messages.setType(type);
	     	//底層數據
	     	PageInfo<Messages> pageInfo = messagesService.selectMessagesList(messages,page,size);
	     	//工作區數據
	     	messages.setTime(new Date());
	    	List<Messages> list = messagesService.selectMessagesPai(messages);
	    	 model.addAttribute("mlist",list);
	    	 model.addAttribute("messagesList",pageInfo.getList());
	         model.addAttribute("pageInfo",pageInfo);
	         model.addAttribute("messages",messages);
	         model.addAttribute("type",type);
	         return    "doctor/messageList";
	     }
	     
	     
	     /**
			 *醫生列表查詢
			 */
		    @RequestMapping(value = "/messageAjax")
		    @ResponseBody
		    public  List<Messages>  doctorList(HttpServletRequest request) {
		    	 Messages		messages = new Messages();
		         HttpSession session = request.getSession();
		         Doctor dt = (Doctor) session.getAttribute("DOCTOR");
		         messages.setDid(dt.getId());
		       
		     	messages.setType(1);
		     	messages.setTime(new Date());
		    	PageInfo<Messages> pageInfo2 = messagesService.selectMessagesListDemo(messages,1,99);
		       
		       return pageInfo2.getList();
		    }  
		    
      /**
			 *醫生列表查詢
			 */
		    @RequestMapping(value = "/messagesQundingUptate")
		    @ResponseBody
		    public String  messagesQundingUptate(Integer id) {
		    	   if(id != null) {
			        	Messages messages = new Messages();
			        	messages.setId(id);
			        	messages.setType(3); //3表示預約成功
			        	messagesService.updateByPrimaryKeySelective(messages);
			        	Messages selectByPrimaryKey = messagesService.selectByPrimaryKey(id);
			        	Messages  mes = new Messages();
			        	mes.setType(1);
			        	mes.setTime(new Date());
			        	mes.setDid(selectByPrimaryKey.getDid());
				    	List<Messages> list = messagesService.selectMessagesPai(mes);
				    	for (int i = 0; i < list.size(); i++) {
				    		list.get(i).setPai(i+1);
				    		messagesService.updateByPrimaryKeySelective(list.get(i));
						}
			        }
		       
		       return "ok";
		    }  
 
	     
	     
	     /**
	         *患者信息列表
	      */
	     @RequestMapping("/patientList")
	     public String messageList(Model model, Patient patient, @RequestParam(value="page",defaultValue="1")Integer page,HttpServletRequest request) {
	     	if(patient == null) {
	     		patient = new Patient();
	     	}
	        HttpSession session = request.getSession();
	         Doctor dt = (Doctor) session.getAttribute("DOCTOR");
	         if(dt == null){
	        	  return  "redirect:/login/index";
	         }
				/*
				 * PageInfo<Patient> pageInfo =
				 * patientService.selectPatientList(patient,1,size); List<Patient> list =
				 * pageInfo.getList(); List<Patient> list2 = new ArrayList<Patient>(); Messages
				 * messages = new Messages(); boolean pan = false; SimpleDateFormat sdf = new
				 * SimpleDateFormat("yyyy-MM-dd"); for (Patient pa : list) { if(pa.getPid() !=
				 * null && pa.getPid() != 0){ messages.setDid(dt.getId());
				 * messages.setUid(pa.getPid()); messages.setUsername(pa.getName());
				 * List<Messages> ml = messagesService.selectMessages(messages); if(ml.size() >
				 * 0 ){ Date time = ml.get(0).getTime(); pa.setUsername(sdf.format(time));
				 * pa.setPhone(dt.getName()); pa.setIdentitys(dt.getSname()); list2.add(pa); }
				 * 
				 * } } if(list2.size() <= 8) { pageInfo.setPages(1); }
				 */
	         Messages messages = new Messages();
//	         messages.setTime(new Date());
	         messages.setType(1);
	         messages.setDid(dt.getId());    
	         PageInfo<Messages> pageInfo = messagesService.selectMessagesList(messages, 1, size);
	         model.addAttribute("doctorList",pageInfo.getList());
	         model.addAttribute("pageInfo",pageInfo);
	         model.addAttribute("patient",patient);
	         return    "doctor/patientList";
	     }
	     
	    /**
		   *預約信息列表
	     * @throws ParseException 
		 */
	    @RequestMapping(value = "/tiaozhuanList")
	    @ResponseBody
	    public  String  messagesList(@RequestParam("xiao")Integer xiao,@RequestParam("da")Integer da)  {
	    	Messages message = new Messages();
	    	if(xiao != null & da != null) {
	    		Messages mexiao = messagesService.selectByPrimaryKey(xiao);
	    		Integer px = mexiao.getPai();
	    		Messages meda = messagesService.selectByPrimaryKey(da);
	    		mexiao.setPai(meda.getPai());
	    		meda.setPai(px);
	    		messagesService.updateByPrimaryKeySelective(mexiao);
	    		messagesService.updateByPrimaryKeySelective(meda);
	    	  }
		      return  null;
	    }
  
	     /**
	      *  確定預約
	      */
	     @RequestMapping("/messagesUptate")
	     public String messagesUptate(Integer id) {
	        if(id != null) {
	        	Messages messages = new Messages();
	        	messages.setId(id);
	        	messages.setType(3); //3表示預約成功
	        	messagesService.updateByPrimaryKeySelective(messages);
	        }
	         return  "redirect:/doctor/messageList?type=1";
	     }
	     
	     /**
	      *  取消
	      */
	     @RequestMapping("/messagesQuXiao")
	     public String messagesQuXiao(Integer id) {
	        if(id != null) {
	        	Messages messages = new Messages();
	        	messages.setId(id);
	        	messages.setType(2); //2取消預約
	        	messagesService.updateByPrimaryKeySelective(messages);
	        }
	         return  "redirect:/doctor/messageList?type=1";
	     }
	     
	     
	     /**
	      *  退號
	      */
	     @RequestMapping("/messagesTui")
	     public String messagesTui(Integer id) {
	        if(id != null) {
	        	Messages messages = new Messages();
	        	messages.setId(id);
	        	messages.setType(4); //4退號失敗
	        	messagesService.updateByPrimaryKeySelective(messages);
	        }
	         return  "redirect:/doctor/messageList?type=3";
	     }
	     
	     
}

後端管理員控制層:

/**
 * 後端管理員控制層
 */
@Controller
@RequestMapping("/admin")
public class AdminController {
 
    @Autowired
    private AdminService adminService;
  
    @Autowired
    private SectionService sectionService;
    
    @Autowired
    private BannersService  bannersService;   
    
    @Autowired
    private DoctorService doctorService;
    
    @Autowired
    private  PatientService  patientService;
    
    @Autowired
    private   MessagesService  messagesService;
    
    
    private Integer size  = 6;//每頁顯示數量
    
 
    @Value("${fileUrl}") //在配置文件中獲取文件的保存路徑
    private String filePath;
 
    
    /**
     * 導入
     * @param file
     * @param response
     * @throws IOException 
     */
    
    @RequestMapping("/excelInput")
    public String  excelInput(MultipartFile file,HttpServletResponse response) throws IOException {
    	String sb = file.getOriginalFilename();
        List<String[]> jieExcel = ExcelInput.jieExcel(file.getInputStream(), sb.substring(sb.indexOf(".")+1));
	
		  for (String[] strings : jieExcel) {
			  System.out.println(Arrays.toString(strings));  
		  }
        return  "redirect:/admin/index";
    }
    
    /**
     	* 導出
     * 
     * @param file
     * @param response
     */
    @RequestMapping("/xiazai")
    public void  excelString(HttpServletRequest request,HttpServletResponse response) {
        try {
        	response.setCharacterEncoding("utf-8");
        	//content-type類型是告訴頁面要響應內容的類型,以及字符編碼,頁面要以什麼方式打開
        	response.setContentType("application/force-download");// 設置強制下載不打開
            //Content-Disposition是MIMI協議的擴展,瀏覽器以什麼方式處理wenjian
            response.setHeader("Content-Disposition", "attachment; fileName=exportFile.xlsx");
 
        	String[] title = new String[]{"姓名","科室id","科室","日期"};
            List<Doctor> list = doctorService.selectByExample(null);
            Workbook   wo     = ExcelUtils.getExcel("xlsx",title,list);
            wo.write(response.getOutputStream());
    		//Files.copy(file, response.getOutputStream());   		
    	} catch (IOException e) {
    		System.out.println("發生異常");
    		e.printStackTrace();
    	}
    
    }
    
 
    
    
    @RequestMapping("/index")
    public String index(Model model) {
        int  doctor  = doctorService.countByExample(null); //醫生總數
        int  section = sectionService.countByExample(null); //科室總數
        int  patient = patientService.countByExample(null); //患者總數
        int  messages = messagesService.countByExample(null); //預約總數
        model.addAttribute("doctor",doctor);
        model.addAttribute("section",section);
        model.addAttribute("patient",patient);
        model.addAttribute("messages",messages);
        PageInfo<Doctor> pageInfo  =  doctorService.selectDoctorList(null,1,4);
         if(pageInfo.getList() != null && pageInfo.getList().size() >0 ) {
       	    List<Doctor> list = pageInfo.getList();
       	    StringBuffer sb = new StringBuffer();
       	    StringBuffer shu = new StringBuffer();
       	         int v = list.size()-1;
	        	 for(int i=0;i<list.size();i++) {
	        		if(v==i) {
	        			 sb.append(list.get(i).getName());
		        		 shu.append(list.get(i).getYipeoples());
	        		}else {
	        			 sb.append(list.get(i).getName()+",");
		        		 shu.append(list.get(i).getYipeoples()+",");
	        		}
	        	 }
	        	   model.addAttribute("name",sb.toString());
	               model.addAttribute("nu",shu.toString());
         }
        return  "admin/index";
    }
 
     
 
 
	    /**
	     *  管理員修改密碼界面
	     * @return
	     */
    @RequestMapping("/adminUptatePage")
    public String adminUptatePage(Model model) {
        return "admin/adminUptate";
    }
    /**
     *  修改密碼 
     */
    @RequestMapping("/adminUptatePassword")
    public String adminUptatePassword(Model model,Admin admin,HttpServletRequest request) {
        HttpSession session = request.getSession();
        Admin ad = (Admin) session.getAttribute("ADMIN");
        if(ad != null && admin.getPassword() != null){
                admin.setId(ad.getId());
                adminService.updateByPrimaryKeySelective(admin);
        }
        return  "redirect:/admin/index";
    }
    
    
    /**
     *  坐診時間設置界面
     */
    @RequestMapping("/doctorTimePage")
    public String doctorTimePage(Integer id,Model model) {
       if(id !=  null) {
    	   Doctor doctor = doctorService.selectByPrimaryKey(id);
    	   model.addAttribute("doctor",doctor);
       }
        return  "admin/doctorTime";
    }
    
    /**
     *  坐診時間設置界面
     * @throws ParseException 
     */
    @RequestMapping("/doctorTimeUpdate")
    public String doctorTimeUpdate(Integer id,Model model,String begindate,String enddate,String begintime,String endtime) throws ParseException {
       if(id !=  null) {
    	  SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    	  SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("HH:mm"); 
    	   Doctor   doctor = new Doctor();
    	   doctor.setId(id);
    	   doctor.setBegindate(simpleDateFormat.parse(begindate)); 
    	   doctor.setEnddate(simpleDateFormat.parse(enddate));
           doctor.setBegintime(simpleDateFormat2.parse(begintime));
    	   doctor.setEndtime(simpleDateFormat2.parse(endtime));    
    	   doctorService.updateByPrimaryKeySelective(doctor);
       }
        return "redirect:/admin/doctorList";
    } 
    
    	
    
    /**
     *  修改醫生信息
     */
    @RequestMapping("/admindoctorUptate")
    public String adminUptatePassword(Doctor doctor,Model model) {
       if(doctor !=  null && doctor.getId() != null) {
    	   if(doctor.getSid() != null) {
    		   Section section = sectionService.selectByPrimaryKey(doctor.getSid());
    		   doctor.setSid(section.getId());
    		   doctor.setSname(section.getName());
    	   }
    	   doctorService.updateByPrimaryKeySelective(doctor);
       }
        return  "redirect:/admin/doctorList";
    }
    
    /**
     *  刪除醫生信息
     */
    @RequestMapping("/doctorDelect")
    public String doctorDelect(Integer id,Model model) {
       if(id !=  null) {
    	
    	   doctorService.deleteByPrimaryKey(id);
       }
        return  "redirect:/admin/doctorList";
    }
    
    
    /**
     *  醫生註冊界面
    */
   @RequestMapping("/doctorAddPage")
   public String  doctorAddPage(Model model) {
	   	List<Section> sectionlist2  = null;
	   	Section  se = new  Section();
	   	se.setType(1);
		List<Section> sectionlist = sectionService.selectByExample(se);
	    if(sectionlist.size() > 0 ) {
	    	//科室詳情
	    	Section  section = new  Section();
	    	section.setPid(sectionlist.get(0).getId());
	    	section.setType(2);
	    	sectionlist2 = sectionService.selectByExample(section);
	    }
	    model.addAttribute("sectionlist", sectionlist);
	    model.addAttribute("sectionlist2", sectionlist2);
	 	  return    "admin/doctorAdd";
   }
   
    
    
    @RequestMapping("/admindoctorAdd")
    public String admindoctorAdd(Doctor doctor,Model model) {
    	  if(doctor.getId() !=  null){
    	 	   if(doctor.getSid() != null) {
    			   Section selectByPrimaryKey = sectionService.selectByPrimaryKey(doctor.getSid());
    			   doctor.setSname(selectByPrimaryKey.getName());
    		   }
    	       doctorService.updateByPrimaryKeySelective(doctor);
    	   }
        return  "redirect:/admin/doctorList";
    }
    
    
    /**
     * 醫生列表
     */
    @RequestMapping("/doctorList")
    public String doctorList(Model model, Doctor doctor, @RequestParam(value="page",defaultValue="1")Integer page) {
    	if(doctor == null) {
    		doctor = new Doctor();
    	}
    	PageInfo<Doctor> pageInfo  =  doctorService.selectDoctorList(doctor,page,size);
    	
    	List<Doctor> list = pageInfo.getList();
        model.addAttribute("doctorList",pageInfo.getList());
        model.addAttribute("pageInfo",pageInfo);
        model.addAttribute("doctor",doctor);
        return    "admin/doctorList";
    }
    
    
    /**
     *  修改醫生信息界面
     * @return
     */
	@RequestMapping("/doctorUptatePage")
	public String doctorUptatePage(Model model,Integer id) {
		if(id != null) {
			Doctor  doctor = doctorService.selectByPrimaryKey(id);
			List<Section> sectionlist2  = null;
			model.addAttribute("doctor",doctor);
			//科室
	    	Section  se = new  Section();
	    	se.setType(1);
		    List<Section> sectionlist = sectionService.selectByExample(se);
		    model.addAttribute("sectionlist", sectionlist);
	    	//科室詳情
		 	Section  se1 = sectionService.selectByPrimaryKey(doctor.getSid());
			Section  section = new  Section();
			 if(se1 != null) {
			    	section.setPid(se1.getPid());
			    	section.setType(2);
			    	sectionlist2 = sectionService.selectByExample(section);
			 }else {
				 if(sectionlist.size() >0 ) {
	    			 section.setPid(sectionlist.get(0).getId());	
	    			 section.setType(2);
				     sectionlist2 = sectionService.selectByExample(section);
	    		 }
				 se1 = new   Section();
			 }
		    model.addAttribute("sectionlist2", sectionlist2);
		    model.addAttribute("se1", se1);
		    
		}
	    return "admin/doctorUptate";
	}
	    
    /**
     * 科室列表
     */
    @RequestMapping("/sectionList")
    public String sectionList(Model model, Section section, @RequestParam(value="page",defaultValue="1")Integer page) {
    	if(section == null) {
    		section = new Section();
    	}
    	section.setType(1);//1 科室
    	PageInfo<Section> pageInfo   = sectionService.selectSectionListt(section,page,size);
    	List<Section> list = pageInfo.getList();
    	List<Section> list2 = new ArrayList<Section>();
    	Section cs = new Section();
    	for (Section se : list) {
    		cs.setPid(se.getId());
    		List<Section> selectByExample = sectionService.selectByExample(cs);
    		se.setSlist(selectByExample);
    		list2.add(se);
		
    	}
    	
    	
    	
        model.addAttribute("sectionList",list2);
        model.addAttribute("pageInfo",pageInfo);
        model.addAttribute("section",section);
        return    "admin/sectionList";
    }
    
    /**
     * 科室詳情下級列表
     */
    @RequestMapping("/sectionBelowList")
    public String sectionBelowList(Model model, Section section, Integer id) {
    	if(section == null) {
    		section = new Section();
    	}
    	section.setType(2);// 2 科室詳情
    	section.setPid(id);
    	Section se = sectionService.selectByPrimaryKey(id);
    	List<Section> list  = sectionService.selectByExample(section);
        model.addAttribute("sectionList",list);
        model.addAttribute("section",section);
        model.addAttribute("se",se);
        return    "admin/sectionBelow";
    }
    
    
   /**
      * 跳轉添加科室界面
    */
    @RequestMapping("/sectionAddPage")
    public String zuopinList() {
        return  "admin/sectionAdd";
    }
 
    /**
     * 跳轉添加科室下級界面
   */
   @RequestMapping("/sectionAddBelowPage")
   public String zuopinList(Model model,Integer id) {
	   if(id != null) {
			  Section se = sectionService.selectByPrimaryKey(id);
		      model.addAttribute("se",se);
	   }
       return  "admin/sectionAddBelow";
   }
   
   
   
   /**
    * 跳轉修改科室下級界面
  */
  @RequestMapping("/sectionBelowUptatePage")
  public String sectionBelowUptatePage(Model model,Integer id) {
	   if(id != null) {
			  Section se = sectionService.selectByPrimaryKey(id);
			  Section section = sectionService.selectByPrimaryKey(se.getPid());
		      model.addAttribute("se",se);
		      model.addAttribute("sname",section.getName());
	   }
      return  "admin/sectionBelowUptate";
  }
   /**
    * 跳轉修改科室界面
  */
  @RequestMapping("/sectionUptatePage")
  public String sectionUptatePage(Model model,Integer id) {
	   if(id != null) {
			  Section se = sectionService.selectByPrimaryKey(id);
			  model.addAttribute("se",se);
	   }
      return  "admin/sectionUptate";
  }
  
    
    /**
     * 添加科室
     */
    @RequestMapping("/sectionAdd")
    @ResponseBody
    public Map<String,String> sectionAdd(String name) {
            Map<String, String> map =  new HashMap<String, String>();
            if(name != null ){
            	Section section = new Section();
            	section.setName(name);
            	section.setType(1);
            	sectionService.insertSelective(section);
                map.put("pan","ok");
            }else{
                map.put("pan","err");
            }
           return    map;
    }
 
 
    /**
     * 添加科室下級
     */
    @RequestMapping("/sectionAddBelow")
    public String sectionAddBelow(Section section) {
            	section.setType(2);
            	sectionService.insertSelective(section);
            	//"redirect:/admin/sectionBelowList?id="+section.getPid();
          return "redirect:/admin/sectionList";
 
    }
    
    /**
     * 修改科室
     */
    @RequestMapping("/sectionUptate")
    public String sectionUptate(Section section) {
          sectionService.updateByPrimaryKeySelective(section);
          return  "redirect:/admin/sectionList";
 
    }
    /**
     * 修改科室下級
     */
    @RequestMapping("/sectionBelowUptate")
    public String sectionBelowUptate(Section section) {
          sectionService.updateByPrimaryKeySelective(section);
          return "redirect:/admin/sectionBelowList?id="+section.getPid();
 
    }
    /**
     * 刪除科室下級
     */
    @RequestMapping("/sectionBelowDelect")
    public String sectionBelowUptate(Integer id) {
	    	Section section = sectionService.selectByPrimaryKey(id);
	    	Integer pid =  section.getPid();
            sectionService.deleteByPrimaryKey(section.getId());
            return "redirect:/admin/sectionBelowList?id="+pid;
 
    }
    
    /**
     * 刪除科室
     */
    @RequestMapping("/sectionDelect")
    public String sectionDelect(Integer id) {
    	    Section section  = new Section();
    	    section.setPid(id);
    	    section.setType(2);
	    	List<Section> list = sectionService.selectByExample(section);
            sectionService.deleteByPrimaryKey(id);
            for (Section section2 : list) {
            	sectionService.deleteByPrimaryKey(section2.getId());
			}
          return  "redirect:/admin/sectionList";
    }
    
    
	    @RequestMapping("/bannersPageUpdate")
	    public String bannersAdd(Model model,Integer id) {
	        Banners   banners   = null;
	        String[]  imgnames = null;
	        if(id == 1){
	            banners = bannersService.selectByPrimaryKey(1);
	            if(banners == null){
	                banners = new Banners();
	                banners.setId(1);
	                bannersService.insertSelective(banners);
	            }
	        }
	        if(banners.getImg() != null  && !"".equals(banners.getImg())){
	            imgnames  = banners.getImg().split(",");
	        }
	        model.addAttribute("imgnames",imgnames);
	        model.addAttribute("banners",banners);
	        return  "admin/bannersUpdate";
	    }
 
	   /**
	     *輪播圖片刪除
	     */
	    @RequestMapping(value ="/bannersDel")
	    @ResponseBody
	    public  Map<String, Object>  bannersDel(Integer id,String  src) throws IOException{
	        Map<String, Object>  map =  new HashMap<String, Object>();
	        StringBuffer sb  = new  StringBuffer();
	        if(id != null && src != null){
	            Banners banner = bannersService.selectByPrimaryKey(id);
	                if(banner.getImg() != null){
	                    String[] split = banner.getImg().split(",");
	                    for(int i = 0; i<split.length;i++){
	                        if(src.equals(split[i])){
	                            //String fp= filePath.substring(filePath.indexOf("/")+1);//文件的真實路徑
	                            String path = src.substring(src.indexOf("s") + 2);   //獲取文件名
	                            File file = new File(filePath +path);
	                            if(file.exists()){
	                                file.delete();
	                                map.put("massage","刪除成功");
	                            }else{
	                                map.put("massage","刪除失敗");
	                            }
	                        }else{
	                            sb.append(split[i]+",");
	                        }
	                    }
	                }
	        }
	        Banners banners = new Banners();
	        banners.setId(id);
	        banners.setImg(sb.toString());
	        bannersService.updateByPrimaryKeySelective(banners);
	        return map;
	    }
    
	    /**
	      *banner圖片上傳
	     */
	    @RequestMapping(value ="/bannersAdd")
	    @ResponseBody
	    public  Map<String, Object>  bannersAdd(@RequestParam("mf")MultipartFile[] mufile,@RequestParam("id")Integer  id) throws IOException{
	        Map<String, Object> map =  new HashMap<String, Object>();
	        StringBuffer path       =  new StringBuffer();
	        //圖片上傳並保存上傳的路徑
	        for (int i = 0; i < mufile.length; i++) {
	            try {
	                String random   =  StringRandom.getRandom();
	                String filename =  mufile[i].getOriginalFilename();
	                //隨機字符+原圖片名用作新的圖片名
	                filename = random+filename;
	                //文件保存路徑  D:/Java/hospital  
	                File file = new File(filePath+filename);
	                //判斷父級文件是否存在
	                if (!file.getParentFile().exists()) {
	                    file.getParentFile().mkdir();
	                }
	                path.append("/files/"+filename+",");
	                mufile[i].transferTo(file);
	            } catch (IllegalStateException | IOException e) {
	                e.printStackTrace();
	            }
	        }
	        Banners banners = new  Banners();
	        if(id != null){
	            //修改圖片路徑
	            Banners  sh  = bannersService.selectByPrimaryKey(id);
	            banners.setId(id);
	            if(sh.getImg() != null ){
	                banners.setImg(sh.getImg()+path.toString());
	            }else{
	                banners.setImg(path.toString());
	            }
	            bannersService.updateByPrimaryKeySelective(banners);
	        }
	        return map;
	    }
 
    
    
/*
    *//**
     * 管理員-非遺講堂
     *//*
    @RequestMapping(value="/feiyi_videoList")
    public String feiyi_VideoList(Model model, Video video, @RequestParam(value="page",defaultValue="1")Integer page) {
        PageInfo<Video> pageInfo = videoService.selectPageList(video,page,size);
        model.addAttribute("videoList",pageInfo.getList());
        model.addAttribute("pageInfo",pageInfo);
        if(video.getTitle() != null){
            model.addAttribute("title",video.getTitle());
        }
        return "behind/admin/feiyi_videoList";
     }
    *//**
     *  非遺講堂-刪除
     *//*
    @RequestMapping("/videoDelete")
    public String videoDelete(Model model,Integer id) {
        if(id !=  null){
            //String fp= filePath.substring(filePath.indexOf("/")+1);//文件的真實路徑
            Video video = videoService.selectByPrimaryKey(id);
            String urlsrls = video.getUrls();
            String name = urlsrls.substring(urlsrls.indexOf("s") + 2);  //獲取文件名
            File file = new File(filePath +name);
            if(file.exists()){
                file.delete();
            }
            videoService.deleteByPrimaryKey(id);
        }
        return  "redirect:/admin/feiyi_videoList";
    }
    *//**
     * 管理員-人物列表
     *//*
    @RequestMapping("/personList")
    public String personList(Model model,Person person,@RequestParam(value="page",defaultValue="1")Integer page,String sou) {
        PageInfo<Person> pageInfo = personService.selectPageList(person,page,size);
        List<Person> list = pageInfo.getList();
        List<Person> list2 = new ArrayList<Person>();
        //默認顯示第一張圖片
        for(int i =0; i<list.size();i++){
            Person sh = list.get(i);
            String[] img = sh.getImg().split(",");
            if(img.length > 0){
                sh.setImg(img[0]);
                list.set(i,sh);
            }
        }
        if(sou != null && !"".equals(sou)){
            char sz = sou.charAt(0);
            //判斷是否是大寫
            if(Character.isUpperCase(sz)){
                sz = StringRandom.toLower(sz); //大寫轉小寫
            }
            for(int i =0; i<list.size();i++){
                Person sh = list.get(i);
                if(sh.getName() != null){
                    char names = StringRandom.getPinYinHeadChar(sh.getName()); //名字的首字母
                    if(names == sz){
                        list2.add(sh);
                    }
                }
            }
            model.addAttribute("personList",list2);
        }else{
            model.addAttribute("personList",list);
        }
        model.addAttribute("sou",sou);
        model.addAttribute("pageInfo",pageInfo);
        model.addAttribute("person",person);
        return  "behind/admin/feiyi_personList";
    }
    *//**
     * 人物刪除
     * @param model
     * @return
     *//*
    @RequestMapping("/personDelete")
    public String personDelete(Model model,Integer id) {
        if(id !=  null){
            Person person = personService.selectByPrimaryKey(id);
            //刪除人物的圖片
            //String fp= filePath.substring(filePath.indexOf("/")+1);//文件的真實路徑
            String name = person.getImg().substring(person.getImg().indexOf("s") + 2);   //獲取文件名
            File file = new File(filePath +name);
            if(file.exists()){
                file.delete();
            }
            personService.deleteByPrimaryKey(id);
        }
        return  "redirect:/admin/personList";
    }
    *//**
     * 管理員
     *//*
    @RequestMapping("/feiyisList")
    public String zuopinList(Model model,Feiyis feiyis,@RequestParam(value="page",defaultValue="1")Integer page,String sou) {
        feiyis.setState(0);//0為正常 1是管理員下架的
        PageInfo<Feiyis> pageInfo =  feiyisService.selectFeiyis(feiyis,page,size);
        model.addAttribute("feiyiList",pageInfo.getList());
        model.addAttribute("pageInfo",pageInfo);
        model.addAttribute("feiyis",feiyis);
        return  "behind/admin/feiyisList";
    }
    *//**
     * 非遺視界刪除
     * @param model
     * @return
     *//*
    @RequestMapping("/feiyisDelete")
    public String feiyisDelete(Model model,Integer id,Integer type) {
        if (id != null) {
            Feiyis feiyis = feiyisService.selectByPrimaryKey(id);
            //刪除圖片
            // String fp= filePath.substring(filePath.indexOf("/")+1);//文件的真實路徑
            if (feiyis.getImg() != null) {
                String name = feiyis.getImg().substring(feiyis.getImg().indexOf("s") + 2);//獲取文件
                File file = new File(filePath + name);
                if (file.exists()) {
                    file.delete();
                }
            }
            feiyisService.deleteByPrimaryKey(id);
        }
        return "redirect:/admin/feiyisList?type=" + type;
    }
    *//**
     * 後臺主頁
     * @return
     *//*
    @RequestMapping("/index")
    public String index(Model model) {
        //圖表信息
        int zixun =  zixunService.countByExample(null);
        int video =  videoService.countByExample(null);
        int person = personService.countByExample(null);
        int zuocount = feiyisService.countByExamples(1);
        int huocount = feiyisService.countByExamples(2);
        int zoucount = feiyisService.countByExamples(3);
        int facount = feiyisService.countByExamples(4);
        model.addAttribute("zixun",zixun);
        model.addAttribute("video",video);
        model.addAttribute("person",person);
        model.addAttribute("zuocount",zuocount);
        model.addAttribute("huocount",huocount);
        model.addAttribute("zoucount",zoucount);
        model.addAttribute("facount",facount);
        //總評論數
        int commentcount = commentService.countByExample(null);
        //用戶數
        int usercount = usertService.countByExample(null);
        //商品數量
        int shopcount  = shopService.countByExample(null);
        //資訊數量
        int zixuncount  = zixunService.countByExample(null);
        model.addAttribute("commentcount",commentcount);
        model.addAttribute("usercount",usercount);
        model.addAttribute("shopcount",shopcount);
        model.addAttribute("zixuncount",zixuncount);
        return  "behind/admin/index";
    }
    *//**
     * 資訊列表
     * @param model
     * @return
     *//*
    @RequestMapping("/zixunList")
    public String zixunList(Model model, Zixun zixun, @RequestParam(value="page",defaultValue="1")Integer page, String sou) {
        if(zixun == null){
            zixun = new Zixun();
        }
        zixun.setState(0);// 0 是正常 1被下架的
        PageInfo<Zixun> pageInfo =  zixunService.selectZixunList(zixun,page,size);
        model.addAttribute("zixunList",pageInfo.getList());
        model.addAttribute("pageInfo",pageInfo);
        model.addAttribute("zixun",zixun);
        return    "behind/admin/zixunList";
    }
    *//**
     * 資訊下架
     * @param model
     * @return
     *//*
    @RequestMapping("/zixunUptate")
    public String zixunUptate(Model model,Integer id) {
       if(id != null){
           Zixun  zixun = new Zixun();
           zixun.setId(id);
           zixun.setState(1); //1是下架
           zixunService.updateByPrimaryKeySelective(zixun);
       }
        return    "redirect:/admin/zixunList";
    }
    *//**
     * 管理評論
     * @return
     *//*
    @RequestMapping("/commentList")
    public String commentList(Model model,Integer type) {
        if(type != null){
            Comment comment = new Comment();
            comment.setType(type);//商品評論
            comment.setReport(1);//1為舉報的
            List<Comment> commentsList = commentService.selectComment(comment);
            model.addAttribute("commentsList",commentsList);
        }
        return  "behind/admin/commentList";
    }
    *//**
     * 評論刪除
     * @return
     *//*
    @RequestMapping("/commentDel")
    public String commentDel(Model model,Integer id) {
        if(id != null){
            commentService.deleteByPrimaryKey(id);
        }
        return  "redirect:/admin/commentList";
    }
    *//**
     *審核
     * @return
     *//*
    @RequestMapping("/merchantList")
    public String merchantList(Model model,Integer id) {
        Merchant merchant = new Merchant();
        merchant.setState(0);
        List<Merchant> merchantlist =   merchantService.selectMerchant(merchant);
        model.addAttribute("merchantlist",merchantlist);
        return  "behind/admin/merchantList";
    }
    *//**
     *通過
     * @return
     *//*
    @RequestMapping("/merchanUpate")
    public String merchanUpate(Model model,Integer id) {
        Merchant merchant = new Merchant();
        if(id != null){
            merchant.setId(id);
            merchant.setState(1);
            merchantService.updateByPrimaryKeySelective(merchant);
        }
        return  "redirect:/admin/merchantList";
    }
    *//**
     *未通過
     * @return
     *//*
    @RequestMapping("/merchanDel")
    public String merchanDel(Model model,Integer id) {
        if(id != null){
            merchantService.deleteByPrimaryKey(id);
        }
        return  "redirect:/admin/merchantList";
    }
    *//**
     *用戶列表
     * @return
     *//*
    @RequestMapping("/userList")
    public String userList(Model model) {
        List<User> userlist = usertService.selectFull(null);
        model.addAttribute("userlist",userlist);
        return  "behind/admin/userList";
    }
    *//**
     *用戶刪除
     * @return
     *//*
    @RequestMapping("/userDel")
    public String userDel(Model model,Integer id) {
         if(id != null){
             usertService.deleteByPrimaryKey(id);
         }
        return  "redirect:/admin/userList";
    }
    *//**
     *修改密碼
     * @return
     *//*
    @RequestMapping("/adminUptatePassword")
    public String adminUptatePassword(Model model,Admin admin,HttpServletRequest request) {
        HttpSession session = request.getSession();
        Admin ad = (Admin) session.getAttribute("ADMIN");
        if(ad != null && admin.getPassword() != null){
              admin.setId(ad.getId());
               adminService.updateByPrimaryKeySelective(admin);
        }
        return  "redirect:/admin/index";
    }
*/
 
}

到此這篇關於Java實戰寵物醫院預約掛號系統的實現流程的文章就介紹到這瞭,更多相關Java 寵物醫院預約掛號系統內容請搜索WalkonNet以前的文章或繼續瀏覽下面的相關文章希望大傢以後多多支持WalkonNet!

推薦閱讀: