Java实战员工绩效管理系统的实现流程
程序员文章站
2022-06-24 17:45:29
基于ssm+mysql+maven+html实现的员工绩效管理系统。该系统只有后台页面,后台前端框架使用的是layui官网推荐后台界面。角色分为管理员和员工管理员功能有:员工管理、职位管理、部门管理、...
基于ssm+mysql+maven+html实现的员工绩效管理系统。该系统只有后台页面,后台前端框架使用的是layui官网推荐后台界面。
角色分为管理员和员工
管理员功能有:员工管理、职位管理、部门管理、岗位管理、工资管理、工龄管理、考勤管理、工资项管理等。
员工功能有:考勤管理、工资管理、个人信息。
运行环境:jdk1.8、tomcat7.0\8.5、maven3.5\3.6、eclipse、mysql5.x。
后台员工管理控制器代码:
/** * 后台员工管理控制器 * @author administrator * */ @requestmapping("/admin/staff") @controller public class staffcontroller { @autowired private staffservice staffservice; @autowired private jobtitleservice jobtitleservice; @autowired private roleservice roleservice; @autowired private positionservice positionservice; @autowired private departmentservice departmentservice; @autowired private operaterlogservice operaterlogservice; @autowired private attendanceservice attendanceservice; /** * 员工列表页面 * @param model * @param staff * @param pagebean * @return */ @requestmapping(value="/list") public string list(model model, staff staff, pagebean<staff> pagebean){ model.addattribute("title", "员工列表"); model.addattribute("jobnumber", staff.getjobnumber()==null?"":staff.getjobnumber()); model.addattribute("pagebean", staffservice.findlist(staff, pagebean)); return "admin/staff/list"; } /** * 新增员工页面 * @param model * @return */ @requestmapping(value="/add",method=requestmethod.get) public string add(model model){ model.addattribute("roles", roleservice.findall()); model.addattribute("educationenum",educationenum.values()); model.addattribute("jobtitlelist",jobtitleservice.findall()); model.addattribute("positionlist",positionservice.findall()); model.addattribute("departmentlist",departmentservice.findall()); return "admin/staff/add"; } /** * 员工添加表单提交处理 * @param staff * @return */ @requestmapping(value="/add",method=requestmethod.post) @responsebody public result<boolean> add(staff staff){ //用统一验证实体方法验证是否合法 codemsg validate = validateentityutil.validate(staff); if(validate.getcode() != codemsg.success.getcode()){ return result.error(validate); } if(staff.getrole() == null || staff.getrole().getid() == null){ return result.error(codemsg.admin_staff_role_error); } if(!stringutil.ismobile(staff.getmobile())){ return result.error(codemsg.admin_staff_mobile_error); } if(!stringutil.ismobile(staff.getemergencymobile())){ return result.error(codemsg.admin_staff_emergency_mobile_error); } //自动生成工号 int maxid = staffservice.findmaxid()+1; string jobnumber = dateutil.getcurrentdatetime("yyyymmdd"); if(maxid<10){ jobnumber=jobnumber+"0"+maxid; }else{ jobnumber=jobnumber+maxid; } staff.setjobnumber(jobnumber); //到这说明一切符合条件,进行数据库新增 if(staffservice.save(staff) == null){ return result.error(codemsg.admin_staff_add_error); } operaterlogservice.add("添加员工,员工名:" + staff.getname()); return result.success(true); } @requestmapping(value="/edit_self",method=requestmethod.post) @responsebody public result<boolean> edit_self(staff staff, httpservletrequest request){ //用统一验证实体方法验证是否合法 codemsg validate = validateentityutil.validate(staff); if(validate.getcode() != codemsg.success.getcode()){ return result.error(validate); } if(!stringutil.ismobile(staff.getmobile())){ return result.error(codemsg.admin_staff_mobile_error); } if(!stringutil.ismobile(staff.getemergencymobile())){ return result.error(codemsg.admin_staff_emergency_mobile_error); } if(staff.getid() == null || staff.getid().longvalue() <= 0){ return result.error(codemsg.admin_staff_not_exist_error); } //到这说明一切符合条件,进行数据库保存 staff findbyid = staffservice.find(staff.getid()); //讲提交的员工信息指定字段复制到已存在的staff对象中,该方法会覆盖新字段内容 beanutils.copyproperties(staff, findbyid, "id","createtime","updatetime","jobnumber", "role","educationenum","jobtitle", "position","department","entrytime"); staff savestaff = staffservice.save(findbyid); if(savestaff == null){ return result.error(codemsg.admin_staff_edit_error); } staff loginedstaff = sessionutil.getloginedstaff(); if(loginedstaff != null){ if(loginedstaff.getid().longvalue() == findbyid.getid().longvalue()){ loginedstaff.setheadpic(savestaff.getheadpic()); loginedstaff.setname(savestaff.getname()); loginedstaff.setmobile(savestaff.getmobile()); loginedstaff.setemergencycontact(savestaff.getemergencycontact()); loginedstaff.setemergencymobile(savestaff.getemergencymobile()); loginedstaff.setage(savestaff.getage()); loginedstaff.setsex(savestaff.getsex()); sessionutil.set(sessionconstant.session_staff_login_key,loginedstaff); } } operaterlogservice.add("编辑员工,员工名:" + staff.getname()); return result.success(true); } /** * 员工编辑页面 * @param model * @return */ @requestmapping(value="/edit",method=requestmethod.get) public string edit(model model,@requestparam(name="id",required=true)long id){ model.addattribute("staff", staffservice.find(id)); model.addattribute("roles", roleservice.findall()); model.addattribute("educationenum",educationenum.values()); model.addattribute("jobtitlelist",jobtitleservice.findall()); model.addattribute("positionlist",positionservice.findall()); model.addattribute("departmentlist",departmentservice.findall()); return "admin/staff/edit"; } /** * 编辑员工信息表单提交处理 * @param staff * @return */ @requestmapping(value="/edit",method=requestmethod.post) @responsebody public result<boolean> edit(staff staff, httpservletrequest request){ //用统一验证实体方法验证是否合法 codemsg validate = validateentityutil.validate(staff); if(validate.getcode() != codemsg.success.getcode()){ return result.error(validate); } if(staff.getrole() == null || staff.getrole().getid() == null){ return result.error(codemsg.admin_staff_role_error); } if(!stringutil.ismobile(staff.getmobile())){ return result.error(codemsg.admin_staff_mobile_error); } if(!stringutil.ismobile(staff.getemergencymobile())){ return result.error(codemsg.admin_staff_emergency_mobile_error); } if(staff.getid() == null || staff.getid().longvalue() <= 0){ return result.error(codemsg.admin_staff_not_exist_error); } //到这说明一切符合条件,进行数据库保存 staff findbyid = staffservice.find(staff.getid()); //讲提交的员工信息指定字段复制到已存在的staff对象中,该方法会覆盖新字段内容 beanutils.copyproperties(staff, findbyid, "id","createtime","updatetime","jobnumber"); staff savestaff = staffservice.save(findbyid); if(savestaff == null){ return result.error(codemsg.admin_staff_edit_error); } staff loginedstaff = sessionutil.getloginedstaff(); if(loginedstaff != null){ if(loginedstaff.getid().longvalue() == findbyid.getid().longvalue()){ loginedstaff.setheadpic(savestaff.getheadpic()); loginedstaff.setname(savestaff.getname()); loginedstaff.setmobile(savestaff.getmobile()); loginedstaff.setemergencycontact(savestaff.getemergencycontact()); loginedstaff.setemergencymobile(savestaff.getemergencymobile()); loginedstaff.setage(savestaff.getage()); loginedstaff.setsex(savestaff.getsex()); sessionutil.set(sessionconstant.session_staff_login_key,loginedstaff); } } operaterlogservice.add("编辑员工,员工名:" + staff.getname()); return result.success(true); } /** * 离职员工 * @param id * @return */ @requestmapping(value="/delete",method=requestmethod.post) @responsebody public result<boolean> delete(@requestparam(name="id",required=true)long id){ if(staffservice.updatestatus(staffstatus.quit.getcode(), id)<=0){ return result.error(codemsg.admin_staff_status_error); } operaterlogservice.add("员工离职,员工id:" + id); return result.success(true); } /** * 修改个人信息 * @param model * @return */ @requestmapping("/self") public string self(model model){ staff loginedstaff = sessionutil.getloginedstaff(); staff staff = staffservice.find(loginedstaff.getid()); model.addattribute("roles", roleservice.findall()); model.addattribute("educationenum",educationenum.values()); model.addattribute("jobtitlelist",jobtitleservice.findall()); model.addattribute("positionlist",positionservice.findall()); model.addattribute("departmentlist",departmentservice.findall()); model.addattribute("staff",staff); return "admin/staff/self"; } }
后台角色管理控制器:
/** * 后台角色管理控制器 * @author yy * */ @requestmapping("/admin/role") @controller public class rolecontroller { private logger log = loggerfactory.getlogger(rolecontroller.class); @autowired private menuservice menuservice; @autowired private operaterlogservice operaterlogservice; @autowired private roleservice roleservice; /** * 分页搜索角色列表 * @param model * @param role * @param pagebean * @return */ @requestmapping(value="/list") public string list(model model,role role,pagebean<role> pagebean){ model.addattribute("title", "角色列表"); model.addattribute("name", role.getname()); model.addattribute("pagebean", roleservice.findbyname(role, pagebean)); return "admin/role/list"; } /** * 角色添加页面 * @param model * @return */ @requestmapping(value="/add",method=requestmethod.get) public string add(model model){ list<menu> findall = menuservice.findall(); model.addattribute("topmenus",menuutil.gettopmenus(findall)); model.addattribute("secondmenus",menuutil.getsecondmenus(findall)); model.addattribute("thirdmenus",menuutil.getthirdmenus(findall)); return "admin/role/add"; } /** * 角色添加表单提交处理 * @param role * @return */ @requestmapping(value="/add",method=requestmethod.post) @responsebody public result<boolean> add(role role){ //用统一验证实体方法验证是否合法 codemsg validate = validateentityutil.validate(role); if(validate.getcode() != codemsg.success.getcode()){ return result.error(validate); } if(roleservice.save(role) == null){ return result.error(codemsg.admin_role_add_error); } log.info("添加角色【"+role+"】"); operaterlogservice.add("添加角色【"+role.getname()+"】"); return result.success(true); } /** * 角色编辑页面 * @param id * @param model * @return */ @requestmapping(value="/edit",method=requestmethod.get) public string edit(@requestparam(name="id",required=true)long id,model model){ list<menu> findall = menuservice.findall(); model.addattribute("topmenus",menuutil.gettopmenus(findall)); model.addattribute("secondmenus",menuutil.getsecondmenus(findall)); model.addattribute("thirdmenus",menuutil.getthirdmenus(findall)); role role = roleservice.find(id); model.addattribute("role", role); model.addattribute("authorities",jsonarray.tojson(role.getauthorities()).tostring()); return "admin/role/edit"; } /** * 角色修改表单提交处理 * @param request * @param role * @return */ @requestmapping(value="/edit",method=requestmethod.post) @responsebody public result<boolean> edit(role role){ //用统一验证实体方法验证是否合法 codemsg validate = validateentityutil.validate(role); if(validate.getcode() != codemsg.success.getcode()){ return result.error(validate); } role existrole = roleservice.find(role.getid()); if(existrole == null){ return result.error(codemsg.admin_role_no_exist); } existrole.setname(role.getname()); existrole.setremark(role.getremark()); existrole.setstatus(role.getstatus()); existrole.setauthorities(role.getauthorities()); if(roleservice.save(existrole) == null){ return result.error(codemsg.admin_role_edit_error); } log.info("编辑角色【"+role+"】"); operaterlogservice.add("编辑角色【"+role.getname()+"】"); return result.success(true); } /** * 删除角色 * @param request * @param id * @return */ @requestmapping(value="delete",method=requestmethod.post) @responsebody public result<boolean> delete(@requestparam(name="id",required=true)long id){ try { roleservice.delete(id); } catch (exception e) { // todo: handle exception return result.error(codemsg.admin_role_delete_error); } log.info("编辑角色id【"+id+"】"); operaterlogservice.add("删除角色id【"+id+"】"); return result.success(true); } }
后台工龄管理controller:
/** * 后台工龄管理controller */ @controller @requestmapping("/admin/work_years") public class workingyearscontroller { @autowired private workingyearsservice workingyearsservice; @autowired private operaterlogservice operaterlogservice; /** * 分页查询工龄列表 * @param model * @param pagebean * @param workingyears * @return */ @requestmapping("/list") public string list(model model, pagebean<workingyears> pagebean, workingyears workingyears){ model.addattribute("title","工龄列表"); model.addattribute("years",workingyears.getyears()); model.addattribute("pagebean",workingyearsservice.findlist(workingyears, pagebean)); return "/admin/working_years/list"; } /** * 添加页面 * @return */ @requestmapping("/add") public string add(){ return "/admin/working_years/add"; } /** * 工龄添加提交处理 * @param workingyears * @return */ @requestmapping(value = "/add",method = requestmethod.post) @responsebody public result<boolean> add(workingyears workingyears){ //用统一验证实体方法验证是否合法 codemsg validate = validateentityutil.validate(workingyears); if(validate.getcode() != codemsg.success.getcode()){ return result.error(validate); } if(workingyearsservice.findbyyears(workingyears.getyears())!=null){ return result.error(codemsg.admin_working_years_exist_error); } if(workingyearsservice.save(workingyears) == null){ return result.error(codemsg.admin_working_years_add_error); } operaterlogservice.add("添加工龄,工龄补贴为:" + workingyears.getsubsidy()); return result.success(true); } /** * 编辑页面 * @param model * @param id * @return */ @requestmapping("/edit") public string edit(model model,@requestparam(name="id",required=true)long id){ model.addattribute("workyears",workingyearsservice.find(id)); return "/admin/working_years/edit"; } /** * 编辑表单提交处理 * @param workingyears * @return */ @requestmapping(value = "/edit",method = requestmethod.post) @responsebody public result<boolean> edit(workingyears workingyears){ //用统一验证实体方法验证是否合法 codemsg validate = validateentityutil.validate(workingyears); if(validate.getcode() != codemsg.success.getcode()){ return result.error(validate); } if(workingyearsservice.isexistyear(workingyears.getyears(),workingyears.getid())){ return result.error(codemsg.admin_working_years_exist_error); } //到这说明一切符合条件,进行数据库保存 workingyears findbyid = workingyearsservice.find(workingyears.getid()); //讲提交的用户信息指定字段复制到已存在的department对象中,该方法会覆盖新字段内容 beanutils.copyproperties(workingyears, findbyid, "id","createtime","updatetime"); if(workingyearsservice.save(findbyid) == null){ return result.error(codemsg.admin_working_years_edit_error); } operaterlogservice.add("编辑工龄,工龄补贴为:" + workingyears.getsubsidy()); return result.success(true); } /** * 工龄删除操作 * @param id * @return */ @requestmapping(value = "delete",method = requestmethod.post) @responsebody public result<boolean> delete(@requestparam(name="id",required=true)long id){ try{ workingyearsservice.delete(id); }catch (exception e){ return result.error(codemsg.admin_working_years_delete_error); } operaterlogservice.add("删除工龄补贴,工龄id:" + id); return result.success(true); } }
到此这篇关于java实战员工绩效管理系统的实现流程的文章就介绍到这了,更多相关java 员工绩效管理系统内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
上一篇: 轮播图的多种实现及原理