Browse Source

Merge branch 'develop' into jms_20250106_prod

Davidliu 1 month ago
parent
commit
5915e37229
4 changed files with 20 additions and 14 deletions
  1. 1 0
      .gitignore
  2. 10 10
      src/core/callcenter/agent.py
  3. 6 2
      src/core/callcenter/callback.py
  4. 3 2
      src/core/callcenter/esl/client.py

+ 1 - 0
.gitignore

@@ -35,3 +35,4 @@ config/*.xlsx
 **.log
 **.ipynb
 *.pyc
+src.tar.gz

+ 10 - 10
src/core/callcenter/agent.py

@@ -91,7 +91,7 @@ class AgentEventService:
 
         start_time = time.time()
         try:
-            self.logger.info('agent_event_channel, event_name=%s, agent_num=%s, device_id=%s, is_agent=%s, hangup_dir=%s, hangup_count=%s, answer_count=%s', event_name, agent_num, device_id, is_agent, call_info.hangup_dir, call_info.hangup_count, call_info.answer_count)
+            self.logger.info('agent_event_channel, event_name=%s, call_id=%s, agent_num=%s, device_id=%s, is_agent=%s, hangup_dir=%s, hangup_count=%s, answer_count=%s', event_name, call_id, agent_num, device_id, is_agent, call_info.hangup_dir, call_info.hangup_count, call_info.answer_count)
             agent = self.data_handle_server.get_agent(saas_id, agent_num)
             if not agent:
                 # self.logger.warn("event service channel agent is null %s %s %s %s %s", saas_id, event_name, caller, called, json.loads(event.serialize('json')))
@@ -103,9 +103,9 @@ class AgentEventService:
 
             # 信道发起事件,触发完成发起(或桥)&& 坐席侧
             if CHANNEL_ORIGINATE == event_name and is_agent:
-                if call_info.hangup_dir and call_info.hangup_dir == HangupDir.CUSTOMER_HANGUP.code:
-                    self.logger.info('agent_event_channel:already:hangup, event_name=%s, call_id=%s, device_id=%s, is_agent=%s, agent_num=%s, hangup_dir=%s, hangup_count=%s, answer_count=%s', event_name, call_id, device_id, is_agent, agent_num, call_info.hangup_dir, call_info.hangup_count, call_info.answer_count)
-                    return
+                # if call_info.hangup_dir and call_info.hangup_dir == HangupDir.CUSTOMER_HANGUP.code:
+                #     self.logger.info('agent_event_channel:already:hangup, event_name=%s, call_id=%s, device_id=%s, is_agent=%s, agent_num=%s, hangup_dir=%s, hangup_count=%s, answer_count=%s', event_name, call_id, device_id, is_agent, agent_num, call_info.hangup_dir, call_info.hangup_count, call_info.answer_count)
+                    # return
                 self.push_handler.push_on_agent_work_report(saas_id, flow_id, agent_num, call_id, AgentScene.MANUAL, WorkStatus.AGENT_RINGING,phone=call_info.caller)
 
             # 进度事件,外呼时对方提醒。或者入呼时提醒 && 坐席侧
@@ -206,12 +206,12 @@ class AgentEventService:
 
             # 信道发起事件,触发完成发起(或桥)&& 坐席侧
             if CHANNEL_ORIGINATE == event_name and is_agent:
-                if call_info.hangup_dir and call_info.hangup_dir == HangupDir.CUSTOMER_HANGUP.code:
-                    self.logger.info('bot_event_channel:already:hangup, event_name=%s, call_id=%s, device_id=%s, is_agent=%s, agent_num=%s, hangup_dir=%s, hangup_count=%s, answer_count=%s', event_name, call_id, device_id, is_agent, agent_num, call_info.hangup_dir, call_info.hangup_count, call_info.answer_count)
-                    return
+                self.data_handle_server.update_record(call_id, transfer_user_id=agent.user_id,transfer_user_name=agent.agent_name)  # 转接给客服以后更新转接人
+                # if call_info.hangup_dir and call_info.hangup_dir == HangupDir.CUSTOMER_HANGUP.code:
+                #     self.logger.info('bot_event_channel:already:hangup, event_name=%s, call_id=%s, device_id=%s, is_agent=%s, agent_num=%s, hangup_dir=%s, hangup_count=%s, answer_count=%s', event_name, call_id, device_id, is_agent, agent_num, call_info.hangup_dir, call_info.hangup_count, call_info.answer_count)
+                    # return
                 self.push_handler.push_on_call_ring(saas_id, flow_id, agent_num, AgentScene.ROBOT, call_id, ServiceDirect.ROBOT_CALL.service_direct, called, caller, human_service_id)
                 self.push_handler.push_on_agent_work_report(saas_id, flow_id, agent_num, call_id, AgentScene.ROBOT, WorkStatus.AGENT_RINGING,phone=call_info.caller)
-                self.data_handle_server.update_record(call_id, transfer_user_id=agent.user_id,transfer_user_name=agent.agent_name)  #转接给客服以后更新转接人
 
 
             if CHANNEL_ANSWER == event_name:
@@ -916,8 +916,8 @@ class AgentStateService:
 
     def handle_release_agent_lock(self, choose_phone_num, saas_id, service_id='00000000000000000'):
         key = self._lock_key(saas_id, service_id, choose_phone_num)
-        # self.redis_handler.redis.delete(key)
-        self.redis_handler.redis.expire(key, 3)
+        self.redis_handler.redis.delete(key)
+        # self.redis_handler.redis.expire(key, 3)
         self.logger.info('releaseAgent %s %s %s'% (saas_id, service_id, choose_phone_num))
 
     def handle_assign_time(self, saas_id, service_id, choose_phone_num):

+ 6 - 2
src/core/callcenter/callback.py

@@ -4,6 +4,7 @@ import json
 import queue
 import threading
 import concurrent.futures
+import traceback
 
 import mmh3
 import random
@@ -32,13 +33,16 @@ class Callback(object):
                 event, call_info, device_info = self.event_queue.get(timeout=1)
                 call_type = CallType.get_by_code(call_info.call_type) if call_info else None
                 if call_type is None:
+                    event_name = EslEventUtil.getEventName(event)
+                    self.logger.info("callback:call_type_none:return::event_name=%s, call_info=%s, device_info=%s", event_name, call_info, device_info)
                     continue
+
                 if CallType.BOT_CALL == call_type or CallType.INCOMING_BOT_CALL == call_type:
                     self.choose_thread_pool_executor(event).submit(self.agent_event_service.bot_event_channel, event, call_info, device_info)
                 else:
                     self.choose_thread_pool_executor(event).submit(self.agent_event_service.agent_event_channel, event, call_info, device_info)
             except:
-                pass
+                traceback.print_exc()
 
 
     def stop(self):
@@ -61,7 +65,7 @@ class Callback(object):
             self.logger.info("callback:return::event_name=%s, call_id=%s, device_id=%s", event_name, call_id, device_id)
             return
         device_info = call_info.device_info_map.get(device_id) if call_info and call_info.device_info_map else None
-        # self.logger.info("callback::event_name=%s, call_id=%s, device_id=%s", event_name, call_id, device_id)
+        self.logger.info("callback::event_name=%s, call_id=%s, device_id=%s", event_name, call_id, device_id)
         self.event_queue.put_nowait((event, call_info, device_info))
 
 

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

@@ -106,6 +106,7 @@ class InboundClient:
                     self.choose_thread_pool_executor(e).submit(self.process_esl_event, e)
 
     def choose_thread_pool_executor(self, e):
+        event_name = EslEventUtil.getEventName(e)
         call_id = EslEventUtil.getCallId(e)
         device_id = EslEventUtil.getUniqueId(e)
         wdh_device_id = EslEventUtil.getDeviceId(e)
@@ -114,7 +115,7 @@ class InboundClient:
             random_index = abs(mmh3.hash(random_id)) % len(self.executors)
         else:
             random_index = random.randint(0, len(self.executors) - 1) if self.executors else 0
-        # self.logger.info('choose_thread_pool_executor.index=', random_index, call_id, device_id, wdh_device_id)
+        self.logger.info('choose_thread_pool_executor:event_name=%s, random_index=%s, call_id=%s, unique_id=%s, device_id=%s, ', event_name, random_index, call_id, device_id, wdh_device_id)
         return self.executors.get(random_index)
 
     def process_esl_event(self, e):
@@ -210,7 +211,7 @@ class InboundClient:
             next_command = NextCommand(device_id = device_id, next_type=NextType.NEXT_HANGUP.code)
             call_info.next_commands = [next_command]
             self.cache.add_call_info(call_info)
-            # self.dataHandleServer.update_record(call_id, status= 0)
+            self.dataHandleServer.update_record(call_id, hangup_reason= '当前坐席忙,请稍后在播。')
             self.logger.info("waitingTimeOut 开始播放结束音乐 callId:%s customerDeviceId:%s playFile:%s", call_id,
                              device_id, music_file)