فهرست منبع

tojson问题修复,merge

刘威 5 ماه پیش
والد
کامیت
55c3755fc3
5فایلهای تغییر یافته به همراه37 افزوده شده و 22 حذف شده
  1. 4 2
      docker-compose.yml
  2. 10 10
      src/core/callcenter/agent.py
  3. 4 5
      src/core/callcenter/api.py
  4. 18 4
      src/core/callcenter/views.py
  5. 1 1
      src/core/datasource.py

+ 4 - 2
docker-compose.yml

@@ -3,8 +3,10 @@ services:
     image: pjsua2:v2.14.1026
     container_name: pjsua
     restart: always
-    network_mode: host
+#    network_mode: host
+    ports:
+      - "8000:8000"
     volumes:
-      - /home/hongshan/voice-gateway-service:/code
+      - /Users/yushanghui/hongshantianping/git/voice-gateway-service:/code
     environment:
       - SERVE_HOST=192.168.100.159

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

@@ -37,10 +37,10 @@ class AgentOperService:
         db.session.commit()
 
     def disable(self, req: AgentActionRequest):
-        agent = _get_agent(req.saas_id, req.agent_number, req.out_id)
+        agent = _get_agent(req.saas_id, req.agent_id)
         if agent.agent_state == AgentState.DISABLE.code:
             return
-        agent_monitor = _get_agent_monitor(req.saas_id, req.agent_number)
+        agent_monitor = _get_agent_monitor(req.saas_id, agent.agent_number)
         if agent_monitor.check_state == AgentCheck.IN.code and \
                 agent_monitor.service_state == AgentServiceState.CALLING.code:
             raise BizException(BizErrorCode.AGENT_CALLING_NOT_ALLOW_OPERATE)
@@ -54,12 +54,12 @@ class AgentOperService:
         db.session.commit()
 
     def checkin(self, req: AgentActionRequest):
-        agent = _get_agent(req.saas_id, req.agent_number, req.out_id)
+        agent = _get_agent(req.saas_id, req.agent_id)
         if not agent or agent.agent_state == AgentState.DISABLE.code:
             raise BizException(BizErrorCode.ERROR_NOT_FOLLOW_CHECK_IN)
         phone = _get_phone(req.saas_id, agent.phone_num)
 
-        agent_monitor = _get_agent_monitor(req.saas_id, req.agent_number)
+        agent_monitor = _get_agent_monitor(req.saas_id, agent.agent_number)
 
         agent_monitor.check_scene = req.scene
         self.agent_monitor_service.update_checkin(agent_monitor)
@@ -72,11 +72,11 @@ class AgentOperService:
         return self._push_event_for_checkin(agent, agent_monitor, phone, req.scene)
 
     def checkout(self, req: AgentActionRequest):
-        agent = _get_agent(req.saas_id, req.agent_number, req.out_id)
+        agent = _get_agent(req.saas_id, req.agent_id)
         if not agent or agent.agent_state == AgentState.DISABLE.code:
             raise BizException(BizErrorCode.AGENT_DISABLE_NOT_ALLOW_OPERATE)
 
-        agent_monitor = _get_agent_monitor(req.saas_id, req.agent_number)
+        agent_monitor = _get_agent_monitor(req.saas_id, agent.agent_number)
         if not agent_monitor or agent_monitor.service_state == AgentServiceState.CALLING.code:
             raise BizException(BizErrorCode.AGENT_CALLING_NOT_ALLOW_OPERATE)
 
@@ -111,7 +111,7 @@ class AgentOperService:
         self._push_event_for_busy(agent, req.scene)
 
     def idle(self, req: AgentActionRequest):
-        agent = _get_agent(req.saas_id, req.agent_number, req.out_id)
+        agent = _get_agent(req.saas_id, req.agent_id)
         if not agent or agent.agent_state == AgentState.DISABLE.code:
             raise BizException(BizErrorCode.AGENT_DISABLE_NOT_ALLOW_OPERATE)
         self._handle_idle(req.scene, agent)
