浏览代码

发送mqtt失败时,不更新AI状态

peng 1 年之前
父节点
当前提交
e55b9e76a5
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      Controller/AiController.py

+ 2 - 1
Controller/AiController.py

@@ -533,7 +533,6 @@ class AiView(View):
                 uid_set_id = uid_set_qs.id
 
             qs_data['detect_status'] = status  # ai开关状态
-            ai_service_qs.update(**qs_data)
             thing_name = CommonService.query_serial_with_uid(uid)  # 存在序列号则为使用序列号作为物品名
             topic_name = 'ansjer/generic/{}'.format(thing_name)
 
@@ -543,6 +542,7 @@ class AiView(View):
                 req_success = CommonService.req_publish_mqtt_msg(thing_name, topic_name, msg)
                 if not req_success:
                     return response.json(10044)
+                ai_service_qs.update(**qs_data)
                 return response.json(0)
             elif status == 1:  # 开启
                 # 更新或创建uid_push数据
@@ -587,6 +587,7 @@ class AiView(View):
                 req_success = CommonService.req_publish_mqtt_msg(thing_name, topic_name, msg)
                 if not req_success:
                     return response.json(10044)
+                ai_service_qs.update(**qs_data)
                 return response.json(0, {'aiIdentificationUrl': aiIdentificationUrl, 'endTime': endTime, 'etk': etk})
         except Exception as e:
             return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))