|
@@ -13,7 +13,8 @@ from django.db.models import F, Q, Count
|
|
from django.views import View
|
|
from django.views import View
|
|
|
|
|
|
from Ansjer.Config.gatewaySensorConfig import SMART_SCENE_TOPIC, SENSOR_TYPE, EVENT_TYPE, SCENE_EVENT_CREATE, \
|
|
from Ansjer.Config.gatewaySensorConfig import SMART_SCENE_TOPIC, SENSOR_TYPE, EVENT_TYPE, SCENE_EVENT_CREATE, \
|
|
- SCENE_EVENT_EDIT, SCENE_EVENT_DELETE, SCENE_STATUS_ON, SCENE_STATUS_OFF, SCENE_EVENT_EDIT_STATUS
|
|
|
|
|
|
+ SCENE_EVENT_EDIT, SCENE_EVENT_DELETE, SCENE_STATUS_ON, SCENE_STATUS_OFF, SCENE_EVENT_EDIT_STATUS, \
|
|
|
|
+ VOICE_AUDITION_TOPIC
|
|
from Model.models import FamilyRoomDevice, GatewaySubDevice, FamilyRoom, SmartScene, EffectiveTime, Device_Info, \
|
|
from Model.models import FamilyRoomDevice, GatewaySubDevice, FamilyRoom, SmartScene, EffectiveTime, Device_Info, \
|
|
SceneLog
|
|
SceneLog
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.ResponseObject import ResponseObject
|
|
@@ -992,30 +993,28 @@ class SmartSceneView(View):
|
|
except Exception as e:
|
|
except Exception as e:
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
- @classmethod
|
|
|
|
- def voice_audition(cls, request_dict, response):
|
|
|
|
|
|
+ @staticmethod
|
|
|
|
+ def voice_audition(request_dict, response):
|
|
"""
|
|
"""
|
|
智能场景音频试听
|
|
智能场景音频试听
|
|
@param request_dict: 请求参数
|
|
@param request_dict: 请求参数
|
|
- @request_dict deviceId: 网关设备id
|
|
|
|
- @request_dict subDeviceId: 子设备id
|
|
|
|
|
|
+ @request_dict serial_number: 序列号
|
|
@request_dict voiceId: 音频id
|
|
@request_dict voiceId: 音频id
|
|
@param response: 响应对象
|
|
@param response: 响应对象
|
|
@return: response
|
|
@return: response
|
|
"""
|
|
"""
|
|
- device_id = request_dict.get('deviceId', None)
|
|
|
|
- sub_device_id = request_dict.get('subDeviceId', None)
|
|
|
|
|
|
+ serial_number = request_dict.get('serial_number', None)
|
|
voice_id = request_dict.get('voiceId', None)
|
|
voice_id = request_dict.get('voiceId', None)
|
|
- if not any([device_id, sub_device_id]) or voice_id is None:
|
|
|
|
|
|
+ if not all([serial_number, voice_id]):
|
|
return response.json(444)
|
|
return response.json(444)
|
|
try:
|
|
try:
|
|
- if sub_device_id:
|
|
|
|
- device_id = GatewaySubDevice.objects.get(id=sub_device_id).device_id
|
|
|
|
- gateway_sub_device_qs = GatewaySubDevice.objects.filter(device_id=device_id)
|
|
|
|
- if not gateway_sub_device_qs.exists():
|
|
|
|
- return response.json(173)
|
|
|
|
- # 查询序列号
|
|
|
|
-
|
|
|
|
|
|
+ topic_name = VOICE_AUDITION_TOPIC.format(serial_number)
|
|
|
|
+ msg = {'voice_id': int(voice_id)}
|
|
|
|
+ success = CommonService.req_publish_mqtt_msg(serial_number, topic_name, msg)
|
|
|
|
+ try:
|
|
|
|
+ assert success
|
|
|
|
+ except AssertionError:
|
|
|
|
+ return response.json(10044)
|
|
return response.json(0)
|
|
return response.json(0)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|