1.默认每日获取0天到期的
This commit is contained in:
@@ -477,8 +477,10 @@ def get_today_data(request: TodayDataRequest, db: Session = Depends(get_db)):
|
|||||||
def refresh_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 定时任务"""
|
"""接口:通过POST请求触发调度器中的 scheduled_get_max_nyid_by_point_id 定时任务"""
|
||||||
try:
|
try:
|
||||||
|
start = request.start if request.start is not None else 0
|
||||||
|
end = request.end if request.end is not None else 0
|
||||||
from ..utils.scheduler import scheduled_get_max_nyid_by_point_id
|
from ..utils.scheduler import scheduled_get_max_nyid_by_point_id
|
||||||
scheduled_get_max_nyid_by_point_id()
|
scheduled_get_max_nyid_by_point_id(start, end)
|
||||||
account_id = request.account_id
|
account_id = request.account_id
|
||||||
daily_service = DailyDataService()
|
daily_service = DailyDataService()
|
||||||
daily_data = 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)
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ class NYIDRequest(BaseModel):
|
|||||||
# 今日数据请求
|
# 今日数据请求
|
||||||
class TodayDataRequest(BaseModel):
|
class TodayDataRequest(BaseModel):
|
||||||
account_id: str
|
account_id: str
|
||||||
|
start: Optional[int] = None
|
||||||
|
end: Optional[int] = None
|
||||||
# 沉降数据导入请求
|
# 沉降数据导入请求
|
||||||
class SettlementDataImportRequest(BaseModel):
|
class SettlementDataImportRequest(BaseModel):
|
||||||
point_id: str
|
point_id: str
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ def database_cleanup_task():
|
|||||||
return "数据库清理完成"
|
return "数据库清理完成"
|
||||||
|
|
||||||
# 每日自动写入获取最新工况信息
|
# 每日自动写入获取最新工况信息
|
||||||
def scheduled_get_max_nyid_by_point_id():
|
def scheduled_get_max_nyid_by_point_id(start: int = 0, end: int = 0):
|
||||||
"""定时任务:获取max NYID关联数据并批量创建DailyData记录"""
|
"""定时任务:获取max NYID关联数据并批量创建DailyData记录"""
|
||||||
db: Session = None
|
db: Session = None
|
||||||
try:
|
try:
|
||||||
@@ -235,7 +235,7 @@ def scheduled_get_max_nyid_by_point_id():
|
|||||||
|
|
||||||
# 2. 计算到期数据
|
# 2. 计算到期数据
|
||||||
monitor = ConstructionMonitorUtils()
|
monitor = ConstructionMonitorUtils()
|
||||||
daily_data = monitor.get_due_data(result)
|
daily_data = monitor.get_due_data(result, start, end)
|
||||||
data = daily_data['data']
|
data = daily_data['data']
|
||||||
error_data = daily_data['error_data']
|
error_data = daily_data['error_data']
|
||||||
|
|
||||||
@@ -250,7 +250,7 @@ def scheduled_get_max_nyid_by_point_id():
|
|||||||
new_list = [w['point_id'] for w in winters]
|
new_list = [w['point_id'] for w in winters]
|
||||||
# 获取更多历史记录
|
# 获取更多历史记录
|
||||||
nyid_list = daily_service.get_nyid_by_point_id(db, new_list, max_num)
|
nyid_list = daily_service.get_nyid_by_point_id(db, new_list, max_num)
|
||||||
w_list = monitor.get_due_data(nyid_list)
|
w_list = monitor.get_due_data(nyid_list, start, end)
|
||||||
# 更新冬休、待处理、错误数据
|
# 更新冬休、待处理、错误数据
|
||||||
winters = w_list['winter']
|
winters = w_list['winter']
|
||||||
data.extend(w_list['data'])
|
data.extend(w_list['data'])
|
||||||
|
|||||||
Reference in New Issue
Block a user