最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Java畢業(yè)設(shè)計實戰(zhàn)之養(yǎng)老院管理系統(tǒng)的實現(xiàn)

 更新時間:2022年03月07日 11:25:30   作者:qq_1334611189  
讀萬卷書不如行萬里路,只學(xué)書上的理論是遠遠不夠的,只有在實戰(zhàn)中才能獲得能力的提升,本篇文章手把手帶你用java+SSM+JSP+Easyui+maven+mysql實現(xiàn)一個養(yǎng)老院管理系統(tǒng),大家可以在過程中查缺補漏,提升水平

運行環(huán)境:

JDK1.8、tomcat8、eclipse、mysql5.6、Navicat

功能實現(xiàn):

用戶: 用戶名,登錄密碼,姓名,性別,出生日期,用戶照片,聯(lián)系電話,郵箱,家庭地址,注冊時間

老人: 老人編號,姓名,性別,年齡,老人照片,老人介紹,登記用戶,登記時間

房間類型: 房間類型id,房間類型名稱

房間: 房間編號,房間類型,房間名稱,房間主圖,房間價格,房間詳情,房間狀態(tài)

訂單: 訂單編號,入住房間,入住老人,入住日期,入住時間,訂單總金額,訂單狀態(tài),訂單費用明細,訂單時間

老人看護: 記錄id,信息類別,信息標(biāo)題,信息內(nèi)容,發(fā)布時間

接待: 接待記錄id,接待類別,接待主題,接待內(nèi)容,接待日期

部門: 部門編號,部門名稱,成立日期,負(fù)責(zé)人

員工: 用戶名,登錄密碼,所在部門,姓名,性別,出生日期,員工照片,聯(lián)系電話,家庭地址

工資: 工資id,員工,工資年份,工資月份,工資金額,發(fā)放日期,工資備注

用戶管理控制層:

//UserInfo管理控制層
@Controller
@RequestMapping("/UserInfo")
public class UserInfoController extends BaseController {
 
    /*業(yè)務(wù)層對象*/
    @Resource UserInfoService userInfoService;
 
	@InitBinder("userInfo")
	public void initBinderUserInfo(WebDataBinder binder) {
		binder.setFieldDefaultPrefix("userInfo.");
	}
	/*跳轉(zhuǎn)到添加UserInfo視圖*/
	@RequestMapping(value = "/add", method = RequestMethod.GET)
	public String add(Model model,HttpServletRequest request) throws Exception {
		model.addAttribute(new UserInfo());
		return "UserInfo_add";
	}
 
	/*客戶端ajax方式提交添加用戶信息*/
	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public void add(@Validated UserInfo userInfo, BindingResult br,
			Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
		String message = "";
		boolean success = false;
		if (br.hasErrors()) {
			message = "輸入信息不符合要求!";
			writeJsonResponse(response, success, message);
			return ;
		}
		if(userInfoService.getUserInfo(userInfo.getUser_name()) != null) {
			message = "用戶名已經(jīng)存在!";
			writeJsonResponse(response, success, message);
			return ;
		}
		try {
			userInfo.setUserPhoto(this.handlePhotoUpload(request, "userPhotoFile"));
		} catch(UserException ex) {
			message = "圖片格式不正確!";
			writeJsonResponse(response, success, message);
			return ;
		}
        userInfoService.addUserInfo(userInfo);
        message = "用戶添加成功!";
        success = true;
        writeJsonResponse(response, success, message);
	}
	/*ajax方式按照查詢條件分頁查詢用戶信息*/
	@RequestMapping(value = { "/list" }, method = {RequestMethod.GET,RequestMethod.POST})
	public void list(String user_name,String name,String birthDate,String telephone,Integer page,Integer rows, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
		if (page==null || page == 0) page = 1;
		if (user_name == null) user_name = "";
		if (name == null) name = "";
		if (birthDate == null) birthDate = "";
		if (telephone == null) telephone = "";
		if(rows != 0)userInfoService.setRows(rows);
		List<UserInfo> userInfoList = userInfoService.queryUserInfo(user_name, name, birthDate, telephone, page);
	    /*計算總的頁數(shù)和總的記錄數(shù)*/
	    userInfoService.queryTotalPageAndRecordNumber(user_name, name, birthDate, telephone);
	    /*獲取到總的頁碼數(shù)目*/
	    int totalPage = userInfoService.getTotalPage();
	    /*當(dāng)前查詢條件下總記錄數(shù)*/
	    int recordNumber = userInfoService.getRecordNumber();
        response.setContentType("text/json;charset=UTF-8");
		PrintWriter out = response.getWriter();
		//將要被返回到客戶端的對象
		JSONObject jsonObj=new JSONObject();
		jsonObj.accumulate("total", recordNumber);
		JSONArray jsonArray = new JSONArray();
		for(UserInfo userInfo:userInfoList) {
			JSONObject jsonUserInfo = userInfo.getJsonObject();
			jsonArray.put(jsonUserInfo);
		}
		jsonObj.accumulate("rows", jsonArray);
		out.println(jsonObj.toString());
		out.flush();
		out.close();
	}
 
