From 1921015120b47c60c61a7c02e8aa7bd84b5ae6aa 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, 25 Aug 2022 16:26:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E8=A7=A6=E5=8F=91=20?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E5=90=8D=E7=A7=B0bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ecm/service.py | 3 ++- apps/third/dahua.py | 21 +++++++++++++++++++++ apps/third/tapis.py | 4 ++++ apps/third/views.py | 4 ++-- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/apps/ecm/service.py b/apps/ecm/service.py index f651c7d0..7b470660 100644 --- a/apps/ecm/service.py +++ b/apps/ecm/service.py @@ -87,7 +87,8 @@ def notify_event(event: Event, voice_msg=''): # 生成通知文本 ep = event.employee obj_cate = event.obj_cate - params = {'area': event.area.name, 'employee': '', 'event': ''} + area_name = event.area.name if event.area else '' + params = {'area': area_name, 'employee': '', 'event': ''} if ep: ep_name = ep.name ep_type = '员工' diff --git a/apps/third/dahua.py b/apps/third/dahua.py index 47a19722..29a8f7b2 100644 --- a/apps/third/dahua.py +++ b/apps/third/dahua.py @@ -272,3 +272,24 @@ class DhClient: "cascade": True } self.request(**dhapis['face_bind'], json=json_data) + + def face_deploy(self): + + params = { + "id": "001001001", + "checkStat": "1", + "type": "001;00_1;1", + "capability": "1_00000000000000000000000100000000", + "curCount": "0", + "isDomain": 0 + } + _, res = self.request(**dhapis['dev_tree'], params=params) + for i in json.loads(res): + json_data = { + "minSimilarity": "70", + "dpMinSimilarity": 70, + "surveyType": ["1"], + "groups": str(settings.DAHUA_FACEGROUPID_1), + "chnId": i['id'] + } + self.request(**dhapis['face_deploy'], json=json_data) diff --git a/apps/third/tapis.py b/apps/third/tapis.py index 825040bb..6d3b4e19 100755 --- a/apps/third/tapis.py +++ b/apps/third/tapis.py @@ -119,6 +119,10 @@ dhapis = { "face_search": { "url": "/evo-apigw/evo-face/faceSearch/third/faceSearchSync", "method": "post" + }, + "face_deploy": { + "url": "/evo-apigw/evo-face/channelGroup/add/batch", + "method": "post" } } diff --git a/apps/third/views.py b/apps/third/views.py index 78d057ab..5f10b75f 100755 --- a/apps/third/views.py +++ b/apps/third/views.py @@ -30,8 +30,8 @@ class DahuaTestView(MyLoggingMixin, APIView): permission_classes = [IsAuthenticated] def get(self, request, *args, **kwargs): - res = dhClient.face_search(path='/media/2022/07/13/three.jpg') - + # res = dhClient.face_search(path='/media/2022/07/13/three.jpg') + res = dhClient.face_deploy() return Response(res)