Browse Source

修改保存系统表时就不保存到消息表

chenshibin 4 years ago
parent
commit
d93262d106
1 changed files with 32 additions and 27 deletions
  1. 32 27
      Controller/DetectControllerV2.py

+ 32 - 27
Controller/DetectControllerV2.py

@@ -286,19 +286,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=2
-                ))
+
                 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)
@@ -309,10 +297,26 @@ 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=2
+                    ))
                 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)
+
         logger.info("图片信息上传到数据库了")
         if is_st == '0' or is_st == '2':
             logger.info("进到is_st为0或2")
@@ -784,19 +788,6 @@ 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=2
-                ))
                 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)
@@ -807,6 +798,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=2
+                    ))
         if eq_list:
             print('eq_list')
             Equipment_Info.objects.bulk_create(eq_list)