Compare commits
24 Commits
feature/Ad
...
feature/Mi
| Author | SHA1 | Date | |
|---|---|---|---|
| 17a6e903ae | |||
| 5f2d214a56 | |||
| a8c71de069 | |||
| 1e106a0c87 | |||
| 1937f57dd3 | |||
| 72462e8016 | |||
| 55b40eb0cc | |||
| 6db1933046 | |||
| b5aa3371da | |||
| 5d2a6d045b | |||
| eeff2861e5 | |||
| 6ae3fd3d90 | |||
| 6b81075e40 | |||
| 235111ee57 | |||
| ccacb2f916 | |||
| aeb58ed27f | |||
| a8b99706d0 | |||
| 92cf157b29 | |||
| 2f3ebf5808 | |||
| a0ee7cccd3 | |||
| 25e2883e9c | |||
| 23dd62550d | |||
| e3b49ebbb3 | |||
| 7d7507411d |
39
app/Console/Commands/EncodePolyLineCommand.php
Normal file
39
app/Console/Commands/EncodePolyLineCommand.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\Mission;
|
||||||
|
use App\Services\PolylineEncoder;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class EncodePolyLineCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'app:encode-poly-line-command';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'encode all missions that have poly line';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle(PolylineEncoder $polylineEncoder): void
|
||||||
|
{
|
||||||
|
Mission::query()->whereNotNull('area')->each(function ($mission) use ($polylineEncoder) {
|
||||||
|
$encodedValue = $polylineEncoder->encodePolyLine($mission, lng_lat_format:true);
|
||||||
|
$mission->update([
|
||||||
|
'encoded_route' => $encodedValue,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->info("updated successfully");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@ enum CmmsMachineStatus: int
|
|||||||
self::AMADE => 'آماده',
|
self::AMADE => 'آماده',
|
||||||
self::RESERVE => 'رزرو',
|
self::RESERVE => 'رزرو',
|
||||||
self::DAR_MAMORIAT => 'در ماموریت',
|
self::DAR_MAMORIAT => 'در ماموریت',
|
||||||
self::KHAREGE_AZ_RADE => 'خارج از محدوده',
|
self::KHAREGE_AZ_RADE => 'خارج از رده',
|
||||||
self::DAR_TAMIR => 'در تعمیر',
|
self::DAR_TAMIR => 'در تعمیر',
|
||||||
self::FOROKHTEH_SHODE => ' فروخته شده',
|
self::FOROKHTEH_SHODE => ' فروخته شده',
|
||||||
self::NIZE_BE_TAMIR => 'نیاز به تعمیر',
|
self::NIZE_BE_TAMIR => 'نیاز به تعمیر',
|
||||||
|
|||||||
@@ -26,4 +26,17 @@ enum MissionStates: int
|
|||||||
|
|
||||||
return $mapArray[$state];
|
return $mapArray[$state];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::REQUEST_CREATED => 'درخواست ایجاد شد و در حال بررسی توسط واحد تایید کننده است',
|
||||||
|
self::PENDING_CONFIRMATION => 'خودرو اختصاص داده شد و درخواست توسط واحد کنترل در حال بررسی است',
|
||||||
|
self::START_MISSION => 'درخواست توسط واحد کنترل تایید شد و ماموریت آغاز می شود',
|
||||||
|
self::END_MISSION => 'اتمام ماموریت',
|
||||||
|
self::REJECT_BY_TRANSPORTATION => 'عدم تخصیص خودرو توسط واحد تایید کننده و بازگشت درخواست به کارتابل کاربر',
|
||||||
|
self::CANCELLED => 'ماموریت لغو شد',
|
||||||
|
self::CREATED_NO_PROCESS => 'ماموریت بدون فرایند ثبت شد',
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,16 +2,20 @@
|
|||||||
|
|
||||||
namespace App\Enums;
|
namespace App\Enums;
|
||||||
|
|
||||||
|
use function Symfony\Component\String\s;
|
||||||
|
|
||||||
enum MissionViolationStatus: int
|
enum MissionViolationStatus: int
|
||||||
{
|
{
|
||||||
case BEDON_EGHDAM = 0;
|
case BEDON_EGHDAM = 0;
|
||||||
case EGHDAM_SHODE = 1;
|
case EGHDAM_SHODE = 1;
|
||||||
|
case SABT_SHODE = 2;
|
||||||
|
|
||||||
public function label(): string
|
public function label(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::BEDON_EGHDAM => "بدون اقدام",
|
self::BEDON_EGHDAM => "بدون اقدام",
|
||||||
self::EGHDAM_SHODE => "اقدام شده",
|
self::EGHDAM_SHODE => "اقدام شده",
|
||||||
|
self::SABT_SHODE => "ثبت شده توسط حراست"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
73
app/Exports/V3/Mission/Report/Machine/machineReport.php
Normal file
73
app/Exports/V3/Mission/Report/Machine/machineReport.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports\V3\Mission\Report\Machine;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromView;
|
||||||
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||||
|
use Maatwebsite\Excel\Events\AfterSheet;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Exception;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||||
|
|
||||||
|
class machineReport implements FromView, ShouldAutoSize, WithDrawings, WithEvents
|
||||||
|
{
|
||||||
|
public function __construct(private array $data)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function view(): View
|
||||||
|
{ $exportRows = [];
|
||||||
|
|
||||||
|
foreach ($this->data as $r) {
|
||||||
|
$exportRows[] = [
|
||||||
|
'city_name' => $r->c_name ?? '',
|
||||||
|
'province_name' => $r->p_name ?? '',
|
||||||
|
'missions' => $r->missions ?? 0,
|
||||||
|
'distance' => (int) ($r->distance ?? 0),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('v3.Reports.Mission.Report.Machine.ActivityReport', [
|
||||||
|
'rows' => $exportRows,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerEvents(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
AfterSheet::class => function (AfterSheet $event) {
|
||||||
|
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function drawings(): array
|
||||||
|
{
|
||||||
|
$drawing = new Drawing();
|
||||||
|
$drawing->setName('Logo');
|
||||||
|
$drawing->setDescription('This is my logo');
|
||||||
|
$drawing->setPath(public_path('/dist/logo.png'));
|
||||||
|
$drawing->setWidth(50);
|
||||||
|
$drawing->setHeight(50);
|
||||||
|
$drawing->setOffsetX(5);
|
||||||
|
$drawing->setOffsetY(5);
|
||||||
|
$drawing->setCoordinates('A1');
|
||||||
|
|
||||||
|
$drawing2 = new Drawing();
|
||||||
|
$drawing2->setName('Logo');
|
||||||
|
$drawing2->setDescription('This is my logo');
|
||||||
|
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||||
|
$drawing2->setWidth(50);
|
||||||
|
$drawing2->setHeight(50);
|
||||||
|
$drawing2->setOffsetX(5);
|
||||||
|
$drawing2->setOffsetY(5);
|
||||||
|
$drawing2->setCoordinates('D1');
|
||||||
|
|
||||||
|
return [$drawing, $drawing2];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,9 +29,9 @@ class CountryReport implements FromView, ShouldAutoSize, WithDrawings, WithEvent
|
|||||||
$national = [
|
$national = [
|
||||||
'province_name' => $name,
|
'province_name' => $name,
|
||||||
'total' => (int) ($r->total ?? 0),
|
'total' => (int) ($r->total ?? 0),
|
||||||
'khareg_mahdode' => (int) ($r->khareg_mahdode ?? 0),
|
|
||||||
'gps' => (int) ($r->gps ?? 0),
|
'gps' => (int) ($r->gps ?? 0),
|
||||||
'durations' => (int) ($r->durations ?? 0),
|
'durations' => (int) ($r->durations ?? 0),
|
||||||
|
'khareg_mahdode' => (int) ($r->khareg_mahdode ?? 0),
|
||||||
'bafarayand_saeti' => (int) ($r->far_h ?? 0),
|
'bafarayand_saeti' => (int) ($r->far_h ?? 0),
|
||||||
'bafarayand_rozaneh' => (int) ($r->far_d ?? 0),
|
'bafarayand_rozaneh' => (int) ($r->far_d ?? 0),
|
||||||
'bedon_bafarayand_saeti' => (int) ($r->un_far_h ?? 0),
|
'bedon_bafarayand_saeti' => (int) ($r->un_far_h ?? 0),
|
||||||
@@ -50,9 +50,9 @@ class CountryReport implements FromView, ShouldAutoSize, WithDrawings, WithEvent
|
|||||||
}
|
}
|
||||||
|
|
||||||
$grid[$pid]['total'] = (int) ($r->total ?? 0);
|
$grid[$pid]['total'] = (int) ($r->total ?? 0);
|
||||||
$grid[$pid]['khareg_mahdode'] = ($r->khareg_mahdode ?? 0);
|
|
||||||
$grid[$pid]['gps'] = (int) ($r->gps ?? 0);
|
$grid[$pid]['gps'] = (int) ($r->gps ?? 0);
|
||||||
$grid[$pid]['durations'] = (int) ($r->durations ?? 0);
|
$grid[$pid]['durations'] = (int) ($r->durations ?? 0);
|
||||||
|
$grid[$pid]['khareg_mahdode'] = ($r->khareg_mahdode ?? 0);
|
||||||
$grid[$pid]['bafarayand_saeti'] = (int) ($r->far_h ?? 0);
|
$grid[$pid]['bafarayand_saeti'] = (int) ($r->far_h ?? 0);
|
||||||
$grid[$pid]['bafarayand_rozaneh'] = (int) ($r->far_d ?? 0);
|
$grid[$pid]['bafarayand_rozaneh'] = (int) ($r->far_d ?? 0);
|
||||||
$grid[$pid]['bedon_bafarayand_saeti'] = (int) ($r->un_far_h ?? 0);
|
$grid[$pid]['bedon_bafarayand_saeti'] = (int) ($r->un_far_h ?? 0);
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ class ProvinceReport implements FromView, ShouldAutoSize, WithDrawings, WithEven
|
|||||||
$province = [
|
$province = [
|
||||||
'city_name' => $name,
|
'city_name' => $name,
|
||||||
'total' => (int) ($r->total ?? 0),
|
'total' => (int) ($r->total ?? 0),
|
||||||
'khareg_mahdode' => (int) ($r->khareg_mahdode ?? 0),
|
|
||||||
'gps' => (int) ($r->gps ?? 0),
|
'gps' => (int) ($r->gps ?? 0),
|
||||||
'durations' => (int) ($r->durations ?? 0),
|
'durations' => (int) ($r->durations ?? 0),
|
||||||
|
'khareg_mahdode' => (int) ($r->khareg_mahdode ?? 0),
|
||||||
'bafarayand_saeti' => (int) ($r->far_h ?? 0),
|
'bafarayand_saeti' => (int) ($r->far_h ?? 0),
|
||||||
'bafarayand_rozaneh' => (int) ($r->far_d ?? 0),
|
'bafarayand_rozaneh' => (int) ($r->far_d ?? 0),
|
||||||
'bedon_bafarayand_saeti' => (int) ($r->un_far_h ?? 0),
|
'bedon_bafarayand_saeti' => (int) ($r->un_far_h ?? 0),
|
||||||
@@ -51,9 +51,9 @@ class ProvinceReport implements FromView, ShouldAutoSize, WithDrawings, WithEven
|
|||||||
}
|
}
|
||||||
|
|
||||||
$grid[$cid]['total'] = (int) ($r->total ?? 0);
|
$grid[$cid]['total'] = (int) ($r->total ?? 0);
|
||||||
$grid[$cid]['khareg_mahdode'] = ($r->khareg_mahdode ?? 0);
|
|
||||||
$grid[$cid]['gps'] = (int) ($r->gps ?? 0);
|
$grid[$cid]['gps'] = (int) ($r->gps ?? 0);
|
||||||
$grid[$cid]['durations'] = (int) ($r->durations ?? 0);
|
$grid[$cid]['durations'] = (int) ($r->durations ?? 0);
|
||||||
|
$grid[$cid]['khareg_mahdode'] = ($r->khareg_mahdode ?? 0);
|
||||||
$grid[$cid]['bafarayand_saeti'] = (int) ($r->far_h ?? 0);
|
$grid[$cid]['bafarayand_saeti'] = (int) ($r->far_h ?? 0);
|
||||||
$grid[$cid]['bafarayand_rozaneh'] = (int) ($r->far_d ?? 0);
|
$grid[$cid]['bafarayand_rozaneh'] = (int) ($r->far_d ?? 0);
|
||||||
$grid[$cid]['bedon_bafarayand_saeti'] = (int) ($r->un_far_h ?? 0);
|
$grid[$cid]['bedon_bafarayand_saeti'] = (int) ($r->un_far_h ?? 0);
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ class CMMSMachinesController extends Controller
|
|||||||
$request,
|
$request,
|
||||||
allowedFilters: ['*'],
|
allowedFilters: ['*'],
|
||||||
allowedSortings: ['*'],
|
allowedSortings: ['*'],
|
||||||
allowedSelects: ['machine_code', 'id', 'plak_number', 'car_name', 'car_type', 'status'],
|
allowedSelects: ['machine_code', 'id', 'plak_number', 'car_name', 'car_type', 'status',
|
||||||
|
'province_id', 'city_id', 'station_id', 'status','driver_name'],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
19
app/Http/Controllers/V3/CityController.php
Normal file
19
app/Http/Controllers/V3/CityController.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\City;
|
||||||
|
use App\Models\Province;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class CityController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function list(Request $request)
|
||||||
|
{
|
||||||
|
return $this->successResponse(City::query()->where('cities.province_id', $request->query('province_id'))->get(['id', 'name_fa']));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\V3\Dashboard\Mission;
|
namespace App\Http\Controllers\V3\Dashboard\Mission;
|
||||||
|
|
||||||
|
use App\Enums\CmmsMachineStatus;
|
||||||
use App\Enums\FMSResultCode;
|
use App\Enums\FMSResultCode;
|
||||||
use App\Enums\MissionStates;
|
use App\Enums\MissionStates;
|
||||||
use App\Events\V3\Dashboard\Mission\SendDataToFMSEvent;
|
use App\Events\V3\Dashboard\Mission\SendDataToFMSEvent;
|
||||||
@@ -39,10 +40,13 @@ class ControlUnitController extends Controller
|
|||||||
// 'previous_state_name' => $mission->state_name,
|
// 'previous_state_name' => $mission->state_name,
|
||||||
// ]);
|
// ]);
|
||||||
|
|
||||||
$state = MissionStates::START_MISSION->value;
|
$mission->machine()->update([
|
||||||
|
'status' => CmmsMachineStatus::DAR_MAMORIAT->value
|
||||||
|
]);
|
||||||
|
|
||||||
$mission->update([
|
$mission->update([
|
||||||
'state_id' => $state,
|
'state_id' => MissionStates::START_MISSION->value,
|
||||||
'state_name' => MissionStates::name($state),
|
'state_name' => MissionStates::START_MISSION->label(),
|
||||||
'start_time' => $request->time,
|
'start_time' => $request->time,
|
||||||
'km' => $request->km,
|
'km' => $request->km,
|
||||||
]);
|
]);
|
||||||
@@ -63,33 +67,32 @@ class ControlUnitController extends Controller
|
|||||||
// 'previous_state_name' => $mission->state_name,
|
// 'previous_state_name' => $mission->state_name,
|
||||||
// ]);
|
// ]);
|
||||||
|
|
||||||
$state = MissionStates::END_MISSION->value;
|
$mission->machine()->update([
|
||||||
|
'status' => CmmsMachineStatus::AMADE->value
|
||||||
$mission->update([
|
|
||||||
'state_id' => $state,
|
|
||||||
'state_name' => MissionStates::name($state),
|
|
||||||
'finish_time' => $request->time,
|
|
||||||
'mission_duration' => strtotime($request->time) - strtotime($mission->start_time),
|
|
||||||
'end_km' => $request->end_km,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// $getErrorRateService->setInputParameters($mission);
|
// $getErrorRateService->setInputParameters($mission);
|
||||||
// $responseData = $getErrorRateService->run();
|
// $responseData = $getErrorRateService->run();
|
||||||
//
|
|
||||||
// $mission->update([
|
$mission->update([
|
||||||
// 'in_area_duration' => $responseData['timeInAreaSeconds'],
|
// 'in_area_duration' => $responseData['timeInAreaSeconds'],
|
||||||
// 'first_enter' => $responseData['firstEnter'],
|
// 'first_enter' => $responseData['firstEnter'],
|
||||||
// 'last_exit' => $responseData['lastExit'],
|
// 'last_exit' => $responseData['lastExit'],
|
||||||
// 'point_number_sent' => $responseData['noOfPointsInMission'],
|
// 'point_number_sent' => $responseData['noOfPointsInMission'],
|
||||||
// 'fms_result_code' => $responseData['resultCode'],
|
// 'fms_result_code' => $responseData['resultCode'],
|
||||||
// 'fms_result_message' => FMSResultCode::name($responseData['resultCode']),
|
// 'fms_result_message' => FMSResultCode::name($responseData['resultCode']),
|
||||||
// ]);
|
'state_id' => MissionStates::END_MISSION->value,
|
||||||
|
'state_name' => MissionStates::END_MISSION->label(),
|
||||||
|
'finish_time' => $request->time,
|
||||||
|
'mission_duration' => strtotime($request->time) - strtotime($mission->start_time),
|
||||||
|
'end_km' => $request->end_km,
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($mission->category_id == 2) {
|
// if ($mission->category_id == 2) {
|
||||||
$rpc = new OperatorController;
|
// $rpc = new OperatorController;
|
||||||
$rpc->store($mission);
|
// $rpc->store($mission);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// SendDataToFMSEvent::dispatch($mission);
|
// SendDataToFMSEvent::dispatch($mission);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,128 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3\Dashboard\Mission\Report;
|
||||||
|
|
||||||
|
use App\Exports\V3\Mission\Report\Machine\machineReport;
|
||||||
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\City;
|
||||||
|
use App\Models\Mission;
|
||||||
|
use App\Models\Province;
|
||||||
|
use App\Services\Cartables\Mission\Report\ReportMachineService;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Exception;
|
||||||
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
|
||||||
|
class ReportMachineController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function countryMachinesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse([
|
||||||
|
'activities' => $reportMachineService->countryMachinesActivity($request),
|
||||||
|
// 'provinces' => Province::all(['id', 'name_fa']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||||
|
*/
|
||||||
|
public function countryMachinesActivityExcel(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
|
||||||
|
{
|
||||||
|
$data = $reportMachineService->countryMachinesActivity($request);
|
||||||
|
$name = 'گزارش ماشین آلات'.verta()->now()->format('Y-m-d H-i').'.xlsx';
|
||||||
|
|
||||||
|
return Excel::download(new machineReport($data), $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provinceMachinesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse([
|
||||||
|
'activities' => $reportMachineService->countryMachinesActivity($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'])
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||||
|
*/
|
||||||
|
public function provinceMachinesActivityExcel(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
|
||||||
|
{
|
||||||
|
$data = $reportMachineService->countryMachinesActivity($request);
|
||||||
|
$name = 'گزارش ماشین آلات'.verta()->now()->format('Y-m-d H-i').'.xlsx';
|
||||||
|
|
||||||
|
return Excel::download(new machineReport($data), $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function countryMachineTypesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse([
|
||||||
|
'activities' => $reportMachineService->countryMachineTypesActivity($request),
|
||||||
|
// 'provinces' => Province::all(['id', 'name_fa']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||||
|
*/
|
||||||
|
public function countryMachineTypesActivityExcel(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
|
||||||
|
{
|
||||||
|
$data = $reportMachineService->countryMachineTypesActivity($request);
|
||||||
|
$name = 'گزارش ماشین آلات'.verta()->now()->format('Y-m-d H-i').'.xlsx';
|
||||||
|
|
||||||
|
return Excel::download(new machineReport($data), $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provinceMachineTypesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse([
|
||||||
|
'activities' => $reportMachineService->provinceMachineTypesActivity($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 machineDetailsReport(Request $request)
|
||||||
|
{
|
||||||
|
return DataTableFacade::run(
|
||||||
|
Mission::query()->where('machine_id', '=', $request->query('machine_id')),
|
||||||
|
$request,
|
||||||
|
allowedFilters: ['*'],
|
||||||
|
allowedSortings: ['*'],
|
||||||
|
allowedSelects: [
|
||||||
|
'id', 'province_id', 'province_name', 'city_id', 'city_name',
|
||||||
|
'end_km', 'km', 'driver_name', 'state_name', 'station_name'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||||
|
*/
|
||||||
|
public function provinceMachineTypesActivityExcel(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
|
||||||
|
{
|
||||||
|
$data = $reportMachineService->provinceMachineTypesActivity($request);
|
||||||
|
$name = 'گزارش ماشین آلات'.verta()->now()->format('Y-m-d H-i').'.xlsx';
|
||||||
|
|
||||||
|
return Excel::download(new machineReport($data), $name);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,10 +6,13 @@ use App\Enums\FMSResultCode;
|
|||||||
use App\Enums\MissionCategory;
|
use App\Enums\MissionCategory;
|
||||||
use App\Enums\MissionStates;
|
use App\Enums\MissionStates;
|
||||||
use App\Enums\MissionTypes;
|
use App\Enums\MissionTypes;
|
||||||
|
use App\Enums\MissionViolationStatus;
|
||||||
use App\Enums\MissionZones;
|
use App\Enums\MissionZones;
|
||||||
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Controllers\V3\Dashboard\RoadPatrol\OperatorController;
|
use App\Http\Controllers\V3\Dashboard\RoadPatrol\OperatorController;
|
||||||
use App\Http\Requests\V3\Mission\RequestPortal\ChangeStateRequest;
|
use App\Http\Requests\V3\Mission\RequestPortal\ChangeStateRequest;
|
||||||
|
use App\Http\Requests\V3\Mission\RequestPortal\ClarifyUnauthorizedExitRequest;
|
||||||
use App\Http\Requests\V3\Mission\RequestPortal\ContinueMissionRequest;
|
use App\Http\Requests\V3\Mission\RequestPortal\ContinueMissionRequest;
|
||||||
use App\Http\Requests\V3\Mission\RequestPortal\NoProcessRequest;
|
use App\Http\Requests\V3\Mission\RequestPortal\NoProcessRequest;
|
||||||
use App\Http\Requests\V3\Mission\RequestPortal\StoreRequest;
|
use App\Http\Requests\V3\Mission\RequestPortal\StoreRequest;
|
||||||
@@ -17,6 +20,8 @@ use App\Http\Requests\V3\Mission\RequestPortal\UpdateRequest;
|
|||||||
use App\Http\Traits\ApiResponse;
|
use App\Http\Traits\ApiResponse;
|
||||||
use App\Models\CMMSMachine;
|
use App\Models\CMMSMachine;
|
||||||
use App\Models\Mission;
|
use App\Models\Mission;
|
||||||
|
use App\Models\MissionViolation;
|
||||||
|
use App\Models\Rahdaran;
|
||||||
use App\Models\RahdariPoint;
|
use App\Models\RahdariPoint;
|
||||||
use App\Models\RoadObserved;
|
use App\Models\RoadObserved;
|
||||||
use App\Services\Cartables\Mission\RequestPortalService;
|
use App\Services\Cartables\Mission\RequestPortalService;
|
||||||
@@ -36,6 +41,21 @@ class RequestPortalController extends Controller
|
|||||||
return response()->json($requestPortalService->datatable($request));
|
return response()->json($requestPortalService->datatable($request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function violations(Request $request): array
|
||||||
|
{
|
||||||
|
$query = MissionViolation::query()->where([
|
||||||
|
['status', '=', MissionViolationStatus::BEDON_EGHDAM->value],
|
||||||
|
['station_id', '=', auth()->user()->station_id]
|
||||||
|
]);
|
||||||
|
|
||||||
|
return DataTableFacade::run(
|
||||||
|
$query,
|
||||||
|
$request,
|
||||||
|
allowedFilters: ['*'],
|
||||||
|
allowedSortings: ['*'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
@@ -44,9 +64,6 @@ class RequestPortalController extends Controller
|
|||||||
DB::transaction(function () use ($request) {
|
DB::transaction(function () use ($request) {
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
|
||||||
$state = MissionStates::REQUEST_CREATED->value;
|
|
||||||
$category = $request->category_id;
|
|
||||||
|
|
||||||
$mission = Mission::query()->create([
|
$mission = Mission::query()->create([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'username' => $user->username,
|
'username' => $user->username,
|
||||||
@@ -56,8 +73,8 @@ class RequestPortalController extends Controller
|
|||||||
'city_name' => $user->city_fa ?? null,
|
'city_name' => $user->city_fa ?? null,
|
||||||
'edare_shahri_id' => $user->edarate_shahri_id ?? null,
|
'edare_shahri_id' => $user->edarate_shahri_id ?? null,
|
||||||
'edare_shahri_name' => $user->edarate_shahri_name ?? null,
|
'edare_shahri_name' => $user->edarate_shahri_name ?? null,
|
||||||
'state_id' => $state,
|
'state_id' => MissionStates::REQUEST_CREATED->value,
|
||||||
'state_name' => MissionStates::name($state),
|
'state_name' => MissionStates::REQUEST_CREATED->label(),
|
||||||
'requested_machines' => json_encode($request->requested_machines),
|
'requested_machines' => json_encode($request->requested_machines),
|
||||||
'type' => $request->type,
|
'type' => $request->type,
|
||||||
'type_fa' => MissionTypes::name($request->type),
|
'type_fa' => MissionTypes::name($request->type),
|
||||||
@@ -68,13 +85,13 @@ class RequestPortalController extends Controller
|
|||||||
'request_date' => now(),
|
'request_date' => now(),
|
||||||
'description' => $request->description,
|
'description' => $request->description,
|
||||||
'end_point' => $request->end_point,
|
'end_point' => $request->end_point,
|
||||||
'area' => json_encode($request->area),
|
'encoded_route' => $request->encoded_route,
|
||||||
'category_id' => $category,
|
'category_id' => $request->category_id,
|
||||||
'category_name' => MissionCategory::name($category),
|
'category_name' => MissionCategory::name($request->category_id),
|
||||||
'explanation' => $request->explanation,
|
'explanation' => $request->explanation,
|
||||||
'code' => rand(100000, 999999),
|
'code' => rand(100000, 999999),
|
||||||
'station_id' => $user->station_id,
|
'station_id' => $user->station_id,
|
||||||
'station_name' => RahdariPoint::query()->find( $user->station_id)->name,
|
'station_name' => RahdariPoint::query()->find($user->station_id)->name,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$mission->rahdaran()->sync($request->rahdaran);
|
$mission->rahdaran()->sync($request->rahdaran);
|
||||||
@@ -96,31 +113,26 @@ class RequestPortalController extends Controller
|
|||||||
DB::transaction(function () use ($request, $mission, $getErrorRateService) {
|
DB::transaction(function () use ($request, $mission, $getErrorRateService) {
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
|
||||||
|
// $getErrorRateService->setInputParameters($mission);
|
||||||
|
// $responseData = $getErrorRateService->run();
|
||||||
|
|
||||||
$mission->update([
|
$mission->update([
|
||||||
|
// 'in_area_duration' => $responseData['timeInAreaSeconds'],
|
||||||
|
// 'first_enter' => $responseData['firstEnter'],
|
||||||
|
// 'last_exit' => $responseData['lastExit'],
|
||||||
|
// 'point_number_sent' => $responseData['noOfPointsInMission'],
|
||||||
|
// 'fms_result_code' => $responseData['resultCode'],
|
||||||
|
// 'fms_result_message' => FMSResultCode::name($responseData['resultCode']),
|
||||||
'finish_time' => now(),
|
'finish_time' => now(),
|
||||||
'state_id' => MissionStates::END_MISSION->value,
|
'state_id' => MissionStates::END_MISSION->value,
|
||||||
'state_name' => MissionStates::name(MissionStates::END_MISSION->value),
|
'state_name' => MissionStates::name(MissionStates::END_MISSION->value),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$getErrorRateService->setInputParameters($mission);
|
|
||||||
$responseData = $getErrorRateService->run();
|
|
||||||
|
|
||||||
$mission->update([
|
|
||||||
'in_area_duration' => $responseData['timeInAreaSeconds'],
|
|
||||||
'first_enter' => $responseData['firstEnter'],
|
|
||||||
'last_exit' => $responseData['lastExit'],
|
|
||||||
'point_number_sent' => $responseData['noOfPointsInMission'],
|
|
||||||
'fms_result_code' => $responseData['resultCode'],
|
|
||||||
'fms_result_message' => FMSResultCode::name($responseData['resultCode']),
|
|
||||||
]);
|
|
||||||
|
|
||||||
// if ($mission->category_id == 2) {
|
// if ($mission->category_id == 2) {
|
||||||
// $rpc = new OperatorController;
|
// $rpc = new OperatorController;
|
||||||
// $rpc->store($mission);
|
// $rpc->store($mission);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
$state = MissionStates::START_MISSION->value;
|
|
||||||
$category = $request->category_id;
|
|
||||||
$machine = CMMSMachine::query()->find($request->machine_id);
|
$machine = CMMSMachine::query()->find($request->machine_id);
|
||||||
|
|
||||||
$newMission = Mission::query()->create([
|
$newMission = Mission::query()->create([
|
||||||
@@ -132,8 +144,8 @@ class RequestPortalController extends Controller
|
|||||||
'city_name' => $user->city_fa ?? null,
|
'city_name' => $user->city_fa ?? null,
|
||||||
'edare_shahri_id' => $user->edarate_shahri_id ?? null,
|
'edare_shahri_id' => $user->edarate_shahri_id ?? null,
|
||||||
'edare_shahri_name' => $user->edarate_shahri_name ?? null,
|
'edare_shahri_name' => $user->edarate_shahri_name ?? null,
|
||||||
'state_id' => $state,
|
'state_id' => MissionStates::START_MISSION->value,
|
||||||
'state_name' => MissionStates::name($state),
|
'state_name' => MissionStates::START_MISSION->label(),
|
||||||
'type' => $request->type,
|
'type' => $request->type,
|
||||||
'type_fa' => MissionTypes::name($request->type),
|
'type_fa' => MissionTypes::name($request->type),
|
||||||
'zone' => $request->zone,
|
'zone' => $request->zone,
|
||||||
@@ -143,19 +155,20 @@ class RequestPortalController extends Controller
|
|||||||
'request_date' => now(),
|
'request_date' => now(),
|
||||||
'description' => $request->description,
|
'description' => $request->description,
|
||||||
'end_point' => $request->end_point,
|
'end_point' => $request->end_point,
|
||||||
'area' => json_encode($request->area),
|
'encoded_route' => $request->encoded_route,
|
||||||
'category_id' => $category,
|
'category_id' => $request->category_id,
|
||||||
'category_name' => MissionCategory::name($category),
|
'category_name' => MissionCategory::name($request->category_id),
|
||||||
'explanation' => $request->explanation,
|
'explanation' => $request->explanation,
|
||||||
'start_time' => now(),
|
'start_time' => now(),
|
||||||
'machine_id' => $machine->id,
|
'machine_id' => $machine->id,
|
||||||
'machine_code' => $machine->machine_code,
|
'machine_code' => $machine->machine_code,
|
||||||
'station_id' => $user->station_id,
|
'station_id' => $user->station_id,
|
||||||
'station_name' => RahdariPoint::query()->find( $user->station_id)->name,
|
'station_name' => RahdariPoint::query()->find( $user->station_id)->name,
|
||||||
|
'driver_id' => $request->driver,
|
||||||
|
'driver_name' => Rahdaran::query()->find($request->driver)->name,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$newMission->rahdaran()->sync($request->rahdaran);
|
$newMission->rahdaran()->sync($request->rahdaran);
|
||||||
$newMission->rahdaran()->attach($request->driver, ['is_driver' => true]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
@@ -180,7 +193,7 @@ class RequestPortalController extends Controller
|
|||||||
'end_date' => $request->end_date,
|
'end_date' => $request->end_date,
|
||||||
'description' => $request->description,
|
'description' => $request->description,
|
||||||
'end_point' => $request->end_point,
|
'end_point' => $request->end_point,
|
||||||
'area' => json_encode($request->area),
|
'encoded_route' => $request->encoded_route,
|
||||||
'category_id' => $request->category_id,
|
'category_id' => $request->category_id,
|
||||||
'category_name' => MissionCategory::name($request->category_id),
|
'category_name' => MissionCategory::name($request->category_id),
|
||||||
'explanation' => $request->explanation,
|
'explanation' => $request->explanation,
|
||||||
@@ -206,19 +219,29 @@ class RequestPortalController extends Controller
|
|||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function changeState(ChangeStateRequest $request, Mission $mission): JsonResponse
|
||||||
|
{
|
||||||
|
$mission->update([
|
||||||
|
'state_id' => $request->state_id,
|
||||||
|
'state_name' => MissionStates::name($request->state_id),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->successResponse($mission);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function noProcess(NoProcessRequest $request, GetErrorRateService $getErrorRateService): JsonResponse
|
public function clarifyUnauthorizedExit(ClarifyUnauthorizedExitRequest $request, MissionViolation $violation): JsonResponse
|
||||||
{
|
{
|
||||||
DB::transaction(function () use ($request, $getErrorRateService) {
|
DB::transaction(function () use ($request, $violation) {
|
||||||
$start = Carbon::parse($request->start_date);
|
|
||||||
$end = Carbon::parse($request->end_date);
|
$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;
|
$type = $start->diffInMinutes($end) > 480 ? MissionTypes::NO_PROCESS_ROZANE->value : MissionTypes::NO_PROCESS_SAATY->value;
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
$zone = $request->zone;
|
$zone = $request->zone;
|
||||||
$state = MissionStates::END_MISSION->value;
|
$machine = CMMSMachine::query()->where('machine_code', '=', $violation->machine_code)->first(['id', 'machine_code']);
|
||||||
$machine = CMMSMachine::query()->where('machine_code', '=', $request->machine_code)->first(['id', 'machine_code']);
|
|
||||||
|
|
||||||
$mission = Mission::query()->create([
|
$mission = Mission::query()->create([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
@@ -231,40 +254,34 @@ class RequestPortalController extends Controller
|
|||||||
'edare_shahri_name' => $user->edarate_shahri_name ?? null,
|
'edare_shahri_name' => $user->edarate_shahri_name ?? null,
|
||||||
'zone' => $zone,
|
'zone' => $zone,
|
||||||
'zone_fa' => MissionZones::name($zone),
|
'zone_fa' => MissionZones::name($zone),
|
||||||
|
'encoded_route' => $request->encoded_route,
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'type_fa' => MissionTypes::name($type),
|
'type_fa' => MissionTypes::name($type),
|
||||||
'start_date' => $request->start_date,
|
'start_date' => $violation->exit_station,
|
||||||
'area' => json_encode($request->area),
|
'end_date' => $violation->enter_station,
|
||||||
'end_date' => $request->end_date,
|
|
||||||
'end_point' => $request->end_point,
|
'end_point' => $request->end_point,
|
||||||
'category_id' => $request->category_id,
|
'category_id' => $request->category_id,
|
||||||
'category_name' => MissionCategory::name($request->category_id),
|
'category_name' => MissionCategory::name($request->category_id),
|
||||||
'start_time' => $request->start_date,
|
'start_time' => $violation->exit_station,
|
||||||
'finish_time' => $request->end_date,
|
'finish_time' => $violation->enter_station,
|
||||||
'state_id' => $state,
|
'mission_duration' => strtotime($violation->enter_station) - strtotime($violation->exit_station),
|
||||||
'state_name' => MissionStates::name($state),
|
'state_id' => MissionStates::END_MISSION->value,
|
||||||
|
'state_name' => MissionStates::END_MISSION->label(),
|
||||||
'explanation' => $request->explanation,
|
'explanation' => $request->explanation,
|
||||||
'request_date' => now(),
|
'request_date' => now(),
|
||||||
'machine_id' => $machine->id,
|
'machine_id' => $machine->id,
|
||||||
'machine_code' => $machine->machine_code,
|
'machine_code' => $machine->machine_code,
|
||||||
|
'requested_machines' => $machine->car_type,
|
||||||
'station_id' => $user->station_id,
|
'station_id' => $user->station_id,
|
||||||
'station_name' => RahdariPoint::query()->find( $user->station_id)->name,
|
'station_name' => RahdariPoint::query()->find($user->station_id)->name,
|
||||||
|
'km' => $violation->km ?? null,
|
||||||
|
'driver_id' => $request->driver,
|
||||||
|
'driver_name' => Rahdaran::query()->find($request->driver)->name,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$mission->rahdaran()->sync($request->rahdaran);
|
$mission->rahdaran()->sync($request->rahdaran);
|
||||||
$mission->rahdaran()->attach($request->driver, ['is_driver' => true]);
|
|
||||||
|
|
||||||
$getErrorRateService->setInputParameters($mission);
|
$violation->update(['status' => 1]);
|
||||||
$responseData = $getErrorRateService->run();
|
|
||||||
|
|
||||||
$mission->update([
|
|
||||||
'in_area_duration' => $responseData['timeInAreaSeconds'],
|
|
||||||
'first_enter' => $responseData['firstEnter'],
|
|
||||||
'last_exit' => $responseData['lastExit'],
|
|
||||||
'point_number_sent' => $responseData['noOfPointsInMission'],
|
|
||||||
'fms_result_code' => $responseData['resultCode'],
|
|
||||||
'fms_result_message' => FMSResultCode::name($responseData['resultCode']),
|
|
||||||
]);
|
|
||||||
|
|
||||||
// if ($mission->category_id == 2) {
|
// if ($mission->category_id == 2) {
|
||||||
// $rpc = new OperatorController;
|
// $rpc = new OperatorController;
|
||||||
@@ -274,14 +291,4 @@ class RequestPortalController extends Controller
|
|||||||
|
|
||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function changeState(ChangeStateRequest $request, Mission $mission): JsonResponse
|
|
||||||
{
|
|
||||||
$mission->update([
|
|
||||||
'state' => $request->state_id,
|
|
||||||
'state_name' => MissionStates::name($request->status_id),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $this->successResponse($mission);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use App\Http\Requests\V3\Mission\TransportaionUnit\DeallocateRequest;
|
|||||||
use App\Http\Traits\ApiResponse;
|
use App\Http\Traits\ApiResponse;
|
||||||
use App\Models\CMMSMachine;
|
use App\Models\CMMSMachine;
|
||||||
use App\Models\Mission;
|
use App\Models\Mission;
|
||||||
|
use App\Models\Rahdaran;
|
||||||
use App\Services\Cartables\Mission\TransportationUnitService;
|
use App\Services\Cartables\Mission\TransportationUnitService;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -31,7 +32,6 @@ class TransportationUnitController extends Controller
|
|||||||
public function allocate(AllocateRequest $request, Mission $mission): JsonResponse
|
public function allocate(AllocateRequest $request, Mission $mission): JsonResponse
|
||||||
{
|
{
|
||||||
DB::transaction(function () use ($request, $mission) {
|
DB::transaction(function () use ($request, $mission) {
|
||||||
$mission->rahdaran()->attach($request->driver, ['is_driver' => true]);
|
|
||||||
|
|
||||||
// $mission->histories()->create([
|
// $mission->histories()->create([
|
||||||
// 'user_id' => auth()->user()->id,
|
// 'user_id' => auth()->user()->id,
|
||||||
@@ -47,6 +47,12 @@ class TransportationUnitController extends Controller
|
|||||||
'state_name' => MissionStates::name($state),
|
'state_name' => MissionStates::name($state),
|
||||||
'machine_id' => $machine->id,
|
'machine_id' => $machine->id,
|
||||||
'machine_code' => $machine->machine_code,
|
'machine_code' => $machine->machine_code,
|
||||||
|
'driver_id' => $request->driver_id,
|
||||||
|
'driver_name' => Rahdaran::query()->find($request->driver)->name,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$machine->update([
|
||||||
|
'status' => CmmsMachineStatus::RESERVE->value
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -59,7 +65,6 @@ class TransportationUnitController extends Controller
|
|||||||
public function deallocate(DeallocateRequest $request, Mission $mission): JsonResponse
|
public function deallocate(DeallocateRequest $request, Mission $mission): JsonResponse
|
||||||
{
|
{
|
||||||
DB::transaction(function () use ($request, $mission) {
|
DB::transaction(function () use ($request, $mission) {
|
||||||
$mission->rahdaran()->wherePivot('is_driver', '=', true)->detach();
|
|
||||||
|
|
||||||
// $mission->histories()->create([
|
// $mission->histories()->create([
|
||||||
// 'user_id' => auth()->user()->id,
|
// 'user_id' => auth()->user()->id,
|
||||||
@@ -70,12 +75,18 @@ class TransportationUnitController extends Controller
|
|||||||
|
|
||||||
$state = MissionStates::REJECT_BY_TRANSPORTATION->value;
|
$state = MissionStates::REJECT_BY_TRANSPORTATION->value;
|
||||||
|
|
||||||
|
$mission->machine()->update([
|
||||||
|
'status' => CmmsMachineStatus::AMADE->value
|
||||||
|
]);
|
||||||
|
|
||||||
$mission->update([
|
$mission->update([
|
||||||
'state_id' => $state,
|
'state_id' => $state,
|
||||||
'state_name' => MissionStates::name($state),
|
'state_name' => MissionStates::name($state),
|
||||||
'description' => $request->description,
|
'description' => $request->description,
|
||||||
'machine_id' => null,
|
'machine_id' => null,
|
||||||
'machine_code' => null,
|
'machine_code' => null,
|
||||||
|
'driver_id' => null,
|
||||||
|
'driver_name' => null,
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use App\Http\Traits\ApiResponse;
|
|||||||
use App\Models\CMMSMachine;
|
use App\Models\CMMSMachine;
|
||||||
use App\Models\Mission;
|
use App\Models\Mission;
|
||||||
use App\Models\MissionViolation;
|
use App\Models\MissionViolation;
|
||||||
|
use App\Models\Rahdaran;
|
||||||
use App\Models\RahdariPoint;
|
use App\Models\RahdariPoint;
|
||||||
use App\Services\Cartables\Mission\DailyMoveMachineService;
|
use App\Services\Cartables\Mission\DailyMoveMachineService;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
@@ -35,65 +36,6 @@ class ViolationManagementController extends Controller
|
|||||||
return response()->json($data);
|
return response()->json($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws Throwable
|
|
||||||
*/
|
|
||||||
public function noProcess(NoProcessRequest $request, MissionViolation $violation): JsonResponse
|
|
||||||
{
|
|
||||||
DB::transaction(function () use ($request, $violation) {
|
|
||||||
|
|
||||||
$start = Carbon::parse($request->start_date);
|
|
||||||
$end = Carbon::parse($request->end_date);
|
|
||||||
$type = $start->diffInMinutes($end) > 480 ? MissionTypes::NO_PROCESS_ROZANE->value : MissionTypes::NO_PROCESS_SAATY->value;
|
|
||||||
$user = auth()->user();
|
|
||||||
$zone = $request->zone;
|
|
||||||
$state = MissionStates::END_MISSION->value;
|
|
||||||
$machine = CMMSMachine::query()->where('machine_code', '=', $violation->machine_code)->first(['id', 'machine_code']);
|
|
||||||
|
|
||||||
$mission = Mission::query()->create([
|
|
||||||
'user_id' => $user->id,
|
|
||||||
'username' => $user->username,
|
|
||||||
'province_id' => $user->province_id,
|
|
||||||
'province_name' => $user->province_fa,
|
|
||||||
'city_id' => $user->city_id ?? null,
|
|
||||||
'city_name' => $user->city_fa ?? null,
|
|
||||||
'edare_shahri_id' => $user->edarate_shahri_id ?? null,
|
|
||||||
'edare_shahri_name' => $user->edarate_shahri_name ?? null,
|
|
||||||
'zone' => $zone,
|
|
||||||
'zone_fa' => MissionZones::name($zone),
|
|
||||||
'type' => $type,
|
|
||||||
'type_fa' => MissionTypes::name($type),
|
|
||||||
'start_date' => $request->start_date,
|
|
||||||
'end_date' => $request->end_date,
|
|
||||||
'end_point' => $request->end_point,
|
|
||||||
'category_id' => $request->category_id,
|
|
||||||
'category_name' => MissionCategory::name($request->category_id),
|
|
||||||
'start_time' => $request->start_date,
|
|
||||||
'finish_time' => $request->end_date,
|
|
||||||
'state_id' => $state,
|
|
||||||
'state_name' => MissionStates::name($state),
|
|
||||||
'explanation' => $request->explanation,
|
|
||||||
'request_date' => now(),
|
|
||||||
'machine_id' => $machine->id,
|
|
||||||
'machine_code' => $machine->machine_code,
|
|
||||||
'station_id' => $user->station_id,
|
|
||||||
'station_name' => RahdariPoint::query()->find( $user->station_id)->name,
|
|
||||||
'km' => $violation->km ?? null,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$mission->rahdaran()->sync($request->rahdaran);
|
|
||||||
$mission->rahdaran()->attach($request->driver, ['is_driver' => true]);
|
|
||||||
|
|
||||||
$violation->update(['status' => 1]);
|
|
||||||
|
|
||||||
// if ($mission->category_id == 2) {
|
|
||||||
// $rpc = new OperatorController;
|
|
||||||
// $rpc->store($mission);
|
|
||||||
// }
|
|
||||||
});
|
|
||||||
|
|
||||||
return $this->successResponse();
|
|
||||||
}
|
|
||||||
public function store(StoreRequest $request): JsonResponse
|
public function store(StoreRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
@@ -102,7 +44,7 @@ class ViolationManagementController extends Controller
|
|||||||
'machine_id'=> CMMSMachine::query()->where('machine_code', '=', $request->machine_code)->value('id'),
|
'machine_id'=> CMMSMachine::query()->where('machine_code', '=', $request->machine_code)->value('id'),
|
||||||
'machine_code'=> $request->machine_code,
|
'machine_code'=> $request->machine_code,
|
||||||
'type'=> MissionViolationType::KHOROJ_BEDONE_MOGAVEZ->value,
|
'type'=> MissionViolationType::KHOROJ_BEDONE_MOGAVEZ->value,
|
||||||
'status' => MissionViolationStatus::BEDON_EGHDAM->value,
|
'status' => MissionViolationStatus::SABT_SHODE->value,
|
||||||
'request_date' => now(),
|
'request_date' => now(),
|
||||||
'km' => $request->km,
|
'km' => $request->km,
|
||||||
'gps' => 0,
|
'gps' => 0,
|
||||||
@@ -110,6 +52,9 @@ class ViolationManagementController extends Controller
|
|||||||
'province_name' => $user->province_fa,
|
'province_name' => $user->province_fa,
|
||||||
'city_id' => $user->city_id,
|
'city_id' => $user->city_id,
|
||||||
'city_name' => $user->city_fa,
|
'city_name' => $user->city_fa,
|
||||||
|
'station_id' => $user->station_id,
|
||||||
|
'station_name' => RahdariPoint::query()->find($user->station_id)->name,
|
||||||
|
'exit_station' => $request->exit_station,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
@@ -123,8 +68,8 @@ class ViolationManagementController extends Controller
|
|||||||
public function update(UpdateRequest $request, MissionViolation $violation): JsonResponse
|
public function update(UpdateRequest $request, MissionViolation $violation): JsonResponse
|
||||||
{
|
{
|
||||||
$violation->update([
|
$violation->update([
|
||||||
'enter_time' => $request->enter_time,
|
'enter_station' => $request->enter_station,
|
||||||
'exit_time' => $request->exit_time,
|
'status' => MissionViolationStatus::BEDON_EGHDAM->value,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
@@ -135,5 +80,4 @@ class ViolationManagementController extends Controller
|
|||||||
$violation->delete();
|
$violation->delete();
|
||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
19
app/Http/Controllers/V3/ProvinceController.php
Normal file
19
app/Http/Controllers/V3/ProvinceController.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\City;
|
||||||
|
use App\Models\Province;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ProvinceController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function list()
|
||||||
|
{
|
||||||
|
return $this->successResponse(Province::all(['id', 'name_fa']));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ namespace App\Http\Requests\V3\Mission\ControlUnit;
|
|||||||
use App\Enums\MissionStates;
|
use App\Enums\MissionStates;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Validator;
|
||||||
|
|
||||||
class FinishRequest extends FormRequest
|
class FinishRequest extends FormRequest
|
||||||
{
|
{
|
||||||
@@ -28,4 +29,25 @@ class FinishRequest extends FormRequest
|
|||||||
'end_km' => 'required',
|
'end_km' => 'required',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function after(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
function (Validator $validator) {
|
||||||
|
$mission = $this->mission;
|
||||||
|
if (strtotime($this->time) < strtotime($mission->start_time)) {
|
||||||
|
$validator->errors()->add(
|
||||||
|
'time',
|
||||||
|
'زمان پایان ماموریت باید بعد از زمان شروع ماموریت باشد.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ($this->end_km < $mission->km) {
|
||||||
|
$validator->errors()->add(
|
||||||
|
'end_km',
|
||||||
|
'کیلومتر پایان باید بزرگتر از کیلومتر شروع باشد.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,17 +2,19 @@
|
|||||||
|
|
||||||
namespace App\Http\Requests\V3\Mission\RequestPortal;
|
namespace App\Http\Requests\V3\Mission\RequestPortal;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Validator;
|
||||||
|
|
||||||
class NoProcessRequest extends FormRequest
|
class ClarifyUnauthorizedExitRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Determine if the user is authorized to make this request.
|
* Determine if the user is authorized to make this request.
|
||||||
*/
|
*/
|
||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return $this->violation->status === 0 && $this->violation->type === 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,22 +29,10 @@ class NoProcessRequest extends FormRequest
|
|||||||
'rahdaran.*' => 'exists:rahdaran,id',
|
'rahdaran.*' => 'exists:rahdaran,id',
|
||||||
'driver' => 'required|integer|exists:rahdaran,id',
|
'driver' => 'required|integer|exists:rahdaran,id',
|
||||||
'zone' => 'required|in:1,2,3',
|
'zone' => 'required|in:1,2,3',
|
||||||
'start_date' => 'required|date',
|
|
||||||
'end_date' => 'required|date|after:start_date|before:now',
|
|
||||||
'end_point' => 'required|string',
|
'end_point' => 'required|string',
|
||||||
'area' => 'array',
|
'encoded_route' => 'required|string',
|
||||||
'area.type' => 'string',
|
|
||||||
'area.coordinates' => 'array',
|
|
||||||
'category_id' => 'required|in:1,2,3',
|
'category_id' => 'required|in:1,2,3',
|
||||||
'explanation' => 'required|string',
|
'explanation' => 'required|string',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function messages(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'end_date.before' => 'تاریخ پایان باید قبل از زمان فعلی باشد.',
|
|
||||||
'end_date.after' => 'تاریخ پایان نباید قبل از تاریخ شروع باشد.',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -35,12 +35,9 @@ class ContinueMissionRequest extends FormRequest
|
|||||||
'end_date' => 'required|date',
|
'end_date' => 'required|date',
|
||||||
'description' => 'string',
|
'description' => 'string',
|
||||||
'end_point' => 'required|string',
|
'end_point' => 'required|string',
|
||||||
'area' => 'required|array',
|
'encoded_route' => 'required|string',
|
||||||
'area.type' => 'required|string',
|
|
||||||
'area.coordinates' => 'required|array',
|
|
||||||
'explanation' => 'required|string',
|
'explanation' => 'required|string',
|
||||||
'category_id' => 'required|in:1,2,3',
|
'category_id' => 'required|in:1,2,3',
|
||||||
'road_observed_id' => 'required_if:category_id,3|exists:road_observeds,id',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,12 +34,9 @@ class StoreRequest extends FormRequest
|
|||||||
'end_date' => 'required|date',
|
'end_date' => 'required|date',
|
||||||
'description' => 'string',
|
'description' => 'string',
|
||||||
'end_point' => 'required|string',
|
'end_point' => 'required|string',
|
||||||
'area' => 'required|array',
|
'encoded_route' => 'required|string',
|
||||||
'area.type' => 'required|string',
|
|
||||||
'area.coordinates' => 'required|array',
|
|
||||||
'explanation' => 'required|string',
|
'explanation' => 'required|string',
|
||||||
'category_id' => 'required|in:1,2,3',
|
'category_id' => 'required|in:1,2,3',
|
||||||
'road_observed_id' => 'required_if:category_id,3|exists:road_observeds,id',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +55,12 @@ class StoreRequest extends FormRequest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (strtotime($this->end_date) < strtotime($this->start_date)) {
|
||||||
|
$validator->errors()->add(
|
||||||
|
'time',
|
||||||
|
'زمان پایان ماموریت باید بعد از زمان شروع ماموریت باشد.'
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,12 +35,9 @@ class UpdateRequest extends FormRequest
|
|||||||
'end_date' => 'required|date',
|
'end_date' => 'required|date',
|
||||||
'description' => 'string',
|
'description' => 'string',
|
||||||
'end_point' => 'required|string',
|
'end_point' => 'required|string',
|
||||||
'area' => 'required|array',
|
'encoded_route' => 'required|string',
|
||||||
'area.type' => 'required|string',
|
|
||||||
'area.coordinates' => 'required|array',
|
|
||||||
'explanation' => 'required|string',
|
'explanation' => 'required|string',
|
||||||
'category_id' => 'required|in:1,2,3',
|
'category_id' => 'required|in:1,2,3',
|
||||||
'road_observed_id' => 'required_if:category_id,3|exists:road_observeds,id',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +56,12 @@ class UpdateRequest extends FormRequest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (strtotime($this->end_date) < strtotime($this->start_date)) {
|
||||||
|
$validator->errors()->add(
|
||||||
|
'time',
|
||||||
|
'زمان پایان ماموریت باید بعد از زمان شروع ماموریت باشد.'
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ class AllocateRequest extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
return $this->mission->edare_shahri_id == auth()->user()->edarate_shahri_id && $this->mission->state_id == MissionStates::REQUEST_CREATED->value;
|
return $this->mission->station_id == auth()->user()->station_id && $this->mission->state_id == MissionStates::REQUEST_CREATED->value
|
||||||
|
|| auth()->user()->username === 'witel';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,8 +13,9 @@ class DeallocateRequest extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
return $this->mission->edare_shahri_id == auth()->user()->edarate_shahri_id &&
|
return $this->mission->station_id == auth()->user()->station_id &&
|
||||||
in_array($this->mission->state_id, [MissionStates::REQUEST_CREATED->value, MissionStates::PENDING_CONFIRMATION->value]);
|
in_array($this->mission->state_id, [MissionStates::REQUEST_CREATED->value, MissionStates::PENDING_CONFIRMATION->value])
|
||||||
|
|| auth()->user()->username === 'witel';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Http\Requests\V3\Mission\Violation;
|
namespace App\Http\Requests\V3\Mission\Violation;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Validator;
|
||||||
|
|
||||||
class NoProcessRequest extends FormRequest
|
class NoProcessRequest extends FormRequest
|
||||||
{
|
{
|
||||||
@@ -27,22 +29,10 @@ class NoProcessRequest extends FormRequest
|
|||||||
'rahdaran.*' => 'exists:rahdaran,id',
|
'rahdaran.*' => 'exists:rahdaran,id',
|
||||||
'driver' => 'required|integer|exists:rahdaran,id',
|
'driver' => 'required|integer|exists:rahdaran,id',
|
||||||
'zone' => 'required|in:1,2,3',
|
'zone' => 'required|in:1,2,3',
|
||||||
'start_date' => 'required|date',
|
|
||||||
'end_date' => 'required|date|after:start_date|before:now',
|
|
||||||
'end_point' => 'required|string',
|
'end_point' => 'required|string',
|
||||||
'area' => 'array',
|
// 'encoded_route' => 'required|string',
|
||||||
'area.type' => 'string',
|
|
||||||
'area.coordinates' => 'array',
|
|
||||||
'category_id' => 'required|in:1,2,3',
|
'category_id' => 'required|in:1,2,3',
|
||||||
'explanation' => 'required|string',
|
'explanation' => 'required|string',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function messages(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'end_date.before' => 'تاریخ پایان باید قبل از زمان فعلی باشد.',
|
|
||||||
'end_date.after' => 'تاریخ پایان نباید قبل از تاریخ شروع باشد.',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ class StoreRequest extends FormRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'machine_code' => 'required',
|
'exit_station' => 'required|date',
|
||||||
|
'machine_code' => 'required',
|
||||||
'km'=> 'string',
|
'km'=> 'string',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ class UpdateRequest extends FormRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'exit_time' => 'date',
|
'enter_station' => 'required|date',
|
||||||
'enter_time' => 'date',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class City extends Model
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
protected $guarded = ['id'];
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
'name_en',
|
'name_en',
|
||||||
'feature_id',
|
'feature_id',
|
||||||
|
|||||||
@@ -28,13 +28,6 @@ class Mission extends Model
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function area(): Attribute
|
|
||||||
{
|
|
||||||
return Attribute::make(
|
|
||||||
get: fn($value) => json_decode($value, true)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function histories(): HasMany
|
public function histories(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(MissionHistory::class);
|
return $this->hasMany(MissionHistory::class);
|
||||||
@@ -50,21 +43,6 @@ class Mission extends Model
|
|||||||
return $this->hasMany(RoadItemsProject::class);
|
return $this->hasMany(RoadItemsProject::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function roadObserveds(): MorphToMany
|
|
||||||
{
|
|
||||||
return $this->morphedByMany(RoadObserved::class, 'missionable');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function machines(): MorphToMany
|
|
||||||
{
|
|
||||||
return $this->morphToMany(CMMSMachine::class,
|
|
||||||
'machinable',
|
|
||||||
'machinables',
|
|
||||||
'machinable_id',
|
|
||||||
'machine_id'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function rahdaran(): MorphToMany
|
public function rahdaran(): MorphToMany
|
||||||
{
|
{
|
||||||
return $this->morphToMany(Rahdaran::class,
|
return $this->morphToMany(Rahdaran::class,
|
||||||
@@ -75,17 +53,6 @@ class Mission extends Model
|
|||||||
)->withPivot('is_driver');
|
)->withPivot('is_driver');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function roadObserved(): MorphToMany
|
|
||||||
{
|
|
||||||
return $this->morphedByMany(
|
|
||||||
RoadObserved::class,
|
|
||||||
'missionable',
|
|
||||||
'missionables',
|
|
||||||
'mission_id',
|
|
||||||
'missionable_id'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function machine(): BelongsTo
|
public function machine(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(CMMSMachine::class, 'machine_id');
|
return $this->belongsTo(CMMSMachine::class, 'machine_id');
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class Province extends Model
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
protected $guarded = ['id'];
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
'feature_id',
|
'feature_id',
|
||||||
//'center_lat',
|
//'center_lat',
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class ControlUnitService
|
|||||||
allowedSelects: [
|
allowedSelects: [
|
||||||
'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name',
|
'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name',
|
||||||
'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', 'area', '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',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services\Cartables\Mission;
|
namespace App\Services\Cartables\Mission;
|
||||||
|
|
||||||
|
use App\Enums\MissionViolationStatus;
|
||||||
use App\Facades\DataTable\DataTableFacade;
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
use App\Models\MissionViolation;
|
use App\Models\MissionViolation;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -13,7 +14,8 @@ class DailyMoveMachineService
|
|||||||
{
|
{
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
|
|
||||||
$query = MissionViolation::query()->with('machine:id,car_name');
|
$query = MissionViolation::query()->with('machine:id,car_name')
|
||||||
|
->where('mission_violations.status', '=', MissionViolationStatus::SABT_SHODE->value);
|
||||||
|
|
||||||
if ($user->hasPermissionTo('manage-violation-station')) {
|
if ($user->hasPermissionTo('manage-violation-station')) {
|
||||||
$query->whereRelation('machine', 'station_id', '=', $user->station_id);
|
$query->whereRelation('machine', 'station_id', '=', $user->station_id);
|
||||||
|
|||||||
137
app/Services/Cartables/Mission/Report/ReportMachineService.php
Normal file
137
app/Services/Cartables/Mission/Report/ReportMachineService.php
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Cartables\Mission\Report;
|
||||||
|
|
||||||
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
|
use App\Models\MissionViolation;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class ReportMachineService
|
||||||
|
{
|
||||||
|
public function countryMachinesActivity(Request $request): array
|
||||||
|
{
|
||||||
|
$from = $request->from_date ?? today()->startOfDay();
|
||||||
|
$to = $request->date_to ? Carbon::parse($request->date_to)->endOfDay() : today()->endOfDay();
|
||||||
|
|
||||||
|
$sql = "SELECT
|
||||||
|
m.machine_id,
|
||||||
|
m.machine_code,
|
||||||
|
cm.car_name,
|
||||||
|
COUNT(*) AS missions,
|
||||||
|
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
|
||||||
|
GROUP BY machine_id;";
|
||||||
|
|
||||||
|
return DB::select($sql, [
|
||||||
|
'from' => $from,
|
||||||
|
'to' => $to,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provinceMachinesActivity(Request $request): array
|
||||||
|
{
|
||||||
|
$from = $request->from_date ?? today()->startOfDay();
|
||||||
|
$to = $request->date_to ? Carbon::parse($request->date_to)->endOfDay() : today()->endOfDay();
|
||||||
|
$province = $request->province_id;
|
||||||
|
|
||||||
|
$sql = "SELECT machine_id, machine_code, cm.car_name, COUNT(*) AS missions, 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 start_time >= :from AND finish_time <= :to AND province_id = :province_id
|
||||||
|
GROUP BY machine_id;";
|
||||||
|
|
||||||
|
return DB::select($sql, [
|
||||||
|
'from' => $from,
|
||||||
|
'to' => $to,
|
||||||
|
'province_id' => $province,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function countryMachineTypesActivity(Request $request): array
|
||||||
|
{
|
||||||
|
$from = $request->from_date ?? today()->startOfDay();
|
||||||
|
$to = $request->date_to ? Carbon::parse($request->date_to)->endOfDay() : today()->endOfDay();
|
||||||
|
|
||||||
|
$sql = "SELECT
|
||||||
|
cm.car_type,
|
||||||
|
COUNT(*) AS missions,
|
||||||
|
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
|
||||||
|
GROUP BY cm.car_type;";
|
||||||
|
|
||||||
|
return DB::select($sql, [
|
||||||
|
'from' => $from,
|
||||||
|
'to' => $to,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provinceMachineTypesActivity(Request $request): array
|
||||||
|
{
|
||||||
|
$from = $request->from_date ?? today()->startOfDay();
|
||||||
|
$to = $request->date_to ? Carbon::parse($request->date_to)->endOfDay() : today()->endOfDay();
|
||||||
|
$province = $request->province_id;
|
||||||
|
|
||||||
|
$sql = "SELECT
|
||||||
|
cm.car_type,
|
||||||
|
COUNT(*) AS missions,
|
||||||
|
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
|
||||||
|
GROUP BY cm.car_type;";
|
||||||
|
|
||||||
|
return DB::select($sql, [
|
||||||
|
'from' => $from,
|
||||||
|
'to' => $to,
|
||||||
|
'province_id' => $province,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function countryMachineDriversActivity(Request $request): array
|
||||||
|
{
|
||||||
|
$from = $request->from_date ?? today()->startOfDay();
|
||||||
|
$to = $request->date_to ? Carbon::parse($request->date_to)->endOfDay() : today()->endOfDay();
|
||||||
|
|
||||||
|
$sql = "SELECT
|
||||||
|
m.driver_id,
|
||||||
|
m.driver_name,
|
||||||
|
COUNT(*) AS missions,
|
||||||
|
SUM(m.end_km - m.km) AS func
|
||||||
|
FROM missions m
|
||||||
|
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to
|
||||||
|
GROUP BY m.driver_id;";
|
||||||
|
|
||||||
|
return DB::select($sql, [
|
||||||
|
'from' => $from,
|
||||||
|
'to' => $to,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provinceMachineDriversActivity(Request $request): array
|
||||||
|
{
|
||||||
|
$from = $request->from_date ?? today()->startOfDay();
|
||||||
|
$to = $request->date_to ? Carbon::parse($request->date_to)->endOfDay() : today()->endOfDay();
|
||||||
|
$province = $request->province_id;
|
||||||
|
|
||||||
|
$sql = "SELECT
|
||||||
|
m.driver_id,
|
||||||
|
m.driver_name,
|
||||||
|
COUNT(*) AS missions,
|
||||||
|
SUM(m.end_km - m.km) AS func
|
||||||
|
FROM missions m
|
||||||
|
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to AND province_id = :province_id
|
||||||
|
GROUP BY m.driver_id;";
|
||||||
|
|
||||||
|
return DB::select($sql, [
|
||||||
|
'from' => $from,
|
||||||
|
'to' => $to,
|
||||||
|
'province_id' => $province,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@ class RequestPortalService
|
|||||||
allowedSelects: [
|
allowedSelects: [
|
||||||
'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name',
|
'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name',
|
||||||
'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', 'area', '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',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class TransportationUnitService
|
|||||||
allowedSelects: [
|
allowedSelects: [
|
||||||
'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name',
|
'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name',
|
||||||
'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', 'area', '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', 'km', 'city_id', 'city_name', 'province_id', 'station_name',
|
'code', 'category_id', 'category_name', 'explanation', 'km', 'city_id', 'city_name', 'province_id', 'station_name',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|||||||
88
app/Services/PolylineEncoder.php
Normal file
88
app/Services/PolylineEncoder.php
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PolylineEncoder
|
||||||
|
*
|
||||||
|
* Encodes a list of latitude/longitude coordinates into an encoded polyline string.
|
||||||
|
*
|
||||||
|
* This implementation is compatible with Google's Polyline Algorithm Format:
|
||||||
|
* https://developers.google.com/maps/documentation/utilities/polylinealgorithm
|
||||||
|
*
|
||||||
|
* Example input:
|
||||||
|
* [
|
||||||
|
* [lat, lng],
|
||||||
|
* [lat, lng]
|
||||||
|
* ]
|
||||||
|
*
|
||||||
|
* or if `$lng_lat_format = true`:
|
||||||
|
* [
|
||||||
|
* [lng, lat],
|
||||||
|
* [lng, lat]
|
||||||
|
* ]
|
||||||
|
*
|
||||||
|
* @package App\Services
|
||||||
|
*/
|
||||||
|
class PolylineEncoder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Encode an array of coordinates into a polyline string.
|
||||||
|
*
|
||||||
|
* Each coordinate is encoded as a delta from the previous point,
|
||||||
|
* scaled by the given precision factor.
|
||||||
|
*
|
||||||
|
* @param array $coords Array of coordinate pairs:
|
||||||
|
* - default: [lat, lng]
|
||||||
|
* - if $lng_lat_format = true: [lng, lat]
|
||||||
|
* @param int $precision Number of decimal places to preserve (default: 6)
|
||||||
|
* @param bool $lng_lat_format If true, input is treated as [lng, lat] instead of [lat, lng]
|
||||||
|
*
|
||||||
|
* @return string Encoded polyline string
|
||||||
|
*/
|
||||||
|
public function encodePolyline(array $coords, int $precision = 6, bool $lng_lat_format = false): string
|
||||||
|
{
|
||||||
|
$factor = 10 ** $precision;
|
||||||
|
$output = '';
|
||||||
|
$prevLat = 0;
|
||||||
|
$prevLng = 0;
|
||||||
|
|
||||||
|
foreach ($coords as [$a, $b]) {
|
||||||
|
[$lat, $lng] = $lng_lat_format ? [$b, $a] : [$a, $b];
|
||||||
|
|
||||||
|
$output .= $this->encodeValue((int)round($lat * $factor) - $prevLat);
|
||||||
|
$output .= $this->encodeValue((int)round($lng * $factor) - $prevLng);
|
||||||
|
|
||||||
|
$prevLat = (int)round($lat * $factor);
|
||||||
|
$prevLng = (int)round($lng * $factor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes a single integer value using Google's polyline encoding algorithm.
|
||||||
|
*
|
||||||
|
* Steps:
|
||||||
|
* - Left shift the value
|
||||||
|
* - Invert bits if negative
|
||||||
|
* - Split into 5-bit chunks
|
||||||
|
* - Convert to ASCII characters
|
||||||
|
*
|
||||||
|
* @param int $value Signed integer delta to encode
|
||||||
|
*
|
||||||
|
* @return string Encoded character sequence
|
||||||
|
*/
|
||||||
|
public function encodeValue(int $value): string
|
||||||
|
{
|
||||||
|
$value = $value < 0 ? ~($value << 1) : ($value << 1);
|
||||||
|
$result = '';
|
||||||
|
|
||||||
|
while ($value >= 0x20) {
|
||||||
|
$result .= chr((0x20 | ($value & 0x1f)) + 63);
|
||||||
|
$value >>= 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result . chr($value + 63);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ return new class extends Migration
|
|||||||
$table->unsignedBigInteger('edare_shahri_id')->nullable();
|
$table->unsignedBigInteger('edare_shahri_id')->nullable();
|
||||||
$table->foreign('edare_shahri_id')->references('id')->on('edarate_shahri')->noActionOnDelete();
|
$table->foreign('edare_shahri_id')->references('id')->on('edarate_shahri')->noActionOnDelete();
|
||||||
$table->string('edare_shahri_name')->nullable();
|
$table->string('edare_shahri_name')->nullable();
|
||||||
$table->json('requested_machines');
|
$table->json('requested_machines')->nullable();
|
||||||
$table->string('type');
|
$table->string('type');
|
||||||
$table->dateTime('start_date');
|
$table->dateTime('start_date');
|
||||||
$table->dateTime('end_date');
|
$table->dateTime('end_date');
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ return new class extends Migration
|
|||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
Schema::table('missions', function (Blueprint $table) {
|
Schema::table('missions', function (Blueprint $table) {
|
||||||
$table->json('area');
|
$table->json('area')->nullable();
|
||||||
$table->integer('zone');
|
$table->integer('zone');
|
||||||
$table->string('zone_fa');
|
$table->string('zone_fa');
|
||||||
$table->string('type_fa');
|
$table->string('type_fa');
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('missions', function (Blueprint $table) {
|
||||||
|
$table->integer('driver_id')->nullable();
|
||||||
|
$table->string('driver_name')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('missions', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('driver_name','driver_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('mission_violations', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['exit_station', 'enter_station']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('missions', function (Blueprint $table) {
|
||||||
|
$table->longText('encoded_route')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('missions', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('encoded_route');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>گزارش کل تردد های یک ماشین </title>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
table,
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body dir="rtl" style="text-align: center;">
|
||||||
|
@php
|
||||||
|
// show a dot if key missing or value is 0/empty
|
||||||
|
function cell($row, $key) {
|
||||||
|
return array_key_exists($key, $row) ? ($row[$key] ?: '0') : '0';
|
||||||
|
}
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="4"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
|
||||||
|
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="4"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="4"
|
||||||
|
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
|
||||||
|
گزارش ماشین های ماموریت رفته
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th rowspan="1"
|
||||||
|
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||||
|
استان
|
||||||
|
</th>
|
||||||
|
<th rowspan="1"
|
||||||
|
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||||
|
شهر
|
||||||
|
</th>
|
||||||
|
<th rowspan="1"
|
||||||
|
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||||
|
تعداد ماموریت </th>
|
||||||
|
<th rowspan="1"
|
||||||
|
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||||
|
جمع کارکرد
|
||||||
|
</th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
@foreach ($rows as $item)
|
||||||
|
<tr>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['province_name'] ?? '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['city_name'] ?? '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['missions'] ?? '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['distance'] ?? '-' }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -93,9 +93,9 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td style="border: 1px solid black;text-align: center;">{{ $item['province_name'] ?? '-' }}</td>
|
<td style="border: 1px solid black;text-align: center;">{{ $item['province_name'] ?? '-' }}</td>
|
||||||
<td style="border: 1px solid black;text-align: center;">{{ $item['total'] ?? '-' }}</td>
|
<td style="border: 1px solid black;text-align: center;">{{ $item['total'] ?? '-' }}</td>
|
||||||
<td style="border: 1px solid black;text-align: center;">{{ $item['khareg_mahdode'] ?? '-' }}</td>
|
|
||||||
<td style="border: 1px solid black;text-align: center;">{{ $item['gps'] ?? '-' }}</td>
|
<td style="border: 1px solid black;text-align: center;">{{ $item['gps'] ?? '-' }}</td>
|
||||||
<td style="border: 1px solid black;text-align: center;">{{ $item['durations'] ?? '-' }}</td>
|
<td style="border: 1px solid black;text-align: center;">{{ $item['durations'] ?? '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['khareg_mahdode'] ?? '-' }}</td>
|
||||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bafarayand_saeti'] ?? '-' }}</td>
|
<td style="border: 1px solid black;text-align: center;">{{ $item['bafarayand_saeti'] ?? '-' }}</td>
|
||||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bafarayand_rozaneh'] ?? '-' }}</td>
|
<td style="border: 1px solid black;text-align: center;">{{ $item['bafarayand_rozaneh'] ?? '-' }}</td>
|
||||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bedon_bafarayand_saeti'] ?? '-' }}</td>
|
<td style="border: 1px solid black;text-align: center;">{{ $item['bedon_bafarayand_saeti'] ?? '-' }}</td>
|
||||||
|
|||||||
@@ -93,9 +93,9 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td style="border: 1px solid black;text-align: center;">{{ $item['city_name'] ?? '-' }}</td>
|
<td style="border: 1px solid black;text-align: center;">{{ $item['city_name'] ?? '-' }}</td>
|
||||||
<td style="border: 1px solid black;text-align: center;">{{ $item['total'] ?? '-' }}</td>
|
<td style="border: 1px solid black;text-align: center;">{{ $item['total'] ?? '-' }}</td>
|
||||||
<td style="border: 1px solid black;text-align: center;">{{ $item['khareg_mahdode'] ?? '-' }}</td>
|
|
||||||
<td style="border: 1px solid black;text-align: center;">{{ $item['gps'] ?? '-' }}</td>
|
<td style="border: 1px solid black;text-align: center;">{{ $item['gps'] ?? '-' }}</td>
|
||||||
<td style="border: 1px solid black;text-align: center;">{{ $item['durations'] ?? '-' }}</td>
|
<td style="border: 1px solid black;text-align: center;">{{ $item['durations'] ?? '-' }}</td>
|
||||||
|
<td style="border: 1px solid black;text-align: center;">{{ $item['khareg_mahdode'] ?? '-' }}</td>
|
||||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bafarayand_saeti'] ?? '-' }}</td>
|
<td style="border: 1px solid black;text-align: center;">{{ $item['bafarayand_saeti'] ?? '-' }}</td>
|
||||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bafarayand_rozaneh'] ?? '-' }}</td>
|
<td style="border: 1px solid black;text-align: center;">{{ $item['bafarayand_rozaneh'] ?? '-' }}</td>
|
||||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bedon_bafarayand_saeti'] ?? '-' }}</td>
|
<td style="border: 1px solid black;text-align: center;">{{ $item['bedon_bafarayand_saeti'] ?? '-' }}</td>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Http\Controllers\V3\Auth\LogoutController;
|
use App\Http\Controllers\V3\Auth\LogoutController;
|
||||||
|
use App\Http\Controllers\V3\CityController;
|
||||||
use App\Http\Controllers\V3\CMMSMachinesController;
|
use App\Http\Controllers\V3\CMMSMachinesController;
|
||||||
use App\Http\Controllers\V3\DamageManagementController;
|
use App\Http\Controllers\V3\DamageManagementController;
|
||||||
use App\Http\Controllers\V3\Dashboard\Accident\AccidentReceiptController;
|
use App\Http\Controllers\V3\Dashboard\Accident\AccidentReceiptController;
|
||||||
@@ -15,6 +16,7 @@ use App\Http\Controllers\V3\Dashboard\Harim\TechnicalDeputyController;
|
|||||||
use App\Http\Controllers\V3\Dashboard\ItemsManagementController;
|
use App\Http\Controllers\V3\Dashboard\ItemsManagementController;
|
||||||
use App\Http\Controllers\V3\Dashboard\Mission\ControlUnitController;
|
use App\Http\Controllers\V3\Dashboard\Mission\ControlUnitController;
|
||||||
use App\Http\Controllers\V3\Dashboard\Mission\DetailController;
|
use App\Http\Controllers\V3\Dashboard\Mission\DetailController;
|
||||||
|
use App\Http\Controllers\V3\Dashboard\Mission\Report\ReportMachineController;
|
||||||
use App\Http\Controllers\V3\Dashboard\Mission\Report\ReportTradodController;
|
use App\Http\Controllers\V3\Dashboard\Mission\Report\ReportTradodController;
|
||||||
use App\Http\Controllers\V3\Dashboard\Mission\Report\ReportViolationController;
|
use App\Http\Controllers\V3\Dashboard\Mission\Report\ReportViolationController;
|
||||||
use App\Http\Controllers\V3\Dashboard\Mission\RequestPortalController;
|
use App\Http\Controllers\V3\Dashboard\Mission\RequestPortalController;
|
||||||
@@ -37,6 +39,7 @@ use App\Http\Controllers\V3\LogListManagementController;
|
|||||||
use App\Http\Controllers\V3\NotificationController;
|
use App\Http\Controllers\V3\NotificationController;
|
||||||
use App\Http\Controllers\V3\PermissionManagementController;
|
use App\Http\Controllers\V3\PermissionManagementController;
|
||||||
use App\Http\Controllers\V3\ProfileController;
|
use App\Http\Controllers\V3\ProfileController;
|
||||||
|
use App\Http\Controllers\V3\ProvinceController;
|
||||||
use App\Http\Controllers\V3\RahdaranController;
|
use App\Http\Controllers\V3\RahdaranController;
|
||||||
use App\Http\Controllers\V3\WebServices\RoadItemController;
|
use App\Http\Controllers\V3\WebServices\RoadItemController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
@@ -492,13 +495,14 @@ Route::prefix('missions')
|
|||||||
->controller(RequestPortalController::class)
|
->controller(RequestPortalController::class)
|
||||||
->group(function () {
|
->group(function () {
|
||||||
Route::get('/', 'index')->name('index');
|
Route::get('/', 'index')->name('index');
|
||||||
|
Route::get('/violations', 'violations')->name('violations');
|
||||||
Route::post('/', 'store')->name('store');
|
Route::post('/', 'store')->name('store');
|
||||||
Route::post('/no_process','noProcess')->name('noProcess');
|
Route::post('/clarify_unauthorized_exit/{violation}','clarifyUnauthorizedExit')->name('clarifyUnauthorizedExit');
|
||||||
Route::post('/continue/{mission}','continueMission')->name('continueMission');
|
Route::post('/continue/{mission}','continueMission')->name('continueMission');
|
||||||
Route::get('/{mission}', 'show')->name('show');
|
Route::get('/{mission}', 'show')->name('show');
|
||||||
Route::post('/{mission}', 'update')->name('update');
|
Route::post('/{mission}', 'update')->name('update');
|
||||||
Route::delete('/{mission}', 'destroy')->name('destroy');
|
Route::delete('/{mission}', 'destroy')->name('destroy');
|
||||||
Route::post('/change_state/{mission}', 'changeState')->name('changeState');
|
Route::post('/change_state/{mission}', 'changeState')->name('changeState')->middleware('permission:mission-change-state');
|
||||||
});
|
});
|
||||||
Route::name('transportationUnit.')
|
Route::name('transportationUnit.')
|
||||||
->prefix('transportation_unit')
|
->prefix('transportation_unit')
|
||||||
@@ -533,7 +537,6 @@ Route::prefix('missions')
|
|||||||
->group(function () {
|
->group(function () {
|
||||||
Route::get('/', 'index')->name('index');
|
Route::get('/', 'index')->name('index');
|
||||||
Route::post('/', 'store')->name('store');
|
Route::post('/', 'store')->name('store');
|
||||||
Route::post('/no_process/{violation}','noProcess')->name('noProcess');
|
|
||||||
Route::get('/{violation}', 'show')->name('show');
|
Route::get('/{violation}', 'show')->name('show');
|
||||||
Route::post('/{violation}', 'update')->name('update');
|
Route::post('/{violation}', 'update')->name('update');
|
||||||
Route::delete('/{violation}', 'destroy')->name('destroy');
|
Route::delete('/{violation}', 'destroy')->name('destroy');
|
||||||
@@ -558,6 +561,19 @@ Route::prefix('missions')
|
|||||||
Route::get('/country_excel_activity', 'countryExcelActivity')->name('countryExcelActivity');
|
Route::get('/country_excel_activity', 'countryExcelActivity')->name('countryExcelActivity');
|
||||||
Route::get('/province_excel_activity', 'provinceExcelActivity')->name('provinceExcelActivity');
|
Route::get('/province_excel_activity', 'provinceExcelActivity')->name('provinceExcelActivity');
|
||||||
});
|
});
|
||||||
|
Route::prefix('report_machine')
|
||||||
|
->name('reportsMachine.')
|
||||||
|
->middleware(['permission:mission-report-province|mission-report-country'])
|
||||||
|
->controller(ReportMachineController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('/country_machines_activity', 'countryMachinesActivity')->name('countryMachinesActivity');
|
||||||
|
Route::get('/country_machines_activity_excel', 'countryMachinesActivityExcel')->name('countryMachinesActivityExcel');
|
||||||
|
Route::get('/province_machines_activity', 'provinceMachinesActivity')->name('provinceMachinesActivity');
|
||||||
|
Route::get('/province_machines_activity_excel', 'provinceMachinesActivityExcel')->name('provinceMachinesActivityExcel');
|
||||||
|
Route::get('/country_machine_types_activity', 'countryMachineTypesActivity')->name('countryMachineTypesActivity');
|
||||||
|
Route::get('/province_machine_types_activity', 'provinceMachineTypesActivity')->name('provinceMachineTypesActivity');
|
||||||
|
Route::get('/machine_details_report', 'machineDetailsReport')->name('machineDetailsReport');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('harim')
|
Route::prefix('harim')
|
||||||
@@ -670,3 +686,17 @@ Route::get('/test', function () {
|
|||||||
$csvExporter = new \Laracsv\Export();
|
$csvExporter = new \Laracsv\Export();
|
||||||
$csvExporter->build(\App\Models\User::all(), ['id' => 'کد یکتا', 'username' => 'نام کاربری'])->download();
|
$csvExporter->build(\App\Models\User::all(), ['id' => 'کد یکتا', 'username' => 'نام کاربری'])->download();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::prefix('provinces')
|
||||||
|
->name('provinces.')
|
||||||
|
->controller(ProvinceController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('/list', 'list')->name('list');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::prefix('cities')
|
||||||
|
->name('cities.')
|
||||||
|
->controller(CityController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('/list', 'list')->name('list');
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user