	/*ajax方式按照查詢條件分頁查詢用戶信息*/
	@RequestMapping(value = { "/listAll" }, method = {RequestMethod.GET,RequestMethod.POST})
	public void listAll(HttpServletResponse response) throws Exception {
		List<UserInfo> userInfoList = userInfoService.queryAllUserInfo();
        response.setContentType("text/json;charset=UTF-8"); 
		PrintWriter out = response.getWriter();
		JSONArray jsonArray = new JSONArray();
		for(UserInfo userInfo:userInfoList) {
			JSONObject jsonUserInfo = new JSONObject();
			jsonUserInfo.accumulate("user_name", userInfo.getUser_name());
			jsonUserInfo.accumulate("name", userInfo.getName());
			jsonArray.put(jsonUserInfo);
		}
		out.println(jsonArray.toString());
		out.flush();
		out.close();
	}
 
	/*前臺按照查詢條件分頁查詢用戶信息*/
	@RequestMapping(value = { "/frontlist" }, method = {RequestMethod.GET,RequestMethod.POST})
	public String frontlist(String user_name,String name,String birthDate,String telephone,Integer currentPage, Model model, HttpServletRequest request) throws Exception  {
		if (currentPage==null || currentPage == 0) currentPage = 1;
		if (user_name == null) user_name = "";
		if (name == null) name = "";
		if (birthDate == null) birthDate = "";
		if (telephone == null) telephone = "";
		List<UserInfo> userInfoList = userInfoService.queryUserInfo(user_name, name, birthDate, telephone, currentPage);
	    /*計算總的頁數(shù)和總的記錄數(shù)*/
	    userInfoService.queryTotalPageAndRecordNumber(user_name, name, birthDate, telephone);
	    /*獲取到總的頁碼數(shù)目*/
	    int totalPage = userInfoService.getTotalPage();
	    /*當(dāng)前查詢條件下總記錄數(shù)*/
	    int recordNumber = userInfoService.getRecordNumber();
	    request.setAttribute("userInfoList",  userInfoList);
	    request.setAttribute("totalPage", totalPage);
	    request.setAttribute("recordNumber", recordNumber);
	    request.setAttribute("currentPage", currentPage);
	    request.setAttribute("user_name", user_name);
	    request.setAttribute("name", name);
	    request.setAttribute("birthDate", birthDate);
	    request.setAttribute("telephone", telephone);
		return "UserInfo/userInfo_frontquery_result"; 
	}
 
     /*前臺查詢UserInfo信息*/
	@RequestMapping(value="/{user_name}/frontshow",method=RequestMethod.GET)
	public String frontshow(@PathVariable String user_name,Model model,HttpServletRequest request) throws Exception {
		/*根據(jù)主鍵user_name獲取UserInfo對象*/
        UserInfo userInfo = userInfoService.getUserInfo(user_name);
 
        request.setAttribute("userInfo",  userInfo);
        return "UserInfo/userInfo_frontshow";
	}
 
