Ver código fonte

userIDS_set_list

chenjunkai 6 anos atrás
pai
commit
f1693821ef
1 arquivos alterados com 17 adições e 14 exclusões
  1. 17 14
      Controller/DetectController.py

+ 17 - 14
Controller/DetectController.py

@@ -493,21 +493,24 @@ class NotificationView(View):
         qs_list = []
         nowTime = int(time.time())
         # 设备昵称
-
+        userID_ids = []
         for dv in uaqs:
-            add_data = {
-                'userID_id': dv["userID_id"],
-                'eventTime': n_time,
-                'eventType': event_type,
-                'devUid': uid,
-                'devNickName': uid,
-                'Channel': channel,
-                'alarm': 'Motion \tChannel:{channel}'.format(channel=channel),
-                'is_st': int(is_st),
-                'receiveTime': n_time,
-                'addTime': nowTime
-            }
-            qs_list.append(Equipment_Info(**add_data))
+            userID_id = dv["userID_id"]
+            if userID_id not in userID_ids:
+                add_data = {
+                    'userID_id': dv["userID_id"],
+                    'eventTime': n_time,
+                    'eventType': event_type,
+                    'devUid': uid,
+                    'devNickName': uid,
+                    'Channel': channel,
+                    'alarm': 'Motion \tChannel:{channel}'.format(channel=channel),
+                    'is_st': int(is_st),
+                    'receiveTime': n_time,
+                    'addTime': nowTime
+                }
+                qs_list.append(Equipment_Info(**add_data))
+                userID_ids.append(userID_id)
         if qs_list:
             print(1)
             Equipment_Info.objects.bulk_create(qs_list)