add workflow 天润Smart-ccc工单数据,dev
This commit is contained in:
parent
93ff830ba4
commit
0bf1a59741
|
@ -84,15 +84,15 @@ def request_data_signature_post():
|
|||
jsonData = json.dumps(body)
|
||||
print(f'body: {jsonData}')
|
||||
dataReqL=requests.post(url,headers=header,data=jsonData)
|
||||
|
||||
resText = dataReqL.text
|
||||
i = 0
|
||||
while 'error' in dataReqL and i < 5:
|
||||
while 'error' in resText and i < 5:
|
||||
print(f'请求工单列表失败,再次请求第{i+1}次')
|
||||
time.sleep(1)
|
||||
dataReqL=requests.post(url,headers=header,params=body)
|
||||
i = i + 1
|
||||
resL=json.loads(dataReqL.text)
|
||||
resL=json.loads(resText)
|
||||
print(dataReqL)
|
||||
resL=json.loads(dataReqL.text)
|
||||
return resL
|
||||
|
||||
|
||||
|
@ -132,13 +132,15 @@ def request_data_signature_get(id):
|
|||
print(f'url: {url}')
|
||||
|
||||
dataReqL=requests.get(url,headers={},params={})
|
||||
resText = dataReqL.text
|
||||
i = 0
|
||||
while 'error' in dataReqL and i < 5:
|
||||
while 'error' in resText and i < 5:
|
||||
print(f'请求工单详情失败,再次请求第{i+1}次')
|
||||
time.sleep(1)
|
||||
dataReqL=requests.get(url,headers={},params={})
|
||||
i = i + 1
|
||||
resL=json.loads(dataReqL.text)
|
||||
return resL
|
||||
resD=json.loads(resText)
|
||||
return resD
|
||||
|
||||
def load_detail_data_to_db(ids, dataList):
|
||||
conn = psycopg2.connect(database="dataops_db", user="dbuser_dops", password="MIgTi3jA",host="172.17.0.8", port="5432")
|
||||
|
@ -157,14 +159,12 @@ def load_detail_data_to_db(ids, dataList):
|
|||
print('加载数据结束:tickets_detail:获取工单详情')
|
||||
|
||||
def load_detail_exp_to_db(id):
|
||||
try:
|
||||
print(f'添加查询工单异常记录:{id}')
|
||||
conn = psycopg2.connect(database="dataops_db", user="dbuser_dops", password="MIgTi3jA",host="172.17.0.8", port="5432")
|
||||
print('数据库连接成功')
|
||||
dataId=str(uuid.uuid4())
|
||||
total=len(dataList)
|
||||
print('临时id:'+dataId)
|
||||
json_object = json.dumps(dataList)
|
||||
idstr = ','.join(ids)
|
||||
cur=conn.cursor()
|
||||
sql=" INSERT INTO data_api.cc_details_ids_exp (id,api_id,is_loaded,status,request_tm,execute_tm,remark) values (%s,%s,'0','0',current_timestamp(0),current_timestamp(0),'')"
|
||||
cur.execute(sql,[id, '6a977523d60f46788e6004549027bb8e'])
|
||||
|
@ -172,6 +172,8 @@ def load_detail_exp_to_db(id):
|
|||
cur.close()
|
||||
conn.close()
|
||||
print(f'添加查询工单异常记录:{id} 结束')
|
||||
except Exception as e:
|
||||
print(f'添加查询工单异常记录:{id}失败, 错误信息:{e}')
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(f'{formatted2_previous_hour(0)}开始请求工单信息')
|
||||
|
@ -189,6 +191,7 @@ if __name__ == "__main__":
|
|||
try:
|
||||
id = data['id']
|
||||
resD = request_data_signature_get(id)
|
||||
print(f"请求工单详情结果{resD}")
|
||||
if 'error' in resD:
|
||||
error = resD['error']
|
||||
print(f"请求工单详情(id:{id})失败,错误信息:{error}")
|
||||
|
@ -198,7 +201,7 @@ if __name__ == "__main__":
|
|||
dataList = resL['ticketDetail']
|
||||
detailDataList.append(dataList)
|
||||
except Exception as e:
|
||||
print(f'请求工单详情(id:{id})失败, 错误信息:{e}')
|
||||
print(f'请求工单详情(id:{id})异常, )异常信息:{e}')
|
||||
load_detail_exp_to_db(data['id'])
|
||||
load_detail_data_to_db(ids,detailDataList)
|
||||
print(f'{formatted2_previous_hour(0)}请求工单信息结束')
|
Loading…
Reference in New Issue