1.每日数据手动写入

This commit is contained in:
whm
2025-11-15 15:35:55 +08:00
parent 199a60f002
commit eb8e607869

View File

@@ -478,24 +478,16 @@ def get_today_data(request: TodayDataRequest, db: Session = Depends(get_db)):
def refresh_today_data(request: TodayDataRequest, db: Session = Depends(get_db)):
"""接口通过POST请求触发调度器中的 scheduled_get_max_nyid_by_point_id 定时任务"""
try:
# 获取请求参数如果需要从请求体中接收参数可通过request获取
# 示例如需接收account_id可通过 request.account_id 获取
# account_id = request.account_id # 根据根据实际需求决定是否需要
# 触发定时任务(如果需要传入参数,可在这里添加)
from ..utils.scheduler import scheduled_get_max_nyid_by_point_id
scheduled_get_max_nyid_by_point_id()
# 调用服务层获取数据
account_id = request.account_id
daily_service = DailyDataService()
# 如需使用请求参数,可修改为 daily_service.get_daily_data_by_account(db, account_id=account_id)
daily_data = daily_service.get_daily_data_by_account(db, account_id=account_id)
return DataResponse(
code=ResponseCode.SUCCESS,
message="定时时任务触发执行成功!任务已开始处理(具体结果查看系统日志)",
total=1 if daily_data else 0, # 根据实际数据是否存在调整total
total=len(daily_data), # 根据实际数据是否存在调整total
data=daily_data
)
except Exception as e:
@@ -503,7 +495,7 @@ def refresh_today_data(request: TodayDataRequest, db: Session = Depends(get_db))
return DataResponse(
code=ResponseCode.QUERY_FAILED,
message=f"定时任务触发失败:{str(e)}",
total=0,
total=len(daily_data),
data={}
)
# account_id获取所有断面数据