	/*ajax方式顯示用戶修改jsp視圖頁*/
	@RequestMapping(value="/{user_name}/update",method=RequestMethod.GET)
	public void update(@PathVariable String user_name,Model model,HttpServletRequest request,HttpServletResponse response) throws Exception {
        /*根據(jù)主鍵user_name獲取UserInfo對象*/
        UserInfo userInfo = userInfoService.getUserInfo(user_name);
 
        response.setContentType("text/json;charset=UTF-8");
        PrintWriter out = response.getWriter();
		//將要被返回到客戶端的對象 
		JSONObject jsonUserInfo = userInfo.getJsonObject();
		out.println(jsonUserInfo.toString());
		out.flush();
		out.close();
	}
 
	/*ajax方式更新用戶信息*/
	@RequestMapping(value = "/{user_name}/update", method = RequestMethod.POST)
	public void update(@Validated UserInfo userInfo, BindingResult br,
			Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
		String message = "";
    	boolean success = false;
		if (br.hasErrors()) { 
			message = "輸入的信息有錯誤!";
			writeJsonResponse(response, success, message);
			return;
		}
		String userPhotoFileName = this.handlePhotoUpload(request, "userPhotoFile");
		if(!userPhotoFileName.equals("upload/NoImage.jpg"))userInfo.setUserPhoto(userPhotoFileName); 
 
 
		try {
			userInfoService.updateUserInfo(userInfo);
			message = "用戶更新成功!";
			success = true;
			writeJsonResponse(response, success, message);
		} catch (Exception e) {
			e.printStackTrace();
			message = "用戶更新失敗!";
			writeJsonResponse(response, success, message); 
		}
	}
    /*刪除用戶信息*/
	@RequestMapping(value="/{user_name}/delete",method=RequestMethod.GET)
	public String delete(@PathVariable String user_name,HttpServletRequest request) throws UnsupportedEncodingException {
		  try {
			  userInfoService.deleteUserInfo(user_name);
	            request.setAttribute("message", "用戶刪除成功!");
	            return "message";
	        } catch (Exception e) { 
	            e.printStackTrace();
	            request.setAttribute("error", "用戶刪除失敗!");
				return "error";
 
	        }
 
	}
 
	/*ajax方式刪除多條用戶記錄*/
	@RequestMapping(value="/deletes",method=RequestMethod.POST)
	public void delete(String user_names,HttpServletRequest request,HttpServletResponse response) throws IOException, JSONException {
		String message = "";
    	boolean success = false;
        try { 
        	int count = userInfoService.deleteUserInfos(user_names);
        	success = true;
        	message = count + "條記錄刪除成功";
        	writeJsonResponse(response, success, message);
        } catch (Exception e) { 
            //e.printStackTrace();
            message = "有記錄存在外鍵約束,刪除失敗";
            writeJsonResponse(response, success, message);
        }
	}
 
	/*按照查詢條件導(dǎo)出用戶信息到Excel*/
	@RequestMapping(value = { "/OutToExcel" }, method = {RequestMethod.GET,RequestMethod.POST})
	public void OutToExcel(String user_name,String name,String birthDate,String telephone, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
        if(user_name == null) user_name = "";
        if(name == null) name = "";
        if(birthDate == null) birthDate = "";
        if(telephone == null) telephone = "";
        List<UserInfo> userInfoList = userInfoService.queryUserInfo(user_name,name,birthDate,telephone);
        ExportExcelUtil ex = new ExportExcelUtil();
        String _title = "UserInfo信息記錄"; 
        String[] headers = { "用戶名","姓名","性別","出生日期","用戶照片","聯(lián)系電話","郵箱","注冊時間"};
        List<String[]> dataset = new ArrayList<String[]>(); 
        for(int i=0;i<userInfoList.size();i++) {
        	UserInfo userInfo = userInfoList.get(i); 
        	dataset.add(new String[]{userInfo.getUser_name(),userInfo.getName(),userInfo.getGender(),userInfo.getBirthDate(),userInfo.getUserPhoto(),userInfo.getTelephone(),userInfo.getEmail(),userInfo.getRegTime()});
        }
        /*
        OutputStream out = null;
		try {
			out = new FileOutputStream("C://output.xls");
			ex.exportExcel(title,headers, dataset, out);
		    out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		*/
		OutputStream out = null;//創(chuàng)建一個輸出流對象 
		try { 
			out = response.getOutputStream();//
			response.setHeader("Content-disposition","attachment; filename="+"UserInfo.xls");//filename是下載的xls的名,建議最好用英文 
			response.setContentType("application/msexcel;charset=UTF-8");//設(shè)置類型 
			response.setHeader("Pragma","No-cache");//設(shè)置頭 
			response.setHeader("Cache-Control","no-cache");//設(shè)置頭 
			response.setDateHeader("Expires", 0);//設(shè)置日期頭  
			String rootPath = request.getSession().getServletContext().getRealPath("/");
			ex.exportExcel(rootPath,_title,headers, dataset, out);
			out.flush();
		} catch (IOException e) { 
			e.printStackTrace(); 
		}finally{
			try{
				if(out!=null){ 
					out.close(); 
				}
			}catch(IOException e){ 
				e.printStackTrace(); 
			} 
		}
    }
}

