employee detail 返回门禁时间范围

This commit is contained in:
曹前明 2022-09-15 16:22:51 +08:00
parent dd5faaf619
commit 7433d0fd04
2 changed files with 15 additions and 0 deletions

View File

@ -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:

View File

@ -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"