Browse Source

Merge branch 'develop' of ssh://gitlab.fuxicarbon.com:1111/client_service/voice-gateway-service into develop

DavidLiu 4 months ago
parent
commit
6d14aa60c8
1 changed files with 8 additions and 6 deletions
  1. 8 6
      src/core/callcenter/esl/handler/channel_hangup_handler.py

+ 8 - 6
src/core/callcenter/esl/handler/channel_hangup_handler.py

@@ -157,16 +157,18 @@ class ChannelHangupHandler(EslEventHandler):
             sip_status.append(value.sip_status)
             hangup_cause.append(value.hangup_cause)
         self.logger.info("get_call_info_record: %s", records)
-        if records:
-           threading.Thread(target=self._update_record_in_thread, args=(call_info.call_id, records, ",".join(sip_status), ",".join(hangup_cause))).start()
-        else:
-            self.logger.warning("没有找到有效的录音文件")
+        threading.Thread(target=self._update_record_in_thread, args=(call_info.call_id, records, ",".join(sip_status), ",".join(hangup_cause),call_info.answer_count)).start()
 
-    def _update_record_in_thread(self, call_id, records, sip_status, hangup_cause):
+    def _update_record_in_thread(self, call_id, records, sip_status, hangup_cause, answer_count):
         """用于在独立线程中执行 update_record"""
         try:
+            status = 0 if answer_count <= 0 else 1
+            if len(records) == 0:
+                self.logger.warning("没有录音文件,直接更新记录: call_id=%s, sip_status=%s, hangup_cause=%s", call_id, sip_status, hangup_cause)
+                self.dataHandleServer.update_record(call_id, time_end=datetime.now(), sip_status=sip_status, sip_hangup_cause=hangup_cause, status=status)
+                return
             merge_record = self.merge_audio_files(records) if len(records) > 1 else records[0]
-            self.dataHandleServer.update_record(call_id, time_end=datetime.now(), url=merge_record, sip_status=sip_status, sip_hangup_cause=hangup_cause)
+            self.dataHandleServer.update_record(call_id, time_end=datetime.now(), url=merge_record, sip_status=sip_status, sip_hangup_cause=hangup_cause, status=status)
             self.logger.info("更新录音记录完成: call_id=%s", call_id)
         except Exception as e:
             self.logger.error("更新录音记录失败: call_id=%s, error=%s", call_id, str(e))