|
@@ -1,5 +1,7 @@
|
|
#!/usr/bin/env python3
|
|
#!/usr/bin/env python3
|
|
# encoding:utf-8
|
|
# encoding:utf-8
|
|
|
|
+
|
|
|
|
+import traceback
|
|
from src.core.callcenter.constant import START_AGENT_NUM
|
|
from src.core.callcenter.constant import START_AGENT_NUM
|
|
from src.core.callcenter.enumeration import AgentState, AgentCheck, AgentHeartState, AgentServiceState, AgentLogState, \
|
|
from src.core.callcenter.enumeration import AgentState, AgentCheck, AgentHeartState, AgentServiceState, AgentLogState, \
|
|
AgentScene, BizErrorCode, WorkStatus, DownEvent, HumanState
|
|
AgentScene, BizErrorCode, WorkStatus, DownEvent, HumanState
|
|
@@ -62,7 +64,6 @@ class AgentOperService:
|
|
if req.scene == AgentScene.MANUAL.code:
|
|
if req.scene == AgentScene.MANUAL.code:
|
|
# 如果是手动外呼增加置闲
|
|
# 如果是手动外呼增加置闲
|
|
self._handle_idle(req.scene, agent)
|
|
self._handle_idle(req.scene, agent)
|
|
-
|
|
|
|
return self._push_event_for_checkin(agent, agent_monitor, phone, req.scene)
|
|
return self._push_event_for_checkin(agent, agent_monitor, phone, req.scene)
|
|
|
|
|
|
def checkout(self, request: AgentActionRequest):
|
|
def checkout(self, request: AgentActionRequest):
|
|
@@ -106,7 +107,7 @@ class AgentOperService:
|
|
def _push_event_for_checkin(self, agent, agent_monitor, phone, scene):
|
|
def _push_event_for_checkin(self, agent, agent_monitor, phone, scene):
|
|
"""坐席签入事件推送"""
|
|
"""坐席签入事件推送"""
|
|
agent_scene = AgentScene.get_by_code(scene)
|
|
agent_scene = AgentScene.get_by_code(scene)
|
|
- self.push_handler.push_on_agent_work_report(agent.saas_id, "", agent.out_id, agent_scene, WorkStatus.LOGIN_SUCCESS)
|
|
|
|
|
|
+ self.push_handler.push_on_agent_work_report(agent.saas_id, "", agent.out_id, "", agent_scene, WorkStatus.LOGIN_SUCCESS)
|
|
|
|
|
|
event_data = AgentEventData(agent.saas_id, agent.out_id)
|
|
event_data = AgentEventData(agent.saas_id, agent.out_id)
|
|
event_data.data = {'eventName': DownEvent.ON_INITAL_SUCCESS.code,
|
|
event_data.data = {'eventName': DownEvent.ON_INITAL_SUCCESS.code,
|
|
@@ -117,12 +118,12 @@ class AgentOperService:
|
|
'sipServer': phone.sip_server
|
|
'sipServer': phone.sip_server
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return event_data
|
|
|
|
|
|
+ return event_data.__dict__
|
|
|
|
|
|
def _push_event_for_idle(self, agent, scene):
|
|
def _push_event_for_idle(self, agent, scene):
|
|
"""坐席置闲事件推送"""
|
|
"""坐席置闲事件推送"""
|
|
agent_scene = AgentScene.get_by_code(scene)
|
|
agent_scene = AgentScene.get_by_code(scene)
|
|
- self.push_handler.push_on_agent_work_report(agent.saas_id, "", agent.out_id, agent_scene, WorkStatus.AGENT_READY)
|
|
|
|
|
|
+ self.push_handler.push_on_agent_work_report(agent.saas_id, "", agent.out_id, "", agent_scene, WorkStatus.AGENT_READY)
|
|
|
|
|
|
|
|
|
|
class AgentService:
|
|
class AgentService:
|
|
@@ -281,29 +282,29 @@ class AgentMonitorService:
|
|
res.append(data)
|
|
res.append(data)
|
|
return res
|
|
return res
|
|
|
|
|
|
- def update_check_in(self, agent_monitor):
|
|
|
|
|
|
+ def update_checkin(self, agent_monitor):
|
|
agent_monitor.check_state = AgentCheck.IN.code
|
|
agent_monitor.check_state = AgentCheck.IN.code
|
|
- agent_monitor.check_in_time = datetime.utcnow
|
|
|
|
|
|
+ agent_monitor.check_in_time = datetime.utcnow()
|
|
agent_monitor.heart_state = AgentHeartState.NORMAL.code
|
|
agent_monitor.heart_state = AgentHeartState.NORMAL.code
|
|
- agent_monitor.heart_time = datetime.utcnow
|
|
|
|
|
|
+ agent_monitor.heart_time = datetime.utcnow()
|
|
db.session.commit()
|
|
db.session.commit()
|
|
|
|
|
|
- def update_check_out(self, agent_monitor):
|
|
|
|
|
|
+ def update_checkout(self, agent_monitor):
|
|
agent_monitor.check_state = AgentCheck.OUT.code
|
|
agent_monitor.check_state = AgentCheck.OUT.code
|
|
- agent_monitor.check_out_time = datetime.utcnow
|
|
|
|
|
|
+ agent_monitor.check_out_time = datetime.utcnow()
|
|
agent_monitor.service_state = AgentServiceState.LOGOUT.code
|
|
agent_monitor.service_state = AgentServiceState.LOGOUT.code
|
|
agent_monitor.heart_state = AgentHeartState.DEFAULT.code
|
|
agent_monitor.heart_state = AgentHeartState.DEFAULT.code
|
|
- agent_monitor.heart_time = datetime.utcnow
|
|
|
|
|
|
+ agent_monitor.heart_time = datetime.utcnow()
|
|
db.session.commit()
|
|
db.session.commit()
|
|
|
|
|
|
def update_idle(self, agent_monitor):
|
|
def update_idle(self, agent_monitor):
|
|
agent_monitor.service_state = AgentServiceState.IDLE.code
|
|
agent_monitor.service_state = AgentServiceState.IDLE.code
|
|
- agent_monitor.idle_time = datetime.utcnow
|
|
|
|
|
|
+ agent_monitor.idle_time = datetime.utcnow()
|
|
db.session.commit()
|
|
db.session.commit()
|
|
|
|
|
|
def update_busy(self, agent_monitor):
|
|
def update_busy(self, agent_monitor):
|
|
agent_monitor.service_state = AgentServiceState.BUSY.code
|
|
agent_monitor.service_state = AgentServiceState.BUSY.code
|
|
- agent_monitor.busy_time = datetime.utcnow
|
|
|
|
|
|
+ agent_monitor.busy_time = datetime.utcnow()
|
|
db.session.commit()
|
|
db.session.commit()
|
|
|
|
|
|
def update_dialing(self, agent_monitor):
|
|
def update_dialing(self, agent_monitor):
|
|
@@ -312,12 +313,12 @@ class AgentMonitorService:
|
|
|
|
|
|
def update_calling(self, agent_monitor):
|
|
def update_calling(self, agent_monitor):
|
|
agent_monitor.service_state = AgentServiceState.CALLING.code
|
|
agent_monitor.service_state = AgentServiceState.CALLING.code
|
|
- agent_monitor.call_time = datetime.utcnow
|
|
|
|
|
|
+ agent_monitor.call_time = datetime.utcnow()
|
|
db.session.commit()
|
|
db.session.commit()
|
|
|
|
|
|
def update_processing(self, agent_monitor):
|
|
def update_processing(self, agent_monitor):
|
|
agent_monitor.service_state = AgentServiceState.REPROCESSING.code
|
|
agent_monitor.service_state = AgentServiceState.REPROCESSING.code
|
|
- agent_monitor.hang_time = datetime.utcnow
|
|
|
|
|
|
+ agent_monitor.hang_time = datetime.utcnow()
|
|
db.session.commit()
|
|
db.session.commit()
|
|
|
|
|
|
def update_session_id(self, agent_monitor, session_id):
|
|
def update_session_id(self, agent_monitor, session_id):
|
|
@@ -326,7 +327,7 @@ class AgentMonitorService:
|
|
|
|
|
|
def update_heart_error(self, agent_monitor):
|
|
def update_heart_error(self, agent_monitor):
|
|
agent_monitor.heart_state = AgentHeartState.ABNORMAL.code
|
|
agent_monitor.heart_state = AgentHeartState.ABNORMAL.code
|
|
- agent_monitor.heart_time = datetime.utcnow
|
|
|
|
|
|
+ agent_monitor.heart_time = datetime.utcnow()
|
|
db.session.commit()
|
|
db.session.commit()
|
|
|
|
|
|
def _get_day_start(self):
|
|
def _get_day_start(self):
|
|
@@ -351,7 +352,7 @@ class AgentActionLogService:
|
|
if agent_log_enum:
|
|
if agent_log_enum:
|
|
action_log.event_type = agent_log_enum.code
|
|
action_log.event_type = agent_log_enum.code
|
|
action_log.event_desc = agent_log_enum.description
|
|
action_log.event_desc = agent_log_enum.description
|
|
- now = datetime.utcnow
|
|
|
|
|
|
+ now = datetime.utcnow()
|
|
pre_date = None
|
|
pre_date = None
|
|
if agent_monitor.check_state == AgentCheck.IN.code:
|
|
if agent_monitor.check_state == AgentCheck.IN.code:
|
|
pre_date = agent_monitor.check_in_time
|
|
pre_date = agent_monitor.check_in_time
|
|
@@ -368,7 +369,7 @@ class AgentActionLogService:
|
|
def insert_service_state(self, agent_monitor, agent_service_state: AgentServiceState, agent_log_enum: AgentLogState,
|
|
def insert_service_state(self, agent_monitor, agent_service_state: AgentServiceState, agent_log_enum: AgentLogState,
|
|
task_id=None, service_id=None):
|
|
task_id=None, service_id=None):
|
|
if agent_monitor.service_state == agent_service_state.code:
|
|
if agent_monitor.service_state == agent_service_state.code:
|
|
- self.logger.info("agent action log insert service state same %s %s", agent_monitor.service_state, agent_service_state.getValue())
|
|
|
|
|
|
+ self.logger.info("agent action log insert service state same %s %s", agent_monitor.service_state, agent_service_state.code)
|
|
|
|
|
|
action_log = AgentActionLog()
|
|
action_log = AgentActionLog()
|
|
action_log.saas_id = agent_monitor.saas_id
|
|
action_log.saas_id = agent_monitor.saas_id
|
|
@@ -382,7 +383,7 @@ class AgentActionLogService:
|
|
if agent_log_enum:
|
|
if agent_log_enum:
|
|
action_log.event_type = agent_log_enum.code
|
|
action_log.event_type = agent_log_enum.code
|
|
action_log.event_desc = agent_log_enum.description
|
|
action_log.event_desc = agent_log_enum.description
|
|
- now = datetime.utcnow
|
|
|
|
|
|
+ now = datetime.utcnow()
|
|
pre_date = None
|
|
pre_date = None
|
|
if agent_monitor.service_state == AgentServiceState.IDLE.code:
|
|
if agent_monitor.service_state == AgentServiceState.IDLE.code:
|
|
pre_date = agent_monitor.idle_time
|
|
pre_date = agent_monitor.idle_time
|
|
@@ -426,8 +427,8 @@ class AgentStateService:
|
|
key = self._check_in_key(saas_id)
|
|
key = self._check_in_key(saas_id)
|
|
state_data = AgentStateData()
|
|
state_data = AgentStateData()
|
|
state_data.status = HumanState.DEFAULT.code
|
|
state_data.status = HumanState.DEFAULT.code
|
|
- state_data.time = datetime.utcnow.timestamp()
|
|
|
|
- self.redis_handler.redis.hset(key, phone_num, json.dumps(state_data))
|
|
|
|
|
|
+ state_data.time = datetime.utcnow().timestamp()
|
|
|
|
+ self.redis_handler.redis.hset(key, phone_num, state_data.to_json_string())
|
|
self.redis_handler.redis.expire(key, self._get_expire_time())
|
|
self.redis_handler.redis.expire(key, self._get_expire_time())
|
|
|
|
|
|
def checkout(self, saas_id, agent_id, phone_num):
|
|
def checkout(self, saas_id, agent_id, phone_num):
|
|
@@ -480,6 +481,7 @@ def _get_newest_agent_number(saas_id):
|
|
def _get_agent_monitor(saas_id, agent_number):
|
|
def _get_agent_monitor(saas_id, agent_number):
|
|
monitor = AgentMonitor.query.filter(AgentMonitor.saas_id == saas_id,
|
|
monitor = AgentMonitor.query.filter(AgentMonitor.saas_id == saas_id,
|
|
AgentMonitor.agent_num == agent_number).first()
|
|
AgentMonitor.agent_num == agent_number).first()
|
|
|
|
+ print('_get_agent_monitor', saas_id, agent_number, monitor)
|
|
return monitor
|
|
return monitor
|
|
|
|
|
|
|
|
|