请教个考勤方面的?如何得到和考勤班次规定较近的时间?

wangj_0520 2009-05-01 11:00:50
请教?
例如:
班次表Bc_info
序号 班次名称 开始刷卡时间 结束刷卡时间 最早刷卡时间 最晚刷卡时间 是否跨越零点

id(唯一) Bc_info_Name Bc_info_Begin Bc_info_End Bc_info_early Bc_info_last Bc_info_KZore
1 早班 00:30 08:30 23:00 10:00 T

2 中班 08:30 17:30 07:00 18:00 F

3 晚班 16:30 00:30 15:00 02:00 T

4 夜班 20:30 08:30 19:00 10:00 T

5 长班1 16:30 07:30 15:30 10:30 T

6 长班2 08:30 08:30 07:30 10:00 T

排班表PB_info
序号 人员标志 1号 2号 3号 4号 31号 月份
id Person_id Date1 date2 date3 date4-------Date31 Month
1 101 早班 早班 晚班 中班 5
2 102 早班 晚班 晚班 中班 5
3 103 早班 长班1 休息 中班 5


刷卡记录表 SK_Record
序号 人员标志 刷卡日期 刷卡时间 考勤机号
SK_Record_id Person_id SK_Record_Data SK_Record_Time KQ_matchinge
1 101 2009-5-1 23:30 1
2 101 2009-5-2 00:20 2
3 101 2009-5-3 16:10
4 101 2009-5-4 07:30
5 102 2009-5-1 00:10
6 102 2009-5-2 16:35
7 102 2009-5-3 16:10
8 102 2009-5-4 06:30
9 102 2009-5-4 06:31
9 102 2009-5-4 06:31
10 101 2009-5-1 00:20 2
11 101 2009-5-1 00:20 3
12 101 2009-5-1 08:20 4
12 101 2009-5-1 08:30 4
12 101 2009-5-1 08:31 4
12 101 2009-5-2 10:00 4
12 101 2009-5-2 01:35 4

如何得到如下记录:
人员标志 班次名称 刷卡日期 上班卡 下班卡 机器名称
Person_id Bc_info_Name SK_Record_Data SK_Record_Time1 SK_Record_Time2 KQ_matchinge
101 早班 2009-5-1 23:30 08:30
101 早班 2009-5-2 00:20 08:30
101 晚班 2009-5-3 02:00 00:30
这个日结果规则是这样的:
如果1个人连续刷卡多次,如果是时间较接近排班班次的上班时间,并且不早于最早刷卡时间,无论刷了多少次,将最接近该日排班的开始时间为上班卡时间
如果1个人连续刷卡多次,如果是时间较接近排班班次的下班时间,并且不晚于最晚刷卡时间,无论刷了多少次,将最接近该日排班的结束时间为下班卡时间
还要考虑跨夜,跨越零点的问题,真麻烦,还请高手赐教?!






...全文
461 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
tsp3ng 2009-05-14
  • 打赏
  • 举报
回复
在考勤方面整整做了六年, 有一些了解, 它的随机性,复杂性不是三言两语能说清楚的,简单可用千奇百怪来形容.
ouyangzhifei 2009-05-14
  • 打赏
  • 举报
回复
真正做好考勤系统可不是一件很容易的事情喔
wanshichen 2009-05-14
  • 打赏
  • 举报
回复
关注,学习,以前的考勤,采用过2楼的办法,不过没楼主这么复杂
cc4512 2009-05-14
  • 打赏
  • 举报
回复
先把每个员工规定的正常时间段分好,然后拿员工的刷卡记录与之进行比对。
人鱼传说 2009-05-12
  • 打赏
  • 举报
回复
我也在做考勤,但做来做去发现技术不能解决所有问题,即便你解决了,那也是累死了不少脑细胞,而且只是为了解决极少数不守规定打卡的员工的问题,还是要制度先行,考勤系统能解决90%的正常打卡就不错了
wangj_0520 2009-05-12
  • 打赏
  • 举报
回复
这个没个解决方案吗?
高手出来指点下????!1
stephenewong 2009-05-04
  • 打赏
  • 举报
