package emp.controller;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSONArray;
import emp.controller.vo.EmpAttendance;
import emp.dao.mapper.ApplicantsMapper;
import emp.dao.mapper.AttendanceMapper;
import emp.dao.mapper.EmployeeMapper;
import emp.dao.mapper.MettingMapper;
import emp.dao.mapper.TrainMapper;
import emp.dao.model.Applicants;
import emp.dao.model.Attendance;
import emp.dao.model.Employee;
import emp.dao.model.Metting;
import emp.dao.model.Train;
import emp.utils.DateUtils;
import utils.page.PageView;
@Controller
@RequestMapping("/manager")
public class ManagerController {
@Autowired
private EmployeeMapper empMapper;
@Autowired
private AttendanceMapper attMapper;
@Autowired
private MettingMapper mettingMapper;
@Autowired
private ApplicantsMapper appMapper;
@Autowired
private TrainMapper trainMapper;
@RequestMapping("login")
public String loginPage() {
return "manager/login";
}
@RequestMapping("login-form")
public ModelAndView loginForm(String username, String pwd, HttpSession session) {
ModelAndView mav = new ModelAndView("redirect:home");
Employee record = new Employee(username, pwd);
record.setRole(2);
List<Employee> emp = empMapper.select(record);
if(emp == null || emp.size() == 0) {
mav.addObject("msg", "用户名或密码错误");
mav.setViewName("manager/login");
}else {
session.setAttribute("currManager", emp.get(0));
}
return mav;
}
@RequestMapping("logout")
public String logout(HttpSession session) {
session.removeAttribute("currManager");
return "redirect:login";
}
@RequestMapping("home")
public ModelAndView home(HttpSession session) {
ModelAndView mav = new ModelAndView("manager/home");
Employee emp = (Employee) session.getAttribute("currManager");
String day = DateUtils.getTodayStr();
Attendance att = attMapper.findEmpAttToday(day , emp.getEmpId());
if(att != null) {
if(att.getCheckin() != null) {
mav.addObject("checkin", DateUtils.parseTime(att.getCheckin()));
}
if(att.getCheckout() != null) {
mav.addObject("checkout", DateUtils.parseTime(att.getCheckout()));
}
}
mav.addObject("today", DateUtils.getTodayStr());
mav.addObject("now", DateUtils.getCnDateTimeStr());
return mav;
}
/**
* 上班打卡
* @param emp
* @return
*/
@RequestMapping("checkin")
public String checkin(String today, HttpSession session) {
Employee emp = (Employee) session.getAttribute("currManager");
Attendance att = attMapper.findEmpAttToday(today , emp.getEmpId());
boolean insert = false;
if(att == null) {
att = new Attendance();
insert = true;
}
att.setAttDay(today);
att.setEmpId(emp.getEmpId());
att.setCheckin(new Date());
String status = "正常";
if(DateUtils.checkLate(att.getCheckin())) {
status = "迟到";
}
att.setStatus(status);
if(insert) {
attMapper.insert(att);
}else {
attMapper.updateByPrimaryKeySelective(att);
}
return "redirect:attmgr";
}
/**
* 下班打卡
* @param emp
* @return
*/
@RequestMapping("checkout")
public String checkout(String today, HttpSession session) {
Employee emp = (Employee) session.getAttribute("currManager");
Attendance att = attMapper.findEmpAttToday(today , emp.getEmpId());
boolean insert = false;
if(att == null) {
att = new Attendance();
insert = true;
}
att.setAttDay(today);
att.setEmpId(emp.getEmpId());
att.setCheckout(new Date());
String status = "";
if(StringUtils.isNotBlank(att.getStatus())) {
status += att.getStatus();
}
if(DateUtils.checkLeave(att.getCheckout())) {
if(StringUtils.isNotBlank(status)) {
status += "|";
}
status += "早退";
}
att.setStatus(status);
if(insert) {
attMapper.insert(att);
}else {
attMapper.updateByPrimaryKeySelective(att);
}
return "redirect:attmgr";
}
/* *********************员工信息管理**************************/
@RequestMapping("toaddemp")
public ModelAndView toAddEmp(HttpSession session) {
ModelAndView mav = new ModelAndView("manager/emp-add");
Employee mgr = (Employee) session.getAttribute("currManager");//当前登录的主管
mav.addObject("mgr", mgr);
return mav;
}
@RequestMapping("saveEmp")
public String saveEmp(Employee emp) {
empMapper.insert(emp);
return "redirect:empmgr";
}
@RequestMapping("empmgr")
public ModelAndView empList(PageView<Employee> page, HttpSession session) {
ModelAndView mav = new ModelAndView("manager/emp-list");
Employee emp = new Employee();
emp.setRole(1);//主管只能管理普通员工
Employee mgr = (Employee) session.getAttribute("currManager");//当前登录的主管
emp.setDept(mgr.getDept());//主管只能查询自己部门的员工
List<Employee> list = empMapper.selectByRowBounds(emp, new RowBounds(page.getFirstResult(), page.getMaxresult())); //empService.findUsers(page.getFirstResult(), page.getMaxresult());
page.setRecords(list);
page.setTotalrecord(empMapper.selectCount(new Employee()));
mav.addObject("page", page);
return mav;
}
@RequestMapping("toupdateemp")
public ModelAndView toUserModify(Integer uid) {
ModelAndView mav = new ModelAndView("manager/emp-update");
Employee emp = empMapper.selectByPrimaryKey(uid);
mav.addObject("emp", emp);
return mav;
}
@RequestMapping("updateemp")
public String updateUser(Employee emp) {
empMapper.updateByPrimaryKey(emp);
return "redirect:empmgr";
}
@RequestMapping("toupdatesal")
public ModelAndView toupdatesal(Integer uid) {
ModelAndView mav = new ModelAndView("manager/emp-update2");
Employee emp = empMapper.selectByPrimaryKey(uid);
mav.addObject("emp", emp);
return mav;
}
@RequestMapping("updateemp2")
public String updateUser2(Integer empId, Integer discount) {
Employee emp = empMapper.selectByPrimaryKey(empId);
emp.setDiscount(discount);
return "redirect:empmgr";
}
/**
* 注销员工
* @param uid
* @return
*/
@RequestMapping("deleteemp")
public String deleteUser(Integer uid) {
Employee emp = empMapper.selectByPrimaryKey(uid);
emp.setStatus(-1);
empMapper.updateByPrimaryKeySelective(emp);
return "redirect:empmgr";
}
/* *********************员工信息管理END**************************/
/* *********************考勤信息管理**************************/
/**
* 考勤信息列表
* @param page
* @return
*/
@RequestMapping("attmgr")
public ModelAndView attList(PageView<EmpAttendance> page, HttpSession session) {
ModelAndView mav = new ModelAndView("manager/att-list");
Employee mgr = (Employee) session.getAttribute("currManager");//当前登录的主管
List<Attendance> list = attMapper.findDeptAttendancePage(mgr.getDept(), page.getFirstResult(), page.getMaxresult());
List<EmpAttendance> vos = new ArrayList<>();
for (Attendance att : list) {
EmpAttendance vo = new EmpAttendance();
vo.setEmp(empMapper.selectByPrimaryKey(att.getEmpId()));
vo.setAtt(att);
vos.add(vo);
}
page
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
基于Springboot人力资源管理系统设计源码案例设计.zip (802个子文件)
main.css 235KB
H-ui.css 207KB
bootstrap.css 149KB
H-ui.min.css 149KB
bootstrap.min.css 118KB
bootstrap-theme.css 26KB
bootstrap-theme.min.css 23KB
swiper-3.4.2.min.css 17KB
iconfont.css 17KB
iconfont.min.css 14KB
layer.css 14KB
common.css 14KB
column.css 12KB
webuploader.css 12KB
basic.css 7KB
H-ui.admin.css 7KB
metroStyle.css 7KB
zTreeStyle.css 6KB
datepicker-dev.css 5KB
datepicker.css 4KB
datepicker.css 4KB
datepicker.css 3KB
headIng.css 3KB
H-ui.reset.css 3KB
H-ui.ie.css 3KB
zTreeStyleForApi.css 3KB
H-ui.login.css 2KB
H-ui.login.css 2KB
skin.css 1KB
skin.css 1KB
skin.css 1KB
skin.css 1KB
skin.css 1KB
common_ie6.css 1KB
style.css 1KB
skin.css 1KB
laypage.css 1KB
style.css 160B
WdatePicker.css 152B
iconfont.eot 132KB
glyphicons-halflings-regular.eot 20KB
35.gif 13KB
71.gif 13KB
69.gif 10KB
loading.gif 8KB
18.gif 8KB
19.gif 8KB
11.gif 8KB
32.gif 7KB
zTreeStandard.gif 7KB
78.gif 6KB
loading-0.gif 6KB
31.gif 6KB
zTreeStandard.gif 5KB
99.gif 5KB
75.gif 5KB
85.gif 5KB
8.gif 5KB
29.gif 5KB
74.gif 5KB
metro.gif 5KB
5.gif 5KB
45.gif 4KB
33.gif 4KB
72.gif 4KB
0.gif 4KB
26.gif 4KB
loading-b.gif 4KB
7.gif 4KB
10.gif 4KB
76.gif 4KB
80.gif 4KB
49.gif 4KB
66.gif 3KB
205.gif 3KB
91.gif 3KB
9.gif 3KB
28.gif 3KB
70.gif 3KB
6.gif 3KB
68.gif 3KB
79.gif 3KB
22.gif 3KB
97.gif 3KB
56.gif 3KB
51.gif 3KB
27.gif 3KB
86.gif 3KB
41.gif 2KB
50.gif 2KB
25.gif 2KB
103.gif 2KB
84.gif 2KB
83.gif 2KB
24.gif 2KB
12.gif 2KB
89.gif 2KB
101.gif 2KB
106.gif 2KB
105.gif 2KB
共 802 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
FL1768317420
- 粉丝: 4088
- 资源: 4617
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功