|
@@ -1,3 +1,5 @@
|
|
|
+
|
|
|
+import time
|
|
|
from src.core import with_app_context
|
|
|
from src.core.callcenter.constant import START_AGENT_NUM
|
|
|
from src.core.callcenter.dao import *
|
|
@@ -7,6 +9,7 @@ class DataHandleServer:
|
|
|
"""通话记录服务"""
|
|
|
def __init__(self,app):
|
|
|
self.app = app
|
|
|
+ self.logger = app.logger
|
|
|
|
|
|
@with_app_context
|
|
|
def create_record(self, call_id, caller_number, call_type, service_category=None, category=0, user_id=None,user_name=None):
|
|
@@ -48,10 +51,11 @@ class DataHandleServer:
|
|
|
|
|
|
@with_app_context
|
|
|
def update_record(self, session_id, **kwargs):
|
|
|
- self.app.logger.info(f"update_record::session_id:{session_id}")
|
|
|
+ start_time = time.time()
|
|
|
+ self.logger.info(f"update_record::session_id:{session_id}")
|
|
|
call_record = CallRecord.query.filter(CallRecord.session_id == session_id).first()
|
|
|
if not call_record:
|
|
|
- self.app.logger.info("update_record::call_recard is empty !!!")
|
|
|
+ self.logger.info("update_record::call_recard is empty !!!")
|
|
|
return
|
|
|
time_end = kwargs.get('time_end')
|
|
|
user_id = kwargs.get('user_id')
|
|
@@ -60,7 +64,7 @@ class DataHandleServer:
|
|
|
bot_record = BotRecords.query.filter(BotRecords.session == session_id).first()
|
|
|
call_record.bussiness_type = bot_record.intent if bot_record else '未知'
|
|
|
# 如果记录是转人工并且有客服接通把客服更新到转接字段
|
|
|
- self.app.logger.debug(f"Received kwargs: {kwargs} user_id:{user_id},user_name:{user_name}, call_record:{call_record}")
|
|
|
+ self.logger.debug(f"Received kwargs: {kwargs} user_id:{user_id},user_name:{user_name}, call_record:{call_record}")
|
|
|
#如果记录已经有user_id不再更新 删除参数里面的user_id
|
|
|
if call_record.user_id and 'user_id' in kwargs:
|
|
|
kwargs.pop('user_id', None)
|
|
@@ -69,9 +73,11 @@ class DataHandleServer:
|
|
|
for key, value in kwargs.items():
|
|
|
if hasattr(call_record, key):
|
|
|
setattr(call_record, key, value)
|
|
|
- self.app.logger.info(f"更新通话记录: {kwargs}, {call_record.to_dict()}")
|
|
|
db.session.commit()
|
|
|
|
|
|
+ time_cost = (time.time() - start_time) * 1000
|
|
|
+ self.logger.info(f"更新通话记录::session_id:{session_id}, time_cost:{time_cost}, {kwargs}, {call_record.to_dict()}")
|
|
|
+
|
|
|
@with_app_context
|
|
|
def get_user_name(self,agent_num):
|
|
|
agent = Agent.query.filter(Agent.agent_num == agent_num).first()
|