123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- #!/usr/bin/env python3
- # encoding:utf-8
- import json
- from src.core.callcenter.enumeration import CallStage
- saasId = "mdj"
- UTF_8 = "UTF-8"
- SPACE = " "
- EMPTY = ""
- LF = "\n"
- CR = "\r"
- AT = "@"
- CO = ":"
- UNDER_LINE = "_"
- POINT = "."
- SK = "/"
- LINE = "-"
- JSON = ".json"
- XML = ".xml"
- HTTP = "http://"
- HTTPS = "https://"
- #vip等级进线
- VIP_LEVEL = "vipLevel"
- START_TIME = "startTime"
- QUEUE_TIME = "queueTime"
- #指定坐席
- DESIGNATE_AGENT = "desiganteAgent"
- #当前空闲时间
- LONG_READY = "longReady"
- #空闲次数
- READY_TIMES = "readyTimes"
- #服务次数
- SEREVICE_TIMES = "serviceTimes"
- HOLD_MUSIC_PATH = '/freeswitch/music/hold.wav'
- WaitingHangupMusicPath = '/freeswitch/music/sorry.wav'
- BASE_RECORD_PATH = '/freeswitch/record/'
- EMPTY = ""
- DEFAULT_KEY = ""
- #坐席状态相关
- AGENT_STATE_KEY = "STATE"
- AGENT_LOG_KEY = "LOG"
- DEVOCE_KEY = "DEVICE"
- DETAIL_KEY = "DETAIL"
- CALLLOG_KEY = "CALLLOG"
- AGENT_STATE_EXCHANGE = "AGENT-STATE-EXCHANGE"
- CALL_LOG_EXCHANGE = "CALL-LOG-EXCHANGE"
- #话单相关
- CALL_DEVICE_QUEUE = "CALL-DEVICE-QUEUE"
- CALL_LOG_QUEUE = "CALL-LOG-QUEUE"
- CALL_DETAIL_QUEUE = "CALL-DETAIL-QUEUE"
- AGENT_STATE_QUEUE = "AGENT-STATE-QUEUE"
- AGENT_LOG_QUEUE = "AGENT-LOG-QUEUE"
- #配置变更相关
- CC_CONFIG_EXCHANGE = "CC-CONFIG-EXCHANGE"
- CC_CONFIG_QUEUE = "CC-CONFIG-QUEUE"
- AGENT_TOKEN = "AGENT_TOKEN:"
- AGENT_INFO = "AGENT_INFO:"
- ADMIN_TOKEN = "ADMIN_TOKEN:"
- ADMIN_INFO = "ADMIN_INFO:"
- CALL_INFO = "CALL_INFO:"
- START_AGENT_NUM = "1000"
- DELAY_ACTION_BATCH_SIZE = 10
- CTI_ENGINE_DELAY_ACTION = "DELAY:ACTION:%s"
- CTI_ENGINE_DELAY_ACTION_LOCK = "DELAY:ACTION:LOCK:%s"
- NEED_PLAY_HOLD_MUSIC = "CTI:ENGINE:NEED:HOLD:%s"
- AFTER_PLAY_HOLD_MUSIC = "CTI:ENGINE:AFTER:HOLD:%s"
- CTI_MANAGE_CENTER_CALL_END_KEY = "CTI:MANAGE:CENTER:CALL:END:KEY:%s"
- CTI_AGENT_MANUAL_ANSWER = "AGENT:MANUAL:ANSWER:%s:%s"
- def get_json_dict(json_text=None):
- if isinstance(json_text, str):
- _data = json.loads(json_text)
- elif isinstance(json_text, bytes):
- json_string = json_text.decode('UTF-8')
- _data = json.loads(json_string)
- else:
- _data = json_text
- return _data
- def success_response(data=None, code=0, msg=""):
- response = json.dumps({"code": code, "msg": msg, "data": data})
- return response, 200, {"Content-Type": "application/json"}
- def error_response(msg, data=None, code=1, http_code=200):
- print("liuwei::debubgger::error_response:code=%s, msg=%s, data=%s" % (code, msg, data), flush=True)
- response = json.dumps({"code": code, "msg": msg, "data": data})
- return response, http_code, {"Content-Type": "application/json"}
- def format_time_millis(time_millis, pattern='%Y%m%d'):
- from datetime import datetime
- dt = datetime.utcfromtimestamp(time_millis)
- return dt.strftime(pattern)
- # def get_record_prefix(call):
- # return BASE_RECORD_PATH + call.call_type + '/' + call.saas_id + '/' + call.caller + '/' + format_time_millis(call.call_time)
- def get_record_prefix(call):
- # 确保所有的值都是字符串类型
- return BASE_RECORD_PATH + str(call.call_type) + '/' + str(call.saas_id) + '/' + str(call.caller) + '/' + format_time_millis(call.call_time)
- def get_record_file_name(call_id, stage: CallStage):
- if stage.ROBOT == stage:
- return call_id + '_0'
- if stage.AGENT == stage:
- return call_id + '_1'
- return call_id
|