Java项目:养老院管理系统(java+SpringBoot+thymeleaf+HTML+Js+mysql)

二.Springboot+Thymeleaf 整合之前后端(文本)交互 springboot 与 thymeleaf 整合前后端(文本)交互 阅读详情

源码获取:博客首页 "资源" 里下载!

项目介绍

基于springboot的养老院管理系统,本系统为后台管理系统,分为三个角色,分别是超级管理员、管理员、用户。

超级管理员、管理员的功能如下:
登录、修改密码、账号管理、健康档案管理、病例管理、药品管理、每月餐饮管理、外出报备、入住登记、寝室分配、事故记录、访客记录、收费管理; 其中超级管理员可进行管理员账号管理;

用户的功能如下:
登录、修改密码、个人信息、家人情况、每月餐饮管理、外出报备、查看收费标准

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 5.7版本;
6.是否Maven项目: 是;查看源码目录中是否包含pom.xml;

若包含,则为maven项目,否则为非maven项目

技术栈

1.后端:springboot+Mybatis

2.前端:HTML+thymeleaf+Javascript+css

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat;
3. 将项目中application-dev.yml配置文件中的数据库配置改为自己的配置
4. 运行项目,在浏览器中输入地址:http://localhost:8080/ 登录账号;
超级管理员:root/123456
管理员:admin/123456
用户:user/123456

 

 

 

 

 

 

用户管理控制层:

//UserInfo管理控制层
@Controller
@RequestMapping("/UserInfo")
public class UserInfoController extends BaseController {

    /*业务层对象*/
    @Resource UserInfoService userInfoService;

