|
@@ -152,20 +152,30 @@ class ChannelHangupHandler(EslEventHandler):
|
|
|
records = []
|
|
|
sip_status = []
|
|
|
hangup_cause = []
|
|
|
+ agent_name = ''
|
|
|
for value in call_info.device_info_map.values():
|
|
|
records.append(value.record) if value.record else None
|
|
|
sip_status.append(value.sip_status)
|
|
|
hangup_cause.append(value.hangup_cause)
|
|
|
- self.logger.info("get_call_info_record: %s", records)
|
|
|
- threading.Thread(target=self._update_record_in_thread, args=(call_info.call_id, list(set(records)), ",".join(sip_status), ",".join(hangup_cause),call_info.answer_count)).start()
|
|
|
+ if value.device_type == DeviceType.AGENT.code :
|
|
|
+ agent_name = value.agent_key
|
|
|
+ self.logger.info("get_call_info_record: %s,agent_name:%s", records, agent_name)
|
|
|
+ threading.Thread(target=self._update_record_in_thread, args=(call_info.call_id, list(set(records)), ",".join(sip_status), ",".join(hangup_cause), agent_name)).start()
|
|
|
|
|
|
- def _update_record_in_thread(self, call_id, records, sip_status, hangup_cause, answer_count):
|
|
|
+ def update_name(self,call_id, agent_name):
|
|
|
+ try:
|
|
|
+ agent = self.dataHandleServer.get_user_name(agent_name)
|
|
|
+ return agent
|
|
|
+ except Exception as e:
|
|
|
+ self.logger.error("update_name error: %s", str(e))
|
|
|
+ def _update_record_in_thread(self, call_id, records, sip_status, hangup_cause, agent_name):
|
|
|
"""用于在独立线程中执行 update_record"""
|
|
|
try:
|
|
|
+ agent = self.update_name(call_id, agent_name)
|
|
|
# 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)
|
|
|
+ self.logger.warning("没有录音文件,直接更新记录: call_id=%s, sip_status=%s, hangup_cause=%s, agent_name=%s", call_id, sip_status, hangup_cause,agent_name)
|
|
|
+ self.dataHandleServer.update_record(call_id, time_end=datetime.now(), sip_status=sip_status, sip_hangup_cause=hangup_cause,user_id=agent.user_id, user_name=agent.agent_name)
|
|
|
return
|
|
|
merge_record = self.merge_audio_files(records) if len(records) > 1 else records[0]
|
|
|
# try:
|
|
@@ -175,7 +185,7 @@ class ChannelHangupHandler(EslEventHandler):
|
|
|
# except Exception as chmod_error:
|
|
|
# self.logger.error("设置文件权限失败: %s, error: %s", merge_record, str(chmod_error))
|
|
|
|
|
|
- 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,user_id=agent.user_id, user_name=agent.agent_name)
|
|
|
self.logger.info("更新录音记录完成: call_id=%s", call_id)
|
|
|
except Exception as e:
|
|
|
self.logger.error("更新录音记录失败: call_id=%s, error=%s", call_id, str(e))
|