DavidLiu 3 月之前
父節點
當前提交
dab1c4239f
共有 4 個文件被更改,包括 32 次插入22 次删除
  1. 6 5
      src/core/callcenter/acd.py
  2. 18 12
      src/core/callcenter/call.py
  3. 7 5
      src/core/callcenter/esl/client.py
  4. 1 0
      src/core/voip/bot.py

+ 6 - 5
src/core/callcenter/acd.py

@@ -31,16 +31,17 @@ class AcdService:
         self.checkIdleScheduler.add_job(self.try_transfer_agent, 'interval', seconds=2, max_instances=1)
         self.checkIdleScheduler.start()
 
+    def hold(self, call_id, device_id):
+        # 1. hold住并且播放等待音
+        self.call_service.hold(call_id, device_id)
+        # self.wait_timeout(call_id)
+
     def transfer_to_agent(self, call_id, device_id, service_id='00000000000000000'):
         call_info = self.cache.get_call_info(call_id)
         self.logger.info('transfer_to_agent, come in, call_id:%s, call_info:%s'%(call_id, call_info))
         if not call_info:
             return
         call_info.answer_flag = AnswerFlag.TRANSFER_TO_AGENT.code
-        # 1. hold住并且播放等待音
-        self.call_service.hold(call_info, device_id)
-        self.wait_timeout(call_id)
-
         # 获得空闲坐席
         agent_number = self.agent_service.assign(AgentActionRequest(saas_id=saasId, service_id=service_id))
         if not agent_number:
@@ -105,4 +106,4 @@ class AcdService:
 
     def wait_timeout(self, call_id, timeouts=30):
         delay_action = DelayAction(call_id=call_id)
-        self.cache.add_delay_message(DelayActionEnum.ACD_TIMEOUT_PLAY.name, delay_action, timeouts)
+        # self.cache.add_delay_message(DelayActionEnum.ACD_TIMEOUT_PLAY.name, delay_action, timeouts)

+ 18 - 12
src/core/callcenter/call.py

@@ -70,18 +70,24 @@ class CallService:
         self.agent_actionlog_service.insert_service_state(agent_monitor, AgentServiceState.DIALING, AgentLogState.DIALING)
         self.data_handle_server.create_record(call_info.call_id, call_info.called, call_info.call_type, service_category=0, destination=agent_id, category=1)
 
-    def hold(self, call_info: CallInfo, device_id):
-        devices = call_info.device_list
-        # try:
-        #     devices.remove(device_id)
-        # except:
-        #     pass
-        # custom_device_id = devices[0]
-        custom_device_id = device_id
-        self.logger.info('hold, custom_device_id=%s'%custom_device_id)
-        self.client.bridge_break(call_info.call_id, custom_device_id)
-        self.cache.set_need_play_hold_music(call_info.call_id)
-        self.logger.info('hold success custom_device_id=%s'%custom_device_id)
+    def hold(self, call_id, device_id):
+        self.logger.info('hold, custom_device_id=%s'%device_id)
+        self.client.bridge_break(call_id, device_id)
+        self.cache.set_need_play_hold_music(call_id)
+        self.logger.info('hold success custom_device_id=%s'%device_id)
+
+    # def hold(self, call_info: CallInfo, device_id):
+    #     devices = call_info.device_list
+    #     # try:
+    #     #     devices.remove(device_id)
+    #     # except:
+    #     #     pass
+    #     # custom_device_id = devices[0]
+    #     custom_device_id = device_id
+    #     self.logger.info('hold, custom_device_id=%s'%custom_device_id)
+    #     self.client.bridge_break(call_info.call_id, custom_device_id)
+    #     self.cache.set_need_play_hold_music(call_info.call_id)
+    #     self.logger.info('hold success custom_device_id=%s'%custom_device_id)
 
     def cancel_hold(self, call_info: CallInfo, device_id):
         self.client.bridge_call(call_info.call_id, call_info.device_list[0], call_info.device_list[1])

+ 7 - 5
src/core/callcenter/esl/client.py

@@ -541,6 +541,7 @@ class OutboundClient:
                         # 检查白名单
                         _bucket_call_type = 0
                         con.execute("answer", "", device_id)
+                        self.server.agent.acd_service.hold(call_id, device_id)
                         self.build_call_info(CallType.INCOMING_AGENT_CALL.code, call_id, device_id, new_device_id, destination=None, bucket_type=_bucket_call_type, **kwargs)
                         self.server.agent.acd_service.transfer_to_agent(call_id, device_id)
                     elif bucket and bucket.name == 'AI':
@@ -555,17 +556,18 @@ class OutboundClient:
                     else:
                         # 传统服务
                         con.execute("answer", "", device_id)
+                        self.server.agent.acd_service.hold(call_id, device_id)
                         self.build_call_info(CallType.INCOMING_AGENT_CALL.code, call_id, device_id, new_device_id, destination=None, bucket_type=_bucket_call_type,  **kwargs)
                         self.server.agent.acd_service.transfer_to_agent(call_id, device_id)
 
                     registry.CALL_INCOMING_REQUESTS.labels(f"{_bucket_call_type}").inc()
                     self.server.dataHandleServer.create_record(call_id, caller_number, _bucket_call_type, service_category=service_category, destination=destination)
 
-                    # try:
-                    #     con.disconnect()
-                    #     self.server.logger.info("connection disconnected !!!")
-                    # except:
-                    #     traceback.print_exc()
+                    try:
+                        con.disconnect()
+                        self.server.logger.info("connection disconnected !!!")
+                    except:
+                        traceback.print_exc()
                 else:
                     self.server.logger.info("Failed to connect to FreeSWITCH")
             except:

+ 1 - 0
src/core/voip/bot.py

@@ -596,6 +596,7 @@ class BotAgent:
 
     def transfer(self, user_part, call_id, device_id, service_id='00000000000000000'):
         if self.acd_service:
+            self.acd_service.hold(call_id, device_id)
             self.acd_service.transfer_to_agent(call_id, device_id, service_id)
         # sip_headers = {'P-LIBRA-HangUpReason': 'transferToAgent', 'P-LIBRA-ServiceId': service_id}
         try_count = 100