Compare commits
7 Commits
feature/Mi
...
fc853d318e
| Author | SHA1 | Date | |
|---|---|---|---|
| fc853d318e | |||
|
|
5a2a477789 | ||
|
|
a45b4955db | ||
| ace0b018e7 | |||
| 0b7b22ff87 | |||
| e7ced6267d | |||
| 55c736ac3e |
@@ -28,7 +28,8 @@ class EncodePolyLineCommand extends Command
|
|||||||
public function handle(PolylineEncoder $polylineEncoder): void
|
public function handle(PolylineEncoder $polylineEncoder): void
|
||||||
{
|
{
|
||||||
Mission::query()->whereNotNull('area')->each(function ($mission) use ($polylineEncoder) {
|
Mission::query()->whereNotNull('area')->each(function ($mission) use ($polylineEncoder) {
|
||||||
$encodedValue = $polylineEncoder->encodePolyLine($mission, lng_lat_format:true);
|
$area = json_decode($mission->area, true);
|
||||||
|
$encodedValue = $polylineEncoder->encodePolyLine($area['coordinates'], lng_lat_format:true);
|
||||||
$mission->update([
|
$mission->update([
|
||||||
'encoded_route' => $encodedValue,
|
'encoded_route' => $encodedValue,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -7,11 +7,13 @@ use App\Facades\DataTable\DataTableFacade;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Traits\ApiResponse;
|
use App\Http\Traits\ApiResponse;
|
||||||
use App\Models\City;
|
use App\Models\City;
|
||||||
|
use App\Models\CMMSMachine;
|
||||||
use App\Models\Mission;
|
use App\Models\Mission;
|
||||||
use App\Models\Province;
|
use App\Models\Province;
|
||||||
use App\Services\Cartables\Mission\Report\ReportMachineService;
|
use App\Services\Cartables\Mission\Report\ReportMachineService;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
use PhpOffice\PhpSpreadsheet\Exception;
|
use PhpOffice\PhpSpreadsheet\Exception;
|
||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
@@ -109,7 +111,7 @@ class ReportMachineController extends Controller
|
|||||||
allowedSortings: ['*'],
|
allowedSortings: ['*'],
|
||||||
allowedSelects: [
|
allowedSelects: [
|
||||||
'id', 'province_id', 'province_name', 'city_id', 'city_name',
|
'id', 'province_id', 'province_name', 'city_id', 'city_name',
|
||||||
'end_km', 'km', 'driver_name', 'state_name', 'station_name'
|
'end_km', 'km', 'driver_name', 'state_id', 'station_name'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -125,4 +127,55 @@ class ReportMachineController extends Controller
|
|||||||
|
|
||||||
return Excel::download(new machineReport($data), $name);
|
return Excel::download(new machineReport($data), $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function countryMachineDriversActivity(Request $request, ReportMachineService $reportMachineService)
|
||||||
|
{
|
||||||
|
return $this->successResponse([
|
||||||
|
'activities' => $reportMachineService->countryMachineDriversActivity($request),
|
||||||
|
// 'provinces' => Province::all(['id', 'name_fa']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provinceMachineDriversActivity(Request $request, ReportMachineService $reportMachineService)
|
||||||
|
{
|
||||||
|
return $this->successResponse([
|
||||||
|
'activities' => $reportMachineService->provinceMachineDriversActivity($request),
|
||||||
|
// 'city' => City::query()
|
||||||
|
// ->where('province_id', $request->province_id)
|
||||||
|
// ->where(function ($query) {
|
||||||
|
// $query->where('type_id', 1)
|
||||||
|
// ->orWhereIn('name_fa', ['اداره ماشينآلات', 'اداره نقلیه']);
|
||||||
|
// })
|
||||||
|
// ->get(['id', 'name_fa'])
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function machineTypeDetailsReport(Request $request)
|
||||||
|
{
|
||||||
|
$machineIds = CMMSMachine::query()->where('car_type', '=', $request->query('car_type'))->pluck('machine_id');
|
||||||
|
return DataTableFacade::run(
|
||||||
|
Mission::query()->whereIn('machine_id', $machineIds),
|
||||||
|
$request,
|
||||||
|
allowedFilters: ['*'],
|
||||||
|
allowedSortings: ['*'],
|
||||||
|
allowedSelects: [
|
||||||
|
'id', 'province_id', 'province_name', 'city_id', 'city_name',
|
||||||
|
'end_km', 'km', 'driver_name', 'state_name', 'station_name'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function machineDriverDetailsReport(Request $request)
|
||||||
|
{
|
||||||
|
return DataTableFacade::run(
|
||||||
|
Mission::query()->where('driver_id', '=', $request->query('driver_id')),
|
||||||
|
$request,
|
||||||
|
allowedFilters: ['*'],
|
||||||
|
allowedSortings: ['*'],
|
||||||
|
allowedSelects: [
|
||||||
|
'id', 'province_id', 'province_name', 'city_id', 'city_name',
|
||||||
|
'end_km', 'km', 'driver_name', 'state_id', 'station_name'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,4 +29,18 @@ class UpdateRequest extends FormRequest
|
|||||||
'enter_station' => 'required|date',
|
'enter_station' => 'required|date',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function after(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
function (Validator $validator) {
|
||||||
|
if (strtotime($this->violation->exit_station) < strtotime($this->enter_station)) {
|
||||||
|
$validator->errors()->add(
|
||||||
|
'time',
|
||||||
|
'زمان پایان ماموریت باید بعد از زمان شروع ماموریت باشد.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class ReportMachineService
|
|||||||
SUM(m.end_km - m.km) AS func
|
SUM(m.end_km - m.km) AS func
|
||||||
FROM missions m
|
FROM missions m
|
||||||
JOIN cmms_machines cm ON cm.id = m.machine_id
|
JOIN cmms_machines cm ON cm.id = m.machine_id
|
||||||
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to AND province_id = :province_id
|
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to AND m.province_id = :province_id
|
||||||
GROUP BY cm.car_type;";
|
GROUP BY cm.car_type;";
|
||||||
|
|
||||||
return DB::select($sql, [
|
return DB::select($sql, [
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class RequestPortalService
|
|||||||
'description', 'requested_machines', 'type', 'type_fa', 'start_date', 'state_id',
|
'description', 'requested_machines', 'type', 'type_fa', 'start_date', 'state_id',
|
||||||
'end_date', 'request_date', 'end_point', 'encoded_route', 'zone', 'zone_fa', 'start_time', 'finish_time',
|
'end_date', 'request_date', 'end_point', 'encoded_route', 'zone', 'zone_fa', 'start_time', 'finish_time',
|
||||||
'code', 'category_id', 'category_name', 'explanation', 'city_id', 'city_name', 'province_id', 'station_name',
|
'code', 'category_id', 'category_name', 'explanation', 'city_id', 'city_name', 'province_id', 'station_name',
|
||||||
|
'driver_id', 'driver_name'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -573,6 +573,10 @@ Route::prefix('missions')
|
|||||||
Route::get('/country_machine_types_activity', 'countryMachineTypesActivity')->name('countryMachineTypesActivity');
|
Route::get('/country_machine_types_activity', 'countryMachineTypesActivity')->name('countryMachineTypesActivity');
|
||||||
Route::get('/province_machine_types_activity', 'provinceMachineTypesActivity')->name('provinceMachineTypesActivity');
|
Route::get('/province_machine_types_activity', 'provinceMachineTypesActivity')->name('provinceMachineTypesActivity');
|
||||||
Route::get('/machine_details_report', 'machineDetailsReport')->name('machineDetailsReport');
|
Route::get('/machine_details_report', 'machineDetailsReport')->name('machineDetailsReport');
|
||||||
|
Route::get('/country_machine_drivers_activity', 'countryMachineDriversActivity')->name('countryMachineDriversActivity');
|
||||||
|
Route::get('/province_machine_drivers_activity', 'provinceMachineDriversActivity')->name('provinceMachineDriversActivity');
|
||||||
|
Route::get('/machine_driver_details_report', 'machineDriverDetailsReport')->name('machineDriverDetailsReport');
|
||||||
|
Route::get('/machine_type_details_report', ' machineTypeDetailsReport')->name('machineTypeDetailsReport');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user