基于javaweb+mysql的ssm+maven企业绩效工资管理系统(java+ssm+html+layui+bootstrap+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM+Maven企业绩效工资管理系统(java+ssm+html+layui+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. 前端:HTML+CSS+JavaScript+LayUI+jquery+bootstrap
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中dbconfig.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ssm_esms 登录 注:tomcat中需配置路径为/ssm_esms,否则会有异常 管理员账号/密码:admin/admin 用户账号/密码:18080833/123456
* @throws Exception
*/
@RequestMapping("/add.do")
@ResponseBody
public int add(String d_name, String d_remark) throws Exception {
Department department = departmentService.findByDname(d_name);
//查找是否同名
if(department != null) {
return department.getdId();
} else {
Department d = new Department();
d.setdId(null);
d.setdName(d_name);
d.setdRemark(d_remark);
d.setdIsdel(1);
departmentService.insertSelective(d);
return 0;
}
}
/**
* 查找一个部门
* @param id
* @return
* @throws Exception
*/
@RequestMapping("/findByPrimaryKey.do")
@ResponseBody
public Department findByPrimaryKey(int id) throws Exception {
Department department = departmentService.selectByPrimaryKey(id);
return department;
}
/**
* 更新部门
* @param id
* @param d_name
* @param d_remark
* @throws Exception
*/
@RequestMapping("/updateByPrimaryKey.do")
@ResponseBody
public int updateByPrimaryKey(int id, String d_name, String d_remark) throws Exception {
/**
* 查找
* @param pageNum
* @param limit
* @param e_account
* @param d_id
* @param attendance_time
* @return
* @throws Exception
*/
@RequestMapping("/findSelective.do")
@ResponseBody
public MonthlyAttendancePages findSelective(
@RequestParam(value="page", defaultValue="1")int pageNum,
@RequestParam(value="limit", defaultValue="5") int limit,
@RequestParam(value="e_account", defaultValue="") String e_account,
@RequestParam(value="d_id", defaultValue="0") int d_id,
@RequestParam(value="attendance_time", defaultValue="") String attendance_time) throws Exception {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("e_account",e_account);
map.put("d_id",d_id);
map.put("attendance_time",attendance_time);
//pageNum:起始页面 pageSize:每页的大小
PageHelper.startPage(pageNum,limit);
//查找条件,一定要紧跟在startPage后
List<MonthlyAttendanceCustomVo> list =
monthlyAttendanceCustomVoMapper.selectMonthlyAttendanceCustomVoMapperByeAccountAnddIdAndTime(map);
// System.out.println(list.get(0).getMonthlyAttendance().getAttendanceTime()+"========================");
PageInfo pageResult = new PageInfo(list);
//设置前台需要的数据
MonthlyAttendancePages monthlyAttendancePages = new MonthlyAttendancePages();
monthlyAttendancePages.setCode(0);
monthlyAttendancePages.setMsg("");
monthlyAttendancePages.setCount((int) pageResult.getTotal());
monthlyAttendancePages.setData(pageResult.getList());
return monthlyAttendancePages;
}
/**
* 查找一个
* @param id
*/
@RequestMapping("/selectVoByPrimaryKey.do")
@ResponseBody
public MonthlyAttendanceCustomVo selectVoByPrimaryKey(int id) {
MonthlyAttendanceCustomVo monthlyAttendanceCustomVo = new MonthlyAttendanceCustomVo();
monthlyAttendanceCustomVo = monthlyAttendanceCustomVoMapper.selectVoByPrimaryKey(id);
// System.out.println(monthlyAttendanceCustomVo+"=======================");
return monthlyAttendanceCustomVo;
}
/**
* 更新
* @param maId
* @param sickLeaveNum
* @param compassionateLeaveNum
* @param overtimeHour
* @param weekendHour
* @param holidayHour
* @param lateNum
* @param earlyNum
* @param absenceNum
* @param businessTravelNum
* @return
* @throws Exception
*/
@RequestMapping("/updateByPrimaryKeySelective.do")
@ResponseBody
public int updateByPrimaryKeySelective(int maId,
int sickLeaveNum,
int compassionateLeaveNum,
double overtimeHour,
double weekendHour,
double holidayHour,
int lateNum,
int earlyNum,
int absenceNum,
int businessTravelNum
) throws Exception {
MonthlyAttendance monthlyAttendance = new MonthlyAttendance();
monthlyAttendance.setMaId(maId);
monthlyAttendance.setSickLeaveNum(sickLeaveNum);
monthlyAttendance.setCompassionateLeaveNum(compassionateLeaveNum);
monthlyAttendance.setOvertimeHour(overtimeHour);
monthlyAttendance.setWeekendHour(weekendHour);
e.printStackTrace();
throw new CustomException("下载失败");
}
}
}
/**
* @Description:
*/
public class LoginInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse, Object o) throws Exception {
// String requestUri = httpServletRequest.getRequestURI();
// String contextPath = httpServletRequest.getContextPath();
// String url = requestUri.substring(contextPath.length());
// System.out.println(url);
// System.out.println(requestUri);
// if ("/".equals(url)){
// return true;
// }
// if ("/employeeLogin.do".equals(url)){
// return true;
// }else{
String string = (String) httpServletRequest.getSession().getAttribute("employeeId");
SystemManager systemManager = (SystemManager) httpServletRequest.getSession().getAttribute("admin");
if (string != null) {
return true;
} else if (string == null){
httpServletResponse.sendRedirect("/");
return false;
} else if (systemManager != null) {
return true;
} else {
httpServletResponse.sendRedirect("/admin.do");
map.put("status","0");
return map;
}
}
@RequestMapping(value = "/loginSuccess.do")
public String loginSucceses(Model model) throws Exception
{
return "employee/index.html";
}
//管理员登录判断
@RequestMapping(value = "/adminLogin.do")
@ResponseBody
public Map<String,String> adminLogin(Model model, HttpSession httpSession, String username,
String password, String identifyingcode)
{
String code = (String) httpSession.getAttribute("identifyingCode");
HashMap<String, String> map = new HashMap<String, String>();
if(identifyingcode.equalsIgnoreCase(code)){
SystemManager manager = null;
try {
manager = loginService.findSystemManagerByIdAndPassword(username, password);
} catch (CustomException e) {
map.put("msg",e.getMessage());
map.put("status","500");
return map;
}
// 保存到session
httpSession.setAttribute("admin",manager);
map.put("url","toPage.do?url=admin/index.html");
map.put("msg","成功");
map.put("status","200");
return map;
}else{
map.put("msg","验证码错误");
map.put("status","0");
return map;
}
}
@RequestMapping(value = "/getAdminAccount.do")
@ResponseBody
public String getAdminAccount(HttpSession httpSession){
SystemManager systemManager = (SystemManager) httpSession.getAttribute("admin");
// SystemManager manager = loginService.findSystemManagerById(id);
return systemManager.getSmAccount();
}
@RequestMapping(value = "/getEmployeeAccount.do")
@ResponseBody
salary3.add(23000.00);
e3.setSalary(salary3);
echMonthSalaryList.add(e1);
echMonthSalaryList.add(e2);
echMonthSalaryList.add(e3);
stringListMap.put("list",echMonthSalaryList);
return stringListMap;*/
return echartsService.getMonthSalary();
}
}
/**
* @Description:
*/
@Controller
public class UserInforController {
@Autowired
private UserInforServiceImpl userInforService = null;
@RequestMapping("changePassword.do")
@ResponseBody
public Map<String, String> changePassword(String oldPassword, String newPassword1,
String newPassword2, HttpSession httpSession){
System.out.println(oldPassword+" "+newPassword1+" "+newPassword2);
HashMap<String, String> map = new HashMap<String, String>();
if (newPassword1.equals(newPassword2)){
SystemManager admin = (SystemManager) httpSession.getAttribute("admin");
String encodeByMD5 = MD5Utils.encodeByMD5(oldPassword);
if (encodeByMD5.equals(admin.getSmPassword())){
/**
* 批量删除
* @param ids
*/
@RequestMapping("/deleteByQuery.do")
public void deleteByQuery (@RequestParam(value = "arr")int[] ids) {
//批量删除,实则修改状态为0
//如果有id才执行
if(ids.length > 0) {
positionService.deleteByQuery(ids);
}
}
}
/**
* @Description:
*/
@Controller
public class RankBonusController {
@Autowired
private IRankBonusService service;
//@Qualifier("rankBonusService")
public void setiRankBonusService(IRankBonusService iRankBonusService) {
this.service = iRankBonusService;
}
return map;
}
else{
map.put("result","只能导入Microsoft Excel 97-2003 工作表 (.xls),请检查文件是否正确");
return map;
}*/
} else {
map.put("result","导入的文件不存在,请重新选择文件");
return map;
}
}
/**
*
* @param excel 补发金额表excel
* @return
*/
@RequestMapping("/importReissue.do")
@ResponseBody
public Map<String,String> importReissueTable(@RequestParam("file") MultipartFile excel) throws Exception{
Map<String,String> map = new HashMap<String, String>();
if (!excel.isEmpty()) {
String result = importDataService.insertReissueTable(excel);
map.put("result",result);
return map;
}
else {
map.put("result","导入的文件不存在,请重新选择文件");
return map;
}
}
}
/**
* @Description:
*/
@Controller
public class UserInforController {
@Autowired
private UserInforServiceImpl userInforService = null;
@RequestMapping("changePassword.do")
@ResponseBody
public Map<String, String> changePassword(String oldPassword, String newPassword1,
String newPassword2, HttpSession httpSession){
System.out.println(oldPassword+" "+newPassword1+" "+newPassword2);
HashMap<String, String> map = new HashMap<String, String>();
if (newPassword1.equals(newPassword2)){
SystemManager admin = (SystemManager) httpSession.getAttribute("admin");
String encodeByMD5 = MD5Utils.encodeByMD5(oldPassword);
if (encodeByMD5.equals(admin.getSmPassword())){
String newPassword = MD5Utils.encodeByMD5(newPassword1);
admin.setSmPassword(newPassword);
userInforService.updateSystemManagePassword(admin.getSmId(),admin);
map.put("status","1");
map.put("msg","密码修改成功");
return map;
}else{
map.put("status","2");
map.put("msg","原密码错误");
return map;
}
}else{
map.put("status","0");
map.put("msg","两次密码不一致");
return map;
}
}
//模糊查询,有多少个条件就接收多少个字段
Department department = new Department();
department.setdName(d_name);
//pageNum:起始页面 pageSize:每页的大小
PageHelper.startPage(pageNum,limit);
//查找条件,一定要紧跟在startPage后
list = departmentService.findSelective(department);
PageInfo pageResult = new PageInfo(list);
//设置前台需要的数据
DepartmentPages departmentPages = new DepartmentPages();
departmentPages.setCode(0);
departmentPages.setMsg("");
departmentPages.setCount((int) pageResult.getTotal());
departmentPages.setData(pageResult.getList());
return departmentPages;
}
/**
* 添加部门
* @param d_name
* @param d_remark
* @return
* @throws Exception
*/
@RequestMapping("/add.do")
@ResponseBody
public int add(String d_name, String d_remark) throws Exception {
Department department = departmentService.findByDname(d_name);
//查找是否同名
if(department != null) {
return department.getdId();
} else {
Department d = new Department();
d.setdId(null);
d.setdName(d_name);
d.setdRemark(d_remark);
rankBonusPages.setCode(0);
rankBonusPages.setMsg("");
rankBonusPages.setCount((int) pageResult.getTotal());
rankBonusPages.setData(pageResult.getList());
return rankBonusPages;
}
//根据id删除数据
@RequestMapping("rankBonusDelete.do")
@ResponseBody
public String doDelete(int id){
if(service.CountByRbid(id)>0){
return "exist";
}
if(service.moveRankBonus(id)==true)
return "ok";
else{
return "no";}
}
//更新记录
@RequestMapping("/updateRankBonus.do")
@ResponseBody
public String doUpdate(int id,String rank,int bonus){
RankBonus rankBonus=service.findByName(rank);
if(rankBonus!=null&& !rankBonus.getRbId().equals(id)){
return "exist";
}
RankBonus rb=new RankBonus();
rb.setRbId(id);
rb.setRbBonus(bonus);
rb.setRankName(rank);
if(service.modifyRankName(rb)==true)
return "ok";
else
return "no";
}
}
}
}
/**
* @Description:
*/
@Controller
public class RankBonusController {
@Autowired
private IRankBonusService service;
//@Qualifier("rankBonusService")
public void setiRankBonusService(IRankBonusService iRankBonusService) {
this.service = iRankBonusService;
}
//插入数据
@RequestMapping("/insertRankBonus.do")
@ResponseBody
public String doInsertRankBonus(int bonus,String name){
if(service.CountByName(name)>0){
return "exist";
}
if(!name.equals("")&& bonus>=0){
RankBonus rb= new RankBonus();
rb.setRankName(name);
rb.setRbBonus(bonus);
service.addRankBonus(rb);
return "ok";
}
}
/*//查询出所有记录
@RequestMapping("/findList.do")
public String doFindList(@RequestParam(value="pn",defaultValue = "1") Integer pn, Model model){
// 引入PageHelper分页插件
// 在查询之前只需要调用,传入页码,以及每页的大小
int pageSize = 10;
PageHelper.startPage(pn, pageSize);
// startPage后面紧跟的这个查询就是一个分页查询
List<WorkingYearsBonus> wyb = service.findAll();
System.out.println(wyb+"=================================");
*//*for (RankBonus rb:rbs) {
System.out.println(rb.getRankName());
}*//*
// 使用pageInfo包装查询后的结果,只需要将pageInfo交给页面就行了。
// 封装了详细的分页信息,包括有我们查询出来的数据,传入连续显示的页数
PageInfo page = new PageInfo(wyb, 5);
//ModelAndView modelAndView = new ModelAndView();
// modelAndView.setViewName("admin/rank-list.jsp");
// modelAndView.addObject("pageInfo",page);
model.addAttribute("pageInfo", page);
model.addAttribute("ttttt","tttttttttt********8");
return "admin/year-list.jsp";
}*/
//根据id删除数据
@RequestMapping("/deleteRecord.do")
@ResponseBody
public String doDelete(int id){
if (service.moveWorkYearBonus(id)==true) {
return "ok";
}
else{
return "no";
}
}
//更新记录
@RequestMapping("/updateRecord.do")
@ResponseBody
@RequestMapping("updateInforEmployee.do")
public @ResponseBody String updateInforEmployee(HttpSession httpSession, Employee employee){
Integer id = (Integer) httpSession.getAttribute("employeeId");
employee.seteId(id);
int i = userInforService.updateEmploueeById(id,employee);
if (i==1){
return "1";
}else {
return "0";
}
}
// @RequestMapping("employeeSalaryList.do")
// @ResponseBody
// public EmployeeSalaryVO employeeSalaryList(@RequestParam(name="year",defaultValue = "1") String year,
// HttpSession httpSession){
// Integer eId = (Integer) httpSession.getAttribute("employeeId");
// List<Salary> salaryList = userInforService.getEmployeeSalaryList(eId, year);
//
// EmployeeSalaryVO employeeSalaryVO = new EmployeeSalaryVO();
// employeeSalaryVO.setCode(0);
// employeeSalaryVO.setMsg("");
// employeeSalaryVO.setCount((int) salaryList.size());
// employeeSalaryVO.setData(salaryList);
// return employeeSalaryVO;
// }
@RequestMapping("employeeSalaryList.do")
@ResponseBody
public EmployeeSalaryVO findSelective(
@RequestParam(value="page", defaultValue="1")int pageNum,
@RequestParam(value="limit", defaultValue="10") int limit,
@RequestParam(value="year", defaultValue="1") String year,
HttpSession httpSession) throws Exception {
Integer eId = (Integer) httpSession.getAttribute("employeeId");
//pageNum:起始页面 pageSize:每页的大小
PageHelper.startPage(pageNum,limit);
//查找条件,一定要紧跟在startPage后
List<Salary> salaryList = userInforService.getEmployeeSalaryList(eId, year);
PageInfo pageResult = new PageInfo(salaryList);
//设置前台需要的数据
EmployeeSalaryVO employeeSalaryVO = new EmployeeSalaryVO();
}
/**
* @Description:
*/
public class LoginInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse, Object o) throws Exception {
// String requestUri = httpServletRequest.getRequestURI();
// String contextPath = httpServletRequest.getContextPath();
// String url = requestUri.substring(contextPath.length());
// System.out.println(url);
// System.out.println(requestUri);
// if ("/".equals(url)){
// return true;
// }
// if ("/employeeLogin.do".equals(url)){
// return true;
// }else{
String string = (String) httpServletRequest.getSession().getAttribute("employeeId");
SystemManager systemManager = (SystemManager) httpServletRequest.getSession().getAttribute("admin");
if (string != null) {
return true;
} else if (string == null){
httpServletResponse.sendRedirect("/");
return false;
} else if (systemManager != null) {
return true;
} else {
httpServletResponse.sendRedirect("/admin.do");
return false;
}
}
@Override
public void postHandle(HttpServletRequest httpServletRequest,
p.setpId(id);
p.setpName(p_name);
p.setpDuty(p_duty);
p.setpPostPay(p_post_pay);
p.setpIsdel(null);
positionService.updateByPrimaryKeySelective(p);
return 0;
}
}
/**
* 根据名称查找
* @param p_name
* @return
*/
@RequestMapping("/findByDname.do")
@ResponseBody
public int findByDname(String p_name) {
Position position = positionService.findByDname(p_name);
if(position != null) {
return position.getpId();
} else {
return 0;
}
}
/**
* 删除一个
* @param id
* @throws Exception
*/
@RequestMapping("/deleteByPrimaryKey.do")
@ResponseBody
public int deleteByPrimaryKey(int id) throws Exception {
//删除部门,调用更新操作,将状态改为0
Position position = new Position();
position.setpId(id);
positionService.deleteByPrimaryKey(id);
return 1;
}
monthlyAttendance.setWeekendHour(weekendHour);
monthlyAttendance.setHolidayHour(holidayHour);
monthlyAttendance.setLateNum(lateNum);
monthlyAttendance.setEarlyNum(earlyNum);
monthlyAttendance.setAbsenceNum(absenceNum);
monthlyAttendance.setBusinessTravelNum(businessTravelNum);
// System.out.println(monthlyAttendance+"======================================================");
monthlyAttendanceService.updateByPrimaryKeySelective(monthlyAttendance);
return 1;
}
/**
* 删除
* @param id
* @throws Exception
*/
@RequestMapping("/deleteByPrimaryKey.do")
@ResponseBody
public int deleteByPrimaryKey(int id) throws Exception {
//真删除
MonthlyAttendance monthlyAttendance = new MonthlyAttendance();
monthlyAttendance.setMaId(id);
monthlyAttendanceService.deleteByPrimaryKey(id);
return 1;
}
/**
* 批量删除
* @param ids
*/
@RequestMapping("/deleteByQuery.do")
@ResponseBody
public int deleteByQuery (@RequestParam(value = "arr")int[] ids) {
// for (int i =0 ; i< ids.length;i++) {
// System.out.println(ids[i]);
// }
//真删除
//如果有id才执行
if(ids.length > 0) {
monthlyAttendanceService.deleteByQuery(ids);
}
return 1;
}
@RequestMapping("/findEmployeeAttendance.do")
monthlyAttendance.setLateNum(lateNum);
monthlyAttendance.setEarlyNum(earlyNum);
monthlyAttendance.setAbsenceNum(absenceNum);
monthlyAttendance.setBusinessTravelNum(businessTravelNum);
// System.out.println(monthlyAttendance+"======================================================");
monthlyAttendanceService.updateByPrimaryKeySelective(monthlyAttendance);
return 1;
}
/**
* 删除
* @param id
* @throws Exception
*/
@RequestMapping("/deleteByPrimaryKey.do")
@ResponseBody
public int deleteByPrimaryKey(int id) throws Exception {
//真删除
MonthlyAttendance monthlyAttendance = new MonthlyAttendance();
monthlyAttendance.setMaId(id);
monthlyAttendanceService.deleteByPrimaryKey(id);
return 1;
}
/**
* 批量删除
* @param ids
*/
@RequestMapping("/deleteByQuery.do")
@ResponseBody
public int deleteByQuery (@RequestParam(value = "arr")int[] ids) {
// for (int i =0 ; i< ids.length;i++) {
// System.out.println(ids[i]);
// }
//真删除
//如果有id才执行
if(ids.length > 0) {
monthlyAttendanceService.deleteByQuery(ids);
}
return 1;
}
@RequestMapping("/findEmployeeAttendance.do")
@ResponseBody
public EmployeeMonthlyAttendancePages findEmployeeAttendance(
@RequestParam(value="page", defaultValue="1")int pageNum,
@RequestParam(value="limit", defaultValue="5") int limit,
@RequestParam(value="attendance_time", defaultValue="") String attendance_time,
HttpSession httpSession) throws Exception {