46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
# from module_admin.common.deps import get_db
|
|
from config.get_db import get_db
|
|
from module_admin.system.service.statistics_service import StatisticsService
|
|
from utils.response_util import ResponseUtil
|
|
from utils.log_util import logger
|
|
|
|
|
|
statisticsController = APIRouter(prefix='/system/statistics', tags=['统计模块'])
|
|
|
|
|
|
@statisticsController.get('/getOrderStatistics')
|
|
async def get_order_statistics(db: AsyncSession = Depends(get_db)):
|
|
"""
|
|
获取订单统计信息
|
|
|
|
:param db: 数据库会话
|
|
:return: 订单统计信息
|
|
"""
|
|
try:
|
|
# 调用服务层方法获取订单统计信息
|
|
statistics_result = await StatisticsService.get_order_statistics_services(db)
|
|
|
|
return ResponseUtil.success(data=statistics_result, msg='获取订单统计信息成功')
|
|
except Exception as e:
|
|
logger.error(f'获取订单统计信息失败: {str(e)}')
|
|
return ResponseUtil.failure(msg=f'获取订单统计信息失败: {str(e)}')
|
|
|
|
|
|
@statisticsController.get('/getWorkOrderStatistics')
|
|
async def get_work_order_statistics(db: AsyncSession = Depends(get_db)):
|
|
"""
|
|
获取测试工单统计信息
|
|
|
|
:param db: 数据库会话
|
|
:return: 测试工单统计信息
|
|
"""
|
|
try:
|
|
# 调用服务层方法获取测试工单统计信息
|
|
statistics_result = await StatisticsService.get_work_order_statistics_services(db)
|
|
|
|
return ResponseUtil.success(data=statistics_result, msg='获取测试工单统计信息成功')
|
|
except Exception as e:
|
|
logger.error(f'获取测试工单统计信息失败: {str(e)}')
|
|
return ResponseUtil.failure(msg=f'获取测试工单统计信息失败: {str(e)}') |