$this->monthlyColumns((string) $request->input('month', date('Y-m'))), 'items' => $this->service->monthly($request->all()), ]); } #[OA\Get(path: '/produce/statistics/daily', summary: '日工作统计', tags: ['produce-statistics'])] #[DataResponse(description: '获取日工作统计成功')] #[Permission(code: 'produce:statistics:daily', description: '日工作统计')] public function daily(Request $request): Response { return Json::success('获取成功', [ 'columns' => $this->dailyColumns(), 'items' => $this->service->daily($request->all()), ]); } private function monthlyColumns(string $month): array { $month = preg_match('/^\d{4}-\d{2}$/', $month) ? $month : date('Y-m'); $days = (int) date('t', strtotime($month . '-01')); return array_map(static fn (int $day): array => [ 'key' => (string) $day, 'label' => str_pad((string) $day, 2, '0', STR_PAD_LEFT), ], range(1, $days)); } private function dailyColumns(): array { return array_map(static fn (int $hour): array => [ 'key' => str_pad((string) $hour, 2, '0', STR_PAD_LEFT) . ':00', 'label' => str_pad((string) $hour, 2, '0', STR_PAD_LEFT) . ':00', ], range(0, 23)); } }