添加新的接口, 获取识别总的统计数据接口

This commit is contained in:
haotian 2025-10-11 09:52:24 +08:00
parent c080f730bb
commit 3ee34e8a5b
3 changed files with 44 additions and 2 deletions

View File

@ -31,6 +31,21 @@ async def get_today_identification_statistics(request: Request, query_db: AsyncS
identification_statistics = await Identification_statisticsService.get_today_identification_statistics_services(query_db)
return ResponseUtil.success(data = identification_statistics)
# 获取总的识别统计数据
@identification_statisticsController.get('/total')
async def get_total_identification_statistics(request: Request, query_db: AsyncSession = Depends(get_db)):
"""
获取今天的识别统计数据
:param request:
:param query_db:
:return:
"""
logger.info('获取今天的识别统计数据')
identification_statistics = await Identification_statisticsService.get_total_identification_statistics_services(query_db)
return ResponseUtil.success(data = identification_statistics)
# @identification_statisticsController.get(
# '/list', response_model=PageResponseModel, dependencies=[Depends(CheckUserInterfaceAuth('system:identification_statistics:list'))]

View File

@ -17,10 +17,27 @@ class Identification_statisticsDao:
select(IdentificationStatistics.employ, IdentificationStatistics.stranger, IdentificationStatistics.visitor, IdentificationStatistics.create_time)
.where(IdentificationStatistics.create_time == datetime.now().date())
)
result = await query_db.execute(stmt)
result = await query_db.execute(stmt)
return result.mappings().all()
@classmethod
async def get_total_identification_statistics(cls, query_db: AsyncSession):
"""
获取总的识别统计数据 - 返回各个字段的总和
:param query_db: orm对象
:return: 总和统计数据
"""
stmt = select(
func.sum(IdentificationStatistics.employ).label('employ'),
func.sum(IdentificationStatistics.visitor).label('visitor'),
func.sum(IdentificationStatistics.stranger).label('stranger')
)
result = await query_db.execute(stmt)
return result.mappings().first()
@classmethod
async def get_identification_statistics_detail_by_id(cls, db: AsyncSession, id: int):
"""

View File

@ -24,6 +24,16 @@ class Identification_statisticsService:
"""
result = await Identification_statisticsDao.get_today_identification_statistics(query_db)
return result
@classmethod
async def get_total_identification_statistics_services(cls, query_db: AsyncSession):
"""
获取总的识别统计数据 - 返回各个字段的总和
:param query_db: orm对象
:return: 总和统计数据
"""
result = await Identification_statisticsDao.get_total_identification_statistics(query_db)
return result
@classmethod
async def get_identification_statistics_list_services(