李鼎文徐昌欣郭伟 中图分类号:C37文献标识:A文章编号:16741145(2018)820304 摘要本文介绍了某公司考勤加班统计的规则、原始考勤数据进行预先数据处理的方法,文中依据考勤规则进行了统计,介绍了相应的统计代码,并通过编写的程序实现自动统计,最后文章介绍了应用效果。 关键词考勤管理加班时间统计数据处理VB 目前,企业在进行考勤管理的过程中,一般采用了考勤机来对考勤进行记录,并进行一系列考勤情况统计,比如迟到早退人员统计、旷工人数统计、请假情况统计、加班情况统计等,其中加班情况统计是经常进行的一种。在有的中小企业中,只有考勤机记录的初始记录,没有进一步的考勤统计分析软件,怎样利用考勤初始记录,进行考勤加班统计,是中小企业常常面对的问题。本人在工作中,利用VB编写小程序,通过对考勤初始数据的进行预处理,然后对加班情况进行统计,取代了手工进行考勤加班计算的状况,减轻了考勤统计人员的工作量,并提高了工作的准确性。本人将考勤加班统计的方法、部分源码及计算过程整理出来,以飨读者。 一、考勤加班统计规则的设定 为方便进行考勤管理,必须首先设定考勤规则,让员工有考勤依据,方能准确的打卡,知道自己的考勤情况。某企业中,对考勤加班统计规则设计如下: 1。平时上班时间,每天5点半以后算下班,6点之后刷卡算加班。 2。节假日全天可算加班。 3。平时上班时间,加班超过2。5个小时以上,给予一次餐补。 4。节假日加班,一次加班时间超过3个小时,给予一次餐补,7小时以上,两次餐补封顶。二、考勤原始数据处理某企业中,考勤刷卡的原始数据如下图所示,该数据是由考勤机的记录导出的excel数据。 原始数据包括部门、姓名、考勤号、刷卡时间、记录状态、机器号等六个数据项。在进行考勤加班统计之前,需要对原始数据进行三个方面的预处理:1。去掉一次刷卡记录下来的多次刷卡记录。2。标注是正常上班时间还是节假日。3。取出正常上班时间超出18:00的刷卡数据,做為加班统计的依据。 1。去掉多次刷卡数据,将刷卡数据间隔小于5分钟的数据去掉,即原始数据的间隔小于0。08的,删除后面的数据。代码如下: Fori1Tototalnum1Step1 Ifsheetds。Cells(i,3)sheetds。Cells(i1,3)AndYear(sheetds。Cells(i,4))Year(sheetds。Cells(i1,4))AndMonth(sheetds。Cells(i,4))Month(sheetds。Cells(i1,4))AndDay(sheetds。Cells(i,4))Day(sheetds。Cells(i1,4))AndRound((Hour(sheetds。Cells(i1,4))Hour(sheetds。Cells(i,4))(Minute(sheetds。Cells(i1,4))Minute(sheetds。Cells(i,4)))6f),2)0。08Then pp1 Else sheetds1。Cells(ip,1)sheetds。Cells(i,2) sheetds1。Cells(ip,2)sheetds。Cells(i,4) sheetds1。Cells(ip,3)sheetds。Cells(i,5) shretds1。Cells(ip,4)sheetds,Cells(i,3) p0 2。对原始数据标注是平时上班时间还是节假日。首先通过人机界面确定哪些是休息日,再逐一标注,如果是平时刷卡数据第五列标注为0,如果是节假日刷卡数据第五列标注为1。代码如下: DoWhilesheetso。Cells(totalnum,3)统计记录条数 totalnumtotalnum1 Loop totalnumtotalnum1 Fori2TotatalnumStep1 sheetds。Cells(i1,1)sheetso。Cells(i,1) sheetds。Cers(i1,2)sheetso。Cells(i,2) sheetds。Cells(i1,3)sheetso。Cells(i,3) sleetds。Cells(i1,4)sheetso。Cells(i,4) sheetds。Cells(i1,5)0 Forj1Tok1Step2 IfDay(sheetso。Cells(i,4)a(j)Then sheetds。Cells(i1,5)1 EndIf Nextj Nexti 3。取出正常上班时间超出18:00的刷卡数据。 Ifsheetds1。Cells(i,3)0AndHour(sheetds1。Cells(i,2))18Then平时刷卡时间过了18:00的记录 sheetds2。Cells(ip,1)sbeetds1。Cells(i,1) sheetds2。Cells(ip,2)sheetds1。Cells(i,2) sheetds2。Cells(ip,3)sheetds1。Cells(i,3) sheetds2。Cells(ip,7)sheetds1。Celis(i,4) totalnum1totalnum11 Else pp1 EndIf EndIf Nexti 三、依據统计规则对预处理后的数据进行计算 1。以考勤号为关键字,统计当日休息时段刷卡的次数,及将刷卡次数累加计入第四列。 Fori1Tototalnum1Step1计算打卡记录数 If(Day(sheetds2。Cells(i,2)))(Day(sheetds2。Cells(i1,2)))And(Manth(sheetds2。Cells,2)))(Month(sheetds2。Cells(i1,2)))And(Year(sheetds2。Cells(i,2)))(Year(sheetds2。Cells(i1,2)))And(sheetds2。Cells(i,7)sheetds2。Cells(i1,7))Then bb1 Else sheetds2。Cells(i,4)b b1 EndIf Nexti 2。依据刷卡次数区分奇数次和偶数次刷卡,并按平时加班及休息日加班分别对加班时间进行统计,并计算餐补。这一共有三种情况: (1)正常上班时间、休假时间的偶数次打卡,此时计算两次刷卡记录之差即为加班时间。然后分别按照正常上班时间和休假时间的餐补计算规则,统计餐补数量即可。即正常上班时加班时间超过2。5小时,给予一次餐补,休假时间一次加班时间超过3小时,给予一次餐补,7小时以上给予两次餐补,将餐补结果计入第6列。 Fori1Tototalnum1Step1统计加班时间Ifsheetds2。Cells(i,4)And(sheetds2。Cells(i,4)Mod20)Then正常上班时间、休假时间,偶数次打卡 sheetds2。Cells(i,5)0 sheetds2。Cells(i,6)0 Forj0Tosheetds2。Cells(i,4)2Step2 sheetds2。Cells(i,5)Round((sheetds2。Cells(i,5)Hour(sheetds2。Cells(ij,2))Hour(sheetds2。Cells(ij1,2))(Minute(sheetds2。Cells(ij,2))Minute(sheetds2。Cells(ij1,2)))60),2) IfRound((HOUr(sheetds2。Cells(ij,2))Hoor(sheetds2。Cells(ij1,2))(Minute(sheetds2。Cells(ij,2))Minute(sheetds2。Cells(ij1,2)))60),2)2。5Andsheetds2。Cells(i,3)0Then统计餐补 sheetds2。Cells(i,6)i Else IfRound((Hour(sheetds2。Cells(ij。2))Hour(sheetds2。Cells(ij1,2))(Minute(sheetds2。Cells(ij,2))Minute(sheetds2。Cells(ij1,2)))60),2)7Andsheetds2。Cells(i,3)1Then sheetds2。Cells(i,6)2 EndIf IfRound((Hour(sheetds2。Cells(ij,2))Hour(sheetds2。Cells(ij1,2))(Minute(sheetds2。Cells(ij,2))Minute(sheetds2。Cells(ij1,2)))60),2)3AndRound((Hour(sheetds2。Cells(ij,2))Hour(sheetds2。Cells(ij1,2))(Minute(sheetds2。Cells(ij,2))Minnee(sheetds2。Cells(ij1,2)))60),2)7Andsheetds2。Cells(i,3)1Andsheetds2。Cells(i,6)2Then统计餐补 sheetds2。Cells(i,6)sheetds2。Cells(i,6)1 EndIf EndIf。 Nextj (2)正常上班时间奇数次打卡,此时计算最后一次刷卡与17:30之差即为加班时间,然后依据加班时间和餐补规则计算餐补。 Ifsheetds2。Cells(i,4)Andsheetds2。Cells(i,3)0And(sheetds2。Cell(i,4)Mod21)Then正常上班时间,奇数次打卡 sheetds2。Cells(i,5)0 sheetds2。Cells(i,6)0 sheetds2。Cells(i,5)Round(Hour(sheetds2。Cells(isheetds2。Cells(i,4)1,2))17(Minute(sheetds2。Cells(isheetds2。Cells(i,4)1,2))30)60),2) Ifsheetds2。Cells(i,5)2。5Then統计餐补 sheetds2。Cells(i,6)1 EndIf Ifshellds2。Cells(i,4)1Then Forj0Tosheetds2。Cells(i,4)3Step2 sheetds2。Cells(i,5)Round((sheetds2。Cells(i,5)Hour(sheetds2。Cells(ij,2))Hour(sheetds2。Cells(ij1,2))(Minute(sheetds2。Cells(ij,2))Minute(sheetds2。Cells(ij1,2)))60),2) IfRound((Hour(sheetds2。Cells(ij,2))Hour(sheetds2。Cells(ij1,2))(Minute(sheetds2。Cells(ij,2))Minute(sheetds2。Cells(ij1,2)))60),2)2。5Then统计餐补 sheetds2。Cells(i,6)1 EndIf Nextj EndIf EndIf (3)休假时间奇数次打卡,此时计算第一次刷卡与最后一次刷卡之差即为加班时间,然后依据加班时间和餐补规则计算餐补即可。 Ifsheetds2。Cells(i,4)Andsheetds2。Cells(i,3)1And(sheetds2。Cells(i,4)Mod21)Then休假时间,奇数次打卡 sheetds2。Cells(i,6)0 sheetds2。Cells(i,5)Round((Hour(sheetds2。Cells(i,2))Hour(sheetds2。Cells(isheetds2。Cells(i,4)1,2))(Minute)sheetds2。Cells(i,2))Minute(sheetds2。Cells(isheetds2。Cells(i,4)1,2)))60),2) Ifsheetds2。Cells(i,5)3Andsheetds2。Cells(i,5)7Andsheetds2。Cells(i,6)2Then统计餐补 sheetds2。Cells(i,6)sheetds2。Cells(i,6)1 Else Ifsheetda2。Cells(i,5)7Then sheetds2。Cells(i,6)2 EndIf EndIf EndIf EndIf Nexti 四、依据得到的结果,制作报表计算每日加班时间和当月加班总时间,及每日餐补数和该月餐补数。程序如下: pk2 Fori1Tototalnum1Step1制作报表 Ifsheetds2。Cells(i,4)Then sheetds3。Cells(pk,1)sheetds2。Cells(i,1) sheetds3。Cells(pk,2)sheetds2。Cells(i,7) sheetds3。Cells(pk,3)DateSerial(Year(sheetds2。Cells(i,2)),Month(sheetds2。Cells(i,2)),Day(sheetds2。Cells(i,2))) sheetds3。Cells(pk,4)sheetds2。Cells(i,5) sheetds3。Cells(pk,5)sheetds2。Cells(i,6) pkpk1 EndIf Nexti totaladdsheetds3。Cells(2,4) totalcountsheetds3。Cells(2,5) Fori2Topk1Step1 if(sheetds3。Celts(i,2)sheetds3。Cells(i1,2))Then totladdtataladdsheetds3。cells(i1,4) totalcounttotalcountsheetds3。Cells(i1,5) Else sheetds3。Cells(i,6)totaladd sheetds3。Cells(i,7)totalcount totaladdsheetds3。Cells(i1,4) totalcountsheetds3。Cells(i,1,5) EndIf Nexti EndIf 五、运行效果 (一)程序界面 通过人工输入休息日,来区分正常上班时间和节假日日期,点击加班统计即可进行统计计算。 1。统计过程。 通过不断建立Worksheet,逐层递进得进行计算,最后得到最后的统计结果。 (1)标注是平时工作日还是节假日。 (2)去掉时间间隔小于5分钟的数据并取出正常工作日18:00以后的数据。 (3)计算当日刷卡次数,并统计加班时间及餐补。 (4)最终统计结果。 六、应用效果 该统计软件已经在某公司稳定运行了一段时间,减轻了考勤统计人员的工作量,提高了统计的准确性,保障了公司的考勤管理工作的稳定运行,取得了较好的管理效能。 参考文献: 〔1〕唐勇。RFID身份识别考勤系统设计〔J〕。2013(6)。 〔2〕刘宇。基于WEB的企业定制考勤系统的设计与实现〔J〕。2013(11)。 〔3〕杨洋。基于NET的人事考勤管理系统的设计与开发〔J〕。2011(6)。