回复
我做考勤那会儿也遇到类似问题,解决的方法供你参考:

1、制定严格的考勤规则,主要是清晰考勤卡该怎么打,怎么计算的标准问题
如在什么时间段刷卡记入什么考勤范围等。
2、在上述基础上,进行算法分析即可
meheartfly 2009-05-04
  • 打赏
  • 举报
回复
根据逻辑处理之就可以了,没什么难的
taick 2009-05-04
  • 打赏
  • 举报
回复
已保存
hwj2009 2009-05-04
  • 打赏
  • 举报
回复
学习
叶子 2009-05-04
  • 打赏
  • 举报
回复
PB_info 表设计的貌似有些问题,使过程变得很复杂

函数中不能拼串后执行,这样取动态列就能不好处理。

建议将PB_info改成关系表的模式:
例如:

排班表PB_info
序号 人员标志 时间 班次
1 101 5月1号 早班
2 101 5月2号 早班
3 101 5月3号 晚班
4 101 5月4号 中班
...

叶子 2009-05-04
  • 打赏
  • 举报
回复

create table Bc_info(id int,Bc_info_Name varchar(5),Bc_info_Begin datetime,Bc_info_End datetime,Bc_info_early datetime,Bc_info_last datetime,Bc_info_KZore varchar(1))
insert into Bc_info
select 1,'早班','00:30','08:30','23:00','10:00','T' union all
select 2,'中班','08:30','17:30','07:00','18:00','F' union all
select 3,'晚班','16:30','00:30','15:00','02:00','T' union all
select 4,'夜班','20:30','08:30','19:00','10:00','T' union all
select 5,'长班1','16:30','07:30','15:30','10:30','T' union all
select 6,'长班2','08:30','08:30','07:30','10:00','T'

select * from Bc_info
go

create table PB_info (id int,Person_id int,Date1 varchar(4),date2 varchar(5),date3 varchar(4),date4 varchar(4),Date31 varchar(4),Month int)
insert into PB_info
select 1,101,'早班','早班','晚班','中班','中班',5 union all
select 2,102,'早班','晚班','晚班','中班','中班',5 union all
select 3,103,'早班','长班1','休息','中班','中班',5

select * from PB_info
go

create table SK_Record (SK_Record_id int,Person_id int,SK_Record_Data datetime,SK_Record_Time int,KQ_matchinge sql_variant)
insert into SK_Record
select 1,101,'2009-5-1 23:30',1,null union all
select 2,101,'2009-5-2 00:20',2,null union all
select 3,101,'2009-5-3 16:10',null,null union all
select 4,101,'2009-5-4 07:30',null,null union all
select 5,102,'2009-5-1 00:10',null,null union all
select 6,102,'2009-5-2 16:35',null,null union all
select 7,102,'2009-5-3 16:10',null,null union all
select 8,102,'2009-5-4 06:30',null,null union all
select 9,102,'2009-5-4 06:31',null,null union all
select 9,102,'2009-5-4 06:31',null,null union all
select 10,101,'2009-5-1 00:20',2,null union all
select 11,101,'2009-5-1 00:20',3,null union all
select 12,101,'2009-5-1 08:20',4,null union all
select 12,101,'2009-5-1 08:30',4,null union all
select 12,101,'2009-5-1 08:31',4,null union all
select 12,101,'2009-5-2 10:00',4,null union all
select 12,101,'2009-5-2 01:35',4,null

select * from SK_Record
SimonYeung 2009-05-04
  • 打赏
  • 举报
回复
MARK
musecangying007 2009-05-02
  • 打赏
  • 举报
回复
mark
Q315054403 2009-05-02
  • 打赏
  • 举报
回复
偶有方案,是比较复杂点,应该说繁琐点而巳
claro 2009-05-01
  • 打赏
  • 举报
回复
--用绝对值取最近的时间?
abs(datediff(mi,时间,getdate()))
you_tube 2009-05-01
  • 打赏
  • 举报
回复
麻烦
fuxiaoyang13 2009-05-01
  • 打赏
  • 举报
回复
楼上正解

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