基于javaweb的SSM+Maven员工考勤请假管理系统(java+ssm+jsp+bootstrap+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

240123002402

250123002402

260123002402

270123002402

280123002402

300123002402

310123002402

基于javaweb的SSM+Maven员工考勤请假管理系统(java+ssm+jsp+bootstrap+mysql)

项目介绍

本项目包含管理员、部门经理、员工三种角色;

部门经理角色包含以下功能: 个人信息管理,请假信息审批,部门考勤记录,考勤系统管理等功能。

管理员角色包含以下功能: 管理员登录,员工管理,请假统计等功能。

员工角色包含以下功能: 员工登录,员工签到,考勤记录,请假,请假记录查询等功能。

环境需要

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+jquery+bootstrap

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中mysql.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ 登录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    String departmentIdStr = request.getParameter("departmentId");
if (departmentIdStr != null && !departmentIdStr.isEmpty() && intPattern.matcher(departmentIdStr).matches()) {
departmentId = Integer.parseInt(departmentIdStr);
}

// 判断role是否为整数
String roleStr = request.getParameter("role");
if (roleStr != null && !roleStr.isEmpty() && intPattern.matcher(roleStr).matches()) {
role = Integer.parseInt(roleStr);
}

// 判断grade是否为日期
String gradeStr = request.getParameter("grade");
if (gradeStr != null && !gradeStr.isEmpty() && datePattern.matcher(gradeStr).matches()) {
grade = new SimpleDateFormat("yyyy-MM-dd").parse(gradeStr);
}

// 判断birthday是否为日期
String birthdayStr = request.getParameter("birthday");
if (birthdayStr != null && !birthdayStr.isEmpty() && datePattern.matcher(birthdayStr).matches()) {
birthday = new SimpleDateFormat("yyyy-MM-dd").parse(birthdayStr);
}

Staff staff = new Staff();
staff.setStaffId(staffId);
staff.setStaffName(staffName);
staff.setSex(sex);
staff.setDepartmentId(departmentId);
staff.setRole(role);
staff.setGrade(grade);
staff.setBirthday(birthday);
staff.setTel(tel);
staff.setEmail(email);
staff.setHobby(hobby);
staff.setPassword(password);

staffService.updateById(staff);

return "redirect:/staff/showMassage";
}

//查询考勤记录
@RequestMapping(value = "/signRecord")
public String signRecordShow(Model model, Integer page) throws Exception {
//获取当前用户id
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
@RequestMapping(value = "/addStaff", method = {RequestMethod.POST})
public String addStudent(StaffCustom staffCustom, Model model) throws Exception {

/*System.out.println(staffCustom.getRole());*/
Boolean result = staffCustomService.save(staffCustom);

if (!result) {
model.addAttribute("message", "员工编号重复");
return "/error";
}
//添加成功后,也添加到登录表

//重定向
return "redirect:/admin/showStaff";
}


// 修改员工信息处理
@RequestMapping(value = "/editStaff", method = {RequestMethod.POST})
@ResponseBody
public boolean editStaff(int role,int department,String staffId) throws Exception {
Map<String,Object> paramMap = new HashMap<String, Object>();
paramMap.put("staffId",staffId);
paramMap.put("department",department);
paramMap.put("role",role);

staffCustomService.editStaff(paramMap);
return true;
}

// 删除员工
@RequestMapping(value = "/removeStaff"/*, method = {RequestMethod.GET} */)
public String removeStaff(String id) throws Exception {
if (id == null) {
//加入没有带员工id就进来的话就返回员工显示页面
return "/admin/showStaff";
}
staffCustomService.removeById(id);
loginService.removeById(id);

return "redirect:/admin/showStaff";
}

// 搜索员工
@RequestMapping(value = "/selectStaff")
public String selectStaff(String findByName, Model model) throws Exception {

List<StaffCustom> list = staffCustomService.findByName(findByName);

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29



@Controller
@RequestMapping("/admin")
public class AdminController {

@Resource(name = "staffCustomServiceImpl")
private StaffCustomService staffCustomService;

@Resource(name = "departmentServiceImpl")
private DepartmentService departmentService;

@Resource(name = "loginServiceImpl")
private LoginService loginService;

@Resource(name = "adminServiceImpl")
private AdminService adminService;

// 员工信息显示
@RequestMapping("/showStaff")
public String showStudent(Model model, Integer page) throws Exception {

List<StaffCustom> list = null;
//页码对象
PagingVO pagingVO = new PagingVO();
//设置总页数
pagingVO.setTotalCount(staffCustomService.getStaffCount());
if (page == null || page == 0) {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
    //获取当前用户id
Subject subject = SecurityUtils.getSubject();
String id = (String) subject.getPrincipal();
Staff staff = staffService.findById(id);

int departmentId = staff.getDepartmentId();
int unHandled = leaveService.getUnhandledCount(departmentId);
String result = String.valueOf(unHandled);

return result;
}

//查询请假记录及状态
@RequestMapping(value = "/leaveRecord")
public String leaveRecordShow(Model model, Integer page) throws Exception {
//获取当前用户id
Subject subject = SecurityUtils.getSubject();
String id = (String) subject.getPrincipal();
Staff staff = staffService.findById(id);

int departmentId = staff.getDepartmentId();
List<Leave> list = null;
//页码对象
PagingVO pagingVO = new PagingVO();
//设置总页数
pagingVO.setTotalCount(leaveService.getDepartmentLeaveCount(departmentId));
if (page == null || page == 0) {
pagingVO.setToPageNo(1);
//按页码和用户id查询请假记录
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("toPageNo", pagingVO.getTopageNo());
paramMap.put("pageSize", pagingVO.getPageSize());
paramMap.put("departmentId",staff.getDepartmentId());
list = leaveService.findByPagingD(paramMap);
} else {
pagingVO.setToPageNo(page);
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("toPageNo", pagingVO.getTopageNo());
paramMap.put("pageSize", pagingVO.getPageSize());
paramMap.put("departmentId",staff.getDepartmentId());
list = leaveService.findByPagingD(paramMap);
}

model.addAttribute("leaveList", list);
model.addAttribute("pagingVO", pagingVO);

return "/managers/leaveRecord";
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
            //用户名错误异常
modelAndView.addObject("message", "没有该用户");
modelAndView.setViewName("/error");
return modelAndView;
} else if (e instanceof IncorrectCredentialsException) {
//用户名错误异常
modelAndView.addObject("message", "密码错误");
modelAndView.setViewName("/error");
return modelAndView;
}
else {
customException = new CustomException(e.getMessage());
}

//错误信息
String message = customException.getMessage();



//错误信息传递和错误页面跳转
modelAndView.addObject("message", message);
modelAndView.setViewName("/error");


return modelAndView;
}
}
package com.system.controller;


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30



@Controller
@RequestMapping("/admin")
public class AdminController {

@Resource(name = "staffCustomServiceImpl")
private StaffCustomService staffCustomService;

@Resource(name = "departmentServiceImpl")
private DepartmentService departmentService;

@Resource(name = "loginServiceImpl")
private LoginService loginService;

@Resource(name = "adminServiceImpl")
private AdminService adminService;

// 员工信息显示
@RequestMapping("/showStaff")
public String showStudent(Model model, Integer page) throws Exception {

List<StaffCustom> list = null;
//页码对象
PagingVO pagingVO = new PagingVO();
//设置总页数
pagingVO.setTotalCount(staffCustomService.getStaffCount());
if (page == null || page == 0) {
pagingVO.setToPageNo(1);


项目链接:
https://javayms.github.io?id=201122572008200te
https://javayms.pages.dev?id=201122572008200te