Browse Source

修改查询语音的异常

tanghongbin 4 năm trước cách đây
mục cha
commit
e921732d40
1 tập tin đã thay đổi với 8 bổ sung11 xóa
  1. 8 11
      Controller/VoicePromptController.py

+ 8 - 11
Controller/VoicePromptController.py

@@ -176,14 +176,16 @@ class VoicePromptView(View):
                 'voice_status': 0,
                 'voice_mute': 0
             }
+            enter_voice_id = 0
+            leave_voice_id = 0
             if channel_qs.exists():
                 channel_qs = channel_qs.values('voice_prompt_enter', 'voice_prompt_leave', 'voice_prompt_status',
                                                'voice_prompt_intelligent_mute', 'voice_start_x', 'voice_start_y',
                                                'voice_end_x', 'voice_end_y', 'voice_start_time', 'voice_end_time',
                                                'voice_repeat_day', 'voice_direction')
                 print(channel_qs)
-                res['enter_voice'] = int(channel_qs[0]['voice_prompt_enter'])
-                res['leave_voice'] = int(channel_qs[0]['voice_prompt_leave'])
+                enter_voice_id = int(channel_qs[0]['voice_prompt_enter'])
+                leave_voice_id = int(channel_qs[0]['voice_prompt_leave'])
                 res['voice_status'] = channel_qs[0]['voice_prompt_status']
                 res['voice_mute'] = channel_qs[0]['voice_prompt_intelligent_mute']
                 res['start_x'] = channel_qs[0]['voice_start_x']
@@ -214,12 +216,12 @@ class VoicePromptView(View):
                     del system['filename']
                     if system['type'] == 0:
                         enter_systems.append(system)
-                        if res['enter_voice'] == system['id']:
+                        if enter_voice_id == system['id']:
                             res['enter_voice'] = system
 
                     elif system['type'] == 1:
                         leave_systems.append(system)
-                        if res['leave_voice'] == system['id']:
+                        if leave_voice_id == system['id']:
                             res['leave_voice'] = system
 
             if voice_qs.exists():
@@ -233,18 +235,13 @@ class VoicePromptView(View):
                     del voice['filename']
                     if voice['type'] == 0:
                         enter_customs.append(voice)
-                        if res['enter_voice'] == voice['id']:
+                        if enter_voice_id == voice['id']:
                             res['enter_voice'] = voice
                     elif voice['type'] == 1:
                         leave_customs.append(voice)
-                        if res['leave_voice'] == voice['id']:
+                        if leave_voice_id == voice['id']:
                             res['leave_voice'] = voice
 
-            if res['leave_voice'] == 0:
-                res['leave_voice'] = {}
-            if res['enter_voice'] == 0:
-                res['enter_voice'] = {}
-
             res['system']['enter'] = enter_systems
             res['system']['leave'] = leave_systems
             res['custom']['enter'] = enter_customs