管理員管理控制層:

@Controller
@SessionAttributes("username")
public class SystemController { 
	
	@Resource AdminService adminService;  
	
	@Resource UserInfoService userInfoService;  
	
	@RequestMapping(value="/login",method=RequestMethod.GET)
	public String login(Model model) {
		model.addAttribute(new Admin());
		return "login";
	}
 
	//前臺用戶登錄
	@RequestMapping(value="/frontLogin",method=RequestMethod.POST)
	public void frontLogin(@RequestParam("userName")String userName,@RequestParam("password")String password,HttpServletResponse response,HttpSession session) throws Exception { 
		boolean success = true;
		String msg = ""; 
 
		if (!userInfoService.checkLogin(userName, password)) { 
			msg = userInfoService.getErrMessage();
			success = false; 
		} 
		if(success) {
			session.setAttribute("user_name", userName); 
		}
  
        response.setContentType("text/json;charset=UTF-8");  
        PrintWriter out = response.getWriter();  
        //將要被返回到客戶端的對象   
        JSONObject json=new JSONObject();   
        json.accumulate("success", success);
        json.accumulate("msg", msg);
        out.println(json.toString());   
        out.flush();  
        out.close();  
	}
 
 
	@RequestMapping(value="/login",method=RequestMethod.POST)
	public void login(@Validated Admin admin,BindingResult br,Model model,HttpServletRequest request,HttpServletResponse response,HttpSession session) throws Exception { 
		boolean success = true;
		String msg = ""; 
		if(br.hasErrors()) {
			msg = br.getAllErrors().toString();
			success = false;  
		} 
		if (!adminService.checkLogin(admin)) { 
			msg = adminService.getErrMessage();
			success = false; 
		} 
		if(success) {
			session.setAttribute("username", admin.getUsername()); 
		}  
        response.setContentType("text/json;charset=UTF-8");  
        PrintWriter out = response.getWriter();  
        //將要被返回到客戶端的對象   
        JSONObject json=new JSONObject();   
        json.accumulate("success", success);
        json.accumulate("msg", msg);
        out.println(json.toString());   
        out.flush();  
        out.close();  
	}
	
	
	
	@RequestMapping("/logout")
	public String logout(Model model,HttpSession session) {
		model.asMap().remove("username"); 
		session.invalidate();
		return "redirect:/login";
	}
	
	
	@RequestMapping(value="/changePassword",method=RequestMethod.POST)
	public String ChangePassword(String oldPassword,String newPassword,String newPassword2,HttpServletRequest request,HttpSession session) throws Exception { 
		if(oldPassword.equals("")) throw new UserException("請輸入舊密碼!");
		if(newPassword.equals("")) throw new UserException("請輸入新密碼!");
		if(!newPassword.equals(newPassword2)) throw new UserException("兩次新密碼輸入不一致"); 
		
		String username = (String)session.getAttribute("username");
		if(username == null) throw new UserException("session會話超時,請重新登錄系統(tǒng)!");
		 
		
		Admin admin = adminService.findAdminByUserName(username); 
		if(!admin.getPassword().equals(oldPassword)) throw new UserException("輸入的舊密碼不正確!");
		
		try { 
			adminService.changePassword(username,newPassword);
			request.setAttribute("message", java.net.URLEncoder.encode(
					"密碼修改成功!", "GBK"));
			return "message";
		} catch (Exception e) {
			e.printStackTrace();
			request.setAttribute("error", java.net.URLEncoder
					.encode("密碼修改失敗!","GBK"));
			return "error";
		}   
	}
	
	
	
	
}

