ssm单位人事管理系统源码和文档033
开发工具:idea
数据库mysql5.7+
数据库链接工具:navcat,小海豚等
技术:ssm
摘 要
现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本单位人事管理系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此单位人事管理系统利用当下成熟完善的SSM框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的Mysql数据库进行程序开发。实现了人员基础数据的管理,考勤管理,职位和职称修改。单位人事管理系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。
关键词:单位人事管理系统;SSM框架;Mysql;自动化
Abstract
The fast-paced development of the modern economy and the continuous improvement and upgrading of information technology have allowed the management of traditional data information to be upgraded to software storage, induction, and centralized management of data information. This book lending system was born in such a large environment, which can help managers to process huge data information in a short time. Using this software tool can help managers improve transaction processing efficiency and achieve double the result with half the effort. This book lending system uses the current mature and perfect SSM framework, cross-platform Java language that can be used to develop large-scale commercial websites, and Mysql database, one of the most popular RDBMS application software, for program development. It realizes the functions of book basic data management, book borrowing and return, review of registered teacher information, and announcement information release. The development of the book lending system is designed to be simple and beautiful according to the needs of the operator. The layout of the function module is consistent with the same type of website. When the program realizes the basic requirements, it also provides some practical solutions for the security problems faced by the data information. . It can be said that this program not only helps managers efficiently handle work affairs, but also realizes the integration, standardization and automation of data information.
Key Words:Book borrowing system; SSM framework; Mysql; automation
研究背景
当前社会各行业领域竞争压力非常大,随着当前时代的信息化,科学化发展,让社会各行业领域都争相使用新的信息技术,对行业内的各种相关数据进行科学化,规范化管理。这样的大环境让那些止步不前,不接受信息改革带来的信息技术的企业随时面临被淘汰,被取代的风险。所以当今,各个行业领域,不管是传统的教育行业,餐饮行业,还是旅游行业,医疗行业等领域都将使用新的信息技术进行信息革命,改变传统的纸质化,需要人手工处理工作事务的办公环境。软件信息技术能够覆盖社会各行业领域是时代的发展要求,各种数据以及文件真正实现电子化是信息社会发展的不可逆转的必然趋势。本单位人事管理系统也是紧跟科学技术的发展,运用当今一流的软件技术实现软件系统的开发,让人事管理信息完全通过管理系统实现科学化,规范化,程序化管理。从而帮助信息管理者节省事务处理的时间,降低数据处理的错误率,对于基础数据的管理水平可以起到促进作用,也从一定程度上对随意的业务管理工作进行了避免,同时,单位人事管理系统的数据库里面存储的各种动态信息,也为上层管理人员作出重大决策提供了大量的事实依据。总之,单位人事管理系统是一款可以真正提升管理者的办公效率的软件系统。
package com.controller;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.StringUtil;
import java.lang.reflect.InvocationTargetException;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.ChuqinEntity;
import com.service.ChuqinService;
import com.entity.view.ChuqinView;
import com.service.YonghuService;
import com.entity.YonghuEntity;
import com.utils.PageUtils;
import com.utils.R;
/**
* 考勤
* 后端接口
* @author
* @email
* @date 2021-02-25
*/
@RestController
@Controller
@RequestMapping("/chuqin")
public class ChuqinController {
private static final Logger logger = LoggerFactory.getLogger(ChuqinController.class);
@Autowired
private ChuqinService chuqinService;
@Autowired
private TokenService tokenService;
//级联表service
@Autowired
private YonghuService yonghuService;
//字典表map
Map<String, Map<Integer, String>> dictionaryMap;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role"));
if(StringUtil.isNotEmpty(role) && "用户".equals(role)){
params.put("yonghuId",request.getSession().getAttribute("userId"));
}
PageUtils page = chuqinService.queryPage(params);
//字典表数据转换
List<ChuqinView> list =(List<ChuqinView>)page.getList();
ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
dictionaryMap = (Map<String, Map<Integer, String>>) servletContext.getAttribute("dictionaryMap");
for(ChuqinView c:list){
this.dictionaryConvert(c);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
ChuqinEntity chuqin = chuqinService.selectById(id);
if(chuqin !=null){
//entity转view
ChuqinView view = new ChuqinView();
BeanUtils.copyProperties( chuqin , view );//把实体数据重构到view中
//级联表
YonghuEntity yonghu = yonghuService.selectById(chuqin.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
}
//字典表字典转换
ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
dictionaryMap = (Map<String, Map<Integer, String>>) servletContext.getAttribute("dictionaryMap");
this.dictionaryConvert(view);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 打卡
*/
@RequestMapping("/clockIn")
public R clockIn(String flag, HttpServletRequest request){
logger.debug("clockIn方法:,,Controller:{},,flag:{}",this.getClass().getName(),flag);
try {
Integer id = (Integer)request.getSession().getAttribute("userId");
String role = String.valueOf(request.getSession().getAttribute("role"));
if(StringUtil.isEmpty(role) || "管理员".equals(role)){
return R.error(511,"没有打卡权限");
}
Date d = new Date();
SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
String date = format1.format(d);
List<ChuqinEntity> chuqinList = new ArrayList<ChuqinEntity>();//要生成的list数据
List<String> s = new ArrayList<>();
s.add("yonghu_id+0");
Wrapper<ChuqinEntity> queryWrapper3 = new EntityWrapper<ChuqinEntity>().eq("yonghu_id",id).orderDesc(s);
List<ChuqinEntity> oldChuqinList = chuqinService.selectList(queryWrapper3);
if("1".equals(flag)){
//上班卡
Date date1 = new Date();
date1.setHours(8);
date1.setMinutes(0);
date1.setSeconds(0);
//上班打卡
//新增前先查看当前用户最大打卡时间
if(oldChuqinList != null && oldChuqinList.size()>0){
ChuqinEntity entity = oldChuqinList.get(0);
String today = entity.getToday();//获取出勤表最大出勤
//把日期加一天
Date todayTime = format1.parse(today);
Calendar calendar = new GregorianCalendar();
calendar.setTime(todayTime);
calendar.add(calendar.DATE,1);
String newToday = format1.format(calendar.getTime());
if(date.equals(today)){
return R.error(511,"已经打过上班卡了");
}else if(!date.equals(newToday)){//当天日期 不是出勤最大日期加一天的话 就是补充缺勤日期
chuqinList = this.getQueQin(d, format1, today, id);
}
if(chuqinList !=null && chuqinList.size() >0){
chuqinService.insertBatch(chuqinList);
}
//插入当天的上班卡
ChuqinEntity chuqin = new ChuqinEntity();
chuqin.setOnTime(d);
if(d.compareTo(date1)>0){//当前时间d 大于规定时间date1
chuqin.setChuqinTypes(6);//设置为迟到
}else if(d.compareTo(date1)<=0){//当前时间d 小于等于规定时间date1
chuqin.setChuqinTypes(3);//设置为未打下班卡
}
chuqin.setCreateTime(d);
chuqin.setToday(date);
chuqin.setYonghuId(id);
chuqinService.insert(chuqin);
}else{
//第一次打卡
ChuqinEntity chuqin = new ChuqinEntity();
chuqin.setOnTime(d);
if(d.compareTo(date1)>0){//当前时间d 大于规定时间date1
chuqin.setChuqinTypes(6);//设置为迟到
}else if(d.compareTo(date1)<=0){//当前时间d 小于等于规定时间date1
chuqin.setChuqinTypes(3);//设置为未打下班卡
}
chuqin.setCreateTime(d);
chuqin.setToday(date);
chuqin.setYonghuId(id);
chuqinService.insert(chuqin);
}
}else if("2".equals(flag)){
//下班卡
Date date1 = new Date();
date1.setHours(19);
date1.setMinutes(00);
date1.setSeconds(0);
Date date2 = new Date();
date2.setHours(18);
date2.setMinutes(00);
date2.setSeconds(0);
//下班打卡
if(oldChuqinList!=null){//不是第一次打卡
//查询当前用户是否生成了上班打卡
Wrapper<ChuqinEntity> queryWrapper = new EntityWrapper<ChuqinEntity>().eq("yonghu_id",id).eq("today",date).orderDesc(s);
ChuqinEntity chuqinEntity = chuqinService.selectOne(queryWrapper);
if(chuqinEntity !=null){//生成了上班打卡
chuqinEntity.setDownTime(d);
if("6".equals(String.valueOf(chuqinEntity.getChuqinTypes()))){
}else if(d.compareTo(date1)>0){//当前时间d 大于规定时间 加班
int hours = d.getHours();
int i = hours - 19+1;
if(i>0){
chuqinEntity.setOvertimeNumber(i);
}
chuqinEntity.setChuqinTypes(5);//设置为迟到
}else if(d.compareTo(date2)<0){//当前时间d 小于等于规定时间 早退
chuqinEntity.setChuqinTypes(7);//设置为未打下班卡
}else{
chuqinEntity.setChuqinTypes(1);
}
chuqinService.updateById(chuqinEntity);
}else{
//当天上午没有生成上班打卡,要防止用户昨天及之前没有生成打卡记录
Wrapper<ChuqinEntity> queryWrapper1 = new EntityWrapper<ChuqinEntity>().eq("yonghu_id",id).orderDesc(s);
List<ChuqinEntity> list = chuqinService.selectList(queryWrapper1);
if(list != null && list.size()>0){
ChuqinEntity entity = list.get(0);
String today = entity.getToday();//获取出勤表最大出勤
Date todayTime = format1.parse(today);
Calendar calendar = new GregorianCalendar();
calendar.setTime(todayTime);
calendar.add(calendar.DATE,1);
String newToday = format1.format(calendar.getTime());
if(date.equals(today)){
//昨天id+1 等于今天的话 就是直接新增下午打卡
ChuqinEntity chuqin = new ChuqinEntity();
chuqin.setDownTime(d);
chuqin.setChuqinTypes(2);
chuqinService.insert(chuqin);
}else if(!date.equals(newToday)){//当天日期 不是出勤最大日期加一天的话 就是补充缺勤日期
chuqinList = this.getQueQin(d, format1, today, id);
}
if(chuqinList !=null && chuqinList.size() >0){
chuqinService.insertBatch(chuqinList);
}
}
}
}else{
//第一次打卡
ChuqinEntity chuqin = new ChuqinEntity();
chuqin.setDownTime(d);
chuqin.setChuqinTypes(2);
chuqinService.insert(chuqin);
}
}else {
return R.error(511,"未知错误");
}
} catch (ParseException e) {
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}
return R.ok();
}
//
//
//
// /**
// * 后端保存
// */
// @RequestMapping("/save")
// public R save(@RequestBody ChuqinEntity chuqin, HttpServletRequest request){
// logger.debug("save方法:,,Controller:{},,chuqin:{}",this.getClass().getName(),chuqin.toString());
// Wrapper<ChuqinEntity> queryWrapper = new EntityWrapper<ChuqinEntity>()
// .eq("yonghu_id", chuqin.getYonghuId())
// .eq("today", chuqin.getToday())
// .eq("chuqin_types", chuqin.getChuqinTypes())
// .eq("overtimeNumber", chuqin.getOvertimeNumber())
// ;
// logger.info("sql语句:"+queryWrapper.getSqlSegment());
// ChuqinEntity chuqinEntity = chuqinService.selectOne(queryWrapper);
// if(chuqinEntity==null){
// chuqin.setCreateTime(new Date());
// // String role = String.valueOf(request.getSession().getAttribute("role"));
// // if("".equals(role)){
// // chuqin.set
// // }
// chuqinService.insert(chuqin);
// return R.ok();
// }else {
// return R.error(511,"表中有相同数据");
// }
// }
//
// /**
// * 修改
// */
// @RequestMapping("/update")
// public R update(@RequestBody ChuqinEntity chuqin, HttpServletRequest request){
// logger.debug("update方法:,,Controller:{},,chuqin:{}",this.getClass().getName(),chuqin.toString());
// //根据字段查询是否有相同数据
// Wrapper<ChuqinEntity> queryWrapper = new EntityWrapper<ChuqinEntity>()
// .notIn("id",chuqin.getId())
// .eq("yonghu_id", chuqin.getYonghuId())
// .eq("today", chuqin.getToday())
// .eq("chuqin_types", chuqin.getChuqinTypes())
// .eq("overtimeNumber", chuqin.getOvertimeNumber())
// ;
// logger.info("sql语句:"+queryWrapper.getSqlSegment());
// ChuqinEntity chuqinEntity = chuqinService.selectOne(queryWrapper);
// chuqin.setOnTime(new Date());
// chuqin.setDownTime(new Date());
// if(chuqinEntity==null){
// // String role = String.valueOf(request.getSession().getAttribute("role"));
// // if("".equals(role)){
// // chuqin.set
// // }
// chuqinService.updateById(chuqin);//根据id更新
// return R.ok();
// }else {
// return R.error(511,"表中有相同数据");
// }
// }
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
chuqinService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
*字典表数据转换
*/
public void dictionaryConvert(ChuqinView chuqinView){
//当前表的字典字段
if(StringUtil.isNotEmpty(String.valueOf(chuqinView.getChuqinTypes()))){
chuqinView.setChuqinValue(dictionaryMap.get("chuqin_types").get(chuqinView.getChuqinTypes()));
}
//级联表的字典字段
if(StringUtil.isNotEmpty(String.valueOf(chuqinView.getZhiwuTypes()))){
chuqinView.setZhiwuValue(dictionaryMap.get("zhiwu_types").get(chuqinView.getZhiwuTypes()));
}
if(StringUtil.isNotEmpty(String.valueOf(chuqinView.getZhichengTypes()))){
chuqinView.setZhichengValue(dictionaryMap.get("zhicheng_types").get(chuqinView.getZhichengTypes()));
}
if(StringUtil.isNotEmpty(String.valueOf(chuqinView.getSexTypes()))){
chuqinView.setSexValue(dictionaryMap.get("sex_types").get(chuqinView.getSexTypes()));
}
if(StringUtil.isNotEmpty(String.valueOf(chuqinView.getPoliticsTypes()))){
chuqinView.setPoliticsValue(dictionaryMap.get("politics_types").get(chuqinView.getPoliticsTypes()));
}
if(StringUtil.isNotEmpty(String.valueOf(chuqinView.getMarriageTypes()))){
chuqinView.setMarriageValue(dictionaryMap.get("marriage_types").get(chuqinView.getMarriageTypes()));
}
if(StringUtil.isNotEmpty(String.valueOf(chuqinView.getEducationTypes()))){
chuqinView.setEducationValue(dictionaryMap.get("education_types").get(chuqinView.getEducationTypes()));
}
}
/**
*
* @param d 当前日期
* @param format1 "yyyy-MM-dd"
* @param newToday 数据库存的最大打卡日期 加一天
* @param id 打卡人id
* @return
* @throws ParseException
*/
public static List<ChuqinEntity> getQueQin(Date d,SimpleDateFormat format1,String newToday,Integer id) throws ParseException {
List<ChuqinEntity> list = new ArrayList<>();
// 返回的日期集合
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date start = dateFormat.parse(newToday);
Calendar calendar = new GregorianCalendar();
calendar.setTime(d);
calendar.add(calendar.DATE,-1); //当前时间减去一天,即一天前的时间
Date end = dateFormat.parse(format1.format(calendar.getTime()));
Calendar tempStart = Calendar.getInstance();
tempStart.setTime(start);
Calendar tempEnd = Calendar.getInstance();
tempEnd.setTime(end);
tempEnd.add(Calendar.DATE, +1);// 日期加1(包含结束)
while (tempStart.before(tempEnd)) {
ChuqinEntity chuqinEntity = new ChuqinEntity();
chuqinEntity.setYonghuId(id);
chuqinEntity.setToday(dateFormat.format(tempStart.getTime()));
chuqinEntity.setCreateTime(d);
chuqinEntity.setChuqinTypes(4);
list.add(chuqinEntity);
tempStart.add(Calendar.DAY_OF_YEAR, 1);
}
return list;
}
}