DavidLiu пре 3 месеци
родитељ
комит
165d1fb298

+ 3 - 0
src/core/callcenter/dao.py

@@ -450,6 +450,8 @@ class CallRecord(db.Model):
     times = db.Column(db.String(30), nullable=True, comment='通话时长(暂时按字符串接收)')
     category = db.Column(db.SmallInteger, nullable=True, comment='通话类型(0呼入 1呼出)')
     status = db.Column(db.SmallInteger, nullable=True, comment='通话状态(0未接听 1已接通)')
+    sip_status = db.Column(db.String(32), nullable=True, comment='sip码')
+    sip_hangup_cause = db.Column(db.String(32), nullable=True, comment='sip挂机描述')
     phone = db.Column(db.String(20), nullable=True, comment='电话号码')
     bussiness_type = db.Column(db.String(50), nullable=True, comment='业务类型(创个返回字符串)')
     url = db.Column(db.String(255), nullable=True, comment='录音的地址')
@@ -458,6 +460,7 @@ class CallRecord(db.Model):
     parsed_voice_content = db.Column(db.Text, nullable=True, comment='通话录音内容')
     del_flag = db.Column(db.SmallInteger, nullable=False, default=0, comment='删除标志(0代表存在 2代表删除)')
     revision = db.Column(db.Integer, nullable=True, comment='乐观锁')
+
     create_by = db.Column(db.String(32), nullable=True, default="admin", comment='创建人')
     create_time = db.Column(db.DateTime, nullable=True, default=datetime.now, comment='创建时间')
     update_by = db.Column(db.String(32), nullable=True, default="admin", comment='更新人')

+ 3 - 3
src/core/callcenter/esl/client.py

@@ -182,9 +182,9 @@ class InboundClient:
             #         delay_action = DelayAction(call_id=call_id, device_id=device_id)
             #         self.cache.add_delay_message(DelayActionEnum.CALL_TIMEOUT_DECR, delay_action, timeouts=20)
 
-            # self.cache.add_call_info(call_info)
-            # self.hangup_call(call_id, device_id, CallCause.CALL_TIMEOUT)
-            # self.dataHandleServer.update_record(call_id, status= 0)
+            self.cache.add_call_info(call_info)
+            self.hangup_call(call_id, device_id, CallCause.CALL_TIMEOUT)
+            self.dataHandleServer.update_record(call_id, status= 0)
 
     def exec_when_play_timeout(self, call_id):
         call_info = self.cache.get_call_info(call_id)

+ 5 - 5
src/core/callcenter/esl/handler/channel_hangup_handler.py

@@ -134,7 +134,7 @@ class ChannelHangupHandler(EslEventHandler):
             # 全部挂机以后推送挂机状态
             # self.logger.info('yushanghui::call_info.device_list %s', call_info.device_list)
             if len(call_info.device_list) == 0:
-                self.get_call_info_record(call_info)
+                self.get_call_info_record(call_info, device_info)
 
             # 判断挂机方向 && 更新缓存
             self.hangup_dir(call_info, device_info, cause)
@@ -143,21 +143,21 @@ class ChannelHangupHandler(EslEventHandler):
         except:
             traceback.print_exc()
 
-    def get_call_info_record(self, call_info):
+    def get_call_info_record(self, call_info, device_info):
         records = []
         for value in call_info.device_info_map.values():
             records.append(value.record) if value.record else None
         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)).start()
+           threading.Thread(target=self._update_record_in_thread, args=(call_info.call_id, records, device_info.sip_status, device_info.hangup_cause)).start()
         else:
             self.logger.warning("没有找到有效的录音文件")
 
-    def _update_record_in_thread(self, call_id, records):
+    def _update_record_in_thread(self, call_id, records, sip_status, hangup_cause):
         """用于在独立线程中执行 update_record"""
         try:
             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)
+            self.dataHandleServer.update_record(call_id, time_end=datetime.now(), url=merge_record, sip_status=sip_status, sip_hangup_cause=hangup_cause)
             self.logger.info("更新录音记录完成: call_id=%s", call_id)
         except Exception as e:
             self.logger.error("更新录音记录失败: call_id=%s, error=%s", call_id, str(e))