源码获取:博客首页 "资源" 里下载!一、项目简述
功能介绍:员工管理,用户管理,部门管理,文档管理, 职位管理等等。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +Spring + SpringMVC + html+ css + JavaScript + JQuery + Ajax + maven等等。
【Java毕业设计项目实战篇|Java项目:企业人事管理系统(java+SSM+jsp+mysql+maven)】
文章图片
文章图片
文章图片
文章图片
后台部门管理:
/**
* 后台部门管理Controller
*/
@Controller
@RequestMapping("/admin/department")
public class DepartmentController {@Autowired
private DepartmentService departmentService;
@Autowired
private OperaterLogService operaterLogService;
/**
* 分页查询部门列表
* @param model
* @param pageBean
* @param department
* @return
*/
@RequestMapping("/list")
public String list(Model model, PageBean pageBean,Department department){
model.addAttribute("title","部门列表");
model.addAttribute("name",department.getName());
model.addAttribute("pageBean",departmentService.findList(department, pageBean));
return "/admin/department/list";
}/**
* 添加页面
* @return
*/
@RequestMapping("/add")
public String add(){
return "/admin/department/add";
}/**
* 部门添加提交处理
* @param department
* @return
*/
@RequestMapping(value = "https://www.it610.com/add",method = RequestMethod.POST)
@ResponseBody
public Result add(Department department){//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(department);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}if(department.getNote().length() > 50){
return Result.error(CodeMsg.DEPARTMENT_LENGTH_EXIST);
}if(departmentService.isExistName(department.getName(),0l)){
return Result.error(CodeMsg.ADMIN_DEPARTMENT_NAME_EXIST);
}if(departmentService.save(department) == null){
return Result.error(CodeMsg.ADMIN_DEPARTMENT_SAVE_ERROR);
}
operaterLogService.add("添加部门,部门名:" + department.getName());
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("department",departmentService.find(id));
return "/admin/department/edit";
}/**
* 编辑表单提交处理
* @param department
* @return
*/
@RequestMapping(value = "https://www.it610.com/edit",method = RequestMethod.POST)
@ResponseBody
public Result edit(Department department){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(department);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}if(department.getId() == null || department.getId().longValue() <= 0){
return Result.error(CodeMsg.ADMIN_DEPARTMENT_NO_EXIST);
}if(department.getNote().length() > 50){
return Result.error(CodeMsg.DEPARTMENT_LENGTH_EXIST);
}if(departmentService.isExistName(department.getName(),department.getId())){
return Result.error(CodeMsg.ADMIN_DEPARTMENT_NAME_EXIST);
}
//到这说明一切符合条件,进行数据库保存
Department findById = departmentService.find(department.getId());
//讲提交的用户信息指定字段复制到已存在的department对象中,该方法会覆盖新字段内容
BeanUtils.copyProperties(department, findById, "id","createTime","updateTime");
if(departmentService.save(findById) == null){
return Result.error(CodeMsg.ADMIN_DEPARTMENT_EDIT_ERROR);
}operaterLogService.add("编辑部门,部门名:" + department.getName());
return Result.success(true);
}/**
* 根据id删除
* @param id
* @return
*/
@RequestMapping(value = "https://www.it610.com/article/delete",method = RequestMethod.POST)
@ResponseBody
public Result delete(@RequestParam(name="id",required=true)Long id){
try{
departmentService.delete(id);
}catch (Exception e){
return Result.error(CodeMsg.ADMIN_DEPARTMENT_DELETE_ERROR);
}
operaterLogService.add("删除部门,部门ID:" + id);
return Result.success(true);
}
}
后台考核管理:
/**
* 后台考核管理Controller
*/
@Controller
@RequestMapping("/admin/assessment")
public class AssessmentController {@Autowired
private DepartmentService departmentService;
@Autowired
private StaffService staffService;
@Autowired
private PeranceAssmentService peranceAssmentService;
@Autowired
private AssessTargetService assessTargetService;
@Autowired
private AttendanceService attendanceService;
/**
* 分页查询员工列表
* @param model
* @param pageBean
* @param staff
* @return
*/
@RequestMapping("/list")
public String list(Model model, PageBean pageBean, Staff staff){
model.addAttribute("title","考核列表");
Staff loginedStaff = SessionUtil.getLoginedStaff();
model.addAttribute("jobNumber",staff.getJobNumber());
model.addAttribute("pageBean",staffService.findDepartmentList(staff, pageBean,loginedStaff));
return "/admin/assessment/list";
}/**
* 绩效考核页面
* @return
*/
@RequestMapping("/achieve_add")
public String add(@RequestParam("id")Long id,Model model){
Staff staff = staffService.find(id);
Long departmentId = staff.getDepartment().getId();
Department department = departmentService.find(departmentId);
List assessTargets = department.getAssessTargets();
model.addAttribute("staff",staff);
model.addAttribute("assessTargetList",assessTargets);
return "/admin/assessment/add";
}/**
* 绩效考核添加提交处理
* @param performanceAssessment
* @return
*/
@RequestMapping(value = "https://www.it610.com/achieve_add",method = RequestMethod.POST)
@ResponseBody
public Result add(PerformanceAssessment performanceAssessment,@RequestParam("assTarget")String assTarget){
//判断员工是否存在
Staff staff = performanceAssessment.getStaff();
if(staff==null){
return Result.error(CodeMsg.ADMIN_STAFF_NOT_EXIST_ERROR);
}
//年份判断
Integer year = performanceAssessment.getYear();
if(year<=0){
return Result.error(CodeMsg.ADMIN_PERFORMANCE_YEAR_ERROR);
}
//月份判断
Integer month = performanceAssessment.getMonth();
if(month<=0){
return Result.error(CodeMsg.ADMIN_PERFORMANCE_MONTH_ERROR);
}
PerformanceAssessment assessment = peranceAssmentService.findByYearAndMonthAndStaffId(year, month,staff.getId());
if(assessment!=null){
return Result.error(CodeMsg.ADMIN_PERFORMANCE_EXIST_ERROR);
}
JSONArray array = JSONObject.parseArray(assTarget);
double totalScore=0;
double weight=0;
for(int i=0;
i
后台报表管理:
/**
* 后台报表管理Controller
*/
@Controller
@RequestMapping("/admin/report_form")
public class ReportFormController {@Autowired
private DepartmentService departmentService;
@Autowired
private OperaterLogService operaterLogService;
@Autowired
private StaffService staffService;
@Autowired
private SalaryService salaryService;
/**
* 报表页面
* @return
*/
@RequestMapping("/list")
public String list(Model model,@RequestParam(name = "years",defaultValuehttps://www.it610.com/article/= "",required = false)Integer years,@RequestParam(name = "months",defaultValuehttps://www.it610.com/article/= "",required = false)Integer months){
model.addAttribute("title","报表列表");
List
后台用户管理控制器:
/**
* 后台用户管理控制器
*
*/
@RequestMapping("/admin/user")
@Controller
public class UserController { @Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@Autowired
private OperaterLogService operaterLogService;
/**
* 用户列表页面
* @param model
* @param user
* @param pageBean
* @return
*/
@RequestMapping(value="https://www.it610.com/list")
public String list(Model model,User user,PageBean pageBean){
model.addAttribute("title", "用户列表");
model.addAttribute("username", user.getUsername());
model.addAttribute("pageBean", userService.findList(user, pageBean));
return "admin/user/list";
}
/**
* 新增用户页面
* @param model
* @return
*/
@RequestMapping(value="https://www.it610.com/add",method=RequestMethod.GET)
public String add(Model model){
model.addAttribute("roles", roleService.findAll());
return "admin/user/add";
}
/**
* 用户添加表单提交处理
* @param user
* @return
*/
@RequestMapping(value="https://www.it610.com/add",method=RequestMethod.POST)
@ResponseBody
public Result add(User user){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(user);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}
if(user.getRole() == null || user.getRole().getId() == null){
return Result.error(CodeMsg.ADMIN_USER_ROLE_EMPTY);
}
//判断用户名是否存在
if(userService.isExistUsername(user.getUsername(), 0l)){
return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
}
//到这说明一切符合条件,进行数据库新增
if(userService.save(user) == null){
return Result.error(CodeMsg.ADMIN_USE_ADD_ERROR);
}
operaterLogService.add("添加用户,用户名:" + user.getUsername());
return Result.success(true);
}
/**
* 用户编辑页面
* @param model
* @return
*/
@RequestMapping(value="https://www.it610.com/edit",method=RequestMethod.GET)
public String edit(Model model,@RequestParam(name="id",required=true)Long id){
model.addAttribute("roles", roleService.findAll());
model.addAttribute("user", userService.find(id));
return "admin/user/edit";
}
/**
* 编辑用户信息表单提交处理
* @param user
* @return
*/
@RequestMapping(value="https://www.it610.com/edit",method=RequestMethod.POST)
@ResponseBody
public Result edit(User user){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(user);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}
if(user.getRole() == null || user.getRole().getId() == null){
return Result.error(CodeMsg.ADMIN_USER_ROLE_EMPTY);
}
if(user.getId() == null || user.getId().longValue() <= 0){
return Result.error(CodeMsg.ADMIN_USE_NO_EXIST);
}
if(userService.isExistUsername(user.getUsername(), user.getId())){
return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
}
//到这说明一切符合条件,进行数据库保存
User findById = userService.find(user.getId());
//讲提交的用户信息指定字段复制到已存在的user对象中,该方法会覆盖新字段内容
BeanUtils.copyProperties(user, findById, "id","createTime","updateTime");
if(userService.save(findById) == null){
return Result.error(CodeMsg.ADMIN_USE_EDIT_ERROR);
}
operaterLogService.add("编辑用户,用户名:" + user.getUsername());
return Result.success(true);
}
/**
* 删除用户
* @param id
* @return
*/
@RequestMapping(value="https://www.it610.com/delete",method=RequestMethod.POST)
@ResponseBody
public Result delete(@RequestParam(name="id",required=true)Long id){
try {
userService.delete(id);
} catch (Exception e) {
return Result.error(CodeMsg.ADMIN_USE_DELETE_ERROR);
}
operaterLogService.add("删除用户,用户ID:" + id);
return Result.success(true);
}
}
源码获取:博客首页 "资源" 里下载!
推荐阅读
- java|使用Spring连接mysql数据库
- Leetcode|leetcode-蜡烛之间的盘子(经典空换时)
- java|== 和 equals 的区别你知道吗()
- 面试题|操作系统高频面试题
- #|【JavaWeb】Cookie和Session解析
- #|【JavaWeb】文件的上传和下载
- 图解Redis|什么是缓存雪崩、击穿、穿透()
- java|java 蓝桥杯 输出组合_Java蓝桥杯——排列组合
- 蓝桥杯|Java蓝桥杯——杨辉三角