基于javaweb+mysql的springbootoa办公自动化系统设计和实现(java+springboot+freemarker+mysql+maven+mybatis+jpa)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBootoa办公自动化系统设计和实现(java+springboot+freemarker+mysql+maven+mybatis+jpa)
java springbootOA办公自动化系统:
主要功能模块:系统、用户、角色、考勤、流程、公告、邮件、任务、日程、计划、文件、笔记、通讯录、讨论区等多个模块管理
使用Maven进行项目管理,基于springboot框架开发的项目,mysql底层数据库,前端采用freemarker模板引擎,Bootstrap作为前端UI框架,集成了jpa、mybatis等框架。
}}else{System.out.println("222");if(StringUtil.isEmpty(name)){//查看用户并分页pageuser=udao.findAll(pa);}else{pageuser=udao.findbyUserNameLike(name, pa);}}userlist=pageuser.getContent();// 查询部门表Iterable<Dept> deptlist = ddao.findAll();// 查职位表Iterable<Position> poslist = pdao.findAll();model.addAttribute("emplist", userlist);model.addAttribute("page", pageuser);model.addAttribute("deptlist", deptlist);model.addAttribute("poslist", poslist);model.addAttribute("url", "names");return "common/recivers";}@RequestMapping("amail")public String index3(HttpServletRequest req,@SessionAttribute("userId") Long userId,Model model,@RequestParam(value = "page", defaultValue = "0") int page,@RequestParam(value = "size", defaultValue = "10") int size) {Pageable pa=new PageRequest(page, size);User mu=udao.findOne(userId);String mess=req.getParameter("title");Page<Pagemail> pagelist=null;Page<Inmaillist> pagemail=null;List<Map<String, Object>> maillist=null;if(("收件箱").equals(mess)){//分页及查找pagelist=mservice.recive(page, size, mu, null,mess);maillist=mservice.mail(pagelist);}else if(("发件箱").equals(mess)){pagemail=mservice.inmail(page, size, mu, null,mess);maillist=mservice.maillist(pagemail);}else if(("草稿箱").equals(mess)){pagemail=mservice.inmail(page, size,mu, null,mess);maillist=mservice.maillist(pagemail);}else{//垃圾箱//分页及查找
}else if(("草稿箱").equals(title)){StringTokenizer st = new StringTokenizer(ids, ",");while (st.hasMoreElements()) {//找到该邮件Inmaillist inmail=imdao.findByMailUseridAndMailId(user,Long.parseLong(st.nextToken()));if(inmail.getStar().equals(false)){inmail.setStar(true);}else{inmail.setStar(false);}imdao.save(inmail);}pagemail=mservice.inmail(page, size, user, null,title);maillist=mservice.maillist(pagemail);}else{//垃圾箱StringTokenizer st = new StringTokenizer(ids, ",");while (st.hasMoreElements()) {//找到该用户联系邮件的中间记录Mailrecivermailr=mrdao.findbyReciverIdAndmailId(user,Long.parseLong(st.nextToken()));if(mailr.getStar().equals(false)){mailr.setStar(true);}else{mailr.setStar(false);}mrdao.save(mailr);}//分页及查找pagelist=mservice.recive(page, size, user, null,title);maillist=mservice.mail(pagelist);}if(!Objects.isNull(pagelist)){model.addAttribute("page", pagelist);}else{model.addAttribute("page", pagemail);}model.addAttribute("maillist",maillist);model.addAttribute("url","mailtitle");model.addAttribute("mess",title); return "mail/mailbody";}@RequestMapping("mailtitle")public String serch(@SessionAttribute("userId") Long userId, Model model,HttpServletRequest req,@RequestParam(value = "page", defaultValue = "0") int page,@RequestParam(value = "size", defaultValue = "10") int size){User user=udao.findOne(userId);String title=req.getParameter("title");
}model.addAttribute("type", type);return "file/filetypeload";}@RequestMapping("fileloadshare")public String fileloadshare(@RequestParam("type") String type,@RequestParam(value="checkfileids[]",required=false) List<Long> checkfileids,Model model){if (checkfileids!=null) {fs.doshare(checkfileids);}model.addAttribute("message","分享成功");model.addAttribute("type", type);return "forward:/filetypeload";}@RequestMapping("fileloaddeletefile")public String fileloaddeletefile(@RequestParam("type") String type,@RequestParam(value="checkpathids[]",required=false) List<Long> checkpathids,@RequestParam(value="checkfileids[]",required=false) List<Long> checkfileids,Model model){System.out.println(type+checkpathids+checkfileids);if (checkfileids!=null) {// 删除文件fs.deleteFile(checkfileids);}if (checkpathids!=null) {// 删除文件夹fs.deletePath(checkpathids);}model.addAttribute("type", type);return "forward:/filetypeload";}@RequestMapping("test111")public String testMess(HttpServletRequest req, @Valid SystemMenu menu, BindingResult br) {HttpSession session = req.getSession();Long menuId = null;req.setAttribute("menuObj", menu);// 这里返回ResultVO对象,如果校验通过,ResultEnum.SUCCESS.getCode()返回的值为200;否则就是没有通过;ResultVO res = BindingResultVOUtil.hasErrors(br);// 校验失败if (!ResultEnum.SUCCESS.getCode().equals(res.getCode())) {List<Object> list = new MapToList<>().mapToList(res.getData());req.setAttribute("errormess", list.get(0).toString());// 代码调试阶段,下面是错误的相关信息;System.out.println("list错误的实体类信息:" + menu);System.out.println("list错误详情:" + list);System.out.println("list错误第一条:" + list.get(0));System.out.println("啊啊啊错误的信息——:" + list.get(0).toString());// 下面的info信息是打印出详细的信息log.info("getData:{}", res.getData());log.info("getCode:{}", res.getCode());log.info("getMsg:{}", res.getMsg());}
public String evemoney(Model model, @SessionAttribute("userId") Long userId,HttpServletRequest req,@RequestParam(value = "page", defaultValue = "0") int page,@RequestParam(value = "size", defaultValue = "10") int size){Long proid=Long.parseLong(req.getParameter("id"));//出差申请的idProcessList prolist=prodao.findbyuseridandtitle(userId, proid);//找这个用户的出差申请proservice.index6(model, userId, page, size);model.addAttribute("prolist", prolist);return "process/evectionmoney";}@RequestMapping("moneyeve")public String moneyeve(@RequestParam("filePath")MultipartFile filePath,HttpServletRequest req,@Valid EvectionMoney eve,BindingResult br,@SessionAttribute("userId") Long userId,Model model) throws IllegalStateException, IOException{User lu=udao.findOne(userId);//申请人User shen=udao.findByUserName(eve.getShenname());//审核人Long roleid=lu.getRole().getRoleId();//申请人角色idLong fatherid=lu.getFatherId();//申请人父idLong userid=shen.getUserId();//审核人useridString val=req.getParameter("val");Double allmoney=0.0;if(roleid>=3L && Objects.equals(fatherid, userid)){List<Traffic> ss=eve.getTraffic();for (Traffic traffic : ss) {allmoney+=traffic.getTrafficMoney();User u=udao.findByUserName(traffic.getUsername());traffic.setUser(u);traffic.setEvection(eve);}List<Stay> mm=eve.getStay();for (Stay stay : mm) {allmoney+=stay.getStayMoney()*stay.getDay();User u=udao.findByUserName(stay.getNameuser());stay.setUser(u);stay.setEvemoney(eve);}eve.setMoney(allmoney);//set主表ProcessList pro=eve.getProId();System.out.println(pro+"mmmmmm");proservice.index5(pro, val, lu, filePath,shen.getUserName());emdao.save(eve);//存审核表proservice.index7(shen, pro);
* @param numberOfMoney * 输入的金额 * @return 对应的汉语大写 */ public static String number2CNMontrayUnit(BigDecimal numberOfMoney) { StringBuffer sb = new StringBuffer(); // -1, 0, or 1 as the value of this BigDecimal is negative, zero, or // positive. int signum = numberOfMoney.signum(); // 零元整的情况 if (signum == 0) { return CN_ZEOR_FULL; } //这里会进行金额的四舍五入 long number = numberOfMoney.movePointRight(MONEY_PRECISION) .setScale(0, 4).abs().longValue(); // 得到小数点后两位值 long scale = number % 100; int numUnit = 0; int numIndex = 0; boolean getZero = false; // 判断最后两位数,一共有四中情况:00 = 0, 01 = 1, 10, 11 if (!(scale > 0)) { numIndex = 2; number = number / 100; getZero = true; } if ((scale > 0) && (!(scale % 10 > 0))) { numIndex = 1; number = number / 10; getZero = true; } int zeroSize = 0; while (true) { if (number <= 0) { break; } // 每次获取到最后一个数 numUnit = (int) (number % 10); if (numUnit > 0) { if ((numIndex == 9) && (zeroSize >= 3)) { sb.insert(0, CN_UPPER_MONETRAY_UNIT[6]); } if ((numIndex == 13) && (zeroSize >= 3)) { sb.insert(0, CN_UPPER_MONETRAY_UNIT[10]); } sb.insert(0, CN_UPPER_MONETRAY_UNIT[numIndex]); sb.insert(0, CN_UPPER_NUMBER[numUnit]); getZero = false; zeroSize = 0; } else { ++zeroSize;
List<ScheduleList> aboutmenotice = dayser.aboutmeschedule(userId);for (ScheduleList scheduleList : aboutmenotice) {if(scheduleList.getIsreminded()!=null&&!scheduleList.getIsreminded()){System.out.println(scheduleList.getStartTime());SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");//24小时制 //simpleDateFormat.parse(scheduleList.getStartTime()).getTime(); String start = simpleDateFormat.format(scheduleList.getStartTime());String now = simpleDateFormat.format(new Date());try {long now2 = simpleDateFormat.parse(now).getTime();long start2 = simpleDateFormat.parse(start).getTime(); long cha = start2-now2;if(0<cha && cha <86400000){NoticesList remindnotices = new NoticesList();remindnotices.setTypeId(11l);remindnotices.setStatusId(15l);remindnotices.setTitle("您有一个日程即将开始");remindnotices.setUrl("/daycalendar");remindnotices.setUserId(userId);remindnotices.setNoticeTime(new Date());NoticesList remindnoticeok = informService.save(remindnotices);informrelationservice.save(new NoticeUserRelation(remindnoticeok, user, false));scheduleList.setIsreminded(true);daydao.save(scheduleList);}} catch (ParseException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}List<NoticeUserRelation> notice=irdao.findByReadAndUserId(false,user);//通知List<Mailreciver> mail=mdao.findByReadAndDelAndReciverId(false, false, user);//邮件List<Taskuser> task=tadao.findByUserIdAndStatusId(user, 3);//新任务model.addAttribute("notice", notice.size());
public String testMess(HttpServletRequest req, @Valid NoticesList menu, BindingResult br) {HttpSession session = req.getSession();Long menuId = null;req.setAttribute("menuObj", menu);Long userId = Long.parseLong(session.getAttribute("userId") + "");menu.setUserId(userId);// 这里返回ResultVO对象,如果校验通过,ResultEnum.SUCCESS.getCode()返回的值为200;否则就是没有通过;ResultVO res = BindingResultVOUtil.hasErrors(br);// 校验失败if (!ResultEnum.SUCCESS.getCode().equals(res.getCode())) {List<Object> list = new MapToList<>().mapToList(res.getData());req.setAttribute("errormess", list.get(0).toString());// 代码调试阶段,下面是错误的相关信息;System.out.println("list错误的实体类信息:" + menu);System.out.println("list错误详情:" + list);System.out.println("list错误第一条:" + list.get(0));System.out.println("啊啊啊错误的信息——:" + list.get(0).toString());// 下面的info信息是打印出详细的信息log.info("getData:{}", res.getData());log.info("getCode:{}", res.getCode());log.info("getMsg:{}", res.getMsg());}// 校验通过,下面写自己的逻辑业务else {// 判断是否从编辑界面进来的,前面有"session.setAttribute("getId",getId);",在这里获取,并remove掉;if (!StringUtils.isEmpty(session.getAttribute("noticeId"))) {menuId = (Long) session.getAttribute("noticeId"); // 获取进入编辑界面的menuID值NoticesList inform = informDao.findOne(menuId);menu.setNoticeTime(inform.getNoticeTime());menu.setNoticeId(menuId);session.removeAttribute("noticeId");informService.save(menu);} else {menu.setNoticeTime(new Date());menu.setUserId(userId);NoticesList noticeList = informService.save(menu);List<User> userList = uDao.findByFatherId(userId);for (User user : userList) {informrelationservice.save(new NoticeUserRelation(noticeList, user, false));}}// 执行业务代码System.out.println("此操作是正确的");req.setAttribute("success", "后台验证成功");}System.out.println("是否进入最后的实体类信息:" + menu);return "forward:/informedit";
}if(("费用报销").equals(typename)){Bursement bu=budao.findByProId(pro);if(shen.getFatherId().equals(u.getUserId())){bu.setManagerAdvice(reviewed.getAdvice());budao.save(bu);}if(u.getPosition().getId()==5){bu.setFinancialAdvice(reviewed.getAdvice());bu.setBurseTime(new Date());bu.setOperation(u);budao.save(bu);}}else if(("出差费用").equals(typename)){EvectionMoney emoney=emdao.findByProId(pro);if(shen.getFatherId().equals(u.getUserId())){emoney.setManagerAdvice(reviewed.getAdvice());emdao.save(emoney);}if(u.getPosition().getId()==5){emoney.setFinancialAdvice(reviewed.getAdvice());emdao.save(emoney);}}else if(("出差申请").equals(typename)){Evection ev=edao.findByProId(pro);if(shen.getFatherId().equals(u.getUserId())){ev.setManagerAdvice(reviewed.getAdvice());edao.save(ev);}if(u.getPosition().getId().equals(7L)){ev.setPersonnelAdvice(reviewed.getAdvice());edao.save(ev);}}else if(("加班申请").equals(typename)){ Overtime over=odao.findByProId(pro);if(shen.getFatherId().equals(u.getUserId())){over.setManagerAdvice(reviewed.getAdvice());
// 判断是否共享if (request.getParameter("receiver") != null && (request.getParameter("receiver").trim().length() > 0)) {userss = new HashSet<>();String receivers = request.getParameter("receiver");note.setReceiver(receivers);String[] receiver = receivers.split(";");// 先绑定自己再userss.add(user);// 再绑定其他人for (String re : receiver) {System.out.println(re);User user2 = userDao.findid(re);if (user2 == null) {} elseuserss.add(user2);}} else {// 保存为该用户的笔记 绑定用户iduserss = new HashSet<>();userss.add(user);}}// nid大于0就是修改某个对象if (nid > 0) {note = noteDao.findOne(nid);if (note.getAttachId() == null) {if (!file.isEmpty()) {att = (Attachment) fs.savefile(file, user, null, false);attid = att.getAttachmentId();note.setAttachId(attid);noteDao.save(note);}}if (note.getAttachId() != null)fs.updateatt(file, user, null, note.getAttachId());// 判断是否共享if (request.getParameter("receiver") != null && (request.getParameter("receiver").trim().length() > 0)) {userss = new HashSet<>();String receivers = request.getParameter("receiver");note.setReceiver(receivers);String[] receiver = receivers.split(";");// 先绑定自己再
}if(("费用报销").equals(typename)){Bursement bu=budao.findByProId(pro);if(shen.getFatherId().equals(u.getUserId())){bu.setManagerAdvice(reviewed.getAdvice());budao.save(bu);}if(u.getPosition().getId()==5){bu.setFinancialAdvice(reviewed.getAdvice());bu.setBurseTime(new Date());bu.setOperation(u);budao.save(bu);}}else if(("出差费用").equals(typename)){EvectionMoney emoney=emdao.findByProId(pro);if(shen.getFatherId().equals(u.getUserId())){emoney.setManagerAdvice(reviewed.getAdvice());emdao.save(emoney);}if(u.getPosition().getId()==5){emoney.setFinancialAdvice(reviewed.getAdvice());emdao.save(emoney);}}else if(("出差申请").equals(typename)){Evection ev=edao.findByProId(pro);if(shen.getFatherId().equals(u.getUserId())){ev.setManagerAdvice(reviewed.getAdvice());edao.save(ev);}if(u.getPosition().getId().equals(7L)){ev.setPersonnelAdvice(reviewed.getAdvice());edao.save(ev);}}else if(("加班申请").equals(typename)){ Overtime over=odao.findByProId(pro);if(shen.getFatherId().equals(u.getUserId())){over.setManagerAdvice(reviewed.getAdvice());odao.save(over);}
users.setUserTel(user.getUserTel());users.setEamil(user.getEamil());users.setAddress(user.getAddress());users.setUserEdu(user.getUserEdu());users.setSchool(user.getSchool());users.setIdCard(user.getIdCard());users.setBank(user.getBank());users.setSex(user.getSex());users.setThemeSkin(user.getThemeSkin());users.setBirth(user.getBirth());if(!StringUtil.isEmpty(user.getUserSign())){users.setUserSign(user.getUserSign());}if(!StringUtil.isEmpty(user.getPassword())){users.setPassword(user.getPassword());}if(!StringUtil.isEmpty(imgpath)){users.setImgPath(imgpath);}request.setAttribute("users", users);ResultVO res = BindingResultVOUtil.hasErrors(br);if (!ResultEnum.SUCCESS.getCode().equals(res.getCode())) {List<Object> list = new MapToList<>().mapToList(res.getData());request.setAttribute("errormess", list.get(0).toString());System.out.println("list错误的实体类信息:" + user);System.out.println("list错误详情:" + list);System.out.println("list错误第一条:" + list.get(0));System.out.println("啊啊啊错误的信息——:" + list.get(0).toString());}else{udao.save(users);request.setAttribute("success", "执行成功!");}return "forward:/userpanel";}@RequestMapping("image/**")public void image(Model model, HttpServletResponse response, @SessionAttribute("userId") Long userId, HttpServletRequest request)throws Exception {String projectPath = ClassUtils.getDefaultClassLoader().getResource("").getPath();System.out.println(projectPath);String startpath = new String(URLDecoder.decode(request.getRequestURI(), "utf-8"));//String path = startpath.replace("/image", "");////File f = new File(rootpath, path);File f = new File(request.getRequestURI().substring("/image".length()));ServletOutputStream sos = response.getOutputStream();FileInputStream input = new FileInputStream(f.getPath());byte[] data = new byte[(int) f.length()];
number = number / 10; ++numIndex; } // 如果signum == -1,则说明输入的数字为负数,就在最前面追加特殊字符:负 if (signum == -1) { sb.insert(0, CN_NEGATIVE); } // 输入的数字小数点后两位为"00"的情况,则要在最后追加特殊字符:整 if (!(scale > 0)) { sb.append(CN_FULL); } return sb.toString(); } public static String numbertocn(Double money){ BigDecimal numberOfMoney = new BigDecimal(money); String s = number2CNMontrayUnit(numberOfMoney); System.out.println("你输入的金额为:【"+ money +"】 #--# [" +s.toString()+"]"); return s.toString(); }}
if (nId.contains("cata")) {//从目录编辑那里进来的String newnid = nId.substring(4, nId.length());long ca = Long.valueOf(newnid);Catalog cate = catalogDao.findOne(ca);Request.setAttribute("cata", cate);Request.setAttribute("note", null);Request.setAttribute("id", -3);} else {Long nid = Long.valueOf(nId);// 新建if (nid == -1) {Request.setAttribute("note", null);// 新建idRequest.setAttribute("id", nid);}// 修改else if (nid > 0) {Note note = noteDao.findOne(nid);long ca = Long.valueOf(note.getCatalogId());Catalog cate = catalogDao.findOne(ca);Request.setAttribute("cata", cate);Request.setAttribute("note", note);// 修改idRequest.setAttribute("id", nid);}// Request.setAttribute("id", nid);}userget(page, size, model);Request.setAttribute("users", users);Request.setAttribute("calist", cataloglist);typestatus(Request);return "note/noteedit";}public void userget(int page,int size,Model model){Pageable pa=new PageRequest(page, size);//查看用户并分页Page<User> pageuser=userDao.findAll(pa);List<User> userlist=pageuser.getContent();// 查询部门表Iterable<Dept> deptlist = ddao.findAll();// 查职位表Iterable<Position> poslist = pdao.findAll();model.addAttribute("page", pageuser);model.addAttribute("emplist", userlist);model.addAttribute("deptlist", deptlist);model.addAttribute("poslist", poslist);model.addAttribute("url", "namereceive");}
}return "redirect:/noteview";}// 笔记删除@RequestMapping("notedelete")public String testrw(Model model, HttpServletRequest request, HttpSession session) {long realuserId = Long.valueOf(session.getAttribute("userId") + "");String nid = request.getParameter("nid");long noteid = Long.valueOf(nid);Noteuser u = noteDao.finduserid(noteid, realuserId);if (u != null) {notedelete(realuserId, noteid);return "redirect:/noteview";} else {System.out.println("权限不匹配,不能删除");return "redirect:/notlimit";}}// 目录删除@RequestMapping("catadelete")public String testrwd(Model model, HttpServletRequest request, HttpSession session) {long realuserId = Long.valueOf(session.getAttribute("userId") + "");String cid = request.getParameter("cid");long catalogid = Long.valueOf(cid);//Page upage= NoteService.paging(page, null, null, null, catalogid, null); //paging(model, upage);noteList=noteDao.findByCatalogId(catalogid, realuserId);// 没有做级联删除 先删除目录下的笔记 再删除目录for (Note note : noteList) {NoteService.delete(note.getNoteId());}catalogService.delete(catalogid);return "redirect:/noteview";}// 笔记主界面@RequestMapping(value = "noteview", method = RequestMethod.GET)public String test(Model model, HttpServletRequest request, HttpSession session,@RequestParam(value = "page", defaultValue = "0") int page,@RequestParam(value = "baseKey", required = false) String baseKey,@RequestParam(value = "type", required = false) String type,@RequestParam(value = "status", required = false) String status,@RequestParam(value = "time", required = false) String time,@RequestParam(value = "icon", required = false) String icon) {Long userid = Long.parseLong(session.getAttribute("userId") + "");
num=dis.getDiscussId();}else{Reply replyyy=replyDao.findOne(discussId);dis=replyyy.getDiscuss();num=dis.getDiscussId();}if(!StringUtils.isEmpty(req.getParameter("comment"))){String comment=req.getParameter("comment");System.out.println(comment);if("discuss".equals(module)){//说明是回复-楼主System.out.println("回复-楼主");Discuss discuss=discussDao.findOne(discussId);Reply reply=new Reply(new Date(), comment, user, discuss);num=discuss.getDiscussId();replyService.save(reply);}else{ //说明是回复-评论System.out.println("回复-评论");Reply reply=replyDao.findOne(discussId);Comment comment2=new Comment(new Date(), comment, user, reply);commentservice.save(comment2);num=reply.getDiscuss().getDiscussId();}Discuss discuss=discussDao.findOne(num);if(user.getSuperman()){model.addAttribute("manage", "具有管理权限");}else{if(Objects.equals(user.getUserId(), discuss.getUser().getUserId())){model.addAttribute("manage", "具有管理权限");}}}disService.setDiscussMess(model, num,userId,page,size);return "chat/replytable";}//点赞处理@RequestMapping("likethis")public void likeThis(HttpServletRequest req,HttpServletResponse resp,@SessionAttribute("userId") Long userId){resp.setCharacterEncoding("utf-8");PrintWriter out = null;
来源地址:https://blog.csdn.net/m0_70999423/article/details/132385048