|
@@ -3,8 +3,9 @@
|
|
import json
|
|
import json
|
|
import time
|
|
import time
|
|
from datetime import datetime
|
|
from datetime import datetime
|
|
-from src.core.callcenter.constant import saasId, get_record_prefix
|
|
|
|
-from src.core.callcenter.enumeration import NextType, AnswerFlag, Direction, DeviceType, AgentScene, CdrType
|
|
|
|
|
|
+from src.core.callcenter.constant import saasId, get_record_prefix, get_record_file_name
|
|
|
|
+from src.core.callcenter.enumeration import NextType, AnswerFlag, Direction, DeviceType, AgentScene, CdrType, CallType, \
|
|
|
|
+ CallStage
|
|
from src.core.callcenter.esl.annotation import EslEventName
|
|
from src.core.callcenter.esl.annotation import EslEventName
|
|
import src.core.callcenter.esl.utils.esl_event_util as EslEventUtil
|
|
import src.core.callcenter.esl.utils.esl_event_util as EslEventUtil
|
|
from src.core.callcenter.esl.constant.event_names import CHANNEL_ANSWER
|
|
from src.core.callcenter.esl.constant.event_names import CHANNEL_ANSWER
|
|
@@ -39,7 +40,9 @@ class ChannelAnswerHandler(EslEventHandler):
|
|
if not next_command:
|
|
if not next_command:
|
|
return
|
|
return
|
|
|
|
|
|
|
|
+
|
|
if device_info.device_type == DeviceType.CUSTOMER.code:
|
|
if device_info.device_type == DeviceType.CUSTOMER.code:
|
|
|
|
+ self.record(event, device_id)
|
|
self.push_handler.push_on_ring_start(saas_id=call_info.saas_id, flow_id=call_info.cti_flow_id, user_id=call_info.agent_key, scene=AgentScene.MANUAL, call_id=call_info.call_id)
|
|
self.push_handler.push_on_ring_start(saas_id=call_info.saas_id, flow_id=call_info.cti_flow_id, user_id=call_info.agent_key, scene=AgentScene.MANUAL, call_id=call_info.call_id)
|
|
|
|
|
|
device_info.answer_time = EslEventUtil.getEventDateTimestamp(event)
|
|
device_info.answer_time = EslEventUtil.getEventDateTimestamp(event)
|
|
@@ -48,7 +51,7 @@ class ChannelAnswerHandler(EslEventHandler):
|
|
call_info.next_commands.remove(next_command)
|
|
call_info.next_commands.remove(next_command)
|
|
|
|
|
|
if NextType.NEXT_CALL_OTHER.code == next_command.next_type:
|
|
if NextType.NEXT_CALL_OTHER.code == next_command.next_type:
|
|
- self.call_other(call_info, device_info)
|
|
|
|
|
|
+ self.call_other(call_info, device_info, event)
|
|
elif NextType.NEXT_CALL_BRIDGE.code == next_command.next_type:
|
|
elif NextType.NEXT_CALL_BRIDGE.code == next_command.next_type:
|
|
self.call_bridge(call_info, device_info, next_command, event)
|
|
self.call_bridge(call_info, device_info, next_command, event)
|
|
elif NextType.NEXT_TRANSFER_CALL.code == next_command.next_type:
|
|
elif NextType.NEXT_TRANSFER_CALL.code == next_command.next_type:
|
|
@@ -59,16 +62,15 @@ class ChannelAnswerHandler(EslEventHandler):
|
|
self.logger.warn("can not match command :%s, callId :%s", next_command.next_type, call_id)
|
|
self.logger.warn("can not match command :%s, callId :%s", next_command.next_type, call_id)
|
|
self.cache.add_call_info(call_info)
|
|
self.cache.add_call_info(call_info)
|
|
|
|
|
|
- def call_other(self, call: CallInfo, device: DeviceInfo):
|
|
|
|
|
|
+ def call_other(self, call: CallInfo, device: DeviceInfo, event):
|
|
call_id = call.call_id
|
|
call_id = call.call_id
|
|
device_id = device.device_id
|
|
device_id = device.device_id
|
|
|
|
|
|
# 启用录音, 生产时候打开
|
|
# 启用录音, 生产时候打开
|
|
- record = get_record_prefix(call) + '/' + call_id + '.wav'
|
|
|
|
- self.inbound_client.record(device.device_id, 'start', record, 0)
|
|
|
|
- device.record = record
|
|
|
|
|
|
+ record_url = self.record(event, device_id)
|
|
|
|
+ device.record = record_url
|
|
device.record_start_time = device.answer_time
|
|
device.record_start_time = device.answer_time
|
|
- self.dataHandleServer.update_record(call_id, {"url": record})
|
|
|
|
|
|
+ self.dataHandleServer.update_record(call_id, {"url": record_url})
|
|
|
|
|
|
call.direction = Direction.OUTBOUND.code
|
|
call.direction = Direction.OUTBOUND.code
|
|
call.answer_flag = AnswerFlag.AGENT_ANSWER.code
|
|
call.answer_flag = AnswerFlag.AGENT_ANSWER.code
|
|
@@ -100,6 +102,7 @@ class ChannelAnswerHandler(EslEventHandler):
|
|
def call_bridge(self, call: CallInfo, device: DeviceInfo, next_command: NextCommand, event):
|
|
def call_bridge(self, call: CallInfo, device: DeviceInfo, next_command: NextCommand, event):
|
|
self.logger.info("开始桥接电话: callId:%s, caller:%s, called:%s, device1:%s, device2:%s"% (call.call_id,
|
|
self.logger.info("开始桥接电话: callId:%s, caller:%s, called:%s, device1:%s, device2:%s"% (call.call_id,
|
|
call.caller, call.called, next_command.device_id, next_command.next_value))
|
|
call.caller, call.called, next_command.device_id, next_command.next_value))
|
|
|
|
+ self.record(event, device_id=device.device_id)
|
|
device1 = call.device_info_map.get(next_command.device_id)
|
|
device1 = call.device_info_map.get(next_command.device_id)
|
|
device2 = call.device_info_map.get(next_command.next_value)
|
|
device2 = call.device_info_map.get(next_command.next_value)
|
|
|
|
|
|
@@ -115,6 +118,7 @@ class ChannelAnswerHandler(EslEventHandler):
|
|
# 转接电话 deviceInfo为被转接设备
|
|
# 转接电话 deviceInfo为被转接设备
|
|
from_device_id = next_command.device_id
|
|
from_device_id = next_command.device_id
|
|
device_id = EslEventUtil.getDeviceId(event)
|
|
device_id = EslEventUtil.getDeviceId(event)
|
|
|
|
+ self.record(event, device_id)
|
|
call.next_commands.append(NextCommand(device_id, NextType.NEXT_TRANSFER_SUCCESS.code, call.device_list[1]))
|
|
call.next_commands.append(NextCommand(device_id, NextType.NEXT_TRANSFER_SUCCESS.code, call.device_list[1]))
|
|
self.logger.info("转接电话中 callId:%s, from:%s, to:%s "% (call.call_id, from_device_id, device_id))
|
|
self.logger.info("转接电话中 callId:%s, from:%s, to:%s "% (call.call_id, from_device_id, device_id))
|
|
self.inbound_client.transfer_call(device_id, next_command.next_value)
|
|
self.inbound_client.transfer_call(device_id, next_command.next_value)
|
|
@@ -126,3 +130,21 @@ class ChannelAnswerHandler(EslEventHandler):
|
|
self.logger.info("开始监听 callId:%s, deviceId:%s, nextCommandDeviceId:%s", call.call_id, device_id, next_command.next_value)
|
|
self.logger.info("开始监听 callId:%s, deviceId:%s, nextCommandDeviceId:%s", call.call_id, device_id, next_command.next_value)
|
|
self.inbound_client.listen(device_id, next_command.next_value)
|
|
self.inbound_client.listen(device_id, next_command.next_value)
|
|
|
|
|
|
|
|
+ def record(self, event, device_id):
|
|
|
|
+ call_id = EslEventUtil.getCallId(event)
|
|
|
|
+ call = self.cache.get_call_info(call_id)
|
|
|
|
+ if not call:
|
|
|
|
+ self.logger.info("answer callInfo is null,call_id:%s"%call_id)
|
|
|
|
+ return
|
|
|
|
+
|
|
|
|
+ device =call.device_info_map.get(device_id)
|
|
|
|
+ if not device:
|
|
|
|
+ self.logger.info("answer deviceInfo is null,call_id:%s, device_id:%s"%(call_id, device_id))
|
|
|
|
+ return
|
|
|
|
+
|
|
|
|
+ return self.start_recording(device_id, get_record_file_name(call_id, CallStage.ALL), call)
|
|
|
|
+
|
|
|
|
+ def start_recording(self, device_id, file_name, call: CallInfo):
|
|
|
|
+ record_url = get_record_prefix(call) + '/' + file_name + '.wav'
|
|
|
|
+ self.inbound_client.record(device_id, 'start', record_url, 0)
|
|
|
|
+ return record_url
|