lang 3 роки тому
батько
коміт
c02568e270
2 змінених файлів з 34 додано та 39 видалено
  1. 30 35
      Controller/DetectController.py
  2. 4 4
      Controller/DetectControllerV2.py

+ 30 - 35
Controller/DetectController.py

@@ -105,7 +105,6 @@ class NotificationView(View):
         # 数据库读取数据
         if have_ykey:
             redis_list = eval(redisObj.get_data(key=ykey))
-            print(have_ykey)
         else:
             # 从数据库查询出来
             uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid,uid_set__detect_status=1). \
@@ -114,6 +113,7 @@ class NotificationView(View):
                        'lang', 'm_code', 'tz', 'uid_set__nickname', 'uid_set__detect_interval', 'uid_set__detect_group',
                        'uid_set__channel')
             print(uid_push_qs)
+
             # 新建一个list接收数据
             redis_list = []
             # 把数据库数据追加进redis_list
@@ -241,7 +241,19 @@ class NotificationView(View):
             userID_id = up["userID_id"]
             int_is_st = int(is_st)
             if userID_id not in userID_ids:
-
+                eq_list.append(Equipment_Info(
+                    userID_id=userID_id,
+                    eventTime=n_time,
+                    eventType=event_type,
+                    devUid=uid,
+                    devNickName=nickname,
+                    Channel=channel,
+                    alarm='Motion \tChannel:{channel}'.format(channel=channel),
+                    is_st=int_is_st,
+                    receiveTime=n_time,
+                    addTime=now_time,
+                    storage_location=1
+                ))
                 if is_sys_msg:
                     sys_msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz,
                                                      event_type=event_type, is_sys=1)
@@ -252,25 +264,10 @@ class NotificationView(View):
                         updTime=now_time,
                         uid=uid,
                         eventType=event_type))
-                else:
-                    eq_list.append(Equipment_Info(
-                        userID_id=userID_id,
-                        eventTime=n_time,
-                        eventType=event_type,
-                        devUid=uid,
-                        devNickName=nickname,
-                        Channel=channel,
-                        alarm='Motion \tChannel:{channel}'.format(channel=channel),
-                        is_st=int_is_st,
-                        receiveTime=n_time,
-                        addTime=now_time,
-                        storage_location=1
-                    ))
                 userID_ids.append(userID_id)
         if is_sys_msg:
             SysMsgModel.objects.bulk_create(sys_msg_list)
-        else:
-            Equipment_Info.objects.bulk_create(eq_list)
+        Equipment_Info.objects.bulk_create(eq_list)
         if is_st == '0' or is_st == '2':
             print("is_st=0or2")
             for up in redis_list:
@@ -476,9 +473,9 @@ class NotificationView(View):
                                    client_cert=os.path.join(BASE_DIR, APNS_CONFIG[appBundleId]['pem_path']))
 
             push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
-                         "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
+                         "received_at": n_time, "sound": "", "uid": uid, "zpush": "1", "channel": channel}
             alert = apns2.PayloadAlert(body=msg_text, title=msg_title)
-            payload = apns2.Payload(alert=alert, custom=push_data)
+            payload = apns2.Payload(alert=alert, custom=push_data, sound="default")
 
             # return uid, channel, appBundleId, str(token_val), event_type, n_time, msg_title,msg_text
             n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
@@ -623,7 +620,19 @@ class PushNotificationView(View):
             tz = ua['tz']
             userID_id = ua["userID_id"]
             if userID_id not in userID_ids:
-
+                eq_list.append(Equipment_Info(
+                    userID_id=userID_id,
+                    eventTime=n_time,
+                    eventType=event_type,
+                    devUid=uid,
+                    devNickName=nickname,
+                    Channel=channel,
+                    alarm='Motion \tChannel:{channel}'.format(channel=channel),
+                    is_st=is_st,
+                    receiveTime=n_time,
+                    addTime=now_time,
+                    storage_location=1
+                ))
                 if is_sys_msg:
                     sys_msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz,
                                                      event_type=event_type, is_sys=1)
@@ -634,20 +643,6 @@ class PushNotificationView(View):
                         updTime=now_time,
                         uid=uid,
                         eventType=event_type))
-                else:
-                    eq_list.append(Equipment_Info(
-                        userID_id=userID_id,
-                        eventTime=n_time,
-                        eventType=event_type,
-                        devUid=uid,
-                        devNickName=nickname,
-                        Channel=channel,
-                        alarm='Motion \tChannel:{channel}'.format(channel=channel),
-                        is_st=is_st,
-                        receiveTime=n_time,
-                        addTime=now_time,
-                        storage_location=1
-                    ))
         if eq_list:
             print('eq_list')
             Equipment_Info.objects.bulk_create(eq_list)

+ 4 - 4
Controller/DetectControllerV2.py

@@ -416,9 +416,9 @@ class NotificationView(View):
                                    client_cert=os.path.join(BASE_DIR, APNS_CONFIG[appBundleId]['pem_path']))
 
             push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
-                         "received_at": n_time, "sound": "default", "uid": uid, "zpush": "1", "channel": channel}
+                         "received_at": n_time, "sound": "", "uid": uid, "zpush": "1", "channel": channel}
             alert = apns2.PayloadAlert(body=msg_text, title=msg_title)
-            payload = apns2.Payload(alert=alert, custom=push_data)
+            payload = apns2.Payload(alert=alert, custom=push_data, sound="default")
 
             # return uid, channel, appBundleId, str(token_val), event_type, n_time, msg_title,msg_text
             n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
@@ -925,9 +925,9 @@ class PWnotificationView(View):
                                    client_cert=os.path.join(BASE_DIR, APNS_CONFIG[appBundleId]['pem_path']))
 
             push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
-                         "received_at": n_time, "sound": "default", "uid": uid, "zpush": "1", "channel": channel}
+                         "received_at": n_time, "sound": "", "uid": uid, "zpush": "1", "channel": channel}
             alert = apns2.PayloadAlert(body=msg_text, title=msg_title)
-            payload = apns2.Payload(alert=alert, custom=push_data)
+            payload = apns2.Payload(alert=alert, custom=push_data, sound="default")
 
             # return uid, channel, appBundleId, str(token_val), event_type, n_time, msg_title,msg_text
             n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)