liyinglin 2 years ago
parent 4ae241231c
commit 1245977c04

@ -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++) {

@ -32,8 +32,8 @@
<th class="p-1" style="white-space: nowrap">病区</th>
<th class="p-1" style="white-space: nowrap">床位数量(总数:{{$totalBed}})</th>
<th class="p-1" style="white-space: nowrap">床位占比</th>
<th class="p-1" style="white-space: nowrap">订单数量(总数:{{$orderTotal}})</th>
<th class="p-1" style="white-space: nowrap">护工配比</th>
<th class="p-1" style="white-space: nowrap">陪护人天</th>
<th class="p-1" style="white-space: nowrap">陪护率</th>
</tr>
</thead>
<tbody>

Loading…
Cancel
Save