refector: swipe_next 优化
This commit is contained in:
parent
1b55669a82
commit
f4aacc2129
|
@ -277,16 +277,16 @@ class HrmService:
|
|||
# 先直接创建记录
|
||||
cr = ClockRecord.objects.filter(employee=ep, create_time=s_time_f).first()
|
||||
if cr:
|
||||
pass
|
||||
ClockRecord.objects.filter(id=cr.id).update(exception_type=None, detail=detail)
|
||||
else:
|
||||
cr = ClockRecord()
|
||||
cr.type = card_type
|
||||
cr.exception_type = None
|
||||
cr.employee = ep
|
||||
cr.trigger = trigger
|
||||
cr.detail = detail
|
||||
cr.create_time = s_time_f
|
||||
cr.save()
|
||||
cr.type = card_type
|
||||
cr.exception_type = None
|
||||
cr.employee = ep
|
||||
cr.trigger = trigger
|
||||
cr.detail = detail
|
||||
cr.create_time = s_time_f
|
||||
cr.save()
|
||||
|
||||
if card_type == 10:
|
||||
# 查找当天的进门记录
|
||||
|
@ -307,27 +307,23 @@ class HrmService:
|
|||
time_d = last_obj.create_time - cr_e.create_time
|
||||
if cr_e.type == 10:
|
||||
if time_d < timedelta(hours=7):
|
||||
last_obj.exception_type = ClockRecord.E_TYPE_LESS
|
||||
last_obj.save()
|
||||
ClockRecord.objects.filter(id=last_obj.id).update(type=ClockRecord.E_TYPE_LESS)
|
||||
elif time_d > timedelta(hours=14):
|
||||
last_obj.exception_type = ClockRecord.E_TYPE_MORE
|
||||
last_obj.save()
|
||||
ClockRecord.objects.filter(id=last_obj.id).update(type=ClockRecord.E_TYPE_MORE)
|
||||
elif time_d > timedelta(hours=10):
|
||||
last_obj.exception_type = ClockRecord.E_TYPE_ADD
|
||||
last_obj.save()
|
||||
ClockRecord.objects.filter(id=last_obj.id).update(type=ClockRecord.E_TYPE_ADD)
|
||||
elif cr_e.type == 20:
|
||||
last_obj.exception_type = ClockRecord.E_TYPE_MISS
|
||||
last_obj.save()
|
||||
ClockRecord.objects.filter(id=last_obj.id).update(type=ClockRecord.E_TYPE_MISS)
|
||||
|
||||
# 记录在岗情况
|
||||
last_obj_t = ClockRecord.objects.filter(employee=ep, type__in=[10,20]).order_by('-create_time').first()
|
||||
if last_obj_t:
|
||||
ep.last_check_time = last_obj_t.create_time
|
||||
update_fields = {'last_check_time': last_obj_t.create_time}
|
||||
if last_obj_t.type == 10:
|
||||
ep.is_atwork = True
|
||||
update_fields['is_at_work'] = True
|
||||
else:
|
||||
ep.is_atwork = False
|
||||
ep.save()
|
||||
update_fields['is_at_work'] = False
|
||||
Employee.objects.filter(id=ep.id).update(**update_fields)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue