Browse Source

往来检测新增进入离开状态

zhangdongming 2 years ago
parent
commit
0e33611e3a
3 changed files with 22 additions and 4 deletions
  1. 2 1
      Controller/DetectController.py
  2. 4 1
      Controller/DetectControllerV2.py
  3. 16 2
      Service/DevicePushService.py

+ 2 - 1
Controller/DetectController.py

@@ -126,7 +126,8 @@ class NotificationView(View):
             }
             params = {'nickname': nickname, 'uid': uid, 'kwag_args': kwag_args, 'is_st': is_st,
                       'is_sys_msg': is_sys_msg, 'channel': channel, 'event_type': event_type, 'n_time': n_time,
-                      'electricity': '', 'bucket': bucket, 'app_push': '', 'storage_location': 1, 'ai_type': 0}
+                      'electricity': '', 'bucket': bucket, 'app_push': '', 'storage_location': 1, 'ai_type': 0,
+                      'dealings_type': 0}
             #  推送以及报警消息存库
             result = DevicePushService.save_msg_push(uid_set_push_list=uid_push_list, **params)
             if result['code_date'] is None:

+ 4 - 1
Controller/DetectControllerV2.py

@@ -54,6 +54,8 @@ class NotificationV2View(View):
         electricity = request_dict.get('electricity', '')
         time_token = request_dict.get('time_token', None)
         uid = request_dict.get('uid', None)
+        # 往来检测 1:来,2:离开
+        dealings_type = request_dict.get('dealingsType', 0)
 
         if not all([channel, n_time]):
             return JsonResponse(status=200, data={
@@ -120,7 +122,8 @@ class NotificationV2View(View):
             params = {'nickname': nickname, 'uid': uid, 'kwag_args': kwag_args, 'is_st': is_st, 'region': region,
                       'is_sys_msg': is_sys_msg, 'channel': channel, 'event_type': event_type, 'n_time': n_time,
                       'electricity': electricity, 'bucket': bucket, 'aws_s3_client': aws_s3_client,
-                      'app_push': cache_app_push, 'storage_location': 2, 'ai_type': ai_type}
+                      'app_push': cache_app_push, 'storage_location': 2, 'ai_type': ai_type,
+                      'dealings_type': dealings_type}
             logger.info('已创建s3对象,推送数据为:{}'.format(params))
             # APP消息推送与获取报警消息数据列表
             result = DevicePushService.save_msg_push(uid_set_push_list, **params)

+ 16 - 2
Service/DevicePushService.py

@@ -126,7 +126,7 @@ class DevicePushService:
                 # 发送内容
                 msg_text = cls.get_msg_text(channel=params['channel'], n_time=params['n_time'], lang=lang,
                                             tz=tz, event_type=params['event_type'],
-                                            electricity=params['electricity'])
+                                            electricity=params['electricity'], dealings_type=params['dealings_type'])
                 kwag_args['appBundleId'] = appBundleId
                 kwag_args['token_val'] = token_val
                 kwag_args['msg_title'] = msg_title
@@ -313,7 +313,7 @@ class DevicePushService:
         return nickname
 
     @staticmethod
-    def get_msg_text(channel, n_time, lang, tz, event_type, electricity='', is_sys=0):
+    def get_msg_text(channel, n_time, lang, tz, event_type, electricity='', is_sys=0, dealings_type=0):
         """
         获取消息文本
         """
@@ -328,6 +328,13 @@ class DevicePushService:
                 msg_type = '摄像头唤醒'
             elif etype == 606:
                 msg_type = '有人呼叫,请点击查看'
+            elif etype == 1024:
+                if int(dealings_type) == 1:
+                    msg_type = '有人进入'
+                elif int(dealings_type) == 2:
+                    msg_type = '有人离开'
+                else:
+                    msg_type = '往来检测'
             else:
                 msg_type = ''
             if is_sys:
@@ -343,6 +350,13 @@ class DevicePushService:
                 msg_type = 'Camera wake'
             elif etype == 606:
                 msg_type = 'Someone is calling, please click to view'
+            elif etype == 1024:
+                if dealings_type == 1:
+                    msg_type = 'Someone comes in'
+                elif dealings_type == 2:
+                    msg_type = 'Someone left'
+                else:
+                    msg_type = 'Incoming and outgoing detection'
             else:
                 msg_type = ''
             if is_sys: