update ui

This commit is contained in:
2025-11-14 15:20:58 +08:00
parent 8315aac4d9
commit fc9b4e6257

60
app.py
View File

@@ -8657,7 +8657,7 @@ def get_stock_info(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
result = conn.execute(query, seccode=seccode).fetchone() result = conn.execute(query, {'seccode': seccode}).fetchone()
if not result: if not result:
return jsonify({ return jsonify({
@@ -8681,7 +8681,7 @@ def get_stock_info(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
forecast_result = conn.execute(forecast_query, seccode=seccode).fetchone() forecast_result = conn.execute(forecast_query, {'seccode': seccode}).fetchone()
data = { data = {
'stock_code': result.SECCODE, 'stock_code': result.SECCODE,
@@ -8843,7 +8843,7 @@ def get_balance_sheet(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
result = conn.execute(query, seccode=seccode, limit=limit) result = conn.execute(query, {'seccode': seccode, 'limit': limit})
data = [] data = []
for row in result: for row in result:
@@ -9034,7 +9034,7 @@ def get_income_statement(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
result = conn.execute(query, seccode=seccode, limit=limit) result = conn.execute(query, {'seccode': seccode, 'limit': limit})
data = [] data = []
for row in result: for row in result:
@@ -9244,7 +9244,7 @@ def get_cashflow(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
result = conn.execute(query, seccode=seccode, limit=limit) result = conn.execute(query, {'seccode': seccode, 'limit': limit})
data = [] data = []
for row in result: for row in result:
@@ -9480,7 +9480,7 @@ def get_financial_metrics(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
result = conn.execute(query, seccode=seccode, limit=limit) result = conn.execute(query, {'seccode': seccode, 'limit': limit})
data = [] data = []
for row in result: for row in result:
@@ -9621,7 +9621,7 @@ def get_main_business(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
periods = conn.execute(period_query, seccode=seccode, limit=limit).fetchall() periods = conn.execute(period_query, {'seccode': seccode, 'limit': limit}).fetchall()
# 产品分类数据 # 产品分类数据
product_data = [] product_data = []
@@ -9640,7 +9640,7 @@ def get_main_business(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
result = conn.execute(query, seccode=seccode, enddate=period[0]) result = conn.execute(query, {'seccode': seccode, 'enddate': period[0]})
# Convert result to list to allow multiple iterations # Convert result to list to allow multiple iterations
rows = list(result) rows = list(result)
@@ -9690,7 +9690,7 @@ def get_main_business(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
result = conn.execute(query, seccode=seccode, enddate=period[0]) result = conn.execute(query, {'seccode': seccode, 'enddate': period[0]})
# Convert result to list to allow multiple iterations # Convert result to list to allow multiple iterations
rows = list(result) rows = list(result)
@@ -9752,7 +9752,7 @@ def get_forecast(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
forecast_result = conn.execute(forecast_query, seccode=seccode) forecast_result = conn.execute(forecast_query, {'seccode': seccode})
forecast_data = [] forecast_data = []
for row in forecast_result: for row in forecast_result:
@@ -9794,7 +9794,7 @@ def get_forecast(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
pretime_result = conn.execute(pretime_query, seccode=seccode) pretime_result = conn.execute(pretime_query, {'seccode': seccode})
pretime_data = [] pretime_data = []
for row in pretime_result: for row in pretime_result:
@@ -9894,7 +9894,7 @@ def get_industry_rank(seccode):
# 获取多个报告期的数据 # 获取多个报告期的数据
with engine.connect() as conn: with engine.connect() as conn:
result = conn.execute(query, seccode=seccode, limit_total=limit * 4) result = conn.execute(query, {'seccode': seccode, 'limit_total': limit * 4})
# 按报告期和行业级别组织数据 # 按报告期和行业级别组织数据
data_by_period = {} data_by_period = {}
@@ -10015,7 +10015,7 @@ def get_period_comparison(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
result = conn.execute(query, seccode=seccode, periods=periods) result = conn.execute(query, {'seccode': seccode, 'periods': periods})
data = [] data = []
for row in result: for row in result:
@@ -10140,7 +10140,7 @@ def get_trade_data(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
result = conn.execute(query, seccode=seccode, end_date=end_date, days=days) result = conn.execute(query, {'seccode': seccode, 'end_date': end_date, 'days': days})
data = [] data = []
for row in result: for row in result:
@@ -10217,7 +10217,7 @@ def get_funding_data(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
result = conn.execute(query, seccode=seccode, days=days) result = conn.execute(query, {'seccode': seccode, 'days': days})
data = [] data = []
for row in result: for row in result:
@@ -10276,7 +10276,7 @@ def get_bigdeal_data(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
result = conn.execute(query, seccode=seccode, days=days) result = conn.execute(query, {'seccode': seccode, 'days': days})
data = [] data = []
for row in result: for row in result:
@@ -10351,7 +10351,7 @@ def get_unusual_data(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
result = conn.execute(query, seccode=seccode) result = conn.execute(query, {'seccode': seccode})
data = [] data = []
for row in result: for row in result:
@@ -10430,7 +10430,7 @@ def get_pledge_data(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
result = conn.execute(query, seccode=seccode) result = conn.execute(query, {'seccode': seccode})
data = [] data = []
for row in result: for row in result:
@@ -10488,11 +10488,11 @@ def get_market_summary(seccode):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
trade_result = conn.execute(trade_query, seccode=seccode).fetchone() trade_result = conn.execute(trade_query, {'seccode': seccode}).fetchone()
with engine.connect() as conn: with engine.connect() as conn:
funding_result = conn.execute(funding_query, seccode=seccode).fetchone() funding_result = conn.execute(funding_query, {'seccode': seccode}).fetchone()
with engine.connect() as conn: with engine.connect() as conn:
pledge_result = conn.execute(pledge_query, seccode=seccode).fetchone() pledge_result = conn.execute(pledge_query, {'seccode': seccode}).fetchone()
summary = { summary = {
'stock_code': seccode, 'stock_code': seccode,
@@ -11051,7 +11051,7 @@ def get_comprehensive_analysis(company_code):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
qualitative_result = conn.execute(qualitative_query, company_code=company_code).fetchone() qualitative_result = conn.execute(qualitative_query, {'company_code': company_code}).fetchone()
# 获取业务板块分析 # 获取业务板块分析
segments_query = text(""" segments_query = text("""
@@ -11069,7 +11069,7 @@ def get_comprehensive_analysis(company_code):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
segments_result = conn.execute(segments_query, company_code=company_code).fetchall() segments_result = conn.execute(segments_query, {'company_code': company_code}).fetchall()
# 获取竞争地位数据 - 最新一期 # 获取竞争地位数据 - 最新一期
competitive_query = text(""" competitive_query = text("""
@@ -11095,7 +11095,7 @@ def get_comprehensive_analysis(company_code):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
competitive_result = conn.execute(competitive_query, company_code=company_code).fetchone() competitive_result = conn.execute(competitive_query, {'company_code': company_code}).fetchone()
# 获取业务结构数据 - 最新一期 # 获取业务结构数据 - 最新一期
business_structure_query = text(""" business_structure_query = text("""
@@ -11123,7 +11123,7 @@ def get_comprehensive_analysis(company_code):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
business_structure_result = conn.execute(business_structure_query, company_code=company_code).fetchall() business_structure_result = conn.execute(business_structure_query, {'company_code': company_code}).fetchall()
# 构建返回数据 # 构建返回数据
response_data = { response_data = {
@@ -11261,7 +11261,7 @@ def get_value_chain_analysis(company_code):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
nodes_result = conn.execute(nodes_query, company_code=company_code).fetchall() nodes_result = conn.execute(nodes_query, {'company_code': company_code}).fetchall()
# 获取产业链流向数据 # 获取产业链流向数据
flows_query = text(""" flows_query = text("""
@@ -11282,7 +11282,7 @@ def get_value_chain_analysis(company_code):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
flows_result = conn.execute(flows_query, company_code=company_code).fetchall() flows_result = conn.execute(flows_query, {'company_code': company_code}).fetchall()
# 构建节点数据结构 # 构建节点数据结构
nodes_by_level = {} nodes_by_level = {}
@@ -11393,7 +11393,7 @@ def get_key_factors_timeline(company_code):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
categories_result = conn.execute(categories_query, company_code=company_code).fetchall() categories_result = conn.execute(categories_query, {'company_code': company_code}).fetchall()
# 获取关键因素详情 # 获取关键因素详情
factors_query = text(""" factors_query = text("""
@@ -11479,9 +11479,7 @@ def get_key_factors_timeline(company_code):
""") """)
with engine.connect() as conn: with engine.connect() as conn:
timeline_result = conn.execute(timeline_query, timeline_result = conn.execute(timeline_query, {'company_code': company_code, 'limit': event_limit}).fetchall()
company_code=company_code,
limit=event_limit).fetchall()
# 构建关键因素数据结构 # 构建关键因素数据结构
key_factors_data = {} key_factors_data = {}