From 42cbd43117d3d298b434e0fda04b3a3131c5e81f Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 15 Feb 2022 11:12:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E6=96=99=E8=AE=A1=E7=AE=97=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E6=8C=89=E7=89=A9=E6=96=99=E7=B1=BB=E5=9E=8B=E5=92=8C?= =?UTF-8?q?=E7=BC=96=E5=8F=B7=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/hrm/views.py | 18 ++++++++++++++++++ hb_server/apps/pm/views.py | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hb_server/apps/hrm/views.py b/hb_server/apps/hrm/views.py index ed733da..e22ec6b 100644 --- a/hb_server/apps/hrm/views.py +++ b/hb_server/apps/hrm/views.py @@ -126,6 +126,24 @@ class FaceLogin(CreateAPIView): if user: refresh = RefreshToken.for_user(user) # 可设为在岗 + now = timezone.now() + now_local = timezone.localtime() + if 8<=now_local.hour<=17: + ins, created = ClockRecord.objects.get_or_create( + create_by = user, create_time__hour__range = [8,18], + create_time__year=now_local.year, create_time__month=now_local.month, + create_time__day=now_local.day, + defaults={ + 'type':ClockRecord.ClOCK_WORK1, + 'create_by':user, + 'create_time':now + }) + # 设为在岗 + if created: + user.is_atwork = True + user.last_check_time = now + user.save() + return Response({ 'refresh': str(refresh), 'access': str(refresh.access_token), diff --git a/hb_server/apps/pm/views.py b/hb_server/apps/pm/views.py index 28e9c3d..62a7bbb 100644 --- a/hb_server/apps/pm/views.py +++ b/hb_server/apps/pm/views.py @@ -232,7 +232,8 @@ class ResourceViewSet(GenericViewSet): # 计算输入物料 materials = SubprodctionMaterial.objects.filter(subproduction__product__id=i['id'], subproduction__is_deleted=False, is_deleted=False, - type= SubprodctionMaterial.SUB_MA_TYPE_IN).order_by('material__number')\ + type= SubprodctionMaterial.SUB_MA_TYPE_IN).order_by( + 'material__type', 'material__number')\ .values('material__id', 'material__name', 'material__number', 'material__type', 'count', 'material__count', 'material__count_safe')