基于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
map.put("msg", "");
map.put("data", map2);
return map;
}
}
public final class CaptchaUtil
{
private CaptchaUtil(){}
/*
* 随机字符字典
*/
private static final char[] CHARS = { '2', '3', '4', '5', '6', '7', '8',
'9' };
/*
* 随机数
*/
private static Random random = new Random();
/*
* 获取4位随机数
*/
private static String getRandomString()
{
StringBuffer buffer = new StringBuffer();
for(int i = 0; i < 4; i++)
{
buffer.append(CHARS[random.nextInt(CHARS.length)]);
}
return buffer.toString();
}
/*
* 获取随机数颜色
*/
private static Color getRandomColor()
{
return new Color(random.nextInt(255),random.nextInt(255),
random.nextInt(255));
}
file.transferTo(files);
}
} catch (Exception e) {
} finally {
try {
if (out != null) {
out.close();
}
if (fileInput != null) {
fileInput.close();
}
} catch (IOException e) {
}
}
Map<String, Object> map2 = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<String, Object>();
// 返回上传后的图片地址 img/head/……jpg
map2.put("src", "/ssm_esms/img/head/" + dateStr + index + "." + prefix);
map.put("code", 0);
map.put("msg", "");
map.put("data", map2);
return map;
}
}
public final class CaptchaUtil
{
private CaptchaUtil(){}
* @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 {
Integer id = (Integer) httpSession.getAttribute("employeeId");
//pageNum:起始页面 pageSize:每页的大小
PageHelper.startPage(pageNum,limit);
//查找条件,一定要紧跟在startPage后
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("e_id",id);
map.put("attendance_time",attendance_time);
List<MonthlyAttendance> list = monthlyAttendanceMapper.selectMonthlyAttendanceMapperByeEidAndTime(map);
PageInfo pageResult = new PageInfo(list);
//设置前台需要的数据
EmployeeMonthlyAttendancePages employeeMonthlyAttendancePages = new EmployeeMonthlyAttendancePages();
employeeMonthlyAttendancePages.setCode(0);
employeeMonthlyAttendancePages.setMsg("");
employeeMonthlyAttendancePages.setCount((int) pageResult.getTotal());
employeeMonthlyAttendancePages.setData(pageResult.getList());
return employeeMonthlyAttendancePages;
}
}
* @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 {
Integer id = (Integer) httpSession.getAttribute("employeeId");
//pageNum:起始页面 pageSize:每页的大小
PageHelper.startPage(pageNum,limit);
//查找条件,一定要紧跟在startPage后
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("e_id",id);
map.put("attendance_time",attendance_time);
List<MonthlyAttendance> list = monthlyAttendanceMapper.selectMonthlyAttendanceMapperByeEidAndTime(map);
PageInfo pageResult = new PageInfo(list);
//设置前台需要的数据
EmployeeMonthlyAttendancePages employeeMonthlyAttendancePages = new EmployeeMonthlyAttendancePages();
employeeMonthlyAttendancePages.setCode(0);
employeeMonthlyAttendancePages.setMsg("");
employeeMonthlyAttendancePages.setCount((int) pageResult.getTotal());
employeeMonthlyAttendancePages.setData(pageResult.getList());
return employeeMonthlyAttendancePages;
return "no";
}
}
/**
* @Description:
*/
@Controller
public class WorkYearController {
@Autowired
private IWorkYearService service;
/*查询所有数据*/
@RequestMapping("/findWorkingYearBonusList.do")
@ResponseBody
public WokingYearsBonusPages findAll(
@RequestParam(value="page", defaultValue="1")int pageNum,
@RequestParam(value="limit", defaultValue="5") int limit,
@RequestParam(value="year", defaultValue="0") int year) throws Exception {
List<WorkingYearsBonus> list;
//模糊查询,有多少个条件就接收多少个字段
WorkingYearsBonus wyb = new WorkingYearsBonus();
wyb.setWybYear(year);
//pageNum:起始页面 pageSize:每页的大小
PageHelper.startPage(pageNum,limit);
//查找条件,一定要紧跟在startPage后
list = service.findSelective(wyb);
PageInfo pageResult = new PageInfo(list);
//设置前台需要的数据
WokingYearsBonusPages wybp = new WokingYearsBonusPages();
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
public Map<String,String> getEmployeeAccount(HttpSession httpSession){
Integer id = (Integer) httpSession.getAttribute("employeeId");
Employee employee = loginService.findEmployeeById(id);
HashMap<String, String> map = new HashMap<String, String>();
map.put("account",employee.geteAccount());
map.put("name",employee.geteName());
return map;
}
@RequestMapping(value = "/logout.do")
public String logout(HttpSession httpSession){
httpSession.removeAttribute("employeeId");
return "redirect:/";
}
@RequestMapping(value = "/logoutAdmin.do")
public String logoutAdmin(HttpSession httpSession){
httpSession.removeAttribute("admin");
return "redirect:/admin.do";
}
}
EchMonthSalary e3 = new EchMonthSalary();
List<Double> salary3 = new ArrayList<Double>();
salary3.add(6000.00);
salary3.add(8800.00);
salary3.add(23000.00);
salary3.add(6000.00);
salary3.add(8800.00);
salary3.add(23000.00);
salary3.add(6000.00);
salary3.add(8800.00);
salary3.add(23000.00);
salary3.add(6000.00);
salary3.add(8800.00);
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 ImportDataController {
@Autowired
private IImportDataService importDataService;
/**
* 跳转到importAttendanceTeable.jsp
* @return
*/
@RequestMapping("toImportAttendance.do")
public String toImportAttendance(){
return "admin/importData/importAttendanceTable.jsp";
}
/**
* 跳转到importReissueTable.jsp
* @return
*/
@RequestMapping("toImportReissue.do")
public String toImportReissue(){
return "admin/importData/importReissueTable.jsp";
}
/**
*上传月出勤表
@RequestParam(value="limit", defaultValue="5") int limit,
@RequestParam(value="attendance_time", defaultValue="") String attendance_time,
HttpSession httpSession) throws Exception {
Integer id = (Integer) httpSession.getAttribute("employeeId");
//pageNum:起始页面 pageSize:每页的大小
PageHelper.startPage(pageNum,limit);
//查找条件,一定要紧跟在startPage后
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("e_id",id);
map.put("attendance_time",attendance_time);
List<MonthlyAttendance> list = monthlyAttendanceMapper.selectMonthlyAttendanceMapperByeEidAndTime(map);
PageInfo pageResult = new PageInfo(list);
//设置前台需要的数据
EmployeeMonthlyAttendancePages employeeMonthlyAttendancePages = new EmployeeMonthlyAttendancePages();
employeeMonthlyAttendancePages.setCode(0);
employeeMonthlyAttendancePages.setMsg("");
employeeMonthlyAttendancePages.setCount((int) pageResult.getTotal());
employeeMonthlyAttendancePages.setData(pageResult.getList());
return employeeMonthlyAttendancePages;
}
}
@Autowired
private IImportDataService importDataService;
/**
* 跳转到importAttendanceTeable.jsp
* @return
*/
@RequestMapping("toImportAttendance.do")
public String toImportAttendance(){
return "admin/importData/importAttendanceTable.jsp";
}
/**
* 跳转到importReissueTable.jsp
* @return
*/
@RequestMapping("toImportReissue.do")
public String toImportReissue(){
return "admin/importData/importReissueTable.jsp";
}
/**
*上传月出勤表
* @param excel 考勤表文件
* @return
*/
@RequestMapping("/importAttendance.do")
@ResponseBody
public Map<String,String> importAttendanceTable(@RequestParam("file") MultipartFile excel) throws Exception{
Map<String,String> map = new HashMap<String, String>();
if (!excel.isEmpty()) {
String result = importDataService.insertMATable(excel);
map.put("result",result);
return map;
/*if (importDataService.insertMATable(excel)) {
//return "admin/importData/success.jsp";
map.put("result","导入成功");
return map;
}
else{
map.put("result","只能导入Microsoft Excel 97-2003 工作表 (.xls),请检查文件是否正确");
return map;
}*/
else
return "no";
}
}
/**
* @Description:
*/
@Controller
public class WorkYearController {
@Autowired
private IWorkYearService service;
/*查询所有数据*/
@RequestMapping("/findWorkingYearBonusList.do")
@ResponseBody
public WokingYearsBonusPages findAll(
@RequestParam(value="page", defaultValue="1")int pageNum,
@RequestParam(value="limit", defaultValue="5") int limit,
@RequestParam(value="year", defaultValue="0") int year) throws Exception {
List<WorkingYearsBonus> list;
//模糊查询,有多少个条件就接收多少个字段
WorkingYearsBonus wyb = new WorkingYearsBonus();
wyb.setWybYear(year);
//pageNum:起始页面 pageSize:每页的大小
PageHelper.startPage(pageNum,limit);
//查找条件,一定要紧跟在startPage后
list = service.findSelective(wyb);
PageInfo pageResult = new PageInfo(list);
public class UploadPhotoController {
@RequestMapping("uploadPhoto.do")
@ResponseBody
public Object updateHeadPhoto(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws Exception {
// 文件后缀
String prefix = "";
// 时间前缀
String dateStr = "";
//保存上传
OutputStream out = null;
InputStream fileInput = null;
// 随机数前缀
double index = 1000 * (Math.random());
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
if (file != null) {
String originalName = file.getOriginalFilename();
prefix = originalName.substring(originalName.lastIndexOf(".") + 1);
dateStr = format.format(new Date());
String filepath = request.getServletContext().getRealPath("/img/head/") + dateStr + index + "." + prefix;
filepath = filepath.replace("\\", "/");
File files = new File(filepath);
//打印查看上传路径
System.out.println(filepath);
if (!files.getParentFile().exists()) {
files.getParentFile().mkdirs();
}
file.transferTo(files);
}
} catch (Exception e) {
} finally {
try {
if (out != null) {
out.close();
}
if (fileInput != null) {
fileInput.close();
}
} catch (IOException e) {
}
}
Map<String, Object> map2 = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<String, Object>();
/**
* @Description:
*/
@Controller
@RequestMapping("/employee")
public class EmployeeController {
@Autowired
private EmployeeService employeeService;
@Autowired
private EmployeeCustomVoMapper employeeCustomVoMapper = null;
@RequestMapping("/findSelective.do")
@ResponseBody
public EmployeePages 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="e_name", defaultValue="") String e_name,
@RequestParam(value="d_id", defaultValue="0") int d_id) throws Exception {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("e_account",e_account);
map.put("e_name",e_name);
map.put("d_id",d_id);
//pageNum:起始页面 pageSize:每页的大小
PageHelper.startPage(pageNum,limit);
//查找条件,一定要紧跟在startPage后
List<EmployeeCustomVo> list =
employeeCustomVoMapper.selectEmployeeSelective(map);
// System.out.println(list.get(0).getMonthlyAttendance().getAttendanceTime()+"========================");
PageInfo pageResult = new PageInfo(list);
//设置前台需要的数据
EmployeePages employeePages = new EmployeePages();
employeePages.setCode(0);
employeePages.setMsg("");
employeePages.setCount((int) pageResult.getTotal());
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);
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]);
@RequestMapping("/updateByPrimaryKeySelective.do")
@ResponseBody
public int updateByPrimaryKeySelective(
int eId,
String eName,
String eIdcard,
int rbId,
String eSex,
String eBirthday,
String eDagree,
int dId,
int pId,
String eEntryTime,
double eBasePay,
String ePhone,
String eEmail,
String eUrgentPerson,
String eUrgentPhone,
String eHometown,
String headPath) throws Exception {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Employee employee = new Employee();
employee.seteId(eId);
employee.seteName(eName);
employee.seteIdcard(eIdcard);
employee.seteRank(rbId);
employee.seteSex(eSex);
employee.seteBirthday(format.parse(eBirthday));
employee.seteDagree(eDagree);
employee.setdId(dId);
employee.setpId(pId);
employee.seteEntryTime(format.parse(eEntryTime));
employee.seteBasePay(eBasePay);
employee.setePhone(ePhone);
employee.seteEmail(eEmail);
employee.seteUrgentPerson(eUrgentPerson);
employee.seteUrgentPhone(eUrgentPhone);
employee.seteHometown(eHometown);
employee.seteHeadPath(headPath);
}
/**
* 更新
* @param id
* @param p_name
* @param p_duty
* @param p_post_pay
* @throws Exception
*/
@RequestMapping("/updateByPrimaryKey.do")
@ResponseBody
public int updateByPrimaryKey(int id, String p_name, String p_duty, Double p_post_pay) throws Exception {
Position position = positionService.findByDname(p_name);
System.out.println(p_name);
System.out.println(position);
System.out.println(position != null && !position.getpName().equals(p_name));
//有同名的且不是同一个
if(position != null && !position.getpId().equals(id) ) {
return position.getpId();
} else {
Position p = new Position();
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;
}
}
/**
* 删除一个
PageInfo pageResult = new PageInfo(salaryList);
//设置前台需要的数据
EmployeeSalaryVO employeeSalaryVO = new EmployeeSalaryVO();
employeeSalaryVO.setCode(0);
employeeSalaryVO.setMsg("");
employeeSalaryVO.setCount((int) pageResult.getTotal());
employeeSalaryVO.setData(pageResult.getList());
return employeeSalaryVO;
}
}
/**
* @Description: 管理员和员工登陆控制
**/
@Controller
public class LoginController {
@Autowired
private LoginServiceImpl loginService = null;
* 查找一个部门
* @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 {
Department department = departmentService.findByDname(d_name);
//有同名的且不是同一个
if(department != null && !department.getdId().equals(id) ) {
return department.getdId();
} else {
Department d = new Department();
d.setdId(id);
d.setdName(d_name);
d.setdRemark(d_remark);
d.setdIsdel(null);
departmentService.updateByPrimaryKeySelective(d);
return 0;
}
}
@RequestMapping("/findByDname.do")
@ResponseBody
public int findByDname(String d_name) {
Department department = departmentService.findByDname(d_name);
if(department != null) {
return department.getdId();
} else {