From 97710370b6896d7784d88be74a99595cda1209ad 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, 20 Oct 2022 17:54:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E8=84=B8=E8=AF=86=E5=88=AB=E9=98=88?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/hrm/serializers.py | 5 +++-- apps/third/dahua.py | 6 +++--- apps/third/views.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/hrm/serializers.py b/apps/hrm/serializers.py index 5b982f06..66c44d4b 100755 --- a/apps/hrm/serializers.py +++ b/apps/hrm/serializers.py @@ -74,14 +74,15 @@ class EmployeeCreateUpdateSerializer(CustomModelSerializer): instance.user.save() # 同时去除门禁授权 if settings.DAHUA_ENABLED and dhClient: - if instance.type == 'employee': + # 如果是正式员工或相关方且有门禁权限: + if instance.type in ['employee', 'remployee'] and instance.third_info.get('dh_face_card', None): start_time = None end_time = None if instance.job_state == 20 and old_job_state == 10: # 离职 now = datetime.now() start_time = now end_time = now + timedelta(minutes=60) - elif instance.job_state == 10 and old_job_state == 20: # 重新在职 + elif instance.job_state == 10 and old_job_state == 20 and instance.type == 'employee': # 正式员工重新在职 now = datetime.now() start_time = now end_time = now + timedelta(days=7300) diff --git a/apps/third/dahua.py b/apps/third/dahua.py index 083145c7..ed8b7513 100644 --- a/apps/third/dahua.py +++ b/apps/third/dahua.py @@ -258,7 +258,7 @@ class DhClient: } self.request(**dhapis['face_bind'], json=json_data) - def face_deploy(self): + def face_deploy(self, minSim: int = 90): params = { "id": "001001001", @@ -271,8 +271,8 @@ class DhClient: _, res = self.request(**dhapis['dev_tree'], params=params) for i in json.loads(res): json_data = { - "minSimilarity": "80", - "dpMinSimilarity": 80, + "minSimilarity": str(minSim), + "dpMinSimilarity": minSim, "surveyType": ["1"], "groups": str(settings.DAHUA_FACEGROUPID_1), "chnId": i['id'] diff --git a/apps/third/views.py b/apps/third/views.py index 336d5a9f..1db089bd 100755 --- a/apps/third/views.py +++ b/apps/third/views.py @@ -396,5 +396,5 @@ class DhCommonViewSet(CreateModelMixin, CustomGenericViewSet): 人脸库同步到所有智能设备 """ - dhClient.face_deploy() + dhClient.face_deploy(request.data.get('minSim', 90)) return Response()