소스 검색

修复设置ai开关影响移动侦测开关的问题

locky 3 년 전
부모
커밋
fbba0aa2d6
1개의 변경된 파일8개의 추가작업 그리고 15개의 파일을 삭제
  1. 8 15
      Controller/AiController.py

+ 8 - 15
Controller/AiController.py

@@ -132,24 +132,19 @@ class AiView(View):
         status = request_dict.get('status', None)
         m_code = request_dict.get('m_code', None)
         uid = request_dict.get('uid', None)
-        # 设备语言
         lang = request_dict.get('lang', 'en')
         tz = request_dict.get('tz', '0')
-        # 消息提醒功能新增
-
-        # 如果传空上来,就默认为0
-        if tz == '':
-            tz = 0
-        else:
-            tz = tz.replace("GMT", "")
         detect_group = request_dict.get('detect_group', None)
         interval = request_dict.get('interval', None)
+
         if not status:
             return response.json(444, 'status')
         # 关闭推送
         if not all([appBundleId, app_type, token_val, uid, m_code]):
             return response.json(444, 'appBundleId,app_type,token_val,uid,m_code')
 
+        # 如果传空上来,就默认为0
+        tz = 0 if tz == '' else tz.replace("GMT", "")
         # 判断推送类型对应key是否存在
         if push_type == '0':
             if appBundleId not in APNS_CONFIG.keys():
@@ -164,11 +159,11 @@ class AiView(View):
             return response.json(173)
 
         try:
-            hasAiService = AiService.objects.filter(uid=uid, use_status=1)
-            if not hasAiService.exists():
+            ai_service_qs = AiService.objects.filter(uid=uid, use_status=1)
+            if not ai_service_qs.exists():
                 return response.json(10053)
             nowTime = int(time.time())
-            endTime = hasAiService.values('endTime')[0]['endTime']
+            endTime = ai_service_qs.values('endTime')[0]['endTime']
             if nowTime > endTime:
                 return response.json(10054)
 
@@ -181,7 +176,6 @@ class AiView(View):
             if uid_set_qs.exists():
                 uid_set_id = uid_set_qs[0].id
                 qs_data = {
-                    'detect_status': status,
                     'updTime': nowTime,
                 }
                 if interval:
@@ -192,7 +186,6 @@ class AiView(View):
             else:
                 qs_data = {
                     'uid': uid,
-                    'detect_status': status,
                     'addTime': nowTime,
                     'updTime': nowTime,
                 }
@@ -204,7 +197,8 @@ class AiView(View):
                 uid_set_qs = UidSetModel.objects.create(**qs_data)
                 uid_set_id = uid_set_qs.id
 
-            hasAiService.update(**qs_data)
+            qs_data['detect_status'] = status       # ai开关状态
+            ai_service_qs.update(**qs_data)
             topic_name = 'ansjer/generic/{}'.format(uid)
             if status == 0:     # 关闭
                 # mqtt通知设备关闭AI识别功能
@@ -228,7 +222,6 @@ class AiView(View):
                     }
                     uid_push_qs.update(**uid_push_update_dict)
                 else:
-                    # uid_set_id = uid_set_qs[0].id
                     uid_push_create_dict = {
                         'uid_set_id': uid_set_id,
                         'userID_id': userID,