Bläddra i källkod

Merge branch 'dev_bucket_20241202' into dev_metrics_20241203

DavidLiu 4 månader sedan
förälder
incheckning
678965875e

+ 3 - 1
src/core/callcenter/acd.py

@@ -1,5 +1,6 @@
 #!/usr/bin/env python3
 # encoding:utf-8
+import json
 import time
 from datetime import datetime
 from queue import Queue
@@ -76,10 +77,11 @@ class AcdService:
             call_id = call_info_queue.get_nowait()
             call_info = self.cache.get_call_info(call_id)
             if not call_info or not call_info.device_list:
+                self.logger.info("AcdService tryTransferAgent callInfoCache is null %s", call_id)
                 continue
             agent_number = self.agent_service.assign(AgentActionRequest(saas_id=saasId, service_id=task_service_id))
             if not agent_number:
-                self.logger.info("AcdService tryTransferAgent agentNumber is Empty %s"% call_id)
+                self.logger.info("AcdService tryTransferAgent agentNumber is Empty %s %s"% (call_id, json.dumps(call_info.device_list)))
                 tmp_arr.append(call_id)
                 continue
             self.logger.info(

+ 5 - 3
src/core/callcenter/cache.py

@@ -124,20 +124,22 @@ class Cache:
         delay_action.uuid = str(uuid.uuid4())
         key = CTI_ENGINE_DELAY_ACTION % action
         msg = delay_action.to_json_string()
-        action_time = datetime.utcnow().timestamp() + timeouts * 1000
+        action_time = datetime.utcnow().timestamp()*1000 + timeouts * 1000
         self.redis_handler.redis.zadd(key, {msg : action_time})
 
     def get_delay_message(self, action):
         key = CTI_ENGINE_DELAY_ACTION % action
-        current_time = int(time.time() * 1000)  # 毫秒级时间戳
+        current_time = int(datetime.utcnow().timestamp() * 1000)  # 毫秒级时间戳
         members = self.redis_handler.redis.zrangebyscore(key, 0, current_time, start=0, num=DELAY_ACTION_BATCH_SIZE, withscores=True)
         if not members:
             return []
         self.logger.info('get_delay_message %s %s %s'%(key, action, members))
         # scored_entries = [{"member": entry[0].decode('utf-8'), "score": entry[1]} for entry in members]
         action_list = [entry[0].decode('utf-8') for entry in members]
+        self.logger.info('get_delay_message %s %s %s'%(key, action, json.dumps(action_list)))
         if action_list:
-            self.redis_handler.redis.zrem(key, *action_list)
+            a = self.redis_handler.redis.zrem(key, *action_list)
+            self.logger.info('get_delay_message %s %s %s %s'%(key, action, json.dumps(action_list), a))
         return action_list
 
     def lock_delay_action(self, val):

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

@@ -77,8 +77,6 @@ class CallService:
             pass
         custom_device_id = devices[0]
         self.logger.info('hold, custom_device_id=%s'%custom_device_id)
-        # self.client.sync_invoke_method("bridge_break", method_args=(custom_device_id,))
-        # self.client.sync_invoke_method("hold_play", method_args=(custom_device_id,HOLD_MUSIC_PATH))
         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)

+ 3 - 8
src/core/callcenter/enumeration.py

@@ -277,14 +277,9 @@ class DeviceType(Enum):
 
 
 class CallType(Enum):
-    IM = (0, 'IM')
-    INBOUND_CALL = (1, '呼入')
-    AGENT_CALL = (2, '手动外呼')
-    AUTO_CALL = (3, '预测外呼')
-    BOT_CALL = (4, '机器人外呼')
-    BOTH_CALL = (5, '双向外呼')
-    SIP_OUTBOUND_CALL = (6, '硬话机外呼')
-    INNER_CALL = (7, '内呼')
+    AGENT_CALL = (1, '手动外呼')
+    BOT_CALL = (2, '机器人外呼')
+    BOTH_CALL = (3, '双向外呼')
 
     def __init__(self, code=None, description=None):
         self.code = code

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

@@ -119,13 +119,13 @@ class InboundClient:
         event_name = EslEventUtil.getEventName(e)
         coreUUID = EslEventUtil.getCoreUuid(e)
         address = self.host + ':' + self.port
-        self.logger.info("process_esl_event.event_name=%s,coreUUID=%s", event_name, coreUUID)
+        # self.logger.info("process_esl_event.event_name=%s,coreUUID=%s", event_name, coreUUID)
         try:
             if event_name in self.handler_table:
                 items = self.handler_table.get(event_name)
                 for x in items:
                     try:
-                        self.logger.info("process_esl_event.handle.%s", x.__class__.__name__)
+                        # self.logger.info("process_esl_event.handle.%s", x.__class__.__name__)
                         x.handle(address, e, coreUUID)
                     except:
                         traceback.print_exc()
@@ -604,12 +604,12 @@ class OutboundClient:
                                      cti_flow_id=None, conference=None, agent_name=None, from_agent=None, caller=None, called=None, display=None, called_location=None, caller_location=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)
 
             call_info.device_list.append(device_id)
-            self.server.logger.info("liuwei::debugger:3333::call_id=%s, device_id=%s" % (call_id, device_id))
+            # self.server.logger.info("liuwei::debugger:3333::call_id=%s, device_id=%s" % (call_id, device_id))
             call_info.device_list.append(new_device_id)
-            self.server.logger.info("liuwei::debugger:4444::call_id=%s, device_id=%s" % (call_id, new_device_id))
+            # self.server.logger.info("liuwei::debugger:4444::call_id=%s, device_id=%s" % (call_id, new_device_id))
             # call_info.next_commands.append(NextCommand(device_id, NextType.NEXT_CALL_BRIDGE.code, new_device_id))
             call_info.device_info_map = {device_id: device_custom, new_device_id: device_bot}
-            self.server.logger.info("lwoutBound, call_info=%s"%(call_info))
+            # self.server.logger.info("lwoutBound, call_info=%s"%(call_info))
             self.server.cache.add_call_info(call_info)
 
 

+ 1 - 1
src/core/callcenter/esl/handler/channel_answer_handler.py

@@ -40,7 +40,7 @@ class ChannelAnswerHandler(EslEventHandler):
         if not next_command:
             return
 
-        if device_info.device_type == DeviceType.CUSTOMER.code:
+        if CallType.AGENT_CALL.code == call_info.call_type and 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)
 

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

@@ -177,7 +177,7 @@ def manual_call():
     # ext?: object
     # callId: string
     data = request.get_json()
-    req = AgentCallRequest(saas_id=data.get('saas_id'), call_type=CallType.OUTBOUND_CALL, caller=data.get('caller'),
+    req = AgentCallRequest(saas_id=data.get('saas_id'), call_type=CallType.AGENT_CALL.code, caller=data.get('caller'),
                            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)