赞
踩
基于javaweb+mysql的ssm员工管理系统员工考勤薪资管理(java+ssm+html+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM员工管理系统员工考勤薪资管理(java+ssm+html+mysql)
登录:
admin 123456
@GetMapping(value = "deleteDuty.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> deleteDuty(String id) { Map<String, Object> map = new HashMap<String, Object>(); int num = this.dutyService.deleteDuty(id); if (num > 0) { map.put("success", true); map.put("code", num); map.put("message", "删除成功"); } else { map.put("success", false); map.put("code", num); map.put("message", "删除失败"); } return map; } // 按主键批量删除职务 @PostMapping(value = "deleteDutyByIds.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> deleteDutyByIds(@RequestBody String[] ids) { int num = 0; for (String dutyid : ids) { num += this.dutyService.deleteDuty(dutyid); } Map<String, Object> map = new HashMap<String, Object>(); if (num > 0) { map.put("success", true); map.put("code", num); map.put("message", "删除成功"); } else { map.put("success", false); map.put("code", num); map.put("message", "删除失败"); } return map; } // 修改职务 @PostMapping(value = "updateDuty.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> updateDuty(@RequestBody String jsonStr) { JSONObject obj = JSONObject.parseObject(jsonStr); // 将JSON字符串转换成object Duty duty = this.dutyService.getDutyById(obj.getString("dutyid")); // 获取object中dutyid字段 duty.setDutyname(obj.getString("dutyname")); // 为职务名称赋值 duty.setAddtime(obj.getString("addtime")); // 为创建日期赋值
String path = this.getRequest().getSession().getServletContext().getRealPath("/") + "upfiles/"; String imageFileName = file.getOriginalFilename(); int i = imageFileName.lastIndexOf("."); String name = String.valueOf(VeDate.getStringDatex()); String type = imageFileName.substring(i + 1); imageFileName = name + "." + type; File targetFile = new File(path, imageFileName); if (!targetFile.exists()) { targetFile.mkdirs(); } Map<String, Object> map = new HashMap<String, Object>(); try { file.transferTo(targetFile); map.put("success", true); map.put("url", imageFileName); map.put("message", "上传成功"); } catch (Exception e) { map.put("success", false); map.put("message", "上传失败"); } return map; } }
return map; } // 按主键查询员工培训数据 @GetMapping(value = "getTrainsById.action") @ResponseBody // 将java对象转为json格式的数据返回 public Trains getTrainsById(String id) { Trains trains = this.trainsService.getTrainsById(id); return trains; } } @RestController // 定义为控制器 返回JSON类型数据 @RequestMapping(value = "/attend", produces = "application/json; charset=utf-8") // 设置请求路径 @CrossOrigin // 允许跨域访问其资源 public class AttendController extends BaseController { @Autowired // @Autowired的作用是自动注入依赖的ServiceBean private AttendService attendService; // 预处理 获取基础参数 @GetMapping(value = "createAttend.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> createAttend() { Map<String, Object> map = new HashMap<String, Object>(); map.put("today", VeDate.getStringDateShort()); return map; } // 新增员工考勤
@RestController // 定义为控制器 返回JSON类型数据 @RequestMapping(value = "/attend", produces = "application/json; charset=utf-8") // 设置请求路径 @CrossOrigin // 允许跨域访问其资源 public class AttendController extends BaseController { @Autowired // @Autowired的作用是自动注入依赖的ServiceBean private AttendService attendService; // 预处理 获取基础参数 @GetMapping(value = "createAttend.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> createAttend() { Map<String, Object> map = new HashMap<String, Object>(); map.put("today", VeDate.getStringDateShort()); return map; } // 新增员工考勤 @PostMapping(value = "insertAttend.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> insertAttend(@RequestBody String jsonStr) { Map<String, Object> map = new HashMap<String, Object>(); JSONObject obj = JSONObject.parseObject(jsonStr); // 将JSON字符串转换成object Attend attend = new Attend(); attend.setEmployid(obj.getString("employid")); // 为员工赋值 attend.setWork(obj.getString("work")); // 为考勤状态赋值 attend.setAddtime(VeDate.getStringDateShort()); // 为日期赋值 attend.setMemo(obj.getString("memo")); // 为备注赋值 int num = this.attendService.insertAttend(attend);
@ResponseBody // 将java对象转为json格式的数据 public Map<String, Object> exit() { Map<String, Object> map = new HashMap<String, Object>(); map.put("success", true); return map; } } @Controller //定义为控制器 @RequestMapping(value = "/ajaxupload", produces = "application/json; charset=utf-8")// 设置路径 @CrossOrigin // 允许从不同的域访问其资源 public class AjaxUploadController extends BaseController { @PostMapping("upload.action") @ResponseBody public Map<String, Object> upload(@RequestParam(value = "image", required = false) MultipartFile file) { String path = this.getRequest().getSession().getServletContext().getRealPath("/") + "upfiles/"; String imageFileName = file.getOriginalFilename(); int i = imageFileName.lastIndexOf("."); String name = String.valueOf(VeDate.getStringDatex()); String type = imageFileName.substring(i + 1); imageFileName = name + "." + type; File targetFile = new File(path, imageFileName); if (!targetFile.exists()) { targetFile.mkdirs(); } Map<String, Object> map = new HashMap<String, Object>(); try { file.transferTo(targetFile); map.put("success", true); map.put("url", imageFileName); map.put("message", "上传成功"); } catch (Exception e) {
g.setColor(getRandColor(110, 133)); // 绘制干扰线 for (int i = 0; i <= lineSize; i++) { drowLine(g); } // 绘制随机字符 String randomString = ""; for (int i = 1; i <= stringNum; i++) { randomString = drowString(g, randomString, i); } // 将生成的随机字符串保存到session中,而jsp界面通过session.getAttribute("RANDOMCODEKEY"), // 获得生成的验证码,然后跟用户输入的进行比较 session.removeAttribute(RANDOMCODEKEY); session.setAttribute(RANDOMCODEKEY, randomString); g.dispose(); try { // 将内存中的图片通过流动形式输出到客户端 ImageIO.write(image, "JPEG", response.getOutputStream()); } catch (Exception e) { e.printStackTrace(); } } /* * 绘制字符串 */ private String drowString(Graphics g, String randomString, int i) { g.setFont(getFont()); g.setColor(new Color(random.nextInt(101), random.nextInt(111), random.nextInt(121))); String rand = String.valueOf(getRandomString(random.nextInt(randString.length()))); randomString += rand; g.translate(random.nextInt(3), random.nextInt(3)); g.drawString(rand, 13 * i, 16); return randomString; } /* * 绘制干扰线 */ private void drowLine(Graphics g) { int x = random.nextInt(width); int y = random.nextInt(height); int xl = random.nextInt(13); int yl = random.nextInt(15); g.drawLine(x, y, x + xl, y + yl); } /* * 获取随机的字符 */ public String getRandomString(int num) { return String.valueOf(randString.charAt(num));
int num = this.rewardsService.updateRewards(rewards); if (num > 0) { map.put("success", true); map.put("code", num); map.put("message", "修改成功"); } else { map.put("success", false); map.put("code", num); map.put("message", "修改失败"); } return map; } // 查询全部员工奖惩数据 在下拉菜单中显示 @GetMapping(value = "getAllRewards.action") @ResponseBody // 将java对象转为json格式的数据返回 public List<Rewards> getAllRewards() { return this.rewardsService.getAllRewards(); } // 通过AJAX在表格中显示员工奖惩数据 @GetMapping(value = "getRewardsByPage.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> getRewardsByPage(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit) { // 定义一个Map对象 用来返回数据 Map<String, Object> map = new HashMap<String, Object>(); Page<Rewards> pager = com.github.pagehelper.PageHelper.startPage(page, limit);// 定义当前页和分页条数 List<Rewards> list = this.rewardsService.getAllRewards(); // 返回的map中定义数据格式 map.put("count", pager.getTotal()); map.put("total", list.size()); map.put("data", list); map.put("code", 0); map.put("msg", ""); map.put("page", page); map.put("limit", limit); return map; } // 按主键查询员工奖惩数据 @GetMapping(value = "getRewardsById.action") @ResponseBody // 将java对象转为json格式的数据返回 public Rewards getRewardsById(String id) { Rewards rewards = this.rewardsService.getRewardsById(id); return rewards; } }
@Controller //定义为控制器 @RequestMapping(value = "/ajaxupload", produces = "application/json; charset=utf-8")// 设置路径 @CrossOrigin // 允许从不同的域访问其资源 public class AjaxUploadController extends BaseController { @PostMapping("upload.action") @ResponseBody public Map<String, Object> upload(@RequestParam(value = "image", required = false) MultipartFile file) { String path = this.getRequest().getSession().getServletContext().getRealPath("/") + "upfiles/"; String imageFileName = file.getOriginalFilename(); int i = imageFileName.lastIndexOf("."); String name = String.valueOf(VeDate.getStringDatex()); String type = imageFileName.substring(i + 1); imageFileName = name + "." + type; File targetFile = new File(path, imageFileName); if (!targetFile.exists()) { targetFile.mkdirs(); } Map<String, Object> map = new HashMap<String, Object>(); try { file.transferTo(targetFile); map.put("success", true); map.put("url", imageFileName); map.put("message", "上传成功"); } catch (Exception e) { map.put("success", false); map.put("message", "上传失败"); } return map; } }
public Map<String, Object> deleteAdmin(String id) { Map<String, Object> map = new HashMap<String, Object>(); int num = this.adminService.deleteAdmin(id); if (num > 0) { map.put("success", true); map.put("code", num); map.put("message", "删除成功"); } else { map.put("success", false); map.put("code", num); map.put("message", "删除失败"); } return map; } // 按主键批量删除管理员 @PostMapping(value = "deleteAdminByIds.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> deleteAdminByIds(@RequestBody String[] ids) { int num = 0; for (String adminid : ids) { num += this.adminService.deleteAdmin(adminid); } Map<String, Object> map = new HashMap<String, Object>(); if (num > 0) { map.put("success", true); map.put("code", num); map.put("message", "删除成功"); } else { map.put("success", false); map.put("code", num); map.put("message", "删除失败"); } return map; } // 修改管理员 @PostMapping(value = "updateAdmin.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> updateAdmin(@RequestBody String jsonStr) { JSONObject obj = JSONObject.parseObject(jsonStr); // 将JSON字符串转换成object Admin admin = this.adminService.getAdminById(obj.getString("adminid")); // 获取object中adminid字段 admin.setUsername(obj.getString("username")); // 为用户名赋值 admin.setRealname(obj.getString("realname")); // 为姓名赋值 admin.setContact(obj.getString("contact")); // 为联系方式赋值 Map<String, Object> map = new HashMap<String, Object>();
map.put("message", "删除成功"); } else { map.put("success", false); map.put("code", num); map.put("message", "删除失败"); } return map; } // 修改管理员 @PostMapping(value = "updateAdmin.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> updateAdmin(@RequestBody String jsonStr) { JSONObject obj = JSONObject.parseObject(jsonStr); // 将JSON字符串转换成object Admin admin = this.adminService.getAdminById(obj.getString("adminid")); // 获取object中adminid字段 admin.setUsername(obj.getString("username")); // 为用户名赋值 admin.setRealname(obj.getString("realname")); // 为姓名赋值 admin.setContact(obj.getString("contact")); // 为联系方式赋值 Map<String, Object> map = new HashMap<String, Object>(); int num = this.adminService.updateAdmin(admin); if (num > 0) { map.put("success", true); map.put("code", num); map.put("message", "修改成功"); } else { map.put("success", false); map.put("code", num); map.put("message", "修改失败"); } return map; } // 查询全部管理员数据 在下拉菜单中显示 @GetMapping(value = "getAllAdmin.action") @ResponseBody // 将java对象转为json格式的数据返回 public List<Admin> getAllAdmin() { return this.adminService.getAllAdmin(); } // 通过AJAX在表格中显示管理员数据 @GetMapping(value = "getAdminByPage.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> getAdminByPage(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit) { // 定义一个Map对象 用来返回数据 Map<String, Object> map = new HashMap<String, Object>(); Page<Admin> pager = com.github.pagehelper.PageHelper.startPage(page, limit);// 定义当前页和分页条数
// 按主键删除一个管理员 @GetMapping(value = "deleteAdmin.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> deleteAdmin(String id) { Map<String, Object> map = new HashMap<String, Object>(); int num = this.adminService.deleteAdmin(id); if (num > 0) { map.put("success", true); map.put("code", num); map.put("message", "删除成功"); } else { map.put("success", false); map.put("code", num); map.put("message", "删除失败"); } return map; } // 按主键批量删除管理员 @PostMapping(value = "deleteAdminByIds.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> deleteAdminByIds(@RequestBody String[] ids) { int num = 0; for (String adminid : ids) { num += this.adminService.deleteAdmin(adminid); } Map<String, Object> map = new HashMap<String, Object>(); if (num > 0) { map.put("success", true); map.put("code", num); map.put("message", "删除成功"); } else { map.put("success", false); map.put("code", num); map.put("message", "删除失败"); } return map; } // 修改管理员 @PostMapping(value = "updateAdmin.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> updateAdmin(@RequestBody String jsonStr) { JSONObject obj = JSONObject.parseObject(jsonStr); // 将JSON字符串转换成object Admin admin = this.adminService.getAdminById(obj.getString("adminid")); // 获取object中adminid字段 admin.setUsername(obj.getString("username")); // 为用户名赋值 admin.setRealname(obj.getString("realname")); // 为姓名赋值 admin.setContact(obj.getString("contact")); // 为联系方式赋值 Map<String, Object> map = new HashMap<String, Object>(); int num = this.adminService.updateAdmin(admin); if (num > 0) { map.put("success", true);
return new Font("Fixedsys", Font.CENTER_BASELINE, 18); } /* * 获得颜色 */ private Color getRandColor(int fc, int bc) { if (fc > 255) fc = 255; if (bc > 255) bc = 255; int r = fc + random.nextInt(bc - fc - 16); int g = fc + random.nextInt(bc - fc - 14); int b = fc + random.nextInt(bc - fc - 18); return new Color(r, g, b); } /** * 生成随机图片 */ public void getRandcode(HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(); // BufferedImage类是具有缓冲区的Image类,Image类是用于描述图像信息的类 BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR); Graphics g = image.getGraphics();// 产生Image对象的Graphics对象,改对象可以在图像上进行各种绘制操作 g.fillRect(0, 0, width, height); g.setFont(new Font("Times New Roman", Font.ROMAN_BASELINE, 18)); g.setColor(getRandColor(110, 133)); // 绘制干扰线 for (int i = 0; i <= lineSize; i++) { drowLine(g); } // 绘制随机字符 String randomString = ""; for (int i = 1; i <= stringNum; i++) { randomString = drowString(g, randomString, i); } // 将生成的随机字符串保存到session中,而jsp界面通过session.getAttribute("RANDOMCODEKEY"), // 获得生成的验证码,然后跟用户输入的进行比较 session.removeAttribute(RANDOMCODEKEY); session.setAttribute(RANDOMCODEKEY, randomString); g.dispose(); try { // 将内存中的图片通过流动形式输出到客户端 ImageIO.write(image, "JPEG", response.getOutputStream()); } catch (Exception e) { e.printStackTrace();
// 预处理 获取基础参数 @GetMapping(value = "createEmploy.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> createEmploy() { Map<String, Object> map = new HashMap<String, Object>(); map.put("eno", "E" + VeDate.getStringDatex()); return map; } // 新增员工 @PostMapping(value = "insertEmploy.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> insertEmploy(@RequestBody String jsonStr) { Map<String, Object> map = new HashMap<String, Object>(); JSONObject obj = JSONObject.parseObject(jsonStr); // 将JSON字符串转换成object Employ employ = new Employ(); employ.setEno(obj.getString("eno")); // 为员工号赋值 employ.setRealname(obj.getString("realname")); // 为姓名赋值 employ.setSex(obj.getString("sex")); // 为性别赋值 employ.setDeptid(obj.getString("deptid")); // 为部门赋值 employ.setDutyid(obj.getString("dutyid")); // 为职务赋值 employ.setXueli(obj.getString("xueli")); // 为学历赋值 employ.setGraduate(obj.getString("graduate")); // 为毕业院校赋值 employ.setWorkdate(obj.getString("workdate")); // 为入职日期赋值 employ.setMemo(obj.getString("memo")); // 为备注赋值 int num = this.employService.insertEmploy(employ); if (num > 0) { map.put("success", true); map.put("code", num); map.put("message", "保存成功"); } else { map.put("success", false); map.put("code", num); map.put("message", "保存失败"); } return map; } // 按主键删除一个员工 @GetMapping(value = "deleteEmploy.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> deleteEmploy(String id) { Map<String, Object> map = new HashMap<String, Object>(); int num = this.employService.deleteEmploy(id); if (num > 0) { map.put("success", true); map.put("code", num); map.put("message", "删除成功"); } else { map.put("success", false); map.put("code", num);
@RestController // 定义为控制器 返回JSON类型数据 @RequestMapping(value = "/login", produces = "application/json; charset=utf-8") // 设置路径 @CrossOrigin // 允许从不同的域访问其资源 public class LoginController extends BaseController { // @Autowired的作用是自动注入依赖的ServiceBean @Autowired private AdminService adminService; // 管理员登录 @PostMapping(value = "login.action") @ResponseBody // 将java对象转为json格式的数据 public Map<String, Object> login(@RequestBody String jsonStr) { Map<String, Object> map = new HashMap<String, Object>(); JSONObject obj = JSONObject.parseObject(jsonStr); String username = obj.getString("username"); String password = obj.getString("password"); Admin adminEntity = new Admin(); adminEntity.setUsername(username); List<Admin> adminlist = this.adminService.getAdminByCond(adminEntity); if (adminlist.size() == 0) { map.put("success", false); map.put("message", "用户名不存在"); } else { Admin admin = adminlist.get(0); if (password.equals(admin.getPassword())) { map.put("success", true); map.put("message", "登录成功"); map.put("adminid", admin.getAdminid()); map.put("adminname", admin.getUsername()); map.put("realname", admin.getRealname()); map.put("role", "管理员"); } else { map.put("success", false); map.put("message", "密码错误"); } } return map; } // 管理员退出登录
@GetMapping(value = "deleteRewards.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> deleteRewards(String id) { Map<String, Object> map = new HashMap<String, Object>(); int num = this.rewardsService.deleteRewards(id); if (num > 0) { map.put("success", true); map.put("code", num); map.put("message", "删除成功"); } else { map.put("success", false); map.put("code", num); map.put("message", "删除失败"); } return map; } // 按主键批量删除员工奖惩 @PostMapping(value = "deleteRewardsByIds.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> deleteRewardsByIds(@RequestBody String[] ids) { int num = 0; for (String rewardsid : ids) { num += this.rewardsService.deleteRewards(rewardsid); } Map<String, Object> map = new HashMap<String, Object>(); if (num > 0) { map.put("success", true); map.put("code", num); map.put("message", "删除成功"); } else { map.put("success", false); map.put("code", num); map.put("message", "删除失败"); } return map; } // 修改员工奖惩 @PostMapping(value = "updateRewards.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> updateRewards(@RequestBody String jsonStr) { JSONObject obj = JSONObject.parseObject(jsonStr); // 将JSON字符串转换成object Rewards rewards = this.rewardsService.getRewardsById(obj.getString("rewardsid")); // 获取object中rewardsid字段
map.put("message", "修改成功"); } else { map.put("success", false); map.put("code", num); map.put("message", "修改失败"); } return map; } // 查询全部职务数据 在下拉菜单中显示 @GetMapping(value = "getAllDuty.action") @ResponseBody // 将java对象转为json格式的数据返回 public List<Duty> getAllDuty() { return this.dutyService.getAllDuty(); } // 通过AJAX在表格中显示职务数据 @GetMapping(value = "getDutyByPage.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> getDutyByPage(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit) { // 定义一个Map对象 用来返回数据 Map<String, Object> map = new HashMap<String, Object>(); Page<Duty> pager = com.github.pagehelper.PageHelper.startPage(page, limit);// 定义当前页和分页条数 List<Duty> list = this.dutyService.getAllDuty(); // 返回的map中定义数据格式 map.put("count", pager.getTotal()); map.put("total", list.size()); map.put("data", list); map.put("code", 0); map.put("msg", ""); map.put("page", page); map.put("limit", limit); return map; } // 按主键查询职务数据 @GetMapping(value = "getDutyById.action") @ResponseBody // 将java对象转为json格式的数据返回 public Duty getDutyById(String id) { Duty duty = this.dutyService.getDutyById(id); return duty; } }
map.put("success", true); map.put("code", num); map.put("message", "删除成功"); } else { map.put("success", false); map.put("code", num); map.put("message", "删除失败"); } return map; } // 按主键批量删除员工考勤 @PostMapping(value = "deleteAttendByIds.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> deleteAttendByIds(@RequestBody String[] ids) { int num = 0; for (String attendid : ids) { num += this.attendService.deleteAttend(attendid); } Map<String, Object> map = new HashMap<String, Object>(); if (num > 0) { map.put("success", true); map.put("code", num); map.put("message", "删除成功"); } else { map.put("success", false); map.put("code", num); map.put("message", "删除失败"); } return map; } // 修改员工考勤 @PostMapping(value = "updateAttend.action") @ResponseBody // 将java对象转为json格式的数据返回 public Map<String, Object> updateAttend(@RequestBody String jsonStr) { JSONObject obj = JSONObject.parseObject(jsonStr); // 将JSON字符串转换成object Attend attend = this.attendService.getAttendById(obj.getString("attendid")); // 获取object中attendid字段 attend.setEmployid(obj.getString("employid")); // 为员工赋值 attend.setWork(obj.getString("work")); // 为考勤状态赋值
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。