add workflow 天润Smart-ccc通话记录,dev
This commit is contained in:
parent
210a787098
commit
1c05ef709d
|
@ -62,10 +62,10 @@ def build_query_string(params):
|
||||||
return query_string
|
return query_string
|
||||||
|
|
||||||
#计算签名,get请求
|
#计算签名,get请求
|
||||||
def request_data_signature_get():
|
def request_data_signature_get(offset, pageSize):
|
||||||
print(f'开始请求外呼记录数据')
|
print(f'开始请求外呼记录数据,偏移量:{offset}')
|
||||||
url='https://api-bj.clink.cn/cc/list_cdr_ob'
|
url='https://api-bj.clink.cn/cc/list_cdr_ob'
|
||||||
param={'Timestamp':current_time_utc,'Expires':86400,'startTime':previous_hour_timestamp(1),'startTimeEnd':previous_hour_timestamp(0),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177'}
|
param={'Timestamp':current_time_utc,'Expires':86400,'startTime':previous_hour_timestamp(1),'startTimeEnd':previous_hour_timestamp(0),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177','limit':pageSize,'offset':offset}
|
||||||
# param={'Timestamp':current_time_utc,'Expires':86400,'startTime':1717516800,'startTimeEnd':previous_hour_timestamp(0),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177'}
|
# param={'Timestamp':current_time_utc,'Expires':86400,'startTime':1717516800,'startTimeEnd':previous_hour_timestamp(0),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177'}
|
||||||
print(f'param: {param}')
|
print(f'param: {param}')
|
||||||
url_path = build_query_string(param)
|
url_path = build_query_string(param)
|
||||||
|
@ -175,17 +175,30 @@ def load_detail_exp_to_db(id):
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print(f'{formatted2_previous_hour(0)}开始请求外呼记录列表')
|
print(f'{formatted2_previous_hour(0)}开始请求外呼记录列表')
|
||||||
resL = request_data_signature_get()
|
offset = 0
|
||||||
|
pageSize = 100
|
||||||
|
resL = request_data_signature_get(offset, pageSize)
|
||||||
print(resL)
|
print(resL)
|
||||||
if 'error' in resL:
|
if 'error' in resL:
|
||||||
error = resL['error']
|
error = resL['error']
|
||||||
print(f'请求外呼记录列表失败,失败原因:{error}')
|
print(f'请求外呼记录列表失败,失败原因:{error}')
|
||||||
else:
|
else:
|
||||||
dataList = resL['cdrOb']
|
list = resL['cdrOb']
|
||||||
load_data_to_db(dataList)
|
page = resL['pageNumber']
|
||||||
|
total = resL['totalCount']
|
||||||
|
print(f'此次请求数据总数为:{total},需要请求{int(total/page) + 1}次')
|
||||||
|
i = 1
|
||||||
|
while page * pageSize < total:
|
||||||
|
i = i+1
|
||||||
|
offset = page * pageSize
|
||||||
|
resL = request_data_signature_get(offset, pageSize)
|
||||||
|
list = list + resL['cdrOb']
|
||||||
|
page = resL['pageNumber']
|
||||||
|
print(f'总计请求{i}次,此次外呼记录数为{len(list)}')
|
||||||
|
load_data_to_db(list)
|
||||||
detailDataList = []
|
detailDataList = []
|
||||||
ids = []
|
ids = []
|
||||||
for data in dataList:
|
for data in list:
|
||||||
try:
|
try:
|
||||||
id = data['mainUniqueId']
|
id = data['mainUniqueId']
|
||||||
resD = request_detail_signature_get(id)
|
resD = request_detail_signature_get(id)
|
||||||
|
|
|
@ -62,11 +62,11 @@ def build_query_string(params):
|
||||||
return query_string
|
return query_string
|
||||||
|
|
||||||
#计算签名,get请求
|
#计算签名,get请求
|
||||||
def request_data_signature_get():
|
def request_data_signature_get(offset, pageSize):
|
||||||
print(f'开始请求客服来电记录数据')
|
print(f'开始请求客服来电记录数据')
|
||||||
url='https://api-bj.clink.cn/cc/list_cdr_ib'
|
url='https://api-bj.clink.cn/cc/list_cdr_ib'
|
||||||
# param={'Timestamp':current_time_utc,'Expires':86400,'startTime':previous_hour_timestamp(1),'startTimeEnd':previous_hour_timestamp(0),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177'}
|
# param={'Timestamp':current_time_utc,'Expires':86400,'startTime':previous_hour_timestamp(1),'startTimeEnd':previous_hour_timestamp(0),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177'}
|
||||||
param={'Timestamp':current_time_utc,'Expires':86400,'startTime':1712332800,'startTimeEnd':1714838400,'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177'}
|
param={'Timestamp':current_time_utc,'Expires':86400,'startTime':1712332800,'startTimeEnd':1714838400,'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177',,'limit':pageSize,'offset':offset}
|
||||||
|
|
||||||
print(f'param: {param}')
|
print(f'param: {param}')
|
||||||
url_path = build_query_string(param)
|
url_path = build_query_string(param)
|
||||||
|
@ -111,13 +111,26 @@ def load_data_to_db(dataList):
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print(f'{formatted2_previous_hour(0)}开始请求客户来电记录信息')
|
print(f'{formatted2_previous_hour(0)}开始请求客户来电记录信息')
|
||||||
resL = request_data_signature_get()
|
offset = 0
|
||||||
|
pageSize = 100
|
||||||
|
resL = request_data_signature_get(offset,pageSize)
|
||||||
print(resL)
|
print(resL)
|
||||||
if 'error' in resL:
|
if 'error' in resL:
|
||||||
error = resL['error']
|
error = resL['error']
|
||||||
print(f'请求客户来电记录失败,失败原因:{error}')
|
print(f'请求客户来电记录失败,失败原因:{error}')
|
||||||
else:
|
else:
|
||||||
dataList = resL['cdrIb']
|
dataList = resL['cdrIb']
|
||||||
|
page = resL['pageNumber']
|
||||||
|
total = resL['totalCount']
|
||||||
|
print(f'此次请求数据总数为:{total},需要请求{int(total/page) + 1}次')
|
||||||
|
i = 1
|
||||||
|
while page * pageSize < total:
|
||||||
|
i = i+1
|
||||||
|
offset = page * pageSize
|
||||||
|
resL = request_data_signature_get(offset, pageSize)
|
||||||
|
list = list + resL['cdrIbAgent']
|
||||||
|
page = resL['pageNumber']
|
||||||
|
print(f'总计请求{i}次,此次外呼记录数为{len(list)}')
|
||||||
load_data_to_db(dataList)
|
load_data_to_db(dataList)
|
||||||
print(f'{formatted2_previous_hour(0)}请求客户来电记录结束')
|
print(f'{formatted2_previous_hour(0)}请求客户来电记录结束')
|
||||||
|
|
|
@ -62,11 +62,11 @@ def build_query_string(params):
|
||||||
return query_string
|
return query_string
|
||||||
|
|
||||||
#计算签名,get请求
|
#计算签名,get请求
|
||||||
def request_data_signature_get():
|
def request_data_signature_get(offset, pageSize):
|
||||||
print(f'开始请求座席接听记录数据')
|
print(f'开始请求座席接听记录数据')
|
||||||
url='https://api-bj.clink.cn/cc/list_cdr_ib_agent'
|
url='https://api-bj.clink.cn/cc/list_cdr_ib_agent'
|
||||||
# param={'Timestamp':current_time_utc,'Expires':86400,'startTime':previous_hour_timestamp(1),'startTimeEnd':previous_hour_timestamp(0),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177'}
|
# param={'Timestamp':current_time_utc,'Expires':86400,'startTime':previous_hour_timestamp(1),'startTimeEnd':previous_hour_timestamp(0),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177'}
|
||||||
param={'Timestamp':current_time_utc,'Expires':86400,'startTime':1712332800,'startTimeEnd':1714838400,'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177'}
|
param={'Timestamp':current_time_utc,'Expires':86400,'startTime':1712332800,'startTimeEnd':1714838400,'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177',,'limit':pageSize,'offset':offset}
|
||||||
|
|
||||||
print(f'param: {param}')
|
print(f'param: {param}')
|
||||||
url_path = build_query_string(param)
|
url_path = build_query_string(param)
|
||||||
|
@ -114,12 +114,25 @@ def load_data_to_db(dataList):
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print(f'{formatted2_previous_hour(0)}开始请求座席接听记录信息')
|
print(f'{formatted2_previous_hour(0)}开始请求座席接听记录信息')
|
||||||
resL = request_data_signature_get()
|
offset = 0
|
||||||
|
pageSize = 100
|
||||||
|
resL = request_data_signature_get(offset, pageSize)
|
||||||
print(resL)
|
print(resL)
|
||||||
if 'error' in resL:
|
if 'error' in resL:
|
||||||
error = resL['error']
|
error = resL['error']
|
||||||
print(f'请求座席接听记录列表失败,失败原因:{error}')
|
print(f'请求座席接听记录列表失败,失败原因:{error}')
|
||||||
else:
|
else:
|
||||||
dataList = resL['cdrIbAgent']
|
dataList = resL['cdrIbAgent']
|
||||||
|
page = resL['pageNumber']
|
||||||
|
total = resL['totalCount']
|
||||||
|
print(f'此次请求数据总数为:{total},需要请求{int(total/page) + 1}次')
|
||||||
|
i = 1
|
||||||
|
while page * pageSize < total:
|
||||||
|
i = i+1
|
||||||
|
offset = page * pageSize
|
||||||
|
resL = request_data_signature_get(offset, pageSize)
|
||||||
|
list = list + resL['cdrIbAgent']
|
||||||
|
page = resL['pageNumber']
|
||||||
|
print(f'总计请求{i}次,此次外呼记录数为{len(list)}')
|
||||||
load_data_to_db(dataList)
|
load_data_to_db(dataList)
|
||||||
print(f'{formatted2_previous_hour(0)}请求座席接听记录结束')
|
print(f'{formatted2_previous_hour(0)}请求座席接听记录结束')
|
Loading…
Reference in New Issue