add workflow 天润Smart-ccc工单数据,dev

This commit is contained in:
root 2024-08-02 18:50:09 +08:00
parent fb85a1f0a9
commit a34a1c7040
1 changed files with 20 additions and 7 deletions

View File

@ -62,11 +62,11 @@ def build_query_string(params):
return query_string return query_string
def request_data_signature_post(): def request_data_signature_post(offset, pageSize):
print(f'开始请求工单列表数据:{formatted2_previous_hour(0)}') print(f'开始请求工单列表数据:{formatted2_previous_hour(0)}')
url='https://api-bj.clink.cn/ticket/list_ticket' url='https://api-bj.clink.cn/ticket/list_ticket'
header={'Content-Type':'application/json;charset=UTF-8'} header={'Content-Type':'application/json;charset=UTF-8'}
param={'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177','Timestamp':current_time_utc,'Expires':86400,'limit':100} param={'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177','Timestamp':current_time_utc,'Expires':86400,'limit':pageSize,'offset':offset}
print(f'param: {param}') print(f'param: {param}')
url_path = build_query_string(param) url_path = build_query_string(param)
url_param = build_query_string(param) url_param = build_query_string(param)
@ -80,7 +80,7 @@ def request_data_signature_post():
print(f'url: {url}') print(f'url: {url}')
# body={'endTime':formatted2_previous_hour(0),'startTime':'2024-01-01 00:00:00'} # body={'endTime':formatted2_previous_hour(0),'startTime':'2024-01-01 00:00:00'}
body={'endTime':formatted2_previous_hour(0),'startTime':'1900-01-01 00:00:00','updateTimeStart':formatted2_previous_hour(1),'updateTimeEnd':formatted2_previous_hour(0)} body={'endTime':formatted2_previous_hour(0),'startTime':'1900-01-01 00:00:00','updateTimeStart':formatted2_previous_hour(48),'updateTimeEnd':formatted2_previous_hour(0)}
jsonData = json.dumps(body) jsonData = json.dumps(body)
print(f'body: {jsonData}') print(f'body: {jsonData}')
dataReqL=requests.post(url,headers=header,data=jsonData) dataReqL=requests.post(url,headers=header,data=jsonData)
@ -179,17 +179,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_post() offset = 0
pageSize = 10
resL = request_data_signature_post(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['tickets'] list = resL['tickets']
load_data_to_db(dataList) page = resL['pageNumber']
total = resL['totalCount']
print(f'此次请求数据总数为:{total},需要请求{int(total/pageSize) + 1}')
i = 1
while page * pageSize < total:
i = i+1
offset = page * pageSize
resL = request_data_signature_post(offset, pageSize)
list = list + resL['tickets']
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['id'] id = data['id']
resD = request_data_signature_get(id) resD = request_data_signature_get(id)