|
@@ -506,22 +506,22 @@ class CronUpdateDataView(View):
|
|
|
expired_uid_bucket = expired_uid_bucket.filter(~Q(use_status=2)).values('id')
|
|
|
if expired_uid_bucket.exists():
|
|
|
# 如果没有未使用套餐,或下个未使用套餐不是AI云存套餐,mqtt下发停用AI指令
|
|
|
+ # 下个未使用套餐是AI云存套餐,mqtt下发启用AI指令
|
|
|
for bucket in expired_uid_bucket:
|
|
|
uid_bucket = UID_Bucket.objects.get(id=bucket['id'])
|
|
|
uid = uid_bucket.uid
|
|
|
+ # 存在序列号则为使用序列号作为物品名
|
|
|
+ thing_name = CommonService.query_serial_with_uid(uid)
|
|
|
+ topic_name = 'ansjer/generic/{}'.format(thing_name)
|
|
|
+ msg = {'commandType': 'AIDisable'}
|
|
|
if not uid_bucket.has_unused:
|
|
|
- # 存在序列号则为使用序列号作为物品名
|
|
|
- thing_name = CommonService.query_serial_with_uid(uid)
|
|
|
- topic_name = 'ansjer/generic/{}'.format(thing_name)
|
|
|
- msg = {'commandType': 'AIDisable'}
|
|
|
CommonService.req_publish_mqtt_msg(thing_name, topic_name, msg)
|
|
|
else:
|
|
|
next_unused = Unused_Uid_Meal.objects.filter(uid=uid).order_by('addTime').first()
|
|
|
if next_unused is None or not getattr(next_unused, 'is_ai', 0):
|
|
|
- # 存在序列号则为使用序列号作为物品名
|
|
|
- thing_name = CommonService.query_serial_with_uid(uid)
|
|
|
- topic_name = 'ansjer/generic/{}'.format(thing_name)
|
|
|
- msg = {'commandType': 'AIDisable'}
|
|
|
+ CommonService.req_publish_mqtt_msg(thing_name, topic_name, msg)
|
|
|
+ else:
|
|
|
+ msg = {'commandType': 'AIEnable'}
|
|
|
CommonService.req_publish_mqtt_msg(thing_name, topic_name, msg)
|
|
|
expired_uid_bucket.update(use_status=2)
|
|
|
|