From b0d9dbe3f6c3863dd067104c4637bfa54b1e9df3 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Fri, 28 Jul 2023 12:14:09 +0800 Subject: [PATCH] monitor history --- app/Http/Controllers/Controller.php | 4 ++-- app/Services/Admin/DeviceService.php | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 359e510..d05436b 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -7,7 +7,7 @@ use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Routing\Controller as BaseController; use Illuminate\Pagination\LengthAwarePaginator; -use Illuminate\Http\Resources\Json\ResourceCollection ; +use Illuminate\Http\Resources\Json\ResourceCollection; use Illuminate\Support\Arr; class Controller extends BaseController @@ -16,7 +16,7 @@ class Controller extends BaseController public function json($data, $code = 0, $message = '') { - if ($data instanceof ResourceCollection ) { + if ($data instanceof ResourceCollection) { $data = $data->resource; } $result = ['data' => $data ?: '', 'status' => $code, 'msg' => $message]; diff --git a/app/Services/Admin/DeviceService.php b/app/Services/Admin/DeviceService.php index 6cc14d2..73579dc 100644 --- a/app/Services/Admin/DeviceService.php +++ b/app/Services/Admin/DeviceService.php @@ -35,9 +35,11 @@ class DeviceService extends BaseService $url = data_get($item->extends, $history ? 'rtsp_history' : 'rtsp_url'); $src = null; if ($base && $url) { - // 查看历史监控 + // 查看历史监控 &starttime=2023_02_02_14_00_00&endtime=2023_02_02_15_00_00 if ($history && $start && $end) { - $url .= '?start=' . date('Y-m-d', $start) . '&end=' . data('Y-m-d', $end); + $start_format = Carbon::createFromTimestamp($start)->startOfDay()->format('Y_m_d_H_i_s'); + $end_format = Carbon::createFromTimestamp($end)->endOfDay()->format('Y_m_d_H_i_s'); + $url .= (str_contains($url, '?') ? '&' : '?') .'starttime=' . $start_format . '&endtime=' . $end_format; } $src = $base . base64_encode($url); }