1.刷新今日数据
This commit is contained in:
@@ -443,6 +443,39 @@ def get_settlement_by_nyid(
|
|||||||
)
|
)
|
||||||
@router.post("/get_today_data", response_model=DataResponse)
|
@router.post("/get_today_data", response_model=DataResponse)
|
||||||
def get_today_data(request: TodayDataRequest, db: Session = Depends(get_db)):
|
def get_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
|
||||||
|
data=daily_data
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"接口触发定时任务失败:{str(e)}", exc_info=True)
|
||||||
|
return DataResponse(
|
||||||
|
code=ResponseCode.QUERY_FAILED,
|
||||||
|
message=f"定时任务触发失败:{str(e)}",
|
||||||
|
total=0,
|
||||||
|
data={}
|
||||||
|
)
|
||||||
|
|
||||||
|
@router.post("/refresh_today_data", response_model=DataResponse)
|
||||||
|
def refresh_today_data(request: TodayDataRequest, db: Session = Depends(get_db)):
|
||||||
"""接口:通过POST请求触发调度器中的 scheduled_get_max_nyid_by_point_id 定时任务"""
|
"""接口:通过POST请求触发调度器中的 scheduled_get_max_nyid_by_point_id 定时任务"""
|
||||||
try:
|
try:
|
||||||
# 获取请求参数(如果需要从请求体中接收参数,可通过request获取)
|
# 获取请求参数(如果需要从请求体中接收参数,可通过request获取)
|
||||||
|
|||||||
Reference in New Issue
Block a user