From 7433d0fd04e1fc34d02ce342e85846f336c6ba3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Thu, 15 Sep 2022 16:22:51 +0800 Subject: [PATCH] =?UTF-8?q?employee=20detail=20=E8=BF=94=E5=9B=9E=E9=97=A8?= =?UTF-8?q?=E7=A6=81=E6=97=B6=E9=97=B4=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/hrm/serializers.py | 11 +++++++++++ apps/third/tapis.py | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/apps/hrm/serializers.py b/apps/hrm/serializers.py index 9fdd5e40..1ff86283 100755 --- a/apps/hrm/serializers.py +++ b/apps/hrm/serializers.py @@ -11,6 +11,7 @@ from apps.hrm.models import Certificate, ClockRecord, Employee, NotWorkRemark from apps.system.serializers import DeptSimpleSerializer, UserSimpleSerializer from django.db import transaction from apps.third.clients import dhClient +from apps.third.tapis import dhapis from django.conf import settings from apps.utils.tools import check_phone_e @@ -109,6 +110,7 @@ class EmployeeSerializer(CustomModelSerializer): blt_ = serializers.SerializerMethodField() photo_f = MyFilePathField(source='photo', read_only=True) signature_f = MyFilePathField(source='signature', read_only=True) + door_range = serializers.SerializerMethodField() class Meta: model = Employee @@ -121,6 +123,15 @@ class EmployeeSerializer(CustomModelSerializer): return TDeviceSimpleSerializer(instance=obj.tdevice).data return + def get_door_range(self, obj): + third_info = obj.third_info + try: + dh_face_card = third_info['dh_face_card'] + _, res = dhClient.request(**dhapis['card_detail'], params={'cardNumber': dh_face_card}) + return [res['startDate'], res['endDate']] + except Exception: + pass + class EmployeeNotWorkRemarkSerializer(ModelSerializer): class Meta: diff --git a/apps/third/tapis.py b/apps/third/tapis.py index d61b29fd..b0491e19 100755 --- a/apps/third/tapis.py +++ b/apps/third/tapis.py @@ -40,6 +40,10 @@ dhapis = { "url": "/evo-apigw/evo-brm/1.0.0/device/{deviceCode}", "method": "get" }, + "card_detail": { + "url": "/evo-apigw/evo-brm/1.0.0/card/{cardNumber}", + "method": "get" + }, "channel_list": { "url": "/evo-apigw/evo-brm/1.2.0/device/channel/subsystem/page", "method": "post"