删除多余output,优化api调用函数
This commit is contained in:
parent
28a8cd0965
commit
0754804992
|
@ -505,18 +505,14 @@ async def generate_report(base_info, baogao_info):
|
||||||
print(await search_and_replace(output_dir, 'baogao_date', baogao_date.split(' ')[0]))
|
print(await search_and_replace(output_dir, 'baogao_date', baogao_date.split(' ')[0]))
|
||||||
print(await search_and_replace(output_dir, jiegou_xuhao, num_to_chinese[head_num]))
|
print(await search_and_replace(output_dir, jiegou_xuhao, num_to_chinese[head_num]))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
json_data1 = {
|
json_data1 = {
|
||||||
"turbine_id" : "183463dbf40d9278549a76b82b175dd9",
|
"turbine_id" : "183463dbf40d9278549a76b82b175dd9",
|
||||||
}
|
}
|
||||||
|
|
||||||
json_data2 = {
|
json_data2 = {
|
||||||
'shengcheng_dir': r"D:\work\Report_Generate_Server\output",
|
'shengcheng_dir': r".\output",
|
||||||
'muban_dir': r"D:\work\Report_Generate_Server\muban",
|
'muban_dir': r".\muban",
|
||||||
}
|
}
|
||||||
asyncio.run(generate_report(json_data1,json_data2))
|
asyncio.run(generate_report(json_data1,json_data2))
|
||||||
print('文档生成完毕')
|
print('文档生成完毕')
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,79 +1,42 @@
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
from tools.API import *
|
from tools.API import *
|
||||||
def get_project_info(projectId):
|
|
||||||
projecturl = DTURL + GETPROJECTINFO.format(projectId=projectId)
|
def get_data(url, data_type="data", params=None):
|
||||||
headers = {
|
headers = {
|
||||||
"content_type" : "application/x-www-form-urlencoded"
|
"content_type": "application/x-www-form-urlencoded"
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
response = requests.get(projecturl, headers=headers)
|
response = requests.get(url, headers=headers, params=params)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
data = json.loads(response.text)
|
data = json.loads(response.text)
|
||||||
print(f"获取到项目的数据:{data}")
|
print(f"获取到数据:{data}")
|
||||||
return data["data"]
|
return data.get(data_type)
|
||||||
else:
|
else:
|
||||||
print(f"获取项目{projectId}数据失败,状态码:{response.status_code}")
|
print(f"请求数据失败,状态码:{response.status_code}")
|
||||||
return None
|
return None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"获取项目{projectId}数据失败,异常:{e}")
|
print(f"请求数据失败,异常:{e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_project_info(projectId):
|
||||||
|
projecturl = DTURL + GETPROJECTINFO.format(projectId=projectId)
|
||||||
|
return get_data(projecturl, "data")
|
||||||
|
|
||||||
def get_jizu_info(turbineId):
|
def get_jizu_info(turbineId):
|
||||||
jizuurl = DTURL + GETJIZUINFO.format(turbineId=turbineId)
|
jizuurl = DTURL + GETJIZUINFO.format(turbineId=turbineId)
|
||||||
headers = {
|
return get_data(jizuurl, "data")
|
||||||
"content_type" : "application/x-www-form-urlencoded"
|
|
||||||
}
|
|
||||||
try:
|
|
||||||
response = requests.get(jizuurl, headers=headers)
|
|
||||||
if response.status_code == 200:
|
|
||||||
data = json.loads(response.text)
|
|
||||||
print(f"获取到机组的数据:{data}")
|
|
||||||
return data["data"]
|
|
||||||
else:
|
|
||||||
print(f"获取项目{turbineId}数据失败,状态码:{response.status_code}")
|
|
||||||
return None
|
|
||||||
except Exception as e:
|
|
||||||
print(f"获取项目{turbineId}数据失败,异常:{e}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
def get_jizu_shigong_info(turbineId):
|
def get_jizu_shigong_info(turbineId):
|
||||||
jizuurl = DTURL + GETSHIGONGINFO
|
jizuurl = DTURL + GETSHIGONGINFO
|
||||||
headers = {
|
|
||||||
"content_type" : "application/x-www-form-urlencoded"
|
|
||||||
}
|
|
||||||
params = {
|
params = {
|
||||||
"rows" : {
|
"rows": {
|
||||||
"turbineId" : turbineId
|
"turbineId": turbineId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try:
|
result = get_data(jizuurl, "rows", params)
|
||||||
response = requests.get(jizuurl, headers=headers, params=params)
|
return result[0] if result else None
|
||||||
if response.status_code == 200:
|
|
||||||
data = json.loads(response.text)
|
|
||||||
print(f"获取到机组施工的数据:{data}")
|
|
||||||
return data["rows"][0]
|
|
||||||
else:
|
|
||||||
print(f"获取项目{turbineId}施工数据失败,状态码:{response.status_code}")
|
|
||||||
return None
|
|
||||||
except Exception as e:
|
|
||||||
print(f"获取项目{turbineId}施工数据失败,异常:{e}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
def get_weather(weatherid):
|
def get_weather(weatherid):
|
||||||
weatherurl = DTURL + GETWEATHERINFO.format(weatherCode=weatherid)
|
weatherurl = DTURL + GETWEATHERINFO.format(weatherCode=weatherid)
|
||||||
headers = {
|
return get_data(weatherurl, "data")
|
||||||
"content_type" : "application/x-www-form-urlencoded"
|
|
||||||
}
|
|
||||||
try:
|
|
||||||
response = requests.get(weatherurl, headers=headers)
|
|
||||||
if response.status_code == 200:
|
|
||||||
data = json.loads(response.text)
|
|
||||||
print(f"获取到天气数据:{data}")
|
|
||||||
return data["data"]
|
|
||||||
else:
|
|
||||||
print(f"获取天气{weatherid}数据失败,状态码:{response.status_code}")
|
|
||||||
return None
|
|
||||||
except Exception as e:
|
|
||||||
print(f"获取天气{weatherid}数据失败,异常:{e}")
|
|
||||||
return None
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue