diff --git a/app/Http/Controllers/Admin/InformationController.php b/app/Http/Controllers/Admin/InformationController.php index 432689d..f572507 100644 --- a/app/Http/Controllers/Admin/InformationController.php +++ b/app/Http/Controllers/Admin/InformationController.php @@ -10,35 +10,69 @@ class InformationController extends Controller { public function list(Request $request) { - // フィルター取得 - $period = $request->input('period', 'month'); // デフォルト: 最新1ヵ月 + // パラメータ + $period = $request->input('period', 'month'); // month | all + $type = $request->input('type', 'all'); // task(<99) | hard(>99) | all + $status = $request->input('status', 'untreated'); // untreated(=1) | inprogress(=2) | done(=3) | all - $query = DB::table('bat_job_log') - ->leftJoin('device', 'bat_job_log.device_id', '=', 'device.device_id') + $q = DB::table('operator_que as oq') + ->leftJoin('user as u', 'oq.user_id', '=', 'u.user_id') + ->leftJoin('park as p', 'oq.park_id', '=', 'p.park_id') + // オペレータマスタ(テーブル・カラム名は環境に合わせて調整) + ->leftJoin('ope as o', 'oq.operator_id', '=', 'o.ope_id') ->select( - 'bat_job_log.job_log_id', - 'bat_job_log.process_name', - 'bat_job_log.job_name', - 'bat_job_log.device_id', - 'device.park_id', - 'bat_job_log.status_comment', - 'bat_job_log.status', - 'bat_job_log.status_comment as comment', - 'bat_job_log.created_at', - 'bat_job_log.updated_at' + 'oq.que_id','oq.que_class','oq.user_id', + DB::raw('u.user_name as user_name'), + 'oq.contract_id','oq.park_id', + DB::raw('p.park_name as park_name'), + 'oq.que_comment','oq.que_status','oq.que_status_comment', + 'oq.work_instructions','oq.created_at','oq.updated_at','oq.operator_id', + DB::raw('o.ope_name as operator_name') ); - // 期間フィルター + // 期間: 登録日ベース(最新1ヵ月 or 全期間) if ($period === 'month') { - $query->where('bat_job_log.updated_at', '>=', now()->subMonth()); + $q->where('oq.created_at', '>=', now()->subMonth()); } - // 'all'の場合はフィルターなし - $jobs = $query->orderByDesc('bat_job_log.job_log_id')->limit(50)->get(); + // 種別: que_class + if ($type === 'task') { + $q->where('oq.que_class', '<', 99); + } elseif ($type === 'hard') { + $q->where('oq.que_class', '>', 99); + } // all は絞り込みなし - return view('admin.information.list', [ - 'jobs' => $jobs, - 'period' => $period, + // ステータス: que_status + if ($status === 'untreated') { + $q->where('oq.que_status', 1); + } elseif ($status === 'inprogress') { + $q->where('oq.que_status', 2); + } elseif ($status === 'done') { + $q->where('oq.que_status', 3); + } // all は絞り込みなし + + $jobs = $q->orderByDesc('oq.que_id')->paginate(50)->appends($request->query()); + + return view('admin.information.list', compact('jobs','period','type','status')); + } + + // ステータス一括更新(着手=2 / 対応完了=3) + public function updateStatus(Request $request) + { + $request->validate([ + 'ids' => 'required|array', + 'action' => 'required|in:inprogress,done', ]); + + $new = $request->action === 'inprogress' ? 2 : 3; + + DB::table('operator_que') + ->whereIn('que_id', $request->ids) + ->update([ + 'que_status' => $new, + 'updated_at' => now(), + ]); + + return back()->with('success', '選択したキューのステータスを更新しました。'); } } \ No newline at end of file diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 690cf8b..e10bbdd 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -8,6 +8,7 @@ use App\Services\ShjMailSendService; use App\Services\ShjNineService; use App\Services\ShjTenService; use App\Services\ShjSixService; +use Illuminate\Support\Facades\DB; class AppServiceProvider extends ServiceProvider { @@ -75,6 +76,42 @@ class AppServiceProvider extends ServiceProvider */ public function boot(): void { - // + view()->composer('layouts.app', function($view){ + + $stats = DB::table('operator_que') + ->selectRaw(" + SUM(CASE WHEN que_status IN (1,2) AND que_class < 100 THEN 1 ELSE 0 END) AS task_total, + MAX(CASE WHEN que_status IN (1,2) AND que_class < 100 THEN created_at END) AS task_latest, + SUM(CASE WHEN que_status IN (1,2) AND que_class > 99 THEN 1 ELSE 0 END) AS hard_total, + MAX(CASE WHEN que_status IN (1,2) AND que_class > 99 THEN created_at END) AS hard_latest + ") + ->first(); + + $taskCount = (int)($stats->task_total ?? 0); + $hardCount = (int)($stats->hard_total ?? 0); + $taskLatest = $stats->task_latest ?? null; + $hardLatest = $stats->hard_latest ?? null; + + // 最新5件 (未対応/作業中) + $latestTasks = DB::table('operator_que') + ->whereIn('que_status',[1,2]) + ->where('que_class','<',100) + ->orderByDesc('created_at') + ->limit(5) + ->get(); + + $latestHards = DB::table('operator_que') + ->whereIn('que_status',[1,2]) + ->where('que_class','>',99) + ->orderByDesc('created_at') + ->limit(5) + ->get(); + + $view->with(compact( + 'taskCount','taskLatest', + 'hardCount','hardLatest', + 'latestTasks','latestHards' + )); + }); } } diff --git a/resources/views/admin/information/list.blade.php b/resources/views/admin/information/list.blade.php index 8264b6e..9715d08 100644 --- a/resources/views/admin/information/list.blade.php +++ b/resources/views/admin/information/list.blade.php @@ -19,125 +19,95 @@
| - | キューID | -キュー種別 | -利用者 | -定期契約ID | -駐輪場 | -キューコメント | -キューステータス | -コメント | -登録日時 | -更新日時 | -更新オペレータ | -リンク | -
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| - | {{ $job->job_log_id }} | -{{ $job->process_name }} | -{{ $job->job_name }} | -{{ $job->device_id }} | -{{ $job->park_id }} | -{{ $job->status_comment }} | -{{ $job->status }} | -{{ $job->comment }} | -{{ $job->created_at }} | -{{ $job->updated_at }} | -- | -詳細 | -