	@InitBinder("userInfo")
	public void initBinderUserInfo(WebDataBinder binder) {
		binder.setFieldDefaultPrefix("userInfo.");
	}
	/*跳转到添加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 = "用户名已经存在!";
			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);
	    /*计算总的页数和总的记录数*/
	    userInfoService.queryTotalPageAndRecordNumber(user_name, name, birthDate, telephone);
	    /*获取到总的页码数目*/
	    int totalPage = userInfoService.getTotalPage();
	    /*当前查询条件下总记录数*/
	    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);
	    /*计算总的页数和总的记录数*/
	    userInfoService.queryTotalPageAndRecordNumber(user_name, name, birthDate, telephone);
	    /*获取到总的页码数目*/
	    int totalPage = userInfoService.getTotalPage();
	    /*当前查询条件下总记录数*/
	    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 {
		/*根据主键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 {
        /*根据主键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);
        }
	}

	/*按照查询条件导出用户信息到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 = { "用户名","姓名","性别","出生日期","用户照片","联系电话","邮箱","注册时间"};
        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;//创建一个输出流对象 
		try { 
			out = response.getOutputStream();//
			response.setHeader("Content-disposition","attachment; filename="+"UserInfo.xls");//filename是下载的xls的名,建议最好用英文 
			response.setContentType("application/msexcel;charset=UTF-8");//设置类型 
			response.setHeader("Pragma","No-cache");//设置头 
			response.setHeader("Cache-Control","no-cache");//设置头 
			response.setDateHeader("Expires", 0);//设置日期头  
			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
@RequestMapping("/Room")
public class RoomController extends BaseController {

    /*业务层对象*/
    @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.");
	}
	/*跳转到添加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 = "房间编号已经存在!";
			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);
	    /*计算总的页数和总的记录数*/
	    roomService.queryTotalPageAndRecordNumber(roomNo, roomTypeObj, roomName, roomState);
	    /*获取到总的页码数目*/
	    int totalPage = roomService.getTotalPage();
	    /*当前查询条件下总记录数*/
	    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);
	    /*计算总的页数和总的记录数*/
	    roomService.queryTotalPageAndRecordNumber(roomNo, roomTypeObj, roomName, roomState);
	    /*获取到总的页码数目*/
	    int totalPage = roomService.getTotalPage();
	    /*当前查询条件下总记录数*/
	    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 {
		/*根据主键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 {
        /*根据主键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);
        }
	}

	/*按照查询条件导出房间信息到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 = { "房间编号","房间类型","房间名称","房间主图","房间价格","房间状态"};
        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;//创建一个输出流对象 
		try { 
			out = response.getOutputStream();//
			response.setHeader("Content-disposition","attachment; filename="+"Room.xls");//filename是下载的xls的名,建议最好用英文 
			response.setContentType("application/msexcel;charset=UTF-8");//设置类型 
			response.setHeader("Pragma","No-cache");//设置头 
			response.setHeader("Cache-Control","no-cache");//设置头 
			response.setDateHeader("Expires", 0);//设置日期头  
			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
@RequestMapping("/OldMan")
public class OldManController extends BaseController {

    /*业务层对象*/
    @Resource OldManService oldManService;

    @Resource UserInfoService userInfoService;
	@InitBinder("userObj")
	public void initBinderuserObj(WebDataBinder binder) {
		binder.setFieldDefaultPrefix("userObj.");
	}
	@InitBinder("oldMan")
	public void initBinderOldMan(WebDataBinder binder) {
		binder.setFieldDefaultPrefix("oldMan.");
	}
	/*跳转到添加OldMan视图*/
	@RequestMapping(value = "/add", method = RequestMethod.GET)
	public String add(Model model,HttpServletRequest request) throws Exception {
		model.addAttribute(new OldMan());
		/*查询所有的UserInfo信息*/
		List<UserInfo> userInfoList = userInfoService.queryAllUserInfo();
		request.setAttribute("userInfoList", userInfoList);
		return "OldMan_add";
	}

	/*客户端ajax方式提交添加老人信息*/
	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public void add(@Validated OldMan oldMan, BindingResult br,
			Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
		String message = "";
		boolean success = false;
		if (br.hasErrors()) {
			message = "输入信息不符合要求!";
			writeJsonResponse(response, success, message);
			return ;
		}
		try {
			oldMan.setManPhoto(this.handlePhotoUpload(request, "manPhotoFile"));
		} catch(UserException ex) {
			message = "图片格式不正确!";
			writeJsonResponse(response, success, message);
			return ;
		}
        oldManService.addOldMan(oldMan);
        message = "老人添加成功!";
        success = true;
        writeJsonResponse(response, success, message);
	}
	/*ajax方式按照查询条件分页查询老人信息*/
	@RequestMapping(value = { "/list" }, method = {RequestMethod.GET,RequestMethod.POST})
	public void list(String name,@ModelAttribute("userObj") UserInfo userObj,String addTime,Integer page,Integer rows, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
		if (page==null || page == 0) page = 1;
		if (name == null) name = "";
		if (addTime == null) addTime = "";
		if(rows != 0)oldManService.setRows(rows);
		List<OldMan> oldManList = oldManService.queryOldMan(name, userObj, addTime, page);
	    /*计算总的页数和总的记录数*/
	    oldManService.queryTotalPageAndRecordNumber(name, userObj, addTime);
	    /*获取到总的页码数目*/
	    int totalPage = oldManService.getTotalPage();
	    /*当前查询条件下总记录数*/
	    int recordNumber = oldManService.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(OldMan oldMan:oldManList) {
			JSONObject jsonOldMan = oldMan.getJsonObject();
			jsonArray.put(jsonOldMan);
		}
		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<OldMan> oldManList = oldManService.queryAllOldMan();
        response.setContentType("text/json;charset=UTF-8"); 
		PrintWriter out = response.getWriter();
		JSONArray jsonArray = new JSONArray();
		for(OldMan oldMan:oldManList) {
			JSONObject jsonOldMan = new JSONObject();
			jsonOldMan.accumulate("oldManId", oldMan.getOldManId());
			jsonOldMan.accumulate("name", oldMan.getName());
			jsonArray.put(jsonOldMan);
		}
		out.println(jsonArray.toString());
		out.flush();
		out.close();
	}

	/*前台按照查询条件分页查询老人信息*/
	@RequestMapping(value = { "/frontlist" }, method = {RequestMethod.GET,RequestMethod.POST})
	public String frontlist(String name,@ModelAttribute("userObj") UserInfo userObj,String addTime,Integer currentPage, Model model, HttpServletRequest request) throws Exception  {
		if (currentPage==null || currentPage == 0) currentPage = 1;
		if (name == null) name = "";
		if (addTime == null) addTime = "";
		List<OldMan> oldManList = oldManService.queryOldMan(name, userObj, addTime, currentPage);
	    /*计算总的页数和总的记录数*/
	    oldManService.queryTotalPageAndRecordNumber(name, userObj, addTime);
	    /*获取到总的页码数目*/
	    int totalPage = oldManService.getTotalPage();
	    /*当前查询条件下总记录数*/
	    int recordNumber = oldManService.getRecordNumber();
	    request.setAttribute("oldManList",  oldManList);
	    request.setAttribute("totalPage", totalPage);
	    request.setAttribute("recordNumber", recordNumber);
	    request.setAttribute("currentPage", currentPage);
	    request.setAttribute("name", name);
	    request.setAttribute("userObj", userObj);
	    request.setAttribute("addTime", addTime);
	    List<UserInfo> userInfoList = userInfoService.queryAllUserInfo();
	    request.setAttribute("userInfoList", userInfoList);
		return "OldMan/oldMan_frontquery_result"; 
	}

     /*前台查询OldMan信息*/
	@RequestMapping(value="/{oldManId}/frontshow",method=RequestMethod.GET)
	public String frontshow(@PathVariable Integer oldManId,Model model,HttpServletRequest request) throws Exception {
		/*根据主键oldManId获取OldMan对象*/
        OldMan oldMan = oldManService.getOldMan(oldManId);

        List<UserInfo> userInfoList = userInfoService.queryAllUserInfo();
        request.setAttribute("userInfoList", userInfoList);
        request.setAttribute("oldMan",  oldMan);
        return "OldMan/oldMan_frontshow";
	}

	/*ajax方式显示老人修改jsp视图页*/
	@RequestMapping(value="/{oldManId}/update",method=RequestMethod.GET)
	public void update(@PathVariable Integer oldManId,Model model,HttpServletRequest request,HttpServletResponse response) throws Exception {
        /*根据主键oldManId获取OldMan对象*/
        OldMan oldMan = oldManService.getOldMan(oldManId);

        response.setContentType("text/json;charset=UTF-8");
        PrintWriter out = response.getWriter();
		//将要被返回到客户端的对象 
		JSONObject jsonOldMan = oldMan.getJsonObject();
		out.println(jsonOldMan.toString());
		out.flush();
		out.close();
	}

	/*ajax方式更新老人信息*/
	@RequestMapping(value = "/{oldManId}/update", method = RequestMethod.POST)
	public void update(@Validated OldMan oldMan, 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 manPhotoFileName = this.handlePhotoUpload(request, "manPhotoFile");
		if(!manPhotoFileName.equals("upload/NoImage.jpg"))oldMan.setManPhoto(manPhotoFileName); 


		try {
			oldManService.updateOldMan(oldMan);
			message = "老人更新成功!";
			success = true;
			writeJsonResponse(response, success, message);
		} catch (Exception e) {
			e.printStackTrace();
			message = "老人更新失败!";
			writeJsonResponse(response, success, message); 
		}
	}
    /*删除老人信息*/
	@RequestMapping(value="/{oldManId}/delete",method=RequestMethod.GET)
	public String delete(@PathVariable Integer oldManId,HttpServletRequest request) throws UnsupportedEncodingException {
		  try {
			  oldManService.deleteOldMan(oldManId);
	            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 oldManIds,HttpServletRequest request,HttpServletResponse response) throws IOException, JSONException {
		String message = "";
    	boolean success = false;
        try { 
        	int count = oldManService.deleteOldMans(oldManIds);
        	success = true;
        	message = count + "条记录删除成功";
        	writeJsonResponse(response, success, message);
        } catch (Exception e) { 
            //e.printStackTrace();
            message = "有记录存在外键约束,删除失败";
            writeJsonResponse(response, success, message);
        }
	}

	/*按照查询条件导出老人信息到Excel*/
	@RequestMapping(value = { "/OutToExcel" }, method = {RequestMethod.GET,RequestMethod.POST})
	public void OutToExcel(String name,@ModelAttribute("userObj") UserInfo userObj,String addTime, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
        if(name == null) name = "";
        if(addTime == null) addTime = "";
        List<OldMan> oldManList = oldManService.queryOldMan(name,userObj,addTime);
        ExportExcelUtil ex = new ExportExcelUtil();
        String _title = "OldMan信息记录"; 
        String[] headers = { "老人编号","姓名","性别","年龄","老人照片","登记用户","登记时间"};
        List<String[]> dataset = new ArrayList<String[]>(); 
        for(int i=0;i<oldManList.size();i++) {
        	OldMan oldMan = oldManList.get(i); 
        	dataset.add(new String[]{oldMan.getOldManId() + "",oldMan.getName(),oldMan.getSex(),oldMan.getAge() + "",oldMan.getManPhoto(),oldMan.getUserObj().getName(),oldMan.getAddTime()});
        }
        /*
        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;//创建一个输出流对象 
		try { 
			out = response.getOutputStream();//
			response.setHeader("Content-disposition","attachment; filename="+"OldMan.xls");//filename是下载的xls的名,建议最好用英文 
			response.setContentType("application/msexcel;charset=UTF-8");//设置类型 
			response.setHeader("Pragma","No-cache");//设置头 
			response.setHeader("Cache-Control","no-cache");//设置头 
			response.setDateHeader("Expires", 0);//设置日期头  
			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(); 
			} 
		}
    }
}

源码获取:博客首页 "资源" 里下载! 

基于javaweb的社区养老医疗综合服务系统(java+springboot+bootstrap+html+mysql) 基于javaweb的社区养老医疗综合服务系统(java+springboot+bootstrap+html+mysql) 运行环境 Java≥8、MySQL≥5.7 开发工具 eclipse/idea/myeclipse/sts等均可配置运行 适用 课程设计,大作业,毕业设计,项目练习,学习演示等 功能说明 阅读详情

相关推荐

Java项目:精品养老院管理系统(java+Springboot+Maven+mybatis+Vue+Mysql)

一、项目简述 本系统功能包括:通知公告,老人管理,护工管理,问答管理等等功能。 二、项目运行 环境配置: Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。 项目技术: Springboot + Maven + mybatis+ Vue 等等组成,B/S模式 + Maven管理等等。

基于java的敬老院管理系统设计与实现(项目报告+答辩PPT+源代码+数据库+截图+部署视频)

(一)JSP最早是由SunMicrosystems公司提出的,经过其推广,很多的计算机和软件公司逐渐共同参与开发。其主要是通过在HTML文件(*.htm,*.html)中嵌入Scriptlet和JSP标签来实现的。这样,内嵌的Java程序就可以生效,对数据库做出请求、或者启用E-mail等。JSP大概出现上世纪末,SunMicrosystems公司希望利用它来建立动态性的网站,并利用其兼容性和扩展性,来扩大平台应用。从实际效果来看,JSP技术的出现使Web的建设和设计创新不断。

woaimx_1314的博客 2578

spring boot+thymeleaf+bootstrap实现后台管理系统界面

主要为大家详细介绍了spring boot+thymeleaf+bootstrap简单实现后台管理系统界面,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

基于javaweb+mysql的springboot养老院管理系统(java+springboot+thymeleaf+html+js+mysql)

6.是否Maven项目: 是;超级管理员、管理员的功能如下: 登录、修改密码、账号管理、健康档案管理、病例管理、药品管理、每月餐饮管理、外出报备、入住登记、寝室分配、事故记录、访客记录、收费管理;基于javaweb+mysql的springboot养老院管理系统(java+springboot+thymeleaf+html+js+mysql)基于javaweb+mysql的SpringBoot养老院管理系统(java+springboot+thymeleaf+html+js+mysql)

m0_71097188的博客 65

电源设计避坑指南:半桥LLC软启动的5个常见错误及解决方案

本文针对半桥LLC谐振变换器软启动过程中的五个常见设计错误,提供了详细的工程解决方案。重点分析了忽视谐振腔初始状态导致的电流冲击、软启动斜坡与环路带宽不匹配、开环到闭环切换时机不当、变压器偏磁以及参数未考虑边界条件等问题,并给出了包括主动预充电、自适应斜坡、最佳切换点判定等实用调试技巧,帮助工程师实现平稳可靠的电源启动。

weixin_29260291的博客 289

用Python玩转Iris数据集:从数据加载到可视化分析的完整指南

本文提供了使用Python处理Iris数据集的完整指南,涵盖数据加载、探索性分析、特征工程和可视化呈现等关键步骤。通过Pandas、NumPy、Matplotlib和Seaborn等工具,读者将学习如何从零开始完成一个机器学习项目的数据分析流程,掌握数据科学的核心技能。

j2k3l4的博客 852

基于javaweb和mysql的springboot养老院管理系统(java+springboot+thymeleaf+html+js+mysql+maven)

超级管理员、管理员的功能如下: 登录、修改密码、账号管理、健康档案管理、病例管理、药品管理、每月餐饮管理、外出报备、入住登记、寝室分配、事故记录、访客记录、收费管理;用户的功能如下: 登录、修改密码、个人信息、家人情况、每月餐饮管理、外出报备、查看收费标准。基于javaweb和mysql的springboot养老院管理系统(java+springboot+thymeleaf+html+js+mysql+maven)运行项目,在浏览器中输入地址:http://localhost:8080/

私信-在线源码及调试交流 367

LilyPad三色LED共阳极控制:从原理到Arduino编程实战

RGB LED作为可编程光源的核心组件,通过红、绿、蓝三原色的加色混合原理,能够生成丰富的色彩。其内部结构主要分为共阳极和共阴极两种类型,这决定了驱动电路的设计和编程逻辑。在电子织物和可穿戴设备领域,掌握RGB LED的控制技术对于实现动态光效和交互反馈至关重要。本文以LilyPad三色LED为例,深入解析其共阳极特性,并详细演示如何结合Arduino进行PWM编程,从而精准控制颜色与亮度,为智能服装、互动艺术装置等项目提供可靠的照明解决方案。

weixin_30237719的博客 624

基于javaweb+SpringBoot的养老院管理系统(java+SpringBoot+thymeleaf+HTML+Js+mysql)

项目介绍 基于springboot的养老院管理系统,本系统为后台管理系统,分为三个角色,分别是超级管理员、管理员、用户。 超级管理员、管理员的功能如下: 登录、修改密码、账号管理、健康档案管理、病例管理、药品管理、每月餐饮管理、外出报备、入住登记、寝室分配、事故记录、访客记录、收费管理; 其中超级管理员可进行管理员账号管理; 用户的功能如下: 登录、修改密码、个人信息、家人情况、每月餐饮管理、外出报备、查看收费标准 环境需要 1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论

m0_71095879的博客 633

别再只跑recon-all了!FreeSurfer实战:从T1图像到freeview可视化的完整避坑指南

本文详细解析FreeSurfer从T1图像处理到freeview可视化的全流程,包括环境配置、recon-all深度解析、高级可视化技巧及性能优化策略。特别针对常见错误提供解决方案,帮助用户高效完成MRI数据分析,避免常见陷阱。

weixin_33404102的博客 354

Python爬虫实战:利用Selenium与Playwright抓取美团外卖数据

在当今大数据时代,网络数据采集已成为商业分析和市场研究的重要手段。本文以美团外卖平台为例,详细介绍如何使用Python最新爬虫技术(Selenium、Playwright)进行数据采集,并探讨相关技术原理、反爬应对策略及数据存储方案。通过5000+字的详细讲解和完整代码示例,帮助读者掌握现代网络爬虫开发的核心技能。本文详细介绍了使用Python最新爬虫技术采集美团外卖数据的完整流程,涵盖了从环境配置、页面分析到数据存储的全链路解决方案。

2201_76125261的博客 2556

基于javaweb的养老院管理系统(java+springboot+thymeleaf+html+js+mysql)

基于javaweb的养老院管理系统(java+springboot+thymeleaf+html+js+mysql) 运行环境 Java≥8、MySQL≥5.7 开发工具 eclipse/idea/myeclipse/sts等均可配置运行 适用 课程设计,大作业,毕业设计,项目练习,学习演示等 功能说明

m0_68109957的博客 2123

柔性电极材料新突破:清华团队实现0.1mV级脑信号采集精度

清华团队的 0.1mV 级柔性电极突破,不仅是材料科学与神经工程的跨界胜利,更标志着脑机接口从 “信号采集” 向 “神经交互” 的范式转变。当电极与脑组织实现 “柔性共生”,人类首次拥有了窥探大脑微观电活动的 “精密探头”,这既是神经疾病诊疗的里程碑,更是人机融合时代的新起点。随着技术标准化与产业生态的完善,这场始于实验室的 “柔性革命”,正加速向临床病房、智能工厂、消费电子等场景渗透,为脑机接口的大规模应用铺设 “柔性跑道”。:当柔性电极实现 “神经信号的无损捕捉”,如何平衡技术创新与伦理边界?

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 2953

基于javaweb+mysql的养老院管理系统(java+SpringBoot+thymeleaf+HTML+Js+mysql)

项目介绍 基于springboot的养老院管理系统,本系统为后台管理系统,分为三个角色,分别是超级管理员、管理员、用户。 超级管理员、管理员的功能如下: 登录、修改密码、账号管理、健康档案管理、病例管理、药品管理、每月餐饮管理、外出报备、入住登记、寝室分配、事故记录、访客记录、收费管理; 其中超级管理员可进行管理员账号管理; 用户的功能如下: 登录、修改密码、个人信息、家人情况、每月餐饮管理、外出报备、查看收费标准 环境需要 1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论

m0_71480786的博客 377

基于A*算法的二维栅格地图路径规划与避障MATLAB仿真

本文将介绍如何使用MATLAB编写基于A*算法的二维栅格地图路径规划与避障的仿真程序。我们可以使用二维数组表示地图,其中每个元素表示一个栅格的状态,例如1表示障碍物,0表示可行走区域。接下来,我们需要定义A*算法的节点类。G值表示从起始节点到当前节点的代价,H值是启发式函数估计的从当前节点到目标节点的代价。算法,我们可以有效地找到起始点到目标点的最短路径,并在仿真中进行可视化展示。算法的基本思路是从起始节点开始,按照一定的启发式函数选择下一个节点,直到找到目标节点或者遍历完所有可行走区域。

ByteWhizX的博客 1276

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

springboot社区养老院管理系统

SpringBoot社区养老院管理系统是基于现代化信息技术的养老机构管理平台,旨在提升养老院运营效率、优化服务质量,并实现家属与机构的便捷交互。系统采用SpringBoot框架开发,整合MySQL数据库、Thymeleaf模板引擎等技术,具备高可扩展性和稳定性。

mind526的博客 437

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

上一篇: Java项目:体育器材管理系统(java+SpringBoot+Bootstrap+HTML+mysql)
下一篇: Java项目:药品管理系统(java+SpringBoot+html+layui+bootstrap+echarts+mysql)
OldWinePot
博客等级 码龄5年 9274粉丝 1031原创
评论 8
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

打赏作者

OldWinePot

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

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

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

打赏作者

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

抵扣说明:

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

余额充值
⌂ 换网址