1.新增通过断面id获取所有 的 测点数据
This commit is contained in:
@@ -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)):
|
||||
"""获取断面数据 + 观测点"""
|
||||
@@ -427,3 +427,26 @@ def get_all_section_by_account(request: SectionByAccountRequest, db: Session = D
|
||||
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(
|
||||
code=ResponseCode.QUERY_FAILED,
|
||||
message=f"{ResponseMessage.QUERY_FAILED}: {str(e)}",
|
||||
total=0,
|
||||
data=[]
|
||||
)
|
||||
@@ -152,6 +152,7 @@ class SectionDataQueryRequest(BaseModel):
|
||||
# 断面数据导入请求
|
||||
class SectionByAccountRequest(BaseModel):
|
||||
account_id: Optional[str] = None
|
||||
section_id: Optional[str] = None
|
||||
|
||||
# 水准数据查询请求
|
||||
class LevelDataQueryRequest(BaseModel):
|
||||
|
||||
@@ -8,9 +8,7 @@ class CheckpointService(BaseService[Checkpoint]):
|
||||
def __init__(self):
|
||||
super().__init__(Checkpoint)
|
||||
|
||||
def get_by_section_id(self, db: Session, section_id: str) -> List[Checkpoint]:
|
||||
"""根据断面ID获取观测点"""
|
||||
return self.get_by_field(db, "section_id", section_id)
|
||||
|
||||
|
||||
def get_by_point_id(self, db: Session, point_id: str) -> Optional[Checkpoint]:
|
||||
"""根据观测点ID获取观测点"""
|
||||
@@ -122,3 +120,7 @@ class CheckpointService(BaseService[Checkpoint]):
|
||||
def get_by_nyid(self, db: Session, nyid: str) -> List[Checkpoint]:
|
||||
"""根据NYID获取所有相关的测点信息"""
|
||||
return self.get_by_field(db, "NYID", nyid)
|
||||
# 通过section_id获取所有观测点数据
|
||||
def get_by_section_id(self, db: Session, section_id: str) -> List[Checkpoint]:
|
||||
"""根据section_id获取所有相关的测点信息"""
|
||||
return self.get_by_field(db, "section_id", section_id)
|
||||
|
||||
Reference in New Issue
Block a user