update pay ui
This commit is contained in:
45
app.py
45
app.py
@@ -12824,6 +12824,9 @@ def get_hotspot_overview():
|
||||
'surge': len([a for a in alerts if a['alert_type'] == 'surge']),
|
||||
'surge_up': len([a for a in alerts if a['alert_type'] == 'surge_up']),
|
||||
'surge_down': len([a for a in alerts if a['alert_type'] == 'surge_down']),
|
||||
'volume_surge_up': len([a for a in alerts if a['alert_type'] == 'volume_surge_up']),
|
||||
'shrink_surge_up': len([a for a in alerts if a['alert_type'] == 'shrink_surge_up']),
|
||||
'volume_oscillation': len([a for a in alerts if a['alert_type'] == 'volume_oscillation']),
|
||||
'limit_up': len([a for a in alerts if a['alert_type'] == 'limit_up']),
|
||||
'volume_spike': len([a for a in alerts if a['alert_type'] == 'volume_spike']),
|
||||
'rank_jump': len([a for a in alerts if a['alert_type'] == 'rank_jump'])
|
||||
@@ -12848,7 +12851,7 @@ def get_concept_stocks(concept_id):
|
||||
获取概念的相关股票列表(带实时涨跌幅)
|
||||
|
||||
Args:
|
||||
concept_id: 概念 ID(来自 ES concept_library_v3)
|
||||
concept_id: 概念 ID 或概念名称(支持两种方式查询)
|
||||
|
||||
Returns:
|
||||
- stocks: 股票列表 [{code, name, reason, change_pct}, ...]
|
||||
@@ -12857,18 +12860,48 @@ def get_concept_stocks(concept_id):
|
||||
from elasticsearch import Elasticsearch
|
||||
from clickhouse_driver import Client
|
||||
|
||||
# 1. 从 ES 获取概念的股票列表
|
||||
es_client = Elasticsearch(["http://222.128.1.157:19200"])
|
||||
es_result = es_client.get(index='concept_library_v3', id=concept_id)
|
||||
|
||||
if not es_result.get('found'):
|
||||
# 1. 尝试多种方式获取概念数据
|
||||
source = None
|
||||
concept_name = concept_id
|
||||
|
||||
# 方式1: 先尝试按 ID 查询
|
||||
try:
|
||||
es_result = es_client.get(index='concept_library_v3', id=concept_id)
|
||||
if es_result.get('found'):
|
||||
source = es_result.get('_source', {})
|
||||
concept_name = source.get('concept', concept_id)
|
||||
except:
|
||||
pass
|
||||
|
||||
# 方式2: 如果按 ID 没找到,尝试按概念名称搜索
|
||||
if not source:
|
||||
try:
|
||||
search_result = es_client.search(
|
||||
index='concept_library_v3',
|
||||
body={
|
||||
'query': {
|
||||
'term': {
|
||||
'concept.keyword': concept_id
|
||||
}
|
||||
},
|
||||
'size': 1
|
||||
}
|
||||
)
|
||||
hits = search_result.get('hits', {}).get('hits', [])
|
||||
if hits:
|
||||
source = hits[0].get('_source', {})
|
||||
concept_name = source.get('concept', concept_id)
|
||||
except Exception as search_err:
|
||||
app.logger.debug(f"ES 搜索概念失败: {search_err}")
|
||||
|
||||
if not source:
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'error': f'概念 {concept_id} 不存在'
|
||||
}), 404
|
||||
|
||||
source = es_result.get('_source', {})
|
||||
concept_name = source.get('concept', concept_id)
|
||||
raw_stocks = source.get('stocks', [])
|
||||
|
||||
if not raw_stocks:
|
||||
|
||||
Reference in New Issue
Block a user