1.新增通过断面id获取所有 的 测点数据

This commit is contained in:
whm
2025-11-01 14:27:51 +08:00
parent 51068dc4e1
commit e4df0cba43
3 changed files with 31 additions and 5 deletions

View File

@@ -404,7 +404,7 @@ def get_today_data(db: Session = Depends(get_db)):
total=0,
data={}
)
# 查询断面数据对应观察点数据
# account_id获取所有断面数据
@router.post("/get_all_section_by_account", response_model=DataResponse)
def get_all_section_by_account(request: SectionByAccountRequest, db: Session = Depends(get_db)):
"""获取断面数据 + 观测点"""
@@ -419,6 +419,29 @@ def get_all_section_by_account(request: SectionByAccountRequest, db: Session = D
total=len(data_list),
data=data_list
)
except Exception as e:
logger.error(f"Query section data failed: {str(e)}")
return DataResponse(
code=ResponseCode.QUERY_FAILED,
message=f"{ResponseMessage.QUERY_FAILED}: {str(e)}",
total=0,
data=[]
)
# section_id 获取所有观测点数据
@router.post("/get_all_checkpoint_by_section", response_model=DataResponse)
def get_all_checkpoint_by_section(request: SectionByAccountRequest, db: Session = Depends(get_db)):
"""获取断面数据 + 观测点"""
try:
section_id = request.section_id
checkpoint_service = CheckpointService()
result_data = checkpoint_service.get_by_section_id(db, section_id=section_id)
data_list = [item.to_dict() for item in result_data] if result_data else []
return DataResponse(
code=ResponseCode.SUCCESS,
message="查询成功",
total=len(data_list),
data=data_list
)
except Exception as e:
logger.error(f"Query section data failed: {str(e)}")
return DataResponse(