Procházet zdrojové kódy

acd 等待超时逻辑

DavidLiu před 4 měsíci
rodič
revize
558005c404

+ 8 - 2
src/core/callcenter/acd.py

@@ -7,12 +7,12 @@ from typing import Dict, Any, Optional
 from src.core.callcenter.cache import Cache
 from src.core.callcenter.agent import AgentOperService
 from src.core.callcenter.call import CallService
-from src.core.callcenter.api import CallInfo, AgentActionRequest
+from src.core.callcenter.api import CallInfo, AgentActionRequest, DelayAction
 from apscheduler.schedulers.background import BackgroundScheduler
 from concurrent.futures import ThreadPoolExecutor, wait, ALL_COMPLETED, FIRST_COMPLETED
 
 from src.core.callcenter.constant import saasId
-from src.core.callcenter.enumeration import AnswerFlag
+from src.core.callcenter.enumeration import AnswerFlag, DelayActionEnum
 
 
 class AcdService:
@@ -38,7 +38,9 @@ class AcdService:
         self.cache.add_call_info(call_info)
         # 1. hold住并且播放等待音
         self.call_service.hold(call_info, device_id)
+        self.wait_timeout(call_id)
         self.logger.info('transfer_to_agent, 1111111 ')
+
         # 获得空闲坐席
         agent_number = self.agent_service.assign(AgentActionRequest(saas_id=saasId, service_id=service_id))
         self.logger.info('transfer_to_agent, 222222 %s'%agent_number)
@@ -87,3 +89,7 @@ class AcdService:
 
         for call_id in tmp_arr:
             call_info_queue.put_nowait(call_id)
+
+    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)

+ 2 - 0
src/core/callcenter/constant.py

@@ -43,6 +43,8 @@ READY_TIMES = "readyTimes"
 SEREVICE_TIMES = "serviceTimes"
 
 HOLD_MUSIC_PATH = '/freeswitch/music/hold.wav'
+WaitingHangupMusicPath = '/freeswitch/music/sorry.wav'
+
 BASE_RECORD_PATH = '/freeswitch/record/'
 
 EMPTY = ""

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

@@ -19,7 +19,8 @@ from apscheduler.schedulers.background import BackgroundScheduler
 from src.core.callcenter import BizException
 from src.core.callcenter.cache import Cache
 from src.core.callcenter.api import MakeCallContext, DelayAction, CallInfo, DeviceInfo, NextCommand
-from src.core.callcenter.constant import SK, EMPTY, CTI_ENGINE_DELAY_ACTION_LOCK, HOLD_MUSIC_PATH, saasId
+from src.core.callcenter.constant import SK, EMPTY, CTI_ENGINE_DELAY_ACTION_LOCK, HOLD_MUSIC_PATH, saasId, \
+    WaitingHangupMusicPath
 from src.core.callcenter.esl.constant.esl_constant import BRIDGE_VARIABLES, BRIDGE, HANGUP, NORMAL_CLEARING, SIP_HEADER, \
     SPACE, SPLIT, SOFIA, \
     ORIGINATE, PARK, SET, EAVESDROP, SMF_ALEG, EXECUTE, PLAYBACK, PAUSE, TRANSFER, UUID_TRANSFER, UUID_BROADCAST, \
@@ -195,11 +196,14 @@ class InboundClient:
         if device_list and len(device_list) == 1:
             device_id = device_list[0].device_id
             self.bridge_break(device_id)
-            self.hold_play(device_id, HOLD_MUSIC_PATH)
+            if not WaitingHangupMusicPath:
+                self.hangup_call(call_id, device_id, CallCause.WAITING_TIMEOUT)
+                return
+            self.hold_play(device_id, WaitingHangupMusicPath)
             self.play_timeout(call_id, timeout=30)
             self.cache.add_call_info(call_info)
             self.logger.info("waitingTimeOut 开始播放结束音乐 callId:%s customerDeviceId:%s playFile:%s", call_id,
-                             device_id, HOLD_MUSIC_PATH)
+                             device_id, WaitingHangupMusicPath)
 
     def make_call_new(self, context: MakeCallContext):
         called = context.get_called()