浏览代码

修复系统消息及移动消息并存问题

chenshibin 4 年之前
父节点
当前提交
9caceb43ad
共有 1 个文件被更改,包括 32 次插入27 次删除
  1. 32 27
      Controller/DetectController.py

+ 32 - 27
Controller/DetectController.py

@@ -241,19 +241,7 @@ 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)
@@ -264,10 +252,25 @@ 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)
-        Equipment_Info.objects.bulk_create(eq_list)
+        else:
+            Equipment_Info.objects.bulk_create(eq_list)
         if is_st == '0' or is_st == '2':
             print("is_st=0or2")
             for up in redis_list:
@@ -620,19 +623,7 @@ 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)
@@ -643,6 +634,20 @@ 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)