房間管理控制層:

//Room管理控制層
@Controller
@RequestMapping("/Room")
public class RoomController extends BaseController {
 
    /*業(yè)務(wù)層對象*/
    @Resource RoomService roomService;
 
    @Resource RoomTypeService roomTypeService;
	@InitBinder("roomTypeObj")
	public void initBinderroomTypeObj(WebDataBinder binder) {
		binder.setFieldDefaultPrefix("roomTypeObj.");
	}
	@InitBinder("room")
	public void initBinderRoom(WebDataBinder binder) {
		binder.setFieldDefaultPrefix("room.");
	}
	/*跳轉(zhuǎn)到添加Room視圖*/
	@RequestMapping(value = "/add", method = RequestMethod.GET)
	public String add(Model model,HttpServletRequest request) throws Exception {
		model.addAttribute(new Room());
		/*查詢所有的RoomType信息*/
		List<RoomType> roomTypeList = roomTypeService.queryAllRoomType();
		request.setAttribute("roomTypeList", roomTypeList);
		return "Room_add";
	}
 
	/*客戶端ajax方式提交添加房間信息*/
	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public void add(@Validated Room room, BindingResult br,
			Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
		String message = "";
		boolean success = false;
		if (br.hasErrors()) {
			message = "輸入信息不符合要求!";
			writeJsonResponse(response, success, message);
			return ;
		}
		if(roomService.getRoom(room.getRoomNo()) != null) {
			message = "房間編號已經(jīng)存在!";
			writeJsonResponse(response, success, message);
			return ;
		}
		try {
			room.setMainPhoto(this.handlePhotoUpload(request, "mainPhotoFile"));
		} catch(UserException ex) {
			message = "圖片格式不正確!";
			writeJsonResponse(response, success, message);
			return ;
		}
        roomService.addRoom(room);
        message = "房間添加成功!";
        success = true;
        writeJsonResponse(response, success, message);
	}
	/*ajax方式按照查詢條件分頁查詢房間信息*/
	@RequestMapping(value = { "/list" }, method = {RequestMethod.GET,RequestMethod.POST})
	public void list(String roomNo,@ModelAttribute("roomTypeObj") RoomType roomTypeObj,String roomName,String roomState,Integer page,Integer rows, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
		if (page==null || page == 0) page = 1;
		if (roomNo == null) roomNo = "";
		if (roomName == null) roomName = "";
		if (roomState == null) roomState = "";
		if(rows != 0)roomService.setRows(rows);
		List<Room> roomList = roomService.queryRoom(roomNo, roomTypeObj, roomName, roomState, page);
	    /*計算總的頁數(shù)和總的記錄數(shù)*/
	    roomService.queryTotalPageAndRecordNumber(roomNo, roomTypeObj, roomName, roomState);
	    /*獲取到總的頁碼數(shù)目*/
	    int totalPage = roomService.getTotalPage();
	    /*當(dāng)前查詢條件下總記錄數(shù)*/
	    int recordNumber = roomService.getRecordNumber();
        response.setContentType("text/json;charset=UTF-8");
		PrintWriter out = response.getWriter();
		//將要被返回到客戶端的對象
		JSONObject jsonObj=new JSONObject();
		jsonObj.accumulate("total", recordNumber);
		JSONArray jsonArray = new JSONArray();
		for(Room room:roomList) {
			JSONObject jsonRoom = room.getJsonObject();
			jsonArray.put(jsonRoom);
		}
		jsonObj.accumulate("rows", jsonArray);
		out.println(jsonObj.toString());
		out.flush();
		out.close();
	}
 
