功能介绍
本系统开发的目的主要用来解决中小企业的日常办公需求,我们通过对中小心企业的日常办公业务进行调研分析,发现企业业务主要集中在个人日常事务的处理,主要包括个人信息、考勤、加班、请假等;
员工的管理,主要包括在职或者离职以员工的调动情况;
考勤模块,主要包括员工考勤的管理、员工加班的管理;
请假单的管理,主要包括申请和批准等;
部门功能模块,主要包括企业部门的管理、企业一些职称的管理;
还有公司公告管理,主要包括添加公司公告和对已有公告进行修改删除。
经过调查研究,为了满足企业的日常基本办公要求,我们将系统设计成了八大功能模块,其中包括用户的登录和登出功能、个人信息管理功能、员工信息管理功能、考勤信息管理功能、请假信息管理功能、部门信息管理功能、公告信息管理功能以及最后的一个员工打卡功能。
部分功能模块代码
package edu.hjs.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import edu.hjs.entity.Attendance;
import edu.hjs.service.AttendanceService;
@Controller
@RequestMapping("/attendance")
public class AttendanceController {
@Autowired
private AttendanceService attendanceService;
@RequestMapping("/addStart.do")
public String addStart(Integer employeeNumber){
attendanceService.addStart(employeeNumber);
return "welcome";
}
@RequestMapping("/addEnd.do")
public String addEnd(Integer employeeNumber){
attendanceService.addEnd(employeeNumber);
return "welcome";
}
@RequestMapping("/list.do")
public String selectList(Model model){
List<Attendance> list = attendanceService.selectList();
model.addAttribute("aList",list);
return "admin/attendance_list";
}
@RequestMapping("/{employeeNumber}/oneself.do")
public String select(Model model, @PathVariable Integer employeeNumber){
List<Attendance> list = attendanceService.selectByEmployee(employeeNumber);
model.addAttribute("aList",list);
return "admin/oneself_attendance";
}
}
package edu.hjs.service.impl;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import edu.hjs.entity.Attendance;
import edu.hjs.entity.Employee;
import edu.hjs.mapper.AttendanceMapper;
import edu.hjs.mapper.EmployeeMapper;
import edu.hjs.service.AttendanceService;
import edu.hjs.util.MConstant;
import edu.hjs.util.MTimeUtil;
@Service("attendanceService")
public class AttendanceServiceImpl extends ServiceImpl<AttendanceMapper, Attendance>
implements AttendanceService{
@Autowired
private EmployeeMapper employeeMapper;
//获取相关时间
Date amTime = MTimeUtil.stringTimeParse(MConstant.AMTime);
Date amStartTime = MTimeUtil.stringTimeParse(MConstant.AMStartTime);
Date amEndTime = MTimeUtil.stringTimeParse(MConstant.AMEndTime);
Date pmTime = MTimeUtil.stringTimeParse(MConstant.PMTime);
Date pmStartTime = MTimeUtil.stringTimeParse(MConstant.PMStartTime);
Date pmEndTime = MTimeUtil.stringTimeParse(MConstant.PMEndTime);
Date ovTime = MTimeUtil.stringTimeParse(MConstant.OVTime);
Date ovStartTime = MTimeUtil.stringTimeParse(MConstant.OVStartTime);
Date ovEndTime = MTimeUtil.stringTimeParse(MConstant.OVEndTime);
@Override
public void addStart(Integer employeeNumber){
//获取当前时间
Date nowTime = MTimeUtil.nowTime();
//获取当前日期
Date nowDate = MTimeUtil.nowDate();
Attendance attendance = new Attendance();
attendance.setEmployeeNumber(employeeNumber);
attendance.setDay(nowDate);
attendance.setStartTime(nowTime);
if (nowTime.after(amTime) && nowTime.before(amEndTime)) {
Attendance att = baseMapper.selectByNumber(employeeNumber, nowDate, "上午");
if (att == null) {
attendance.setTimeType("上午");
if (nowTime.before(amStartTime)) {
attendance.setStartType("正常");
}else{
attendance.setStartType("迟到");
}
baseMapper.insert(attendance);
}
}else if(nowTime.after(pmTime) && nowTime.before(pmEndTime)){
Attendance att = baseMapper.selectByNumber(employeeNumber, nowDate, "下午");
if (att == null) {
attendance.setTimeType("下午");
if (nowTime.before(pmStartTime)) {
attendance.setStartType("正常");
}else{
attendance.setStartType("迟到");
}
baseMapper.insert(attendance);
}
}else if(nowTime.after(ovTime) && nowTime.before(ovEndTime)){
Attendance att = baseMapper.selectByNumber(employeeNumber, nowDate, "加班");
if (att == null) {
attendance.setTimeType("加班");
if (nowTime.before(ovStartTime)) {
attendance.setStartType("正常");
}else{
attendance.setStartType("迟到");
}
baseMapper.insert(attendance);
}
}
}
@Override
public void addEnd(Integer employeeNumber) {
Date nowTime = MTimeUtil.nowTime();
Date nowDate = MTimeUtil.nowDate();
if (nowTime.after(amStartTime) && nowTime.before(pmStartTime)) {
Attendance attendance = baseMapper.selectByNumber(employeeNumber, nowDate, "上午");
if(attendance != null) {
if (attendance.getEndTime() == null) {
attendance.setEndTime(nowTime);
if (nowTime.after(amEndTime)) {
attendance.setEndType("正常");
} else {
attendance.setEndType("早退");
}
baseMapper.updateById(attendance);
}
}
}else if(nowTime.after(pmStartTime) && nowTime.before(ovStartTime)){
Attendance attendance = baseMapper.selectByNumber(employeeNumber, nowDate, "下午");
if(attendance != null) {
if (attendance.getEndTime() == null) {
attendance.setEndTime(nowTime);
if (nowTime.after(pmEndTime)) {
attendance.setEndType("正常");
} else {
attendance.setEndType("早退");
}
baseMapper.updateById(attendance);
}
}
}else if(nowTime.after(ovStartTime)) {
Attendance attendance = baseMapper.selectByNumber(employeeNumber, nowDate, "加班");
if (attendance != null) {
if (attendance.getEndTime() == null) {
attendance.setEndTime(nowTime);
if (nowTime.after(ovEndTime)) {
attendance.setEndType("正常");
} else {
attendance.setEndType("早退");
}
baseMapper.updateById(attendance);
}
}
}
}
@Override
public List<Attendance> selectList() {
//查询所有的考勤记录,根据id倒序排序
List<Attendance> list = baseMapper.selectList(new EntityWrapper<Attendance>().
orderBy("id", false));
for(Attendance attendance : list){
//为attendance对象setEmployee
Employee employee = employeeMapper.selectByNumber(attendance.getEmployeeNumber());
attendance.setEmployee(employee);
}
return list;
}
@Override
public List<Attendance> selectByEmployee(Integer employeeNumber) {
//查询一个员工的考勤记录,根据id倒序排序
List<Attendance> list = baseMapper.selectList(new EntityWrapper<Attendance>()
.eq("employee_number", employeeNumber)
.orderBy("id", false));
for(Attendance attendance : list){
//为attendance对象setEmployee
Employee employee = employeeMapper.selectByNumber(attendance.getEmployeeNumber());
attendance.setEmployee(employee);
}
return list;
}
}
package edu.hjs.mapper;
import java.util.Date;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import edu.hjs.entity.Attendance;
public interface AttendanceMapper extends BaseMapper<Attendance>{
/**
* 根据employeeNumber和day查询记录
* @param employeeNumber
* @return
*/
Attendance selectByNumber(@Param("employeeNumber") Integer employeeNumber,
@Param("day") Date day, @Param("timeType") String timeType);
}
论文目录