shanghui 3 ヶ月 前
コミット
6862e10d36
1 ファイル変更12 行追加12 行削除
  1. 12 12
      src/core/callcenter/agent.py

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

@@ -283,7 +283,7 @@ class AgentOperService:
         phone.is_delete = 1
         db.session.commit()
 
-    @with_app_context
+
     def checkin(self, req: AgentActionRequest):
         agent = self.data_handle_server.get_agent(req.saas_id, req.agent_id)
         if not agent or agent.agent_state == AgentState.DISABLE.code:
@@ -300,7 +300,6 @@ class AgentOperService:
             self._handle_idle(req.scene, agent)
         return self._push_event_for_checkin(agent, agent_monitor, phone, req.scene)
 
-    @with_app_context
     def checkout(self, req: AgentActionRequest):
         agent = self.data_handle_server.get_agent(req.saas_id, req.agent_id)
         if not agent or agent.agent_state == AgentState.DISABLE.code:
@@ -607,17 +606,16 @@ class AgentMonitorService:
             res.append(data.__dict__)
         return res
 
-    @with_app_context
     def update_checkin(self, agent_monitor):
+        agent_monitor = db.session.query(AgentMonitor).get(agent_monitor.id)
         agent_monitor.check_state = AgentCheck.IN.code
         agent_monitor.check_in_time = datetime.now()
         agent_monitor.heart_state = AgentHeartState.NORMAL.code
         agent_monitor.heart_time = datetime.now()
         self.logger.info("update_checkin %s",  agent_monitor.check_state)
         db.session.commit()
-
-    @with_app_context
     def update_checkout(self, agent_monitor):
+        agent_monitor = db.session.query(AgentMonitor).get(agent_monitor.id)
         agent_monitor.check_state = AgentCheck.OUT.code
         agent_monitor.check_out_time = datetime.now()
         agent_monitor.service_state = AgentServiceState.LOGOUT.code
@@ -626,42 +624,44 @@ class AgentMonitorService:
         self.logger.info("update_checkout %s", agent_monitor.check_out_time)
         db.session.commit()
 
-    @with_app_context
     def update_idle(self, agent_monitor):
+        agent_monitor = db.session.query(AgentMonitor).get(agent_monitor.id)
         agent_monitor.service_state = AgentServiceState.IDLE.code
         agent_monitor.idle_time = datetime.now()
         db.session.commit()
 
-    @with_app_context
     def update_busy(self, agent_monitor):
+        agent_monitor = db.session.query(AgentMonitor).get(agent_monitor.id)
         agent_monitor.service_state = AgentServiceState.BUSY.code
         agent_monitor.busy_time = datetime.now()
         db.session.commit()
 
-    @with_app_context
     def update_dialing(self, agent_monitor):
+        agent_monitor = db.session.query(AgentMonitor).get(agent_monitor.id)
         agent_monitor.service_state = AgentServiceState.DIALING.code
         db.session.commit()
 
-    @with_app_context
+
     def update_calling(self, agent_monitor):
+        agent_monitor = db.session.query(AgentMonitor).get(agent_monitor.id)
         agent_monitor.service_state = AgentServiceState.CALLING.code
         agent_monitor.call_time = datetime.now()
         db.session.commit()
 
-    @with_app_context
+
     def update_processing(self, agent_monitor):
+        agent_monitor = db.session.query(AgentMonitor).get(agent_monitor.id)
         agent_monitor.service_state = AgentServiceState.REPROCESSING.code
         agent_monitor.hang_time = datetime.now()
         db.session.commit()
 
-    @with_app_context
     def update_session_id(self, agent_monitor, session_id):
+        agent_monitor = db.session.query(AgentMonitor).get(agent_monitor.id)
         agent_monitor.session_id = session_id
         db.session.commit()
 
-    @with_app_context
     def update_heart_error(self, agent_monitor):
+        agent_monitor = db.session.query(AgentMonitor).get(agent_monitor.id)
         agent_monitor.heart_state = AgentHeartState.ABNORMAL.code
         agent_monitor.heart_time = datetime.now()
         db.session.commit()