소스 검색

feat:init

余尚辉 5 달 전
부모
커밋
04c9d58b03
5개의 변경된 파일30개의 추가작업 그리고 21개의 파일을 삭제
  1. 1 1
      docker-compose.yml
  2. 1 0
      requirements.txt
  3. 4 0
      src/core/callcenter/api.py
  4. 22 19
      src/core/callcenter/views.py
  5. 2 1
      src/core/datasource.py

+ 1 - 1
docker-compose.yml

@@ -7,6 +7,6 @@ services:
     ports:
       - "8000:8000"
     volumes:
-      - /Users/yushanghui/hongshantianping/git/voice-gateway-service:/code
+      - /home/hongshan/voice-gateway-service:/code
     environment:
       - SERVE_HOST=192.168.100.159

+ 1 - 0
requirements.txt

@@ -1,5 +1,6 @@
 flask
 flask_socketio
+flask_cors
 mmh3
 apscheduler
 gunicorn

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

@@ -111,6 +111,10 @@ class AgentActionRequest(BaseApi):
         # 场景 manual:手动外呼; robot:机器人外呼; monitor:监听
         self.scene = scene
         self.service_id = service_id
+        # 处理多余的参数
+        for key, value in kwargs.items():
+            setattr(self, key, value)
+
 
 
 class HumanServiceQueryRequest(BaseApi):

+ 22 - 19
src/core/callcenter/views.py

@@ -8,7 +8,7 @@ from . import app
 import src.core.callcenter.cache as Cache
 from src.core.callcenter import create_app
 from src.core.callcenter.agent import AgentService, AgentOperService
-from src.core.callcenter.constant import success_response
+from src.core.callcenter.constant import success_response, error_response
 from src.core.callcenter.enumeration import CallType
 from src.core.callcenter.esl.client import InboundClient, OutboundClient
 from flask import Flask, request, render_template_string
@@ -16,13 +16,13 @@ from flask import Flask, request, render_template_string
 from src.core.callcenter.call import CallService
 from src.core.callcenter.api import AgentCallRequest, AgentActionRequest, HangupCallRequest, \
     HumanServiceQueryRequest
-# from src.core.voip.bot import BotAgent
+from src.core.voip.bot import BotAgent
 
 
-# agent = BotAgent(app.logger)
-agent = None
+agent = BotAgent(app.logger)
+# agent = None
 inbound_client = InboundClient(agent, app.logger)
-# outbound_client = OutboundClient(agent, app.logger)
+outbound_client = OutboundClient(agent, app.logger)
 call_service = CallService(inbound_client, app.logger)
 agent_service = AgentService(inbound_client, app.logger)
 agent_oper_service = AgentOperService(inbound_client, app.logger)
@@ -66,13 +66,13 @@ def get_init_config():
     """获取初始化配置"""
     try:
         data = request.get_json()
-        param = AgentActionRequest.from_json(data=data)
+        param = AgentActionRequest.from_json(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
+        return error_response(e)
 
 
 @app.route('/open/agent/check-in', methods=['POST'])
@@ -80,12 +80,12 @@ def check_in():
     """坐席签入"""
     try:
         data = request.get_json()
-        param = AgentActionRequest.from_json(data=data)
+        param = AgentActionRequest.from_json(data)
         res = agent_oper_service.checkin(param)
         return success_response(res)
     except Exception as e:
         print("Exception occurred: %s", str(e))
-        return {"error": "An error occurred", "details": str(e)}, 500
+        return error_response(e)
 
 
 @app.route('/open/agent/check-out', methods=['POST'])
@@ -93,11 +93,12 @@ def check_out():
     """坐席签出"""
     try:
         data = request.get_json()
-        param = AgentActionRequest.from_json(data=data)
-        return agent_oper_service.checkout(param)
+        param = AgentActionRequest.from_json(data)
+        res= agent_oper_service.checkout(param)
+        return success_response(res)
     except Exception as e:
         print("Exception occurred: %s", str(e))
-        return {"error": "An error occurred", "details": str(e)}, 500
+        return error_response(e)
 
 
 @app.route('/open/agent/busy', methods=['POST'])
@@ -105,11 +106,12 @@ def busy():
     """坐席置忙"""
     try:
         data = request.get_json()
-        param = AgentActionRequest.from_json(data=data)
-        return agent_oper_service.busy(param)
+        param = AgentActionRequest.from_json(data)
+        res= agent_oper_service.busy(param)
+        return success_response(res)
     except Exception as e:
         print("Exception occurred: %s", str(e))
-        return {"error": "An error occurred", "details": str(e)}, 500
+        return error_response(e)
 
 
 @app.route('/open/agent/idle', methods=['POST'])
@@ -117,8 +119,9 @@ def idle():
     """坐席置闲"""
     try:
         data = request.get_json()
-        param = AgentActionRequest.from_json(data=data)
-        return agent_oper_service.idle(param)
+        param = AgentActionRequest.from_json(data)
+        res = agent_oper_service.idle(param)
+        return success_response(res)
     except Exception as e:
         print("Exception occurred: %s", str(e))
         return {"error": "An error occurred", "details": str(e)}, 500
@@ -129,7 +132,7 @@ def turn_on():
     """接通"""
     try:
         data = request.get_json()
-        param = AgentActionRequest.from_json(data=data)
+        param = AgentActionRequest.from_json(data)
         return agent_oper_service.checkin(param)
     except Exception as e:
         print("Exception occurred: %s", str(e))
@@ -141,7 +144,7 @@ def hang_up():
     """挂断"""
     try:
         data = request.get_json()
-        param = AgentActionRequest.from_json(data=data)
+        param = AgentActionRequest.from_json(data)
         res = call_service.hangup(param)
         return success_response(res)
     except Exception as e:

+ 2 - 1
src/core/datasource.py

@@ -16,12 +16,13 @@ from redis import StrictRedis, ConnectionPool
 
 SERVE_HOST = os.environ.get("SERVE_HOST")
 
-SERVE_HOST = "192.168.124.6"
+# SERVE_HOST = "192.168.110.203"
 MYSQL_PASSWORD = 'EKoAe3H8xybQKrFPApXM'
 
 if SERVE_HOST != "192.168.100.159":
     SIP_SERVER = SERVE_HOST
     MYSQL_PASSWORD = "12345678"
+    # SIP_SERVER = "pbx.fuxicarbon.com"
 else:
     SIP_SERVER = "pbx.fuxicarbon.com"