diff --git a/app/Exports/V3/Mission/Report/machine/machineReport.php b/app/Exports/V3/Mission/Report/Machine/machineReport.php similarity index 95% rename from app/Exports/V3/Mission/Report/machine/machineReport.php rename to app/Exports/V3/Mission/Report/Machine/machineReport.php index 8f110c9f..83fc99d4 100644 --- a/app/Exports/V3/Mission/Report/machine/machineReport.php +++ b/app/Exports/V3/Mission/Report/Machine/machineReport.php @@ -1,6 +1,6 @@ $r->c_name ?? '', 'province_name' => $r->p_name ?? '', - 'm_c_code' => $r->m_c_code ?? 0, + 'missions' => $r->missions ?? 0, 'distance' => (int) ($r->distance ?? 0), ]; } diff --git a/app/Http/Controllers/V3/Dashboard/Mission/Report/ReportMachineController.php b/app/Http/Controllers/V3/Dashboard/Mission/Report/ReportMachineController.php index 34e32a34..a5c43e57 100644 --- a/app/Http/Controllers/V3/Dashboard/Mission/Report/ReportMachineController.php +++ b/app/Http/Controllers/V3/Dashboard/Mission/Report/ReportMachineController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\V3\Dashboard\Mission\Report; use App\Exports\V3\Mission\Report\Tradod\CountryReport; +use App\Exports\V3\Mission\Report\Tradod\machineReport; use App\Exports\V3\Mission\Report\Tradod\ProvinceReport; use App\Http\Controllers\Controller; use App\Http\Traits\ApiResponse; @@ -21,14 +22,11 @@ class ReportMachineController extends Controller { use ApiResponse; - public function Activity(Request $request, ReportMachineService $reportMachineService): JsonResponse + public function activity(Request $request, ReportMachineService $reportMachineService): JsonResponse { return $this->successResponse([ 'activities' => $reportMachineService->Activity($request), 'provinces' => Province::all(['id', 'name_fa']), - 'code' => Mission::query() - ->where('machine_code', $request->machine_code) - ->get() ]); } @@ -36,12 +34,12 @@ class ReportMachineController extends Controller * @throws Exception * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - public function ExcelActivity(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse + public function excelActivity(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse { $data = $reportMachineService->Activity($request); $name = 'گزارش کل تردد یک ماشین '.verta()->now()->format('Y-m-d H-i').'.xlsx'; - return Excel::download(new CountryReport($data), $name); + return Excel::download(new machineReport($data), $name); } } diff --git a/app/Http/Requests/V3/Mission/ControlUnit/FinishRequest.php b/app/Http/Requests/V3/Mission/ControlUnit/FinishRequest.php index 6fe0a2fe..b62c5124 100644 --- a/app/Http/Requests/V3/Mission/ControlUnit/FinishRequest.php +++ b/app/Http/Requests/V3/Mission/ControlUnit/FinishRequest.php @@ -24,7 +24,6 @@ class FinishRequest extends FormRequest */ public function rules(): array { - $mission = $this->route('mission'); return [ 'time' => 'required|date', 'end_km' => 'required', @@ -35,7 +34,7 @@ class FinishRequest extends FormRequest { return [ function (Validator $validator) { - $mission = $this->route('mission'); + $mission = $this->mission; if (strtotime($this->time) < strtotime($mission->start_time)) { $validator->errors()->add( 'time', diff --git a/app/Services/Cartables/Mission/Report/ReportMachineService.php b/app/Services/Cartables/Mission/Report/ReportMachineService.php index f34ceb4a..b92a5f89 100644 --- a/app/Services/Cartables/Mission/Report/ReportMachineService.php +++ b/app/Services/Cartables/Mission/Report/ReportMachineService.php @@ -22,16 +22,13 @@ class ReportMachineService m.city_id AS c_id, m.province_name AS p_name, m.province_id AS p_id, - COUNT(m.machine_code) As m_c_code, - SUM(m.end_km)-sum(m.km) AS distance + COUNT(m.id) As missions, + (SUM(m.end_km)-SUM(m.km)) AS distance FROM missions m WHERE m.machine_code = :machineCode AND m.created_at >= :from - AND m.created_at <= :to - GROUP BY m.city_id, m.city_name,m.province_id, m.province_name; - - + AND m.created_at <= :to; "; return DB::select($sql, [ diff --git a/resources/views/v3/Reports/Mission/Report/Machine/ActivityReport.blade.php b/resources/views/v3/Reports/Mission/Report/Machine/ActivityReport.blade.php index ef5c1de1..a3ffc93b 100644 --- a/resources/views/v3/Reports/Mission/Report/Machine/ActivityReport.blade.php +++ b/resources/views/v3/Reports/Mission/Report/Machine/ActivityReport.blade.php @@ -57,7 +57,7 @@ تعداد ماموریت