You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.2 KiB
PHP

<?php
namespace App\Http\Controllers\API\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Lib\Rs;
use App\Services\ReportService;
/**
* 报表统计控制器
*/
class ReportController extends Controller
{
protected $reportService;
public function __construct(ReportService $reportService)
{
$this->reportService = $reportService;
}
/**
* 获取预约总体统计报表
*/
public function getAppointmentOverallReport(Request $request)
{
$dateType = $request->input('date_type', 'daily'); // daily, weekly, monthly
$startDate = $request->input('start_date', date('Y-m-d'));
$endDate = $request->input('end_date', date('Y-m-d'));
$departmentId = $request->input('department_id');
$channelId = $request->input('channel_id');
$patientType = $request->input('patient_type');
// 验证参数
if (!in_array($dateType, ['daily', 'weekly', 'monthly'])) {
return Rs::error('日期类型错误,只支持 daily、weekly、monthly');
}
$result = $this->reportService->getAppointmentOverallReport(
$dateType,
$startDate,
$endDate,
$departmentId,
$channelId,
$patientType
);
return $result['success'] ? Rs::success($result['data']) : Rs::error($result['message']);
}
/**
* 获取时间段分布报表
*/
public function getTimeDistributionReport(Request $request)
{
$startDate = $request->input('start_date', date('Y-m-d'));
$endDate = $request->input('end_date', date('Y-m-d'));
$departmentId = $request->input('department_id');
$resourceId = $request->input('resource_id');
$channelId = $request->input('channel_id');
$patientType = $request->input('patient_type');
$result = $this->reportService->getTimeDistributionReport(
$startDate,
$endDate,
$departmentId,
$resourceId,
$channelId,
$patientType
);
return $result['success'] ? Rs::success($result['data']) : Rs::error($result['message']);
}
}