Sfoglia il codice sorgente

修复同步代码遗留的问题

lang 3 anni fa
parent
commit
793973b0c9
1 ha cambiato i file con 33 aggiunte e 28 eliminazioni
  1. 33 28
      Controller/DetectController.py

+ 33 - 28
Controller/DetectController.py

@@ -105,6 +105,7 @@ 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). \
@@ -113,7 +114,6 @@ 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,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)