	/*ajax方式按照查詢條件分頁查詢房間信息*/
	@RequestMapping(value = { "/listAll" }, method = {RequestMethod.GET,RequestMethod.POST})
	public void listAll(HttpServletResponse response) throws Exception {
		List<Room> roomList = roomService.queryAllRoom();
        response.setContentType("text/json;charset=UTF-8"); 
		PrintWriter out = response.getWriter();
		JSONArray jsonArray = new JSONArray();
		for(Room room:roomList) {
			JSONObject jsonRoom = new JSONObject();
			jsonRoom.accumulate("roomNo", room.getRoomNo());
			jsonRoom.accumulate("roomName", room.getRoomName());
			jsonArray.put(jsonRoom);
		}
		out.println(jsonArray.toString());
		out.flush();
		out.close();
	}
 
	/*前臺按照查詢條件分頁查詢房間信息*/
	@RequestMapping(value = { "/frontlist" }, method = {RequestMethod.GET,RequestMethod.POST})
	public String frontlist(String roomNo,@ModelAttribute("roomTypeObj") RoomType roomTypeObj,String roomName,String roomState,Integer currentPage, Model model, HttpServletRequest request) throws Exception  {
		if (currentPage==null || currentPage == 0) currentPage = 1;
		if (roomNo == null) roomNo = "";
		if (roomName == null) roomName = "";
		if (roomState == null) roomState = "";
		List<Room> roomList = roomService.queryRoom(roomNo, roomTypeObj, roomName, roomState, currentPage);
	    /*計算總的頁數(shù)和總的記錄數(shù)*/
	    roomService.queryTotalPageAndRecordNumber(roomNo, roomTypeObj, roomName, roomState);
	    /*獲取到總的頁碼數(shù)目*/
	    int totalPage = roomService.getTotalPage();
	    /*當(dāng)前查詢條件下總記錄數(shù)*/
	    int recordNumber = roomService.getRecordNumber();
	    request.setAttribute("roomList",  roomList);
	    request.setAttribute("totalPage", totalPage);
	    request.setAttribute("recordNumber", recordNumber);
	    request.setAttribute("currentPage", currentPage);
	    request.setAttribute("roomNo", roomNo);
	    request.setAttribute("roomTypeObj", roomTypeObj);
	    request.setAttribute("roomName", roomName);
	    request.setAttribute("roomState", roomState);
	    List<RoomType> roomTypeList = roomTypeService.queryAllRoomType();
	    request.setAttribute("roomTypeList", roomTypeList);
		return "Room/room_frontquery_result"; 
	}
 
     /*前臺查詢Room信息*/
	@RequestMapping(value="/{roomNo}/frontshow",method=RequestMethod.GET)
	public String frontshow(@PathVariable String roomNo,Model model,HttpServletRequest request) throws Exception {
		/*根據(jù)主鍵roomNo獲取Room對象*/
        Room room = roomService.getRoom(roomNo);
 
        List<RoomType> roomTypeList = roomTypeService.queryAllRoomType();
        request.setAttribute("roomTypeList", roomTypeList);
        request.setAttribute("room",  room);
        return "Room/room_frontshow";
	}
 
	/*ajax方式顯示房間修改jsp視圖頁*/
	@RequestMapping(value="/{roomNo}/update",method=RequestMethod.GET)
	public void update(@PathVariable String roomNo,Model model,HttpServletRequest request,HttpServletResponse response) throws Exception {
        /*根據(jù)主鍵roomNo獲取Room對象*/
        Room room = roomService.getRoom(roomNo);
 
        response.setContentType("text/json;charset=UTF-8");
        PrintWriter out = response.getWriter();
		//將要被返回到客戶端的對象 
		JSONObject jsonRoom = room.getJsonObject();
		out.println(jsonRoom.toString());
		out.flush();
		out.close();
	}
 
