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"