Java實(shí)戰(zhàn)員工績(jī)效管理系統(tǒng)的實(shí)現(xiàn)流程
基于SSM+Mysql+Maven+HTML實(shí)現(xiàn)的員工績(jī)效管理系統(tǒng)。該系統(tǒng)只有后臺(tái)頁面,后臺(tái)前端框架使用的是layui官網(wǎng)推薦后臺(tái)界面。
角色分為管理員和員工
管理員功能有:?jiǎn)T工管理、職位管理、部門管理、崗位管理、工資管理、工齡管理、考勤管理、工資項(xiàng)管理等。
員工功能有:考勤管理、工資管理、個(gè)人信息。
運(yùn)行環(huán)境:jdk1.8、tomcat7.0\8.5、maven3.5\3.6、eclipse、mysql5.x。






后臺(tái)員工管理控制器代碼:
/**
* 后臺(tái)員工管理控制器
* @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){
//用統(tǒng)一驗(yàn)證實(shí)體方法驗(yàn)證是否合法
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);
}
//自動(dòng)生成工號(hào)
int maxId = staffService.findMaxId()+1;
String jobNumber = DateUtil.getCurrentDateTime("yyyyMMdd");
if(maxId<10){
jobNumber=jobNumber+"0"+maxId;
}else{
jobNumber=jobNumber+maxId;
}
staff.setJobNumber(jobNumber);
//到這說明一切符合條件,進(jìn)行數(shù)據(jù)庫新增
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){
//用統(tǒng)一驗(yàn)證實(shí)體方法驗(yàn)證是否合法
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);
}
//到這說明一切符合條件,進(jìn)行數(shù)據(jù)庫保存
Staff findById = staffService.find(staff.getId());
//講提交的員工信息指定字段復(fù)制到已存在的staff對(duì)象中,該方法會(huì)覆蓋新字段內(nèi)容
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){
//用統(tǒng)一驗(yàn)證實(shí)體方法驗(yàn)證是否合法
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);
}
//到這說明一切符合條件,進(jìn)行數(shù)據(jù)庫保存
Staff findById = staffService.find(staff.getId());
//講提交的員工信息指定字段復(fù)制到已存在的staff對(duì)象中,該方法會(huì)覆蓋新字段內(nèi)容
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);
}
/**
* 修改個(gè)人信息
* @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";
}
}
后臺(tái)角色管理控制器:
/**
* 后臺(tái)角色管理控制器
* @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){
//用統(tǒng)一驗(yàn)證實(shí)體方法驗(yàn)證是否合法
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){
//用統(tǒng)一驗(yàn)證實(shí)體方法驗(yàn)證是否合法
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("編輯角色I(xiàn)D【"+id+"】");
operaterLogService.add("刪除角色I(xiàn)D【"+id+"】");
return Result.success(true);
}
}
后臺(tái)工齡管理Controller:
/**
* 后臺(tái)工齡管理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){
//用統(tǒng)一驗(yàn)證實(shí)體方法驗(yàn)證是否合法
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("添加工齡,工齡補(bǔ)貼為:" + 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){
//用統(tǒng)一驗(yàn)證實(shí)體方法驗(yàn)證是否合法
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);
}
//到這說明一切符合條件,進(jìn)行數(shù)據(jù)庫保存
WorkingYears findById = workingYearsService.find(workingYears.getId());
//講提交的用戶信息指定字段復(fù)制到已存在的department對(duì)象中,該方法會(huì)覆蓋新字段內(nèi)容
BeanUtils.copyProperties(workingYears, findById, "id","createTime","updateTime");
if(workingYearsService.save(findById) == null){
return Result.error(CodeMsg.ADMIN_WORKING_YEARS_EDIT_ERROR);
}
operaterLogService.add("編輯工齡,工齡補(bǔ)貼為:" + 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("刪除工齡補(bǔ)貼,工齡ID:" + id);
return Result.success(true);
}
}
到此這篇關(guān)于Java實(shí)戰(zhàn)員工績(jī)效管理系統(tǒng)的實(shí)現(xiàn)流程的文章就介紹到這了,更多相關(guān)Java 員工績(jī)效管理系統(tǒng)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
idea導(dǎo)入配置Spring?Boot項(xiàng)目的詳細(xì)步驟教程
這篇文章主要給大家介紹了關(guān)于idea導(dǎo)入配置Spring?Boot項(xiàng)目的詳細(xì)步驟,在項(xiàng)目開發(fā)過程中,無論是導(dǎo)入運(yùn)行團(tuán)隊(duì)開發(fā)的項(xiàng)目,還是一些開源項(xiàng)目,還是其他的項(xiàng)目,想要在IDEA中完整的運(yùn)行起來總有很多坑,需要的朋友可以參考下2023-08-08
記錄一個(gè)使用Spring?Data?JPA設(shè)置默認(rèn)值的問題
這篇文章主要介紹了使用Spring?Data?JPA設(shè)置默認(rèn)值的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-11-11
淺談MultipartFile中transferTo方法的坑
這篇文章主要介紹了MultipartFile中transferTo方法的坑,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-07-07
Java基于外觀模式實(shí)現(xiàn)美食天下食譜功能實(shí)例詳解
這篇文章主要介紹了Java基于外觀模式實(shí)現(xiàn)美食天下食譜功能,較為詳細(xì)的講述了外觀模式的概念、原理并結(jié)合實(shí)例形似詳細(xì)分析了Java基于外觀模式實(shí)現(xiàn)美食天下食譜功能的具體操作步驟與相關(guān)注意事項(xiàng),需要的朋友可以參考下2018-05-05
Java8的Lambda遍歷兩個(gè)List匹配數(shù)據(jù)方式
這篇文章主要介紹了Java8的Lambda遍歷兩個(gè)List匹配數(shù)據(jù)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-03-03
Spring Boot Thymeleaf實(shí)現(xiàn)國(guó)際化的方法詳解
這篇文章主要給大家介紹了關(guān)于Spring Boot Thymeleaf實(shí)現(xiàn)國(guó)際化的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Spring Boot具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10

