|
|
|
|
@ -450,7 +450,7 @@ class StatisticsController extends CommonController
|
|
|
|
|
*/
|
|
|
|
|
public function bed()
|
|
|
|
|
{
|
|
|
|
|
$is_export = \request('is_export',0);
|
|
|
|
|
$is_export = \request('is_export', 0);
|
|
|
|
|
$projects = $this->_checkProjects();
|
|
|
|
|
if (!$projects->count()) {
|
|
|
|
|
return $this->error($this->noProjects);
|
|
|
|
|
@ -460,6 +460,8 @@ class StatisticsController extends CommonController
|
|
|
|
|
|
|
|
|
|
$month = request()->month ?? date("Y-m");
|
|
|
|
|
$months = $this->_getMonths();
|
|
|
|
|
// 当月天数
|
|
|
|
|
$days = date('t', strtotime($month));
|
|
|
|
|
$area = Area::withCount('beds')->where('project_id', $project_id)->get();
|
|
|
|
|
$beds = Bed::whereIn('area_id', $area->pluck('id'))->where('project_id', $project_id)->get();
|
|
|
|
|
$totalBed = $beds->count();
|
|
|
|
|
@ -476,27 +478,27 @@ class StatisticsController extends CommonController
|
|
|
|
|
}
|
|
|
|
|
// 订单数
|
|
|
|
|
$bedsIdTemp = Bed::where('area_id', $item->id)->where('project_id', $project_id)->pluck('id');
|
|
|
|
|
$item->order_total = Orders::where('project_id', $project_id)
|
|
|
|
|
->where('created_at', 'like', '%' . $month . '%')
|
|
|
|
|
$item->order_total = OrderItems::where('created_at', 'like', '%' . $month . '%')
|
|
|
|
|
->where('total', '>', 0)
|
|
|
|
|
->whereIn('bed_id', $bedsIdTemp)
|
|
|
|
|
->count();
|
|
|
|
|
$item->rate = 0;
|
|
|
|
|
if ($bedsIdTemp->count()) {
|
|
|
|
|
// 配比
|
|
|
|
|
$item->rate = round($item->order_total / $bedsIdTemp->count(), 4) * 100;
|
|
|
|
|
$item->rate = round($item->order_total / $days * $bedsIdTemp->count(), 4) * 100;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 导出
|
|
|
|
|
if($is_export){
|
|
|
|
|
if ($is_export) {
|
|
|
|
|
$area = $area->toArray();
|
|
|
|
|
$spreadsheet = new Spreadsheet();
|
|
|
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
|
|
|
$sheet->setCellValue('A1', '病区');
|
|
|
|
|
$sheet->setCellValue('B1', '床位数量');
|
|
|
|
|
$sheet->setCellValue('C1', '床位占比');
|
|
|
|
|
$sheet->setCellValue('D1', '订单数量');
|
|
|
|
|
$sheet->setCellValue('E1', '护工配比');
|
|
|
|
|
$sheet->setCellValue('D1', '陪护人天');
|
|
|
|
|
$sheet->setCellValue('E1', '陪护率');
|
|
|
|
|
|
|
|
|
|
$count = count($area); //计算有多少条数据
|
|
|
|
|
for ($i = 2; $i <= $count + 1; $i++) {
|
|
|
|
|
|