100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 基于javaweb的员工考勤管理系统(java+ssm+jsp+bootstrap+mysql)

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

时间:2023-12-12 11:17:28

相关推荐

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

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

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb+mysql的员工考勤管理系统(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项目:是;

技术栈

后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+CSS+JavaScript+jquery+bootstrap

使用说明

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

管理员管理控制层:

@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 list = null;

//页码对象

PagingVO pagingVO = new PagingVO();

//设置总页数

pagingVO.setTotalCount(staffCustomService.getStaffCount());

if (page == null || page == 0) {

pagingVO.setToPageNo(1);

list = staffCustomService.findByPaging(1);

} else {

pagingVO.setToPageNo(page);

list = staffCustomService.findByPaging(page);

model.addAttribute(“staffList”, list);

model.addAttribute(“pagingVO”, pagingVO);

return “/admin/showStaff”;

//显示员工详细信息

@RequestMapping(“/showStaffDetail”)

public String showStaffDetail(String staffId, Model model) throws Exception{

StaffCustom staffDetail = staffCustomService.findById(staffId);

model.addAttribute(“staffDetail”, staffDetail);

List list = departmentService.finAll();

model.addAttribute(“departmentList”, list);

return “/admin/showStaffDetail”;

// 添加员工信息页面显示

@RequestMapping(value = “/addStaff”, method = {RequestMethod.GET})

public String addStudentUI(Model model) throws Exception {

List list = departmentService.finAll();

model.addAttribute(“departmentList”, list);

return “/admin/addStaff”;

// 添加员工信息操作

@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 list = staffCustomService.findByName(findByName);

model.addAttribute(“staffList”, list);

return “/admin/showStaff”;

// 考勤记录统计查询页面显示

@RequestMapping(value = “/showSign”)

public String showSign() throws Exception {

return “/admin/showSign”;

// 考勤记录统计查询

@RequestMapping(value = “/loadReportInfoData”)

public String loadReportInfoData(Model model,ReportInfo reportInfo) throws Exception {

List reportInfoList = new ArrayList();

try {

reportInfoList = adminService.loadReportInfoData(reportInfo);

} catch (Exception e) {

e.printStackTrace();

model.addAttribute(“reportInfoList”, reportInfoList);

return “/admin/showSign”;

//考勤记录详细信息显示

@RequestMapping(value = “/loadReportDetailData”)

public void loadReportDetailData(PrintWriter printWriter,String reportId, Model model) throws Exception {

List reportDetailList = new ArrayList();

try {

reportDetailList = adminService.loadReportDetailData(reportId);

} catch (Exception e) {

e.printStackTrace();

/model.addAttribute(“reportDetailList”, reportDetailList);/

/System.out.println(reportDetailList.size());/

String resultJson = JSON.toJSONString(reportDetailList);

printWriter.write(resultJson);

printWriter.flush();

printWriter.close();

// 请假记录查询页面显示

@RequestMapping(value = “/showLeave”)

public String showLeave() throws Exception {

return “/admin/showLeave”;

// 请假记录查询页面显示

@RequestMapping(value = “/showLeaveRecord”)

@ResponseBody

public Map<String, Object> showLeaveRecord(String searchText) throws Exception {

List leaveList = new ArrayList();

List returnLeaves = new ArrayList();

try {

leaveList = adminService.loadLeaveList();

} catch (Exception e) {

e.printStackTrace();

for(Leave leave:leaveList) {

if(String.valueOf(leave.getStaffId()).contains(searchText)) {

returnLeaves.add(leave);

JsonConfig jsonConfig = new JsonConfig();

jsonConfig.registerJsonValueProcessor(java.util.Date.class, new DateJsonValueProcessor(“yyyy-MM-dd HH:mm:ss”));

JSONArray jarray = JSONArray.fromObject(returnLeaves,jsonConfig);

for (int i = 0; i < jarray.size(); i++) {

JSONObject json=new JSONObject();

json=jarray.getJSONObject(i);

if(json.get(“handleTime”)==null||!“”.equals(json.get(“handleTime”))){//因为在添加的时候只有这个值可能为NULL所以我就判断了这个。

json.put(“handleTime”, “–”);

jarray.set(i,json);

Map<String, Object> map = new HashMap<String, Object>();

if(returnLeaves != null) {

map.put(“total”, jarray.size());

map.put(“rows”, jarray);

/*String resultJson = JSON.toJSONString(leaveList);

System.out.println(resultJson);*/

return map;

// 本账户密码重置

@RequestMapping(“/passwordReset”)

public String passwordRestUI() throws Exception {

return “/admin/passwordReset”;

登录管理控制层:

@Controller

public class LoginController {

//登录跳转

@RequestMapping(value = “/login”, method = {RequestMethod.GET})

public String loginUI() throws Exception {

return “/login”;

@RequestMapping(value=“/logout”,method = {RequestMethod.GET})

public String logout() throws Exception{

return “/login”;

//登录表单处理

@RequestMapping(value = “/login”, method = {RequestMethod.POST})

public String login(Model model,Staff staff) throws Exception {

//Shiro实现登录

UsernamePasswordToken token = new UsernamePasswordToken(staff.getStaffId(),

staff.getPassword());

Subject subject = SecurityUtils.getSubject();

//如果获取不到用户名就是登录失败,但登录失败的话,会直接抛出异常

subject.login(token);

if (subject.hasRole(“admin”)) {

return “redirect:/admin/showStaff”;

} else if (subject.hasRole(“manager”)) {

return “redirect:/managers/showMassage”;

} else if (subject.hasRole(“staff”)) {

return “redirect:/staff/sign”;

return “/login”;

员工管理控制层:

@Controller

@RequestMapping(value = “/staff”)

public class StaffController {

@Resource(name = “staffServiceImpl”)

private StaffService staffService;

@Resource(name = “signServiceImpl”)

private SignService signService;

@Resource(name = “leaveServiceImpl”)

private LeaveService leaveService;

@Resource(name = “departmentServiceImpl”)

private DepartmentService departmentService;

//签到签退

@RequestMapping(value=“/sign”)

public String staffSign() throws Exception {

return “/staff/sign”;

//签到

@RequestMapping(value=“/signIn”)

public void staffSignIn(HttpServletResponse response) throws Exception {

//获取当前用户id

Subject subject = SecurityUtils.getSubject();

String id = (String) subject.getPrincipal();

Staff staff = staffService.findById(id);

//获取当前时间

Date sign_in_time = new Date();

SimpleDateFormat dateFormat= new SimpleDateFormat(“HH:mm:ss”);

String time=dateFormat.format(sign_in_time);

Sign signIn= new Sign();

signIn.setStaffId(id);

signIn.setDepartmentId(staff.getDepartmentId());

signIn.setSignInTime(sign_in_time);

//判断当天是否已经签到

int isSignIn = signService.isSignIn(signIn);

if (isSignIn !=0){

response.getWriter().println(“今日已签到!”);

else {

//判断签到时间状态,8:00之前0-正常,之后1-迟到

Date beginTime = dateFormat.parse(“09:00:00”);

Calendar date = Calendar.getInstance();

date.setTime(dateFormat.parse(time));

Calendar begin = Calendar.getInstance();

begin.setTime(beginTime);

if (date.after(begin)) {

signIn.setSignInState(“1”);

} else

signIn.setSignInState(“0”);

//签到记录插入表sign_record

signService.signIn(signIn);

//签到时间返回给前端页面

response.getWriter().println(time);

//签退

@RequestMapping(value=“/signOut”)

public void staffSignOut(HttpServletResponse response) throws Exception {

//获取当前用户id

Subject subject = SecurityUtils.getSubject();

String id = (String) subject.getPrincipal();

Staff staff = staffService.findById(id);

//获取当前时间

Date sign_out_time = new Date();

SimpleDateFormat dateFormat= new SimpleDateFormat(“HH:mm:ss”);

String time=dateFormat.format(sign_out_time);

Sign signOut= new Sign();

signOut.setStaffId(id);

signOut.setDepartmentId(staff.getDepartmentId());

signOut.setSignOutTime(sign_out_time);

//判断当天是否已经签到

int isSignIn = signService.isSignIn(signOut);

if(isSignIn == 0){

response.getWriter().println(“今日还未签到,请先签到”);

}else {

//判断签到时间状态,18:00之后0-正常,之前1-迟到

Date endTime = dateFormat.parse(“18:00:00”);

Calendar date = Calendar.getInstance();

date.setTime(dateFormat.parse(time));

Calendar end = Calendar.getInstance();

end.setTime(endTime);

if (date.before(end)) {

signOut.setSignOutState(“1”);

} else signOut.setSignOutState(“0”);

//更新签退记录到已有签到记录

signService.signOut(signOut);

//返回时间到前端页面

response.getWriter().println(“签退成功\n”+“签退时间:”+time);

//显示个人信息

@RequestMapping(value=“/showMassage”, method = {RequestMethod.GET})

public String staffMassageShow(Model model) throws Exception {

//获取当前用户id

Subject subject = SecurityUtils.getSubject();

String id = (String) subject.getPrincipal();

//通过id获取员工信息

Staff staff = staffService.findById(id);

if (staff == null) {

throw new CustomException(“未找到员工信息”);

List list = departmentService.finAll();

model.addAttribute(“departmentList”, list);

model.addAttribute(“staff”, staff);

return “/staff/showMassage”;

//更新个人信息

@RequestMapping(value=“/showMassage”, method = {RequestMethod.POST})

public String staffMassageUpdate(String tel,String email,String hobby) throws Exception {

//获取当前用户id

Subject subject = SecurityUtils.getSubject();

String id = (String) subject.getPrincipal();

Map<String, Object> paramMap = new HashMap<String, Object>();

paramMap.put(“id”,id);

paramMap.put(“tel”,tel);

paramMap.put(“email”,email);

paramMap.put(“hobby”,hobby);

staffService.updateMassage(paramMap);

return “redirect:/staff/showMassage”;

//查询考勤记录

@RequestMapping(value = “/signRecord”)

public String signRecordShow(Model model, Integer page) throws Exception {

//获取当前用户id

Subject subject = SecurityUtils.getSubject();

String id = (String) subject.getPrincipal();

List list = null;

//页码对象

PagingVO pagingVO = new PagingVO();

//设置总页数

pagingVO.setTotalCount(signService.getCountSign(id));

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(“id”, id);

list = signService.findByPaging(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(“id”, id);

list = signService.findByPaging(paramMap);

model.addAttribute(“signList”, list);

model.addAttribute(“pagingVO”, pagingVO);

return “/staff/signRecord”;

//请假申请

@RequestMapping(value=“/leave”)

public String leave() throws Exception {

return “/staff/leave”;

@RequestMapping(value=“/handinLeave”)

public String handinLeave(String leavetime,String reason) throws Exception {

//获取当前用户id

Subject subject = SecurityUtils.getSubject();

String id = (String) subject.getPrincipal();

Staff staff = staffService.findById(id);

//将请假申请写入数据库

Map<String, Object> paramMap = new HashMap<String, Object>();

paramMap.put(“leavetime”, leavetime);

paramMap.put(“reason”, reason);

paramMap.put(“id”, id);

paramMap.put(“departmentId”,staff.getDepartmentId());

/System.out.println(reason);/

leaveService.handinLeave(paramMap);

return “redirect:/staff/leaveRecord”;

//查询请假记录及状态

@RequestMapping(value = “/leaveRecord”)

public String leaveRecordShow(Model model, Integer page) throws Exception {

//获取当前用户id

Subject subject = SecurityUtils.getSubject();

String id = (String) subject.getPrincipal();

List list = null;

//页码对象

PagingVO pagingVO = new PagingVO();

//设置总页数

pagingVO.setTotalCount(leaveService.getCountLeave(id));

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(“id”, id);

list = leaveService.findByPaging(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(“id”, id);

list = leaveService.findByPaging(paramMap);

model.addAttribute(“leaveList”, list);

model.addAttribute(“pagingVO”, pagingVO);

return “/staff/leaveRecord”;

// 显示请假申请详细信息

@RequestMapping(value = “/leaveDetail”)

public String gradeCourse(Integer recordId, Model model) throws Exception {

if (recordId == null) {

return “”;

Leave leaveDetail= leaveService.findByRecordId(recordId);

model.addAttribute(“leaveDetail”, leaveDetail);

return “/staff/showLeaveDetail”;

//修改密码

@RequestMapping(value = “/passwordReset”)

public String passwordRest() throws Exception {

return “/staff/passwordReset”;

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。