数据查询,账号字段增加
This commit is contained in:
@@ -167,8 +167,64 @@ class ComprehensiveDataService:
|
||||
}
|
||||
}
|
||||
|
||||
def get_level_and_original_data(self, db: Session,
|
||||
id: Optional[int] = None,
|
||||
bfpcode: Optional[str] = None,
|
||||
bffb: Optional[str] = None,
|
||||
nyid: Optional[str] = None,
|
||||
linecode: Optional[str] = None,
|
||||
bfpl: Optional[str] = None) -> Dict[str, Any]:
|
||||
"""根据条件获取水准数据+原始数据的组合查询"""
|
||||
# 查询水准数据
|
||||
level_data = self.level_service.search_level_data(
|
||||
db,
|
||||
nyid=nyid,
|
||||
linecode=linecode
|
||||
)
|
||||
|
||||
# 查询原始数据
|
||||
original_data = self.original_service.search_original_data(
|
||||
db,
|
||||
bfpcode=bfpcode,
|
||||
bffb=bffb,
|
||||
nyid=nyid,
|
||||
bfpl=bfpl
|
||||
)
|
||||
result = []
|
||||
original_count = 0
|
||||
for level in level_data:
|
||||
data = {
|
||||
"id": level.id,
|
||||
"linecode": level.linecode,
|
||||
"benchmarkids": level.benchmarkids,
|
||||
"wsphigh": level.wsphigh,
|
||||
"NYID": level.NYID,
|
||||
"createDate": level.createDate,
|
||||
"originalDatas": [
|
||||
{
|
||||
"id": orig.id,
|
||||
"bfpcode": orig.bfpcode,
|
||||
"mtime": orig.mtime,
|
||||
"bffb": orig.bffb,
|
||||
"bfpl": orig.bfpl,
|
||||
"bfpvalue": orig.bfpvalue,
|
||||
"times": orig.times,
|
||||
"NYID": orig.NYID,
|
||||
"sort": orig.sort
|
||||
} for orig in original_data if orig.NYID == level.NYID
|
||||
]
|
||||
}
|
||||
original_count += len(data["originalDatas"])
|
||||
result.append(data)
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"message": "查询成功",
|
||||
"count": original_count,
|
||||
"data": result
|
||||
}
|
||||
|
||||
def get_statistics_summary(self, db: Session) -> Dict[str, Any]:
|
||||
"""获取全局统计摘要"""
|
||||
all_sections = self.section_service.get_all(db, limit=10000)
|
||||
all_checkpoints = self.checkpoint_service.get_all(db, limit=10000)
|
||||
all_settlement = self.settlement_service.get_all(db, limit=10000)
|
||||
|
||||
@@ -49,10 +49,46 @@ class SectionDataService(BaseService[SectionData]):
|
||||
conditions['id'] = id
|
||||
if mileage is not None:
|
||||
conditions['mileage'] = mileage
|
||||
|
||||
section_data = self.search_by_conditions(db, conditions)
|
||||
# 查询对应观察点数据
|
||||
if len(section_data) > 0:
|
||||
|
||||
return self.search_by_conditions(db, conditions)
|
||||
|
||||
def search_sections_with_checkpoints(self, db: Session,
|
||||
id: Optional[int] = None,
|
||||
section_id: Optional[str] = None,
|
||||
mileage: Optional[str] = None,
|
||||
work_site: Optional[str] = None,
|
||||
number: Optional[str] = None,
|
||||
status: Optional[str] = None) -> List[Dict[str, Any]]:
|
||||
"""查询断面数据并返回带观测点的结果"""
|
||||
sections = self.search_section_data(db, id, section_id, mileage, work_site, number, status)
|
||||
|
||||
result = []
|
||||
for section in sections:
|
||||
checkpoints = self.checkpoint_service.get_by_section_id(db, section.section_id)
|
||||
|
||||
section_dict = {
|
||||
"id": section.id,
|
||||
"section_id": section.section_id,
|
||||
"mileage": section.mileage,
|
||||
"work_site": section.work_site,
|
||||
"basic_types": section.basic_types,
|
||||
"height": section.height,
|
||||
"status": section.status,
|
||||
"number": section.number,
|
||||
"transition_paragraph": section.transition_paragraph,
|
||||
"checkpoints": [
|
||||
{
|
||||
"id": cp.id,
|
||||
"point_id": cp.point_id,
|
||||
"aname": cp.aname,
|
||||
"burial_date": cp.burial_date,
|
||||
"section_id": cp.section_id
|
||||
} for cp in checkpoints
|
||||
]
|
||||
}
|
||||
result.append(section_dict)
|
||||
|
||||
return result
|
||||
|
||||
def get_section_with_checkpoints(self, db: Session, section_id: str) -> Dict[str, Any]:
|
||||
"""获取断面数据及其关联的观测点"""
|
||||
|
||||
@@ -24,13 +24,15 @@ class SettlementDataService(BaseService[SettlementData]):
|
||||
).first()
|
||||
|
||||
def search_settlement_data(self, db: Session,
|
||||
id: Optional[str] = None,
|
||||
id: Optional[int] = None,
|
||||
point_id: Optional[str] = None,
|
||||
nyid: Optional[str] = None,
|
||||
sjName: Optional[str] = None,
|
||||
workinfoname: Optional[str] = None) -> List[SettlementData]:
|
||||
"""根据多个条件搜索沉降数据"""
|
||||
conditions = {}
|
||||
if id is not None:
|
||||
conditions["id"] = id
|
||||
if point_id is not None:
|
||||
conditions["point_id"] = point_id
|
||||
if nyid is not None:
|
||||
@@ -42,6 +44,43 @@ class SettlementDataService(BaseService[SettlementData]):
|
||||
|
||||
return self.search_by_conditions(db, conditions)
|
||||
|
||||
def search_settlement_data_formatted(self, db: Session,
|
||||
id: Optional[int] = None,
|
||||
point_id: Optional[str] = None,
|
||||
nyid: Optional[str] = None,
|
||||
sjName: Optional[str] = None,
|
||||
workinfoname: Optional[str] = None) -> List[Dict[str, Any]]:
|
||||
"""查询沉降数据并返回格式化结果"""
|
||||
settlement_data = self.search_settlement_data(db, id, point_id, nyid, sjName, workinfoname)
|
||||
|
||||
result = []
|
||||
for settlement in settlement_data:
|
||||
settlement_dict = {
|
||||
"id": settlement.id,
|
||||
"point_id": settlement.point_id,
|
||||
"CVALUE": settlement.CVALUE,
|
||||
"MAVALUE": settlement.MAVALUE,
|
||||
"MTIME_W": settlement.MTIME_W,
|
||||
"NYID": settlement.NYID,
|
||||
"PRELOADH": settlement.PRELOADH,
|
||||
"PSTATE": settlement.PSTATE,
|
||||
"REMARK": settlement.REMARK,
|
||||
"WORKINFO": settlement.WORKINFO,
|
||||
"createdate": settlement.createdate,
|
||||
"day": settlement.day,
|
||||
"day_jg": settlement.day_jg,
|
||||
"isgzjdxz": settlement.isgzjdxz,
|
||||
"mavalue_bc": settlement.mavalue_bc,
|
||||
"mavalue_lj": settlement.mavalue_lj,
|
||||
"sjName": settlement.sjName,
|
||||
"useflag": settlement.useflag,
|
||||
"workinfoname": settlement.workinfoname,
|
||||
"upd_remark": settlement.upd_remark
|
||||
}
|
||||
result.append(settlement_dict)
|
||||
|
||||
return result
|
||||
|
||||
def _check_checkpoint_exists(self, db: Session, point_id: str) -> bool:
|
||||
"""检查观测点数据是否存在"""
|
||||
checkpoint = db.query(Checkpoint).filter(Checkpoint.point_id == point_id).first()
|
||||
|
||||
Reference in New Issue
Block a user