774056846 пре 5 месеци
родитељ
комит
75c132dcc4
3 измењених фајлова са 16 додато и 11 уклоњено
  1. 10 6
      src/core/callcenter/api.py
  2. 5 4
      src/core/callcenter/call.py
  3. 1 1
      src/core/callcenter/views.py

+ 10 - 6
src/core/callcenter/api.py

@@ -30,7 +30,7 @@ class AgentCallRequest(BaseApi):
     """
 
     def __init__(self, saas_id, agent_id, call_type: CallType, caller, called, caller_display="", called_display="",
-                 uuid1=None, uuid2=None, follow_data: Dict[str, Any] = {}):
+                 cti_flow_id=None, uuid1=None, uuid2=None, follow_data: Dict[str, Any] = {}):
         # 租户id
         self.saas_id = saas_id
         # 坐席号
@@ -45,6 +45,7 @@ class AgentCallRequest(BaseApi):
         self.caller_display = caller_display
         # 被叫显号,接口没传就用主技能配置
         self.called_display = called_display
+        self.cti_flow_id = cti_flow_id
         # uuid1
         self.uuid1 = uuid1
         # uuid2
@@ -205,7 +206,7 @@ class MakeCallContext(BaseApi):
                  device_type: Optional[int] = None,
                  timeout: Optional[int] = 30,
                  originate_timeout: Optional[int] = 30,
-                 sip_header_map: Optional[Dict[str, str]] = [],
+                 sip_header_map: Optional[Dict[str, str]] = {},
                  called_prefix: Optional[str] = "",
                  service_id: Optional[str] = None,
                  call_type: Optional[int] = None):
@@ -432,7 +433,7 @@ class AgentInfo(BaseApi):
 
 
 class CallInfo(BaseApi):
-    def __init__(self, core_uuid=None, call_id=None, conference=None, saas_id=None, group_id=None,
+    def __init__(self, core_uuid=None, cti_flow_id=None, call_id=None, conference=None, saas_id=None, group_id=None,
                  hidden_customer=0, caller_display=None, caller=None, called_display=None, called=None,
                  number_location=None, agent_key=None, agent_name=None, login_type=None, ivr_id=None, task_id=None,
                  media_host=None, sip_server=None, client_host=None, record=None, record2=None, record_time=None,
@@ -443,6 +444,7 @@ class CallInfo(BaseApi):
                  device_info_map: Dict[str, Any] = {}, follow_data: Dict[str, Any] = {},
                  process_data: Dict[str, Any] = {}, next_commands=[], call_details=[]):
         self.core_uuid = core_uuid  # 通话唯一标识
+        self.cti_flow_id = cti_flow_id
         self.call_id = call_id  # 通话唯一标识
         self.conference = conference  # 会议号
         self.saas_id = saas_id  # 企业id
@@ -501,8 +503,8 @@ class CallInfo(BaseApi):
         next_commands = [NextCommand(**x) for x in data.get('next_commands', [])]
         call_details = [CallDetail(**x) for x in data.get('call_details', [])]
 
-        return cls(core_uuid=data.get('core_uuid'), call_id=data.get('call_id'), conference=data.get('conference'),
-                   saas_id=data.get('saas_id'), group_id=data.get('group_id'),
+        return cls(core_uuid=data.get('core_uuid'), cti_flow_id=data.get('cti_flow_id'), call_id=data.get('call_id'),
+                   conference=data.get('conference'), saas_id=data.get('saas_id'), group_id=data.get('group_id'),
                    hidden_customer=data.get('hidden_customer'), caller_display=data.get('caller_display'),
                    caller=data.get('caller'), called_display=data.get('called_display'), called=data.get('called'),
                    number_location=data.get('number_location'), agent_key=data.get('agent_key'),
@@ -528,6 +530,7 @@ class CallInfo(BaseApi):
     def to_json_string(self):
         new_dict = {
             "core_uuid": self.core_uuid,
+            "cti_flow_id": self.cti_flow_id,
             "call_id": self.call_id,
             "conference": self.conference,
             "saas_id": self.saas_id,
@@ -581,12 +584,13 @@ class CallInfo(BaseApi):
 
 
 class DeviceInfo(BaseApi):
-    def __init__(self, call_id=None, conference=None, device_id=None, agent_key=None, agent_name=None, device_type=None,
+    def __init__(self, cti_flow_id=None, call_id=None, conference=None, device_id=None, agent_key=None, agent_name=None, device_type=None,
                  cdr_type=None, from_agent=None, caller=None, called=None, display=None, called_location=None,
                  caller_location=None, call_time=None, ring_start_time=None, ring_end_time=None, answer_time=None,
                  bridge_time=None, end_time=None, talk_time=None, sip_protocol=None, channel_name=None,
                  hangup_cause=None, ring_cause=None, sip_status=None, record=None, record_time=None,
                  record_start_time=None, state=None, apparent_number=None, caller_display=None):
+        self.cti_flow_id = cti_flow_id
         self.call_id = call_id  # 通话唯一标识
         self.conference = conference  # 会议模式
         self.device_id = device_id  # 设备id

+ 5 - 4
src/core/callcenter/call.py

@@ -8,7 +8,7 @@ from src.core.callcenter.constant import saasId, HOLD_MUSIC_PATH
 from src.core.callcenter.enumeration import CallCause, Direction, NextType, DeviceType, CdrType
 from src.core.callcenter.api import AgentCallRequest, CallInfo, HangupCallRequest, CheckInCallRequest, \
     DeviceInfo, NextCommand, MakeCallContext
-from src.core.callcenter.esl.constant.sip_header_constant import sipHeaderServiceId
+from src.core.callcenter.esl.constant.sip_header_constant import sipHeaderServiceId, sipHeaderCtiFlowId
 from src.core.callcenter.snowflake import Snowflake
 
 
@@ -27,12 +27,12 @@ class CallService:
 
         agent = Cache.get_agent_info(request.saas_id, request.agent_id)
         route_gateway = Cache.get_route_gateway(request.saas_id)
-        call_info = CallInfo(call_id=call_id, agent_key=agent.agent_number, sip_server=agent.sip_server,
+        call_info = CallInfo(cti_flow_id=request.cti_flow_id, call_id=call_id, agent_key=agent.agent_number, sip_server=agent.sip_server,
                              caller=agent.agent_number, called=request.called, direction=Direction.INBOUND.code,
                              caller_display=request.caller_display, called_display=request.called_display,
                              call_type=request.call_type.code, call_time=now, follow_data=request.follow_data,
                              uuid1=request.uuid1, uuid2=request.uuid2, saas_id=saasId)
-        device_info = DeviceInfo(device_id=device_id, call_time=now, call_id=call_id, device_type=DeviceType.AGENT.code,
+        device_info = DeviceInfo(cti_flow_id=request.cti_flow_id, device_id=device_id, call_time=now, call_id=call_id, device_type=DeviceType.AGENT.code,
                                  agent_key=agent.agent_number, caller_display=route_gateway.name)
         call_info.device_list.append(device_info)
         call_info.next_commands.append(NextCommand(device_id, NextType.NEXT_CALL_OTHER.code))
@@ -41,7 +41,8 @@ class CallService:
 
         context = MakeCallContext(display=request.called, caller=request.called, called=request.caller,
                                   call_id=call_id, device_id=device_id, device_type=device_info.device_type,
-                                  call_type=call_info.call_type, sip_server=call_info.sip_server)
+                                  call_type=call_info.call_type, sip_server=call_info.sip_server,
+                                  sip_header_map={sipHeaderCtiFlowId: request.cti_flow_id})
 
         self.client.make_call_new(context)
         return call_id

+ 1 - 1
src/core/callcenter/views.py

@@ -180,7 +180,7 @@ def manual_call():
     # callId: string
     data = request.get_json()
     req = AgentCallRequest(saas_id=data.get('saas_id'), call_type=CallType.OUTBOUND_CALL, caller=data.get('caller'),
-                           agent_id=data.get('agent_id'), called=data.get('called'))
+                           agent_id=data.get('agent_id'), called=data.get('called'), cti_flow_id=data.get('ctiFlowId'))
     res = call_service.call(req)
     return success_response(res)