Compare commits
4 Commits
feature/Po
...
fc853d318e
| Author | SHA1 | Date | |
|---|---|---|---|
| fc853d318e | |||
|
|
5a2a477789 | ||
|
|
a45b4955db | ||
| ace0b018e7 |
@@ -13,7 +13,7 @@ class EncodePolyLineCommand extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'polyline:encode';
|
||||
protected $signature = 'app:encode-poly-line-command';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
|
||||
@@ -7,11 +7,13 @@ use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\City;
|
||||
use App\Models\CMMSMachine;
|
||||
use App\Models\Mission;
|
||||
use App\Models\Province;
|
||||
use App\Services\Cartables\Mission\Report\ReportMachineService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
@@ -147,4 +149,33 @@ class ReportMachineController extends Controller
|
||||
// ->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'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,8 +236,8 @@ class RequestPortalController extends Controller
|
||||
{
|
||||
DB::transaction(function () use ($request, $violation) {
|
||||
|
||||
$start = Carbon::parse($violation->exit_time);
|
||||
$end = Carbon::parse($violation->enter_time);
|
||||
$start = Carbon::parse($violation->exit_station);
|
||||
$end = Carbon::parse($violation->enter_station);
|
||||
$type = $start->diffInMinutes($end) > 480 ? MissionTypes::NO_PROCESS_ROZANE->value : MissionTypes::NO_PROCESS_SAATY->value;
|
||||
$user = auth()->user();
|
||||
$zone = $request->zone;
|
||||
@@ -257,14 +257,14 @@ class RequestPortalController extends Controller
|
||||
'encoded_route' => $request->encoded_route,
|
||||
'type' => $type,
|
||||
'type_fa' => MissionTypes::name($type),
|
||||
'start_date' => $violation->exit_time,
|
||||
'end_date' => $violation->enter_time,
|
||||
'start_date' => $violation->exit_station,
|
||||
'end_date' => $violation->enter_station,
|
||||
'end_point' => $request->end_point,
|
||||
'category_id' => $request->category_id,
|
||||
'category_name' => MissionCategory::name($request->category_id),
|
||||
'start_time' => $violation->exit_time,
|
||||
'finish_time' => $violation->enter_time,
|
||||
'mission_duration' => strtotime($violation->enter_time) - strtotime($violation->exit_time),
|
||||
'start_time' => $violation->exit_station,
|
||||
'finish_time' => $violation->enter_station,
|
||||
'mission_duration' => strtotime($violation->enter_station) - strtotime($violation->exit_station),
|
||||
'state_id' => MissionStates::END_MISSION->value,
|
||||
'state_name' => MissionStates::END_MISSION->label(),
|
||||
'explanation' => $request->explanation,
|
||||
|
||||
@@ -54,7 +54,7 @@ class ViolationManagementController extends Controller
|
||||
'city_name' => $user->city_fa,
|
||||
'station_id' => $user->station_id,
|
||||
'station_name' => RahdariPoint::query()->find($user->station_id)->name,
|
||||
'exit_time' => $request->exit_time,
|
||||
'exit_station' => $request->exit_station,
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
@@ -68,7 +68,7 @@ class ViolationManagementController extends Controller
|
||||
public function update(UpdateRequest $request, MissionViolation $violation): JsonResponse
|
||||
{
|
||||
$violation->update([
|
||||
'enter_time' => $request->enter_time,
|
||||
'enter_station' => $request->enter_station,
|
||||
'status' => MissionViolationStatus::BEDON_EGHDAM->value,
|
||||
]);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class StoreRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'exit_time' => 'required|date',
|
||||
'exit_station' => 'required|date',
|
||||
'machine_code' => 'required',
|
||||
'km'=> 'string',
|
||||
];
|
||||
|
||||
@@ -26,7 +26,7 @@ class UpdateRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'enter_time' => 'required|date',
|
||||
'enter_station' => 'required|date',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class UpdateRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
function (Validator $validator) {
|
||||
if (strtotime($this->enter_time) < strtotime($this->violation->exit_time)) {
|
||||
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
|
||||
FROM missions m
|
||||
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;";
|
||||
|
||||
return DB::select($sql, [
|
||||
|
||||
@@ -12,6 +12,8 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('mission_violations', function (Blueprint $table) {
|
||||
$table->dateTime('exit_station')->nullable();
|
||||
$table->dateTime('enter_station')->nullable();
|
||||
$table->unsignedInteger('station_id')->nullable();
|
||||
$table->string('station_name')->nullable();
|
||||
});
|
||||
@@ -23,7 +25,7 @@ return new class extends Migration
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('mission_violations', function (Blueprint $table) {
|
||||
$table->dropColumn(['station_id', 'station_name']);
|
||||
$table->dropColumn(['exit_station', 'enter_station']);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -575,6 +575,8 @@ Route::prefix('missions')
|
||||
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