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
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本人十余年JAVA架构设计经验,擅长JAVA高可用、分布式、高并发系统架构设计。有志于做JAVA系统性的技术提升的同学可与我联系,交个朋友哦~ 本人十余年JAVA架构设计经验,擅长JAVA高可用、分布式、高并发系统架构设计。有志于做JAVA系统性的技术提升的同学可与我联系,交个朋友哦~ 本人十余年JAVA架构设计经验,擅长JAVA高可用、分布式、高并发系统架构设计。有志于做JAVA系统性的技术提升的同学可与我联系,交个朋友哦~
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
共 801 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
季风泯灭的季节
- 粉丝: 696
- 资源: 2920
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- 藏区特产销售平台源代码+论文+毕业设计.zip
- B297C8EC5A69641DB3E681E1B3F894E5.mp4
- PrimitivesPro v2.2.unitypackage
- 财务管理系统源代码+论文.zip
- 高级信息通信运行管理员第七套试卷
- UModeler v2.11.6 (May 10, 2024).unitypackage
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本127.0.6486.0)
- 基于FPGA的CORDIC算法旋转模式实现
- bilibili视频解析下载源码
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本124.0.6367.60)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)