打卡时判断异常情况
This commit is contained in:
parent
830dee3358
commit
367d9b31dd
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.2.12 on 2023-03-10 07:23
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('hrm', '0007_alter_employee_job_state'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='clockrecord',
|
||||||
|
name='exception_type',
|
||||||
|
field=models.PositiveSmallIntegerField(blank=True, choices=[(10, '在岗时间短'), (20, '在岗时间长')], null=True, verbose_name='异常类型'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -83,10 +83,17 @@ class ClockRecord(BaseModel):
|
||||||
(ClOCK_ON, '上班打卡'),
|
(ClOCK_ON, '上班打卡'),
|
||||||
(CLOCK_OFF, '下班打卡'),
|
(CLOCK_OFF, '下班打卡'),
|
||||||
)
|
)
|
||||||
|
E_TYPE_LESS = 10
|
||||||
|
E_TYPE_MORE = 20
|
||||||
|
E_TYPE_CHOISE = (
|
||||||
|
(E_TYPE_LESS, '在岗时间短'),
|
||||||
|
(E_TYPE_MORE, '在岗时间长')
|
||||||
|
)
|
||||||
type = models.PositiveSmallIntegerField('打卡类型', choices=type_choice, default=ClOCK_ON)
|
type = models.PositiveSmallIntegerField('打卡类型', choices=type_choice, default=ClOCK_ON)
|
||||||
employee = models.ForeignKey(Employee, verbose_name='对应人员', on_delete=models.CASCADE)
|
employee = models.ForeignKey(Employee, verbose_name='对应人员', on_delete=models.CASCADE)
|
||||||
trigger = models.CharField('触发', max_length=20)
|
trigger = models.CharField('触发', max_length=20)
|
||||||
detail = models.JSONField('相关记录', default=dict, null=False, blank=True)
|
detail = models.JSONField('相关记录', default=dict, null=False, blank=True)
|
||||||
|
exception_type = models.PositiveSmallIntegerField('异常类型', choices=E_TYPE_CHOISE, null=True, blank=True)
|
||||||
|
|
||||||
|
|
||||||
class Certificate(CommonAModel):
|
class Certificate(CommonAModel):
|
||||||
|
|
|
@ -332,6 +332,15 @@ class HrmService:
|
||||||
ep.is_atwork = False
|
ep.is_atwork = False
|
||||||
ep.last_check_time = s_time_f
|
ep.last_check_time = s_time_f
|
||||||
ep.save()
|
ep.save()
|
||||||
|
# 判断是否有异常
|
||||||
|
cr_e = ClockRecord.objects.filter(create_time__lte=cr_20.create_time).exclude(id=cr_20.id).order_by('-create_time').first()
|
||||||
|
time_d = cr_20.create_time - cr_e.create_time
|
||||||
|
if time_d < timedelta(hours=7):
|
||||||
|
cr_20.exception_type = ClockRecord.E_TYPE_LESS
|
||||||
|
cr_20.save()
|
||||||
|
elif time_d > timedelta(hours=14):
|
||||||
|
cr_20.exception_type = ClockRecord.E_TYPE_MORE
|
||||||
|
cr_20.save()
|
||||||
|
|
||||||
# 进行相关方/访客项目更新
|
# 进行相关方/访客项目更新
|
||||||
Visit.objects.filter(state=Visit.V_ENTER, visitors__employee__id_number=id_number).update(
|
Visit.objects.filter(state=Visit.V_ENTER, visitors__employee__id_number=id_number).update(
|
||||||
|
@ -339,4 +348,4 @@ class HrmService:
|
||||||
Rpj.objects.filter(state=Rpj.RPJ_ENTER, remployees__employee__id_number=id_number).update(
|
Rpj.objects.filter(state=Rpj.RPJ_ENTER, remployees__employee__id_number=id_number).update(
|
||||||
state=Rpj.RPJ_WORKING)
|
state=Rpj.RPJ_WORKING)
|
||||||
|
|
||||||
# 此处可触发安全帽事件逻辑
|
# 此处可触发安全帽事件逻辑
|
Loading…
Reference in New Issue