@@ -123,8 +123,8 @@ class AgentOperService:
         pass
 
     def turn_on(self, req: AgentActionRequest):
-        agent = _get_agent(req.saas_id, req.agent_number, req.out_id)
-        agent_monitor = _get_agent_monitor(req.saas_id, req.agent_number)
+        agent = _get_agent(req.saas_id, req.agent_id)
+        agent_monitor = _get_agent_monitor(req.saas_id, agent.agent_number)
         agent_scene = AgentScene.get_by_code(req.scene)
         if not agent_monitor:
             raise BizException(BizErrorCode.RECORD_NOT_EXIST_ERROR)
@@ -206,7 +206,7 @@ class AgentService:
         self.agent_monitor_service = AgentMonitorService(client, logger)
 
     def get_and_check(self, req: AgentActionRequest):
-        agent = _get_agent(req.saas_id, req.agent_number, req.out_id)
+        agent = _get_agent(req.saas_id, req.agent_id)
         if not agent:
             return {}
         phone = _get_phone(req.saas_id, agent.phone_num)

+ 4 - 5
src/core/callcenter/api.py

@@ -98,15 +98,14 @@ class AgentActionRequest(BaseApi):
     """
     坐席操作
     """
-
-    def __init__(self, saas_id, agent_id, agent_number=None, out_id=None, identity_type=None, scene='manual'):
-        self.saas_id = saas_id
+    def __init__(self, saas_id, agent_id, agent_number=None, out_id=None, identity_type=None, scene='manual',**kwargs):
+        self.saas_id =saas_id
         # 坐席工号
         self.agent_id = agent_id
         # # 坐席工号
         self.agent_number = agent_number
         # 外部展示Id
-        self.out_id = out_id,
+        self.out_id = out_id
         # 身份状态
         self.identity_type = identity_type
         # 场景 manual:手动外呼; robot:机器人外呼; monitor:监听
@@ -119,7 +118,7 @@ class HumanServiceQueryRequest(BaseApi):
     def __init__(self, saas_id, service_id, agent_state, agent_ids: Dict[str, Any] = {}):
         self.saasId = saas_id
         self.serviceId = service_id
-        self.agentState = agent_state,
+        self.agentState = agent_state
         self.agentIds = agent_ids
 
 

+ 18 - 4
src/core/callcenter/views.py

@@ -64,10 +64,24 @@ def get_cdn_url():
 @app.route('/open/agent/get-init-config', methods=['POST'])
 def get_init_config():
     """获取初始化配置"""
-    data = request.get_json()
-    param = AgentActionRequest.from_json(data=data)
-    res = agent_service.get_and_check(param)
-    return success_response(res)
+    try:
+        print("Request Object: %s", request)
+        print("Headers: %s", request.headers)
+        print("JSON Data: %s", request.get_json())
+        print("Data: %s", request.data)
+        print("Method: %s", request.method)
+        print("URL: %s", request.url)
+
+        data = request.get_json()
+        print("Parsed Data: %s", data)
+
+        param = AgentActionRequest.from_json(data=data)
+        res = agent_service.get_and_check(param)
+        return success_response(res)
+
+    except Exception as e:
+        print("Exception occurred: %s", str(e))
+        return {"error": "An error occurred", "details": str(e)}, 500
 
 
 @app.route('/open/agent/check-in', methods=['POST'])

+ 1 - 1
src/core/datasource.py

@@ -15,7 +15,7 @@ from src.core import singleton
 from redis import StrictRedis, ConnectionPool
 
 SERVE_HOST = os.environ.get("SERVE_HOST")
-SERVE_HOST = "192.168.100.195"
+# SERVE_HOST = "192.168.100.195"
 MYSQL_PASSWORD = 'EKoAe3H8xybQKrFPApXM'
 
 if SERVE_HOST != "192.168.100.159":