基于javaweb+mysql的ssm公司企业oa管理系统(java+ssm+jsp+javascript+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM公司企业oa管理系统(java+ssm+jsp+javascript+mysql)
项目介绍
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项目:否;
技术栈
- 后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+CSS+JavaScript
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目; 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/OAManagerSys 登录 注意:路径必须为/OAManagerSys,否则会有图片加载不出来 管理员账号/密码:admin/admin 账号/密码:zhangtao/123
missionService.deleteComment(mission_id, comment_emp, comment, all_comment);
return "redirect:/mission/mission_view?mission_id="+mission_id;
}
}
@Controller
public class AccountController {
@Autowired
private EmployeeService employeeService;
@Autowired
private SysService sysService;
EmployeeCustom activeEmp;
@RequestMapping("/login")
public String login(Model model, HttpServletRequest request) throws Exception {
String exceptionClassName = (String) request.getAttribute("shiroLoginFailure");
if (exceptionClassName != null) {
missionService.comment(mission_id, oldComment, newComment, (EmployeeCustom) session.getAttribute("activeEmp"));
model.addAttribute("mission", missionService.missionDetail(mission_id));
return "mission/mission_view";
}
@RequestMapping("/mission_compose")
public String showComposeForm(Model model)throws Exception{
model.addAttribute("departmentList", sysService.getAbleToPostDeps());
return "mission/mission_compose";
}
@RequestMapping("/post_mission.action")
@RequiresPermissions(value={"mission:create:all","mission:create:main","mission:create:sub"},logical=Logical.OR)
public String postMission(HttpSession session,Mission mission,MultipartFile mission_pic) throws Exception{
//图片上传
String originalFilename = null;
if (mission_pic != null) {
originalFilename = mission_pic.getOriginalFilename();
}
if (mission_pic!=null && originalFilename!=null && originalFilename.trim()!="") {
mission.setPic(sysService.uploadPic("mission", mission_pic));
}
activeEmp = (EmployeeCustom) session.getAttribute("activeEmp");
mission.setAutherId(activeEmp.getId());
mission.setText(mission.getText().replaceAll("\r\n", "<br>"));
missionService.postMission(mission, activeEmp);
return "redirect:/mission?view=all";
}
@RequestMapping("/delete_mission.action")
public String deleteMission(Integer delete_id) throws Exception{
missionService.deleteMission(delete_id);
mail.setPic(sysService.uploadPic("mail", mail_pic));
}
// 将新图片名称写入
mail.setText(mail.getText().replaceAll("\r\n", "<br>"));
mailService.sendMail(mail);
return "redirect:/mail?view=all";
}
@RequestMapping("/mail_compose")
public String showComposeForm(Model model, Integer receiver) throws Exception {
if (receiver != null) {
model.addAttribute("receiver", employeeService.findEmployeeById(receiver));
}
return "mail/mail_compose";
}
}
@Controller
public class HomeController {
@Autowired
@RequestMapping("/mail_compose")
public String showComposeForm(Model model, Integer receiver) throws Exception {
if (receiver != null) {
model.addAttribute("receiver", employeeService.findEmployeeById(receiver));
}
return "mail/mail_compose";
}
}
@Controller
public class HomeController {
@Autowired
EmployeeService employeeService;
@Autowired
AttendanceService attendanceService;
@Autowired
AnnouncementService announcementService;
@Autowired
SysService sysService;
EmployeeCustom activeEmp;
return "redirect:/mission?view=all";
}
@RequestMapping(value="/delete_comment.action",method=RequestMethod.POST)
public String deleteMission(Integer mission_id,Integer comment_emp,String comment,String all_comment) throws Exception{
missionService.deleteComment(mission_id, comment_emp, comment, all_comment);
return "redirect:/mission/mission_view?mission_id="+mission_id;
}
}
@Controller
public class AccountController {
@Autowired
private EmployeeService employeeService;
@Autowired
private SysService sysService;
EmployeeCustom activeEmp;
@RequestMapping("/login")
public String login(Model model, HttpServletRequest request) throws Exception {
String exceptionClassName = (String) request.getAttribute("shiroLoginFailure");
if (exceptionClassName != null) {
@Controller
@RequestMapping("/mail")
@SuppressWarnings("all")
public class MailController {
@Autowired
private MailService mailService;
@Autowired
private EmployeeService employeeService;
@Autowired
private SysService sysService;
// 展示收到的邮件
@RequestMapping("")
public String showMailPage(Model model, HttpSession session, HttpServletRequest request) throws Exception {
List<MailCustom> mailList = new ArrayList<MailCustom>();
switch ((String) request.getParameter("view")) {
case "all":
mailList = mailService.findMailToMe((EmployeeCustom) session.getAttribute("activeEmp"));
model.addAttribute("isSend", false);
break;
case "unread":
mailList = mailService.findUnreadMailToMe((EmployeeCustom) session.getAttribute("activeEmp"));
model.addAttribute("isSend", false);
break;
case "read":
mailList = mailService.findReadMailToMe((EmployeeCustom) session.getAttribute("activeEmp"));
model.addAttribute("isSend", false);
break;
case "send":
mailList = mailService.findMailSendByMe((EmployeeCustom) session.getAttribute("activeEmp"));
model.addAttribute("isSend", true);
break;
default:
mailList = mailService.findMailToMe((EmployeeCustom) session.getAttribute("activeEmp"));
model.addAttribute("isSend", false);
@Controller
public class HomeController {
@Autowired
EmployeeService employeeService;
@Autowired
AttendanceService attendanceService;
@Autowired
AnnouncementService announcementService;
@Autowired
SysService sysService;
EmployeeCustom activeEmp;
@RequestMapping("/home")
public String showHome(Model model,HttpSession session) throws Exception{
activeEmp = (EmployeeCustom) SecurityUtils.getSubject().getPrincipal();
session.setAttribute("activeEmp", activeEmp);
//展示出勤率,[0]正常 [1]加班 [2]迟到早退 [3]缺席[4]剩余天数
int[] attendance = attendanceService.countMonthState(activeEmp);
model.addAttribute("attendance",attendance);
//公告一览
List<AnnouncementCustom> announceList = announcementService.showAllAnnouncement(activeEmp);
model.addAttribute("announceList", announceList);
//可发布公告的对象
model.addAttribute("departmentList", sysService.getAbleToAnnounceDeps());
return "/home/home";
}
@RequestMapping("/announce.action")
@RequiresPermissions(value={"announce:create:all","announce:create:main","announce:create:sub"},logical=Logical.OR)
public String annouce(HttpSession session,String target,Announcement announcement) throws Exception{
activeEmp = (EmployeeCustom)session.getAttribute("activeEmp");
announcement.setText(announcement.getText().replaceAll("\r\n", "<br>"));
@Controller
@RequestMapping("/mission")
@SuppressWarnings("all")
public class MissionController {
@Autowired
private MissionService missionService;
@Autowired
private SysService sysService;
EmployeeCustom activeEmp;
@RequestMapping("")
public String showMissionPage(Model model, HttpSession session,String view) throws Exception {
List<MissionCustom> missionList = null;
activeEmp= (EmployeeCustom) session.getAttribute("activeEmp");
switch (view) {
case "all":
missionList = missionService.showAllMission(activeEmp);
break;
case "overall":
missionList = missionService.filterMission(0);
break;
case "main":
missionList = missionService.filterMission((activeEmp.getDepartmentId()/10)*10);
break;
case "sub":
missionList = missionService.filterMission(activeEmp.getDepartmentId());
break;
default:
missionList = missionService.showAllMission(activeEmp);
break;
}
model.addAttribute("missionList", missionList);
model.addAttribute("isInbox",true);
return "mission/mission_inbox";
}
@RequestMapping(value="/mission_view" ,method=RequestMethod.GET)
public String showMissionDetail(Model model,Integer mission_id,Integer updateProgress) throws Exception{
@RequestMapping("/mission_compose")
public String showComposeForm(Model model)throws Exception{
model.addAttribute("departmentList", sysService.getAbleToPostDeps());
return "mission/mission_compose";
}
@RequestMapping("/post_mission.action")
@RequiresPermissions(value={"mission:create:all","mission:create:main","mission:create:sub"},logical=Logical.OR)
public String postMission(HttpSession session,Mission mission,MultipartFile mission_pic) throws Exception{
//图片上传
String originalFilename = null;
if (mission_pic != null) {
originalFilename = mission_pic.getOriginalFilename();
}
if (mission_pic!=null && originalFilename!=null && originalFilename.trim()!="") {
mission.setPic(sysService.uploadPic("mission", mission_pic));
}
activeEmp = (EmployeeCustom) session.getAttribute("activeEmp");
mission.setAutherId(activeEmp.getId());
mission.setText(mission.getText().replaceAll("\r\n", "<br>"));
missionService.postMission(mission, activeEmp);
return "redirect:/mission?view=all";
}
@RequestMapping("/delete_mission.action")
public String deleteMission(Integer delete_id) throws Exception{
missionService.deleteMission(delete_id);
return "redirect:/mission?view=all";
}
@RequestMapping(value="/delete_comment.action",method=RequestMethod.POST)
public String deleteMission(Integer mission_id,Integer comment_emp,String comment,String all_comment) throws Exception{
missionService.deleteComment(mission_id, comment_emp, comment, all_comment);
return "redirect:/mission/mission_view?mission_id="+mission_id;
// 最终会抛给异常处理器
model.addAttribute("message", "账号不存在");
} else if (IncorrectCredentialsException.class.getName().equals(exceptionClassName)) {
model.addAttribute("message", "用户名/密码错误");
// throw new CustomException("用户名/密码错误");
} else {
model.addAttribute("message", "未知错误");
// throw new Exception();// 最终在异常处理器生成未知错误
}
}
// 访问/login时, 自动进行认证,认证成功后直接跳转出去
// 初次访问时exceptionClassName== null直接到这里
// 认证失败时exceptionClassName!= null , 传递信息后又回到这里
return "misc/login";
}
@RequestMapping(value = "/signup", method = RequestMethod.GET)
public String showSignupPage(Model model) throws Exception {
return "misc/signup";
}
@RequestMapping(value = "/signup", method = RequestMethod.POST)
public String checkUsername(Model model, Employee employee) throws Exception {
try {
employeeService.checkUsername(employee);
model.addAttribute("employee", employee);
model.addAttribute("positionList", sysService.getAbleToRegPos());
return "misc/signup_detail";
} catch (CustomException e) {
model.addAttribute("message", e.getMessage());
}
return "misc/signup";
}
@RequestMapping(value = "/signup2", method = RequestMethod.POST)
public String confirmPosition(Model model, Employee employee, MultipartFile employee_pic) throws Exception {
// 上传图片
return "redirect:home";
} catch (CustomException e) {
model.addAttribute("message", e.getMessage());
}
// 注册失败
return "misc/signup_detail";
}
@RequestMapping("/logout")
public String logout(HttpSession session) throws Exception {
activeEmp = (EmployeeCustom) session.getAttribute("activeEmp");
employeeService.logout(activeEmp);
session.removeAttribute("activeEmp");
session.invalidate();
return "redirect:/login";
}
@RequestMapping("/refuse")
public String refuse() throws Exception {
return "misc/refuse";
}
}
@Controller
@RequestMapping("/mail")
@SuppressWarnings("all")
mailList = mailService.findUnreadMailToMe((EmployeeCustom) session.getAttribute("activeEmp"));
model.addAttribute("isSend", false);
break;
case "read":
mailList = mailService.findReadMailToMe((EmployeeCustom) session.getAttribute("activeEmp"));
model.addAttribute("isSend", false);
break;
case "send":
mailList = mailService.findMailSendByMe((EmployeeCustom) session.getAttribute("activeEmp"));
model.addAttribute("isSend", true);
break;
default:
mailList = mailService.findMailToMe((EmployeeCustom) session.getAttribute("activeEmp"));
model.addAttribute("isSend", false);
break;
}
model.addAttribute("mailList", mailList);
model.addAttribute("isInbox", true);// mail_common中右上角的的按钮
return "mail/mail_inbox";
}
@RequestMapping("/mail_view")
public String showMailDetail(Model model, HttpServletRequest request) throws Exception {
MailCustom mailDetail = mailService.showMailDetail(Integer.parseInt(request.getParameter("mail_id")),
Integer.parseInt(request.getParameter("otherside_id")));
model.addAttribute("mail", mailDetail);
model.addAttribute("isSend", Boolean.parseBoolean(request.getParameter("isSend")));
return "mail/mail_view";
}
@RequestMapping("/send_mail.action")
public String sendMail(Mail mail, MultipartFile mail_pic) throws Exception {
// 上传图片
// 原始名称
String originalFilename = null;
if (mail_pic != null) {
originalFilename = mail_pic.getOriginalFilename();
}
if (mail_pic != null && originalFilename != null && originalFilename.trim() != "") {
@Controller
public class HomeController {
@Autowired
EmployeeService employeeService;
@Autowired
AttendanceService attendanceService;
@Autowired
AnnouncementService announcementService;
@Autowired
SysService sysService;
EmployeeCustom activeEmp;
@RequestMapping("/home")
public String showHome(Model model,HttpSession session) throws Exception{
activeEmp = (EmployeeCustom) SecurityUtils.getSubject().getPrincipal();
session.setAttribute("activeEmp", activeEmp);
//展示出勤率,[0]正常 [1]加班 [2]迟到早退 [3]缺席[4]剩余天数
int[] attendance = attendanceService.countMonthState(activeEmp);
model.addAttribute("attendance",attendance);
//公告一览
List<AnnouncementCustom> announceList = announcementService.showAllAnnouncement(activeEmp);
model.addAttribute("announceList", announceList);
//可发布公告的对象
model.addAttribute("departmentList", sysService.getAbleToAnnounceDeps());
return "/home/home";
}
@RequestMapping("/announce.action")
return "redirect:/mission/mission_view?mission_id="+mission_id;
}
}
@Controller
public class AccountController {
@Autowired
private EmployeeService employeeService;
@Autowired
private SysService sysService;
EmployeeCustom activeEmp;
@RequestMapping("/login")
public String login(Model model, HttpServletRequest request) throws Exception {
String exceptionClassName = (String) request.getAttribute("shiroLoginFailure");
if (exceptionClassName != null) {
if (UnknownAccountException.class.getName().equals(exceptionClassName)) {
// 最终会抛给异常处理器
model.addAttribute("message", "账号不存在");
} else if (IncorrectCredentialsException.class.getName().equals(exceptionClassName)) {
model.addAttribute("message", "用户名/密码错误");
@Autowired
private EmployeeService employeeService;
@Autowired
private SysService sysService;
// 展示收到的邮件
@RequestMapping("")
public String showMailPage(Model model, HttpSession session, HttpServletRequest request) throws Exception {
List<MailCustom> mailList = new ArrayList<MailCustom>();
switch ((String) request.getParameter("view")) {
case "all":
mailList = mailService.findMailToMe((EmployeeCustom) session.getAttribute("activeEmp"));
model.addAttribute("isSend", false);
break;
case "unread":
mailList = mailService.findUnreadMailToMe((EmployeeCustom) session.getAttribute("activeEmp"));
model.addAttribute("isSend", false);
break;
case "read":
mailList = mailService.findReadMailToMe((EmployeeCustom) session.getAttribute("activeEmp"));
model.addAttribute("isSend", false);
break;
case "send":
mailList = mailService.findMailSendByMe((EmployeeCustom) session.getAttribute("activeEmp"));
model.addAttribute("isSend", true);
break;
default:
mailList = mailService.findMailToMe((EmployeeCustom) session.getAttribute("activeEmp"));
model.addAttribute("isSend", false);
break;
}
model.addAttribute("mailList", mailList);
model.addAttribute("isInbox", true);// mail_common中右上角的的按钮
return "mail/mail_inbox";
}
@RequestMapping("/mail_view")
public String showMailDetail(Model model, HttpServletRequest request) throws Exception {
MailCustom mailDetail = mailService.showMailDetail(Integer.parseInt(request.getParameter("mail_id")),
Integer.parseInt(request.getParameter("otherside_id")));
}
// 将新图片名称写入
mail.setText(mail.getText().replaceAll("\r\n", "<br>"));
mailService.sendMail(mail);
return "redirect:/mail?view=all";
}
@RequestMapping("/mail_compose")
public String showComposeForm(Model model, Integer receiver) throws Exception {
if (receiver != null) {
model.addAttribute("receiver", employeeService.findEmployeeById(receiver));
}
return "mail/mail_compose";
}
}
@Controller
@RequestMapping("/login")
public String login(Model model, HttpServletRequest request) throws Exception {
String exceptionClassName = (String) request.getAttribute("shiroLoginFailure");
if (exceptionClassName != null) {
if (UnknownAccountException.class.getName().equals(exceptionClassName)) {
// 最终会抛给异常处理器
model.addAttribute("message", "账号不存在");
} else if (IncorrectCredentialsException.class.getName().equals(exceptionClassName)) {
model.addAttribute("message", "用户名/密码错误");
// throw new CustomException("用户名/密码错误");
} else {
model.addAttribute("message", "未知错误");
// throw new Exception();// 最终在异常处理器生成未知错误
}
}
// 访问/login时, 自动进行认证,认证成功后直接跳转出去
// 初次访问时exceptionClassName== null直接到这里
// 认证失败时exceptionClassName!= null , 传递信息后又回到这里
return "misc/login";
}
@RequestMapping(value = "/signup", method = RequestMethod.GET)
public String showSignupPage(Model model) throws Exception {
return "misc/signup";
}
@RequestMapping(value = "/signup", method = RequestMethod.POST)
public String checkUsername(Model model, Employee employee) throws Exception {
try {
employeeService.checkUsername(employee);
model.addAttribute("employee", employee);
model.addAttribute("positionList", sysService.getAbleToRegPos());
return "misc/signup_detail";
} catch (CustomException e) {
model.addAttribute("message", e.getMessage());
}
return "misc/signup";
}
@RequestMapping(value = "/signup2", method = RequestMethod.POST)
public String confirmPosition(Model model, Employee employee, MultipartFile employee_pic) throws Exception {
// 上传图片
String originalFilename = employee_pic.getOriginalFilename();
if (employee_pic != null && originalFilename != null && originalFilename.trim() != "") {
employee.setPic(sysService.uploadPic("employee", employee_pic));