更新数据截止日2025.12.07

This commit is contained in:
lychang
2025-12-08 16:24:17 +08:00
parent 2c8b096c8f
commit 40f2aabf3a
2 changed files with 0 additions and 117 deletions

55
app.py
View File

@@ -1176,61 +1176,6 @@ def generate_weekly_report():
return api_response(success=False, error=e, status_code=500)
@app.route('/api/render/template', methods=['POST'])
def report_render_template():
data = request.get_json()
template = data.get('template', '')
origin_path = data.get('path', '')
file = ofm.get_file(origin_path)
with open("a.docx", 'wb') as f:
f.write(file)
if file:
template_content = transform_template(file)
response = ofm.upload_file(f"tpldev/render/{template}.template", template_content.encode('utf-8'))
print(response)
if response:
return api_response(success=True,
data={"template_name": template, "template_path": f"tpldev/render/{template}.template"},
status_code=200)
return api_response(success=False, error="上传模板失败", status_code=500)
@app.route('/api/render/insight', methods=['GET', 'POST'])
def report_render():
"""获取统计数据API"""
try:
if request.method == 'GET':
security_code = request.args.get('security_code', '')
else:
data = request.get_json()
security_code = data.get('security_code', '')
url = "http://10.0.0.39/cloud/in/api/online/run/cache"
body = {
"pid": "1988527857586081794",
"fid": "1988527857586081794",
"secCode": security_code
}
resp = requests.post(url=url, json=body)
if resp.status_code != 200:
return api_response(success=False, error=resp.text, status_code=500)
else:
data_info = resp.json().get('data', {}).get('data', '')
data_info = data_info.replace("data:application/json,", "")
data_info = json.loads(data_info)
data_path = data_info.get('url', '')
data = requests.get(data_path)
template_content = ofm.get_file("tpldev/render/insight.template")
html = report_template_render(template_content.decode("utf-8"), data=data.json())
if request.method == 'GET':
return html
else:
return api_response(success=False, content=html, status_code=200)
except Exception as e:
return api_response(success=False, error=e, status_code=500)
if __name__ == '__main__':
# 检查数据库文件是否存在
if not os.path.exists('db/data'):