1.通过accountid获取所有断面数据
This commit is contained in:
@@ -17,7 +17,8 @@ from ..schemas.comprehensive_data import (
|
||||
SettlementDataCheckpointQueryRequest,
|
||||
LevelDataQueryRequest,
|
||||
LinecodeRequest,
|
||||
NYIDRequest
|
||||
NYIDRequest,
|
||||
SectionByAccountRequest
|
||||
)
|
||||
from ..services.daily import DailyDataService
|
||||
from ..services.section_data import SectionDataService
|
||||
@@ -402,4 +403,26 @@ def get_today_data(db: Session = Depends(get_db)):
|
||||
message=f"定时任务触发失败:{str(e)}",
|
||||
total=0,
|
||||
data={}
|
||||
)
|
||||
# 查询断面数据对应观察点数据
|
||||
@router.post("/get_all_section_by_account", response_model=DataResponse)
|
||||
def get_all_section_by_account(request: SectionByAccountRequest, db: Session = Depends(get_db)):
|
||||
"""获取断面数据 + 观测点"""
|
||||
try:
|
||||
account_id = request.account_id
|
||||
section_service = SectionDataService()
|
||||
result_data = section_service.get_all_section_by_account(db, account_id=account_id)
|
||||
return DataResponse(
|
||||
code=ResponseCode.SUCCESS,
|
||||
message="查询成功",
|
||||
total=len(result_data),
|
||||
data=result_data
|
||||
)
|
||||
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=[]
|
||||
)
|
||||
@@ -149,6 +149,9 @@ class SectionDataQueryRequest(BaseModel):
|
||||
foundation_treatment_method: Optional[str] = None
|
||||
rock_mass_classification: Optional[str] = None
|
||||
account_id: Optional[str] = None
|
||||
# 断面数据导入请求
|
||||
class SectionByAccountRequest(BaseModel):
|
||||
account_id: Optional[str] = None
|
||||
|
||||
# 水准数据查询请求
|
||||
class LevelDataQueryRequest(BaseModel):
|
||||
|
||||
@@ -20,7 +20,10 @@ class SectionDataService(BaseService[SectionData]):
|
||||
"""根据断面ID获取断面数据"""
|
||||
sections = self.get_by_field(db, "section_id", section_id)
|
||||
return sections[0] if sections else None
|
||||
|
||||
def get_by_account_id(self, db: Session, account_id: str) -> Optional[SectionData]:
|
||||
"""根据账号ID获取断面数据"""
|
||||
accounts = self.get_by_field(db, "account_id", account_id)
|
||||
return accounts[0] if accounts else None
|
||||
def get_by_number(self, db: Session, number: str) -> List[SectionData]:
|
||||
"""根据桥梁墩(台)编号获取断面数据"""
|
||||
return self.get_by_field(db, "number", number)
|
||||
|
||||
Reference in New Issue
Block a user