Browse Source

发送mqtt失败不更新AI状态

peng 1 year ago
parent
commit
f4d2b487e4
1 changed files with 2 additions and 1 deletions
  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
                 uid_set_id = uid_set_qs.id
 
 
             qs_data['detect_status'] = status  # ai开关状态
             qs_data['detect_status'] = status  # ai开关状态
-            ai_service_qs.update(**qs_data)
             thing_name = CommonService.query_serial_with_uid(uid)  # 存在序列号则为使用序列号作为物品名
             thing_name = CommonService.query_serial_with_uid(uid)  # 存在序列号则为使用序列号作为物品名
             topic_name = 'ansjer/generic/{}'.format(thing_name)
             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)
                 req_success = CommonService.req_publish_mqtt_msg(thing_name, topic_name, msg)
                 if not req_success:
                 if not req_success:
                     return response.json(10044)
                     return response.json(10044)
+                ai_service_qs.update(**qs_data)
                 return response.json(0)
                 return response.json(0)
             elif status == 1:  # 开启
             elif status == 1:  # 开启
                 # 更新或创建uid_push数据
                 # 更新或创建uid_push数据
@@ -587,6 +587,7 @@ class AiView(View):
                 req_success = CommonService.req_publish_mqtt_msg(thing_name, topic_name, msg)
                 req_success = CommonService.req_publish_mqtt_msg(thing_name, topic_name, msg)
                 if not req_success:
                 if not req_success:
                     return response.json(10044)
                     return response.json(10044)
+                ai_service_qs.update(**qs_data)
                 return response.json(0, {'aiIdentificationUrl': aiIdentificationUrl, 'endTime': endTime, 'etk': etk})
                 return response.json(0, {'aiIdentificationUrl': aiIdentificationUrl, 'endTime': endTime, 'etk': etk})
         except Exception as e:
         except Exception as e:
             return response.json(500, repr(e))
             return response.json(500, repr(e))