	/*ajax方式更新房間信息*/
	@RequestMapping(value = "/{roomNo}/update", method = RequestMethod.POST)
	public void update(@Validated Room room, BindingResult br,
			Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
		String message = "";
    	boolean success = false;
		if (br.hasErrors()) { 
			message = "輸入的信息有錯誤!";
			writeJsonResponse(response, success, message);
			return;
		}
		String mainPhotoFileName = this.handlePhotoUpload(request, "mainPhotoFile");
		if(!mainPhotoFileName.equals("upload/NoImage.jpg"))room.setMainPhoto(mainPhotoFileName); 
 
 
		try {
			roomService.updateRoom(room);
			message = "房間更新成功!";
			success = true;
			writeJsonResponse(response, success, message);
		} catch (Exception e) {
			e.printStackTrace();
			message = "房間更新失敗!";
			writeJsonResponse(response, success, message); 
		}
	}
    /*刪除房間信息*/
	@RequestMapping(value="/{roomNo}/delete",method=RequestMethod.GET)
	public String delete(@PathVariable String roomNo,HttpServletRequest request) throws UnsupportedEncodingException {
		  try {
			  roomService.deleteRoom(roomNo);
	            request.setAttribute("message", "房間刪除成功!");
	            return "message";
	        } catch (Exception e) { 
	            e.printStackTrace();
	            request.setAttribute("error", "房間刪除失敗!");
				return "error";
 
	        }
 
	}
 
	/*ajax方式刪除多條房間記錄*/
	@RequestMapping(value="/deletes",method=RequestMethod.POST)
	public void delete(String roomNos,HttpServletRequest request,HttpServletResponse response) throws IOException, JSONException {
		String message = "";
    	boolean success = false;
        try { 
        	int count = roomService.deleteRooms(roomNos);
        	success = true;
        	message = count + "條記錄刪除成功";
        	writeJsonResponse(response, success, message);
        } catch (Exception e) { 
            //e.printStackTrace();
            message = "有記錄存在外鍵約束,刪除失敗";
            writeJsonResponse(response, success, message);
        }
	}
 
	/*按照查詢條件導(dǎo)出房間信息到Excel*/
	@RequestMapping(value = { "/OutToExcel" }, method = {RequestMethod.GET,RequestMethod.POST})
	public void OutToExcel(String roomNo,@ModelAttribute("roomTypeObj") RoomType roomTypeObj,String roomName,String roomState, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
        if(roomNo == null) roomNo = "";
        if(roomName == null) roomName = "";
        if(roomState == null) roomState = "";
        List<Room> roomList = roomService.queryRoom(roomNo,roomTypeObj,roomName,roomState);
        ExportExcelUtil ex = new ExportExcelUtil();
        String _title = "Room信息記錄"; 
        String[] headers = { "房間編號","房間類型","房間名稱","房間主圖","房間價格","房間狀態(tài)"};
        List<String[]> dataset = new ArrayList<String[]>(); 
        for(int i=0;i<roomList.size();i++) {
        	Room room = roomList.get(i); 
        	dataset.add(new String[]{room.getRoomNo(),room.getRoomTypeObj().getTypeName(),room.getRoomName(),room.getMainPhoto(),room.getPrice() + "",room.getRoomState()});
        }
        /*
        OutputStream out = null;
		try {
			out = new FileOutputStream("C://output.xls");
			ex.exportExcel(title,headers, dataset, out);
		    out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		*/
		OutputStream out = null;//創(chuàng)建一個輸出流對象 
		try { 
			out = response.getOutputStream();//
			response.setHeader("Content-disposition","attachment; filename="+"Room.xls");//filename是下載的xls的名,建議最好用英文 
			response.setContentType("application/msexcel;charset=UTF-8");//設(shè)置類型 
			response.setHeader("Pragma","No-cache");//設(shè)置頭 
			response.setHeader("Cache-Control","no-cache");//設(shè)置頭 
			response.setDateHeader("Expires", 0);//設(shè)置日期頭  
			String rootPath = request.getSession().getServletContext().getRealPath("/");
			ex.exportExcel(rootPath,_title,headers, dataset, out);
			out.flush();
		} catch (IOException e) { 
			e.printStackTrace(); 
		}finally{
			try{
				if(out!=null){ 
					out.close(); 
				}
			}catch(IOException e){ 
				e.printStackTrace(); 
			} 
		}
    }
}

