• SSM公司企业OA管理系统


    作者主页:夜未央5788

     简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文末获取源码

     

    项目介绍

    OA办公管理系统,这是一款由JSP+SSM(spring+springmvc+mybatis)+MySQL实现的简单的OA办公管理系统,主要实现的功能有员工注册登录,自动计算当前月迟到、早退、加班、缺勤天数并根据图表展示,任务管理(任务发布、更新、删除、进度条展示完成度),通知管理(通知发布、更新、删除),站内信发布、回复、删除等,发布公告和任务及站内信时可上传图片等。

    环境需要

    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项目:否;

    技术栈

    1. 后端:Spring+SpringMVC+Mybatis

    2. 前端:JSP+CSS+JavaScript

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
    2. 使用IDEA/Eclipse/MyEclipse导入项目;
    3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;
    4. 运行项目,输入localhost:8080/OAManagerSys 登录 注意:路径必须为/OAManagerSys,否则会有图片加载不出来
    管理员账号/密码:admin/admin 

    账号/密码:zhangtao/123

    运行截图

     

     

     

     

     

     

    相关代码

    账户控制器

    1. package com.noa.controller;
    2. import javax.servlet.http.HttpServletRequest;
    3. import javax.servlet.http.HttpSession;
    4. import org.apache.shiro.SecurityUtils;
    5. import org.apache.shiro.authc.IncorrectCredentialsException;
    6. import org.apache.shiro.authc.UnknownAccountException;
    7. import org.apache.shiro.authc.UsernamePasswordToken;
    8. import org.springframework.beans.factory.annotation.Autowired;
    9. import org.springframework.stereotype.Controller;
    10. import org.springframework.ui.Model;
    11. import org.springframework.web.bind.annotation.RequestMapping;
    12. import org.springframework.web.bind.annotation.RequestMethod;
    13. import org.springframework.web.multipart.MultipartFile;
    14. import com.noa.exception.CustomException;
    15. import com.noa.po.Employee;
    16. import com.noa.po.EmployeeCustom;
    17. import com.noa.service.EmployeeService;
    18. import com.noa.service.SysService;
    19. @Controller
    20. public class AccountController {
    21. @Autowired
    22. private EmployeeService employeeService;
    23. @Autowired
    24. private SysService sysService;
    25. EmployeeCustom activeEmp;
    26. @RequestMapping("/login")
    27. public String login(Model model, HttpServletRequest request) throws Exception {
    28. String exceptionClassName = (String) request.getAttribute("shiroLoginFailure");
    29. if (exceptionClassName != null) {
    30. if (UnknownAccountException.class.getName().equals(exceptionClassName)) {
    31. // 最终会抛给异常处理器
    32. model.addAttribute("message", "账号不存在");
    33. } else if (IncorrectCredentialsException.class.getName().equals(exceptionClassName)) {
    34. model.addAttribute("message", "用户名/密码错误");
    35. // throw new CustomException("用户名/密码错误");
    36. } else {
    37. model.addAttribute("message", "未知错误");
    38. // throw new Exception();// 最终在异常处理器生成未知错误
    39. }
    40. }
    41. // 访问/login时, 自动进行认证,认证成功后直接跳转出去
    42. // 初次访问时exceptionClassName== null直接到这里
    43. // 认证失败时exceptionClassName!= null , 传递信息后又回到这里
    44. return "misc/login";
    45. }
    46. @RequestMapping(value = "/signup", method = RequestMethod.GET)
    47. public String showSignupPage(Model model) throws Exception {
    48. return "misc/signup";
    49. }
    50. @RequestMapping(value = "/signup", method = RequestMethod.POST)
    51. public String checkUsername(Model model, Employee employee) throws Exception {
    52. try {
    53. employeeService.checkUsername(employee);
    54. model.addAttribute("employee", employee);
    55. model.addAttribute("positionList", sysService.getAbleToRegPos());
    56. return "misc/signup_detail";
    57. } catch (CustomException e) {
    58. model.addAttribute("message", e.getMessage());
    59. }
    60. return "misc/signup";
    61. }
    62. @RequestMapping(value = "/signup2", method = RequestMethod.POST)
    63. public String confirmPosition(Model model, Employee employee, MultipartFile employee_pic) throws Exception {
    64. // 上传图片
    65. String originalFilename = employee_pic.getOriginalFilename();
    66. if (employee_pic != null && originalFilename != null && originalFilename.trim() != "") {
    67. employee.setPic(sysService.uploadPic("employee", employee_pic));
    68. }
    69. model.addAttribute("employee", employee);
    70. model.addAttribute("departmentList", sysService.getAbleToRegDep(employee.getPositionId()));
    71. return "misc/signup_dep";
    72. }
    73. @RequestMapping(value = "/formal_signup", method = RequestMethod.POST)
    74. public String register(Model model, Employee employee) throws Exception {
    75. try {
    76. employeeService.register(employee);
    77. UsernamePasswordToken token = new UsernamePasswordToken(employee.getUsername(), employee.getPassword());
    78. SecurityUtils.getSubject().login(token);
    79. return "redirect:home";
    80. } catch (CustomException e) {
    81. model.addAttribute("message", e.getMessage());
    82. }
    83. // 注册失败
    84. return "misc/signup_detail";
    85. }
    86. @RequestMapping("/logout")
    87. public String logout(HttpSession session) throws Exception {
    88. activeEmp = (EmployeeCustom) session.getAttribute("activeEmp");
    89. employeeService.logout(activeEmp);
    90. session.removeAttribute("activeEmp");
    91. session.invalidate();
    92. return "redirect:/login";
    93. }
    94. @RequestMapping("/refuse")
    95. public String refuse() throws Exception {
    96. return "misc/refuse";
    97. }
    98. }

    员工控制器

    1. package com.noa.controller;
    2. import java.util.ArrayList;
    3. import java.util.List;
    4. import javax.servlet.http.HttpSession;
    5. import org.springframework.beans.factory.annotation.Autowired;
    6. import org.springframework.http.HttpRequest;
    7. import org.springframework.stereotype.Controller;
    8. import org.springframework.ui.Model;
    9. import org.springframework.web.bind.annotation.RequestMapping;
    10. import com.noa.po.Employee;
    11. import com.noa.po.EmployeeCustom;
    12. import com.noa.service.EmployeeService;
    13. import com.noa.service.SysService;
    14. @Controller
    15. public class EmployeeController {
    16. @Autowired
    17. private EmployeeService employeeService;
    18. @Autowired
    19. private SysService sysService;
    20. @RequestMapping(value = "/changeStage")
    21. public void changeState(Model model, HttpRequest request, HttpSession session, Integer state) throws Exception {
    22. }
    23. @RequestMapping(value = "/search_emp")
    24. public String showSearchPage(Model model, String name, Integer depId, Integer state) throws Exception {
    25. List employeeList = new ArrayList();
    26. if ((name != null && name.trim() != "") || depId != null || state != null) {
    27. Employee condition = new Employee();
    28. if (name != null && name.trim() != "") {
    29. condition.setName(name);
    30. model.addAttribute("name", name);
    31. }
    32. if (depId != null) {
    33. condition.setDepartmentId(depId);
    34. model.addAttribute("depId", depId);
    35. }
    36. if (state != null) {
    37. condition.setWorkingState(state);
    38. model.addAttribute("state", state);
    39. }
    40. employeeList = employeeService.findEmployee(condition);
    41. } else {
    42. // show all employee
    43. employeeList = employeeService.findEmployee(new Employee());
    44. }
    45. model.addAttribute("employeeList", employeeList);
    46. model.addAttribute("allDepartment", sysService.getAllDepartment());
    47. return "search/search_emp";
    48. }
    49. }

    首页控制器

    1. package com.noa.controller;
    2. import java.util.List;
    3. import javax.servlet.http.HttpSession;
    4. import org.apache.shiro.SecurityUtils;
    5. import org.apache.shiro.authz.annotation.Logical;
    6. import org.apache.shiro.authz.annotation.RequiresPermissions;
    7. import org.springframework.beans.factory.annotation.Autowired;
    8. import org.springframework.stereotype.Controller;
    9. import org.springframework.ui.Model;
    10. import org.springframework.web.bind.annotation.RequestMapping;
    11. import com.noa.po.Announcement;
    12. import com.noa.po.AnnouncementCustom;
    13. import com.noa.po.EmployeeCustom;
    14. import com.noa.service.AnnouncementService;
    15. import com.noa.service.AttendanceService;
    16. import com.noa.service.EmployeeService;
    17. import com.noa.service.SysService;
    18. @Controller
    19. public class HomeController {
    20. @Autowired
    21. EmployeeService employeeService;
    22. @Autowired
    23. AttendanceService attendanceService;
    24. @Autowired
    25. AnnouncementService announcementService;
    26. @Autowired
    27. SysService sysService;
    28. EmployeeCustom activeEmp;
    29. @RequestMapping("/home")
    30. public String showHome(Model model,HttpSession session) throws Exception{
    31. activeEmp = (EmployeeCustom) SecurityUtils.getSubject().getPrincipal();
    32. session.setAttribute("activeEmp", activeEmp);
    33. //展示出勤率,[0]正常 [1]加班 [2]迟到早退 [3]缺席[4]剩余天数
    34. int[] attendance = attendanceService.countMonthState(activeEmp);
    35. model.addAttribute("attendance",attendance);
    36. //公告一览
    37. List announceList = announcementService.showAllAnnouncement(activeEmp);
    38. model.addAttribute("announceList", announceList);
    39. //可发布公告的对象
    40. model.addAttribute("departmentList", sysService.getAbleToAnnounceDeps());
    41. return "/home/home";
    42. }
    43. @RequestMapping("/announce.action")
    44. @RequiresPermissions(value={"announce:create:all","announce:create:main","announce:create:sub"},logical=Logical.OR)
    45. public String annouce(HttpSession session,String target,Announcement announcement) throws Exception{
    46. activeEmp = (EmployeeCustom)session.getAttribute("activeEmp");
    47. announcement.setText(announcement.getText().replaceAll("\r\n", "
      "
      ));
    48. announcementService.announce(announcement, activeEmp);
    49. return "redirect:/home";
    50. }
    51. @RequestMapping("/delete_announce.action")
    52. public String deleteAnnouce(HttpSession session,Integer delete_id) throws Exception{
    53. announcementService.deleteAnnouncement(delete_id);
    54. return "redirect:/home";
    55. }
    56. }

    邮件控制器

    1. package com.noa.controller;
    2. import java.util.ArrayList;
    3. import java.util.List;
    4. import javax.servlet.http.HttpServletRequest;
    5. import javax.servlet.http.HttpSession;
    6. import org.springframework.beans.factory.annotation.Autowired;
    7. import org.springframework.stereotype.Controller;
    8. import org.springframework.ui.Model;
    9. import org.springframework.web.bind.annotation.RequestMapping;
    10. import org.springframework.web.multipart.MultipartFile;
    11. import com.noa.po.EmployeeCustom;
    12. import com.noa.po.Mail;
    13. import com.noa.po.MailCustom;
    14. import com.noa.service.EmployeeService;
    15. import com.noa.service.MailService;
    16. import com.noa.service.SysService;
    17. @Controller
    18. @RequestMapping("/mail")
    19. @SuppressWarnings("all")
    20. public class MailController {
    21. @Autowired
    22. private MailService mailService;
    23. @Autowired
    24. private EmployeeService employeeService;
    25. @Autowired
    26. private SysService sysService;
    27. // 展示收到的邮件
    28. @RequestMapping("")
    29. public String showMailPage(Model model, HttpSession session, HttpServletRequest request) throws Exception {
    30. List mailList = new ArrayList();
    31. switch ((String) request.getParameter("view")) {
    32. case "all":
    33. mailList = mailService.findMailToMe((EmployeeCustom) session.getAttribute("activeEmp"));
    34. model.addAttribute("isSend", false);
    35. break;
    36. case "unread":
    37. mailList = mailService.findUnreadMailToMe((EmployeeCustom) session.getAttribute("activeEmp"));
    38. model.addAttribute("isSend", false);
    39. break;
    40. case "read":
    41. mailList = mailService.findReadMailToMe((EmployeeCustom) session.getAttribute("activeEmp"));
    42. model.addAttribute("isSend", false);
    43. break;
    44. case "send":
    45. mailList = mailService.findMailSendByMe((EmployeeCustom) session.getAttribute("activeEmp"));
    46. model.addAttribute("isSend", true);
    47. break;
    48. default:
    49. mailList = mailService.findMailToMe((EmployeeCustom) session.getAttribute("activeEmp"));
    50. model.addAttribute("isSend", false);
    51. break;
    52. }
    53. model.addAttribute("mailList", mailList);
    54. model.addAttribute("isInbox", true);// mail_common中右上角的的按钮
    55. return "mail/mail_inbox";
    56. }
    57. @RequestMapping("/mail_view")
    58. public String showMailDetail(Model model, HttpServletRequest request) throws Exception {
    59. MailCustom mailDetail = mailService.showMailDetail(Integer.parseInt(request.getParameter("mail_id")),
    60. Integer.parseInt(request.getParameter("otherside_id")));
    61. model.addAttribute("mail", mailDetail);
    62. model.addAttribute("isSend", Boolean.parseBoolean(request.getParameter("isSend")));
    63. return "mail/mail_view";
    64. }
    65. @RequestMapping("/send_mail.action")
    66. public String sendMail(Mail mail, MultipartFile mail_pic) throws Exception {
    67. // 上传图片
    68. // 原始名称
    69. String originalFilename = null;
    70. if (mail_pic != null) {
    71. originalFilename = mail_pic.getOriginalFilename();
    72. }
    73. if (mail_pic != null && originalFilename != null && originalFilename.trim() != "") {
    74. mail.setPic(sysService.uploadPic("mail", mail_pic));
    75. }
    76. // 将新图片名称写入
    77. mail.setText(mail.getText().replaceAll("\r\n", "
      "
      ));
    78. mailService.sendMail(mail);
    79. return "redirect:/mail?view=all";
    80. }
    81. @RequestMapping("/mail_compose")
    82. public String showComposeForm(Model model, Integer receiver) throws Exception {
    83. if (receiver != null) {
    84. model.addAttribute("receiver", employeeService.findEmployeeById(receiver));
    85. }
    86. return "mail/mail_compose";
    87. }
    88. }

    如果也想学习本系统,下面领取。关注并回复:172ssm

  • 相关阅读:
    cookie机制 + java 案例
    ClickHouse基本原理
    htb-cronos
    关于二进制无法精确表示小数
    【Java-LangChain:面向开发者的提示工程-4】文本概括
    【阿里云】函数计算 X 通义千问快速部署
    2023最新SSM计算机毕业设计选题大全(附源码+LW)之java新能源汽车销售管理系统gooct
    判断序列是否为正确的出栈序列
    【计算机毕业设计】校园二手市场平台+vue源码
    使用新的 NVIDIA Isaac Foundation 模型和工作流程创建、设计和部署机器人应用程序
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/126412954