到此這篇關(guān)于Java畢業(yè)設(shè)計實戰(zhàn)之養(yǎng)老院管理系統(tǒng)的實現(xiàn)的文章就介紹到這了,更多相關(guān)Java 養(yǎng)老院管理系統(tǒng)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • MyBatis Plus整合Redis實現(xiàn)分布式二級緩存的問題

    MyBatis Plus整合Redis實現(xiàn)分布式二級緩存的問題

    Mybatis內(nèi)置的二級緩存在分布式環(huán)境下存在分布式問題,無法使用,但是我們可以整合Redis來實現(xiàn)分布式的二級緩存,這篇文章給大家介紹MyBatis Plus整合Redis實現(xiàn)分布式二級緩存,感興趣的朋友跟隨小編一起看看吧
    2023-11-11
  • java導(dǎo)出生成csv文件的方法

    java導(dǎo)出生成csv文件的方法

    這篇文章主要為大家詳細介紹了java導(dǎo)出生成csv文件的相關(guān)資料,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • Spring中的refreshContext源碼分析

    Spring中的refreshContext源碼分析

    這篇文章主要介紹了Spring中的refreshContext源碼分析,在SpringBoot啟動流程中,主要的兩個階段是初始化SpringApplication對象以及SpringApplication.run方法執(zhí)行的內(nèi)容,今天主要細講的是SpringApplication.run中的刷新容器refreshContext方法,需要的朋友可以參考下
    2023-12-12
  • java普通項目讀取不到resources目錄下資源文件的解決辦法

    java普通項目讀取不到resources目錄下資源文件的解決辦法

    這篇文章主要給大家介紹了關(guān)于java普通項目讀取不到resources目錄下資源文件的解決辦法,Web項目中應(yīng)該經(jīng)常有這樣的需求,在maven項目的resources目錄下放一些文件,比如一些配置文件,資源文件等,需要的朋友可以參考下
    2023-09-09
  • JDK17安裝教程以及其環(huán)境變量配置教程

    JDK17安裝教程以及其環(huán)境變量配置教程

    環(huán)境變量對Java初學(xué)者來說真的是一件頭疼的事,本人也經(jīng)歷過這樣的事情,這篇文章主要給大家介紹了關(guān)于JDK17安裝教程以及其環(huán)境變量配置的相關(guān)資料,文中通過代碼介紹的非常詳細,需要的朋友可以參考下
    2024-03-03
  • Spring Cloud中使用Feign,@RequestBody無法繼承的解決方案

    Spring Cloud中使用Feign,@RequestBody無法繼承的解決方案

    這篇文章主要介紹了Spring Cloud中使用Feign,@RequestBody無法繼承的解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-10-10
  • SpringBoot實現(xiàn)物品收藏功能

    SpringBoot實現(xiàn)物品收藏功能

    這篇文章主要介紹了SpringBoot實現(xiàn)物品收藏功能,本文通過實例代碼給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-04-04
  • 如何使用java修改文件所有者及其權(quán)限

    如何使用java修改文件所有者及其權(quán)限

    這篇文章主要介紹了如何使用java修改文件所有者及其權(quán)限,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2019-12-12
  • 解決mybatis一對多查詢resultMap只返回了一條記錄問題

    解決mybatis一對多查詢resultMap只返回了一條記錄問題

    小編接到領(lǐng)導(dǎo)一個任務(wù)需求,需要用到使用resultMap相關(guān)知識,在這小編記錄下這個問題的解決方法,對mybatis一對多查詢resultMap項目知識感興趣的朋友一起看看吧
    2021-11-11
  • Java接口名稱沖突問題的講解

    Java接口名稱沖突問題的講解

    今天小編就為大家分享一篇關(guān)于Java接口名稱沖突問題的講解,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2019-04-04

最新評論

集安市| 沛县| 虹口区| 临江市| 平陆县| 澜沧| 台北县| 中卫市| 云和县| 友谊县| 平昌县| 麻阳| 镇安县| 伊宁市| 大余县| 遂川县| 泰安市| 宁陵县| 堆龙德庆县| 舒兰市| 嘉定区| 新闻| 大理市| 临高县| 榆中县| 万源市| 桐城市| 西贡区| 紫金县| 邳州市| 岑巩县| 兰考县| 梅河口市| 嘉善县| 延川县| 社旗县| 临泽县| 资溪县| 太白县| 铜山县| 茌平县|