@@ -16,6 +16,7 @@ use App\Http\Requests\V3\Mission\RequestPortal\UpdateRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\CMMSMachine;
|
||||
use App\Models\Mission;
|
||||
use App\Models\RahdariPoint;
|
||||
use App\Models\RoadObserved;
|
||||
use App\Services\Cartables\Mission\RequestPortalService;
|
||||
use App\Services\FMS\GetErrorRateService;
|
||||
@@ -71,7 +72,8 @@ class RequestPortalController extends Controller
|
||||
'category_name' => MissionCategory::name($category),
|
||||
'explanation' => $request->explanation,
|
||||
'code' => rand(100000, 999999),
|
||||
'station_id' => $user->station_id
|
||||
'station_id' => $user->station_id,
|
||||
'station_name' => RahdariPoint::query()->find( $user->station_id)->name,
|
||||
]);
|
||||
|
||||
$mission->rahdaran()->sync($request->rahdaran);
|
||||
@@ -147,7 +149,8 @@ class RequestPortalController extends Controller
|
||||
'start_time' => now(),
|
||||
'machine_id' => $machine->id,
|
||||
'machine_code' => $machine->machine_code,
|
||||
'station_id' => $user->station_id
|
||||
'station_id' => $user->station_id,
|
||||
'station_name' => RahdariPoint::query()->find( $user->station_id)->name,
|
||||
]);
|
||||
|
||||
$newMission->rahdaran()->sync($request->rahdaran);
|
||||
@@ -242,7 +245,8 @@ class RequestPortalController extends Controller
|
||||
'request_date' => now(),
|
||||
'machine_id' => $machine->id,
|
||||
'machine_code' => $machine->machine_code,
|
||||
'station_id' => $user->station_id
|
||||
'station_id' => $user->station_id,
|
||||
'station_name' => RahdariPoint::query()->find( $user->station_id)->name,
|
||||
]);
|
||||
|
||||
$mission->rahdaran()->sync($request->rahdaran);
|
||||
|
||||
@@ -5,14 +5,18 @@ namespace App\Http\Controllers\V3\Dashboard\Mission;
|
||||
use App\Enums\MissionCategory;
|
||||
use App\Enums\MissionStates;
|
||||
use App\Enums\MissionTypes;
|
||||
use App\Enums\MissionViolationStatus;
|
||||
use App\Enums\MissionViolationType;
|
||||
use App\Enums\MissionZones;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\V3\Dashboard\RoadPatrol\OperatorController;
|
||||
use App\Http\Requests\V3\Mission\RequestPortal\NoProcessRequest;
|
||||
use App\Http\Requests\V3\Mission\Violation\NoProcessRequest;
|
||||
use App\Http\Requests\V3\Mission\Violation\StoreRequest;
|
||||
use App\Http\Requests\V3\Mission\Violation\UpdateRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\CMMSMachine;
|
||||
use App\Models\Mission;
|
||||
use App\Models\MissionViolation;
|
||||
use App\Models\RahdariPoint;
|
||||
use App\Services\Cartables\Mission\DailyMoveMachineService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -72,7 +76,8 @@ class ViolationManagementController extends Controller
|
||||
'request_date' => now(),
|
||||
'machine_id' => $machine->id,//
|
||||
'machine_code' => $machine->machine_code,//
|
||||
'station_id' => $user->station_id
|
||||
'station_id' => $user->station_id,
|
||||
'station_name' => RahdariPoint::query()->find( $user->station_id)->name,
|
||||
]);
|
||||
|
||||
$mission->rahdaran()->sync($request->rahdaran);
|
||||
@@ -88,4 +93,38 @@ class ViolationManagementController extends Controller
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
public function store(StoreRequest $request): JsonResponse
|
||||
{
|
||||
MissionViolation::query()->create([
|
||||
'machine_id'=> CMMSMachine::query()->where('machine_code', '=', $request->machine_code)->value('id'),
|
||||
'machine_code'=> $request->machine_code,
|
||||
'type'=> MissionViolationType::KHOROJ_BEDONE_MOGAVEZ->value,
|
||||
'status' => MissionViolationStatus::BEDON_EGHDAM->value,
|
||||
'request_date' => now(),
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
|
||||
}
|
||||
public function show(MissionViolation $violation): JsonResponse
|
||||
{
|
||||
return $this->successResponse($violation);
|
||||
}
|
||||
|
||||
public function update(UpdateRequest $request, MissionViolation $violation): JsonResponse
|
||||
{
|
||||
$violation->update([
|
||||
'enter_time' => $request->enter_time,
|
||||
'exit_time' => $request->exit_time,
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function destroy(MissionViolation $violation): JsonResponse
|
||||
{
|
||||
$violation->delete();
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -226,6 +226,6 @@ class RoadMaintenanceStationController extends Controller
|
||||
|
||||
public function giveListToFms(): JsonResponse
|
||||
{
|
||||
return $this->successResponse(RahdariPoint::all(['id', 'name', 'lat', 'lng', 'area']));
|
||||
return $this->successResponse(RahdariPoint::all(['id', 'province_id', 'province_name', 'city_id', 'city_name', 'name', 'lat', 'lng', 'area']));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ class RahdaranController extends Controller
|
||||
public function store(StoreRequest $request): JsonResponse
|
||||
{
|
||||
$province = Province::query()->find($request->input('province_id'));
|
||||
$edareh = EdarateShahri::query()->find($request->input('edareh_shahri_id'));
|
||||
|
||||
Rahdaran::query()->create([
|
||||
'name' => $request->name,
|
||||
@@ -48,8 +47,6 @@ class RahdaranController extends Controller
|
||||
'mobile' => $request->mobile,
|
||||
'province_id' => $province->id,
|
||||
'province_name' => $province->name_fa,
|
||||
'edareh_shahri_id' => $request->edareh_shahri_id,
|
||||
'edareh_shahri_name' => $edareh->name_fa,
|
||||
'is_driver' => $request->is_driver,
|
||||
]);
|
||||
|
||||
@@ -64,7 +61,6 @@ class RahdaranController extends Controller
|
||||
public function update(UpdateRequest $request, Rahdaran $rahdaran): JsonResponse
|
||||
{
|
||||
$province = Province::query()->find($request->input('province_id'));
|
||||
$edareh = EdarateShahri::query()->find($request->input('edareh_shahri_id'));
|
||||
|
||||
$rahdaran->update([
|
||||
'name' => $request->name,
|
||||
@@ -72,8 +68,6 @@ class RahdaranController extends Controller
|
||||
'mobile' => $request->mobile,
|
||||
'province_id' => $province->id,
|
||||
'province_name' => $province->name_fa,
|
||||
'edareh_shahri_id' => $request->edareh_shahri_id,
|
||||
'edareh_shahri_name' => $edareh->name_fa,
|
||||
'is_driver' => $request->is_driver,
|
||||
]);
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ class NoProcessRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
// return $this->violation->status === 0 && $this->violation->type === 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
48
app/Http/Requests/V3/Mission/Violation/NoProcessRequest.php
Normal file
48
app/Http/Requests/V3/Mission/Violation/NoProcessRequest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Mission\Violation;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class NoProcessRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->violation->status === 0 && $this->violation->type === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'rahdaran' => 'array',
|
||||
'rahdaran.*' => 'exists:rahdaran,id',
|
||||
'driver' => 'required|integer|exists:rahdaran,id',
|
||||
'zone' => 'required|in:1,2,3',
|
||||
'start_date' => 'required|date',
|
||||
'end_date' => 'required|date|after:start_date|before:now',
|
||||
'end_point' => 'required|string',
|
||||
'area' => 'array',
|
||||
'area.type' => 'string',
|
||||
'area.coordinates' => 'array',
|
||||
'category_id' => 'required|in:1,2,3',
|
||||
'explanation' => 'required|string',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'end_date.before' => 'تاریخ پایان باید قبل از زمان فعلی باشد.',
|
||||
'end_date.after' => 'تاریخ پایان نباید قبل از تاریخ شروع باشد.',
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Requests/V3/Mission/Violation/StoreRequest.php
Normal file
32
app/Http/Requests/V3/Mission/Violation/StoreRequest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Mission\Violation;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class StoreRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'machine_code' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
33
app/Http/Requests/V3/Mission/Violation/UpdateRequest.php
Normal file
33
app/Http/Requests/V3/Mission/Violation/UpdateRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Mission\Violation;
|
||||
|
||||
use App\Enums\MissionStates;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class UpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'exit_time' => 'required',
|
||||
'enter_time' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,6 @@ class StoreRequest extends FormRequest
|
||||
'code' => 'required|string|max:255|unique:rahdaran,code',
|
||||
'mobile' => 'required|digits:11|regex:/^09\d{9}$/',
|
||||
'province_id' => 'required|exists:provinces,id',
|
||||
'edareh_shahri_id' => 'required|exists:edarate_shahri,id',
|
||||
'is_driver' => 'required|boolean',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ class UpdateRequest extends FormRequest
|
||||
'code' => ['required', 'string', Rule::unique('rahdaran', 'code')->ignore($this->rahdaran->id)],
|
||||
'mobile' => 'required|digits:11|regex:/^09\d{9}$/',
|
||||
'province_id' => 'required|exists:provinces,id',
|
||||
'edareh_shahri_id' => 'required|exists:edarate_shahri,id',
|
||||
'is_driver' => 'required|boolean',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ class MissionViolation extends Model
|
||||
return $this->belongsTo(Mission::class);
|
||||
}
|
||||
|
||||
public function machine(): HasOne
|
||||
public function machine(): BelongsTo
|
||||
{
|
||||
return $this->hasOne(CMMSMachine::class);
|
||||
return $this->belongsTo(CMMSMachine::class, 'machine_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ class DailyMovingMachinesService
|
||||
$inputData = $this->makeInputParameters();
|
||||
|
||||
return Http::withBody($inputData)
|
||||
->timeout(120)
|
||||
->throw()
|
||||
->withoutVerifying()
|
||||
->post($this->url)
|
||||
|
||||
@@ -41,7 +41,7 @@ class ControlUnitService
|
||||
'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name',
|
||||
'description', 'requested_machines', 'type', 'type_fa', 'start_date', 'state_id',
|
||||
'end_date', 'request_date', 'end_point', 'area', 'zone', 'zone_fa', 'start_time', 'finish_time',
|
||||
'code', 'category_id', 'category_name', 'explanation'
|
||||
'code', 'category_id', 'category_name', 'explanation', 'city_id', 'city_name', 'province_id', 'station_name'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ class DailyMoveMachineService
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedSelects: ['id', 'mission_id', 'machine_code', 'request_date', 'type', 'exit_time', 'enter_time', 'status']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,13 +39,13 @@ class ReportService
|
||||
|
||||
COUNT(DISTINCT CASE
|
||||
WHEN mv.type = 1
|
||||
AND mv.created_at BETWEEN :from AND :to
|
||||
AND mv.created_at BETWEEN :from_mv AND :to_mv
|
||||
THEN mv.id
|
||||
END) AS no_mission_count,
|
||||
|
||||
COUNT(DISTINCT CASE
|
||||
WHEN m.mission_duration != m.in_area_duration
|
||||
AND m.created_at BETWEEN :from AND :to
|
||||
AND m.created_at BETWEEN :from_m AND :to_m
|
||||
THEN m.id
|
||||
END) AS out_of_area_count
|
||||
|
||||
@@ -61,6 +61,7 @@ class ReportService
|
||||
)
|
||||
|
||||
SELECT
|
||||
-1 AS province_id,
|
||||
'کل کشور' AS province_name,
|
||||
SUM(no_mission_count) AS no_mission_count,
|
||||
SUM(out_of_area_count) AS out_of_area_count
|
||||
@@ -78,8 +79,10 @@ class ReportService
|
||||
";
|
||||
|
||||
return DB::select($sql, [
|
||||
'from' => $from,
|
||||
'to' => $to,
|
||||
'from_mv' => $from,
|
||||
'to_mv' => $to,
|
||||
'from_m' => $from,
|
||||
'to_m' => $to,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class RequestPortalService
|
||||
'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name',
|
||||
'description', 'requested_machines', 'type', 'type_fa', 'start_date', 'state_id',
|
||||
'end_date', 'request_date', 'end_point', 'area', 'zone', 'zone_fa', 'start_time', 'finish_time',
|
||||
'code', 'category_id', 'category_name', 'explanation'
|
||||
'code', 'category_id', 'category_name', 'explanation', 'city_id', 'city_name', 'province_id', 'station_name'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class TransportationUnitService
|
||||
'id', 'user_id', 'username', 'state_name', 'province_name', 'edare_shahri_name',
|
||||
'description', 'requested_machines', 'type', 'type_fa', 'start_date', 'state_id',
|
||||
'end_date', 'request_date', 'end_point', 'area', 'zone', 'zone_fa', 'start_time', 'finish_time',
|
||||
'code', 'category_id', 'category_name', 'explanation', 'km'
|
||||
'code', 'category_id', 'category_name', 'explanation', 'km', 'city_id', 'city_name', 'province_id', 'station_name'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('mission_violations', function (Blueprint $table) {
|
||||
$table->foreignId('machine_id')->constrained('cmms_machines');
|
||||
$table->foreignId('machine_id')->nullable()->constrained('cmms_machines');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,14 @@
|
||||
@can('create-road-item')
|
||||
<a href="{{ route('v2.road_items.operator.create') }}" class="btn btn-default btn-block my-2">ثبت فعالیت روزانه</a>
|
||||
@endcan
|
||||
@canany(['manage-request-portal-city', 'manage-request-portal-province', 'manage-request-portal-country', 'manage-request-portal-station',
|
||||
'manage-transportation-unit-city', 'manage-transportation-unit-province', 'manage-transportation-unit-country', 'manage-transportation-unit-station',
|
||||
'manage-control-unit-city', 'manage-control-unit-province', 'manage-control-unit-country', 'manage-control-unit-station',
|
||||
])
|
||||
<a href="/v3/dashboard/" class="btn btn-default btn-block my-2">
|
||||
ماموریت
|
||||
</a>
|
||||
@endcan
|
||||
@can('add-road-patrol')
|
||||
<a href="{{ route('v2.road_patrols.operator.create') }}" class="btn btn-default btn-block my-2">ثبت گشت راهداری و ترابری</a>
|
||||
@endcan
|
||||
|
||||
@@ -527,7 +527,11 @@ Route::prefix('missions')
|
||||
->controller(ViolationManagementController::class)
|
||||
->group(function () {
|
||||
Route::get('/', 'index')->name('index');
|
||||
Route::post('/', 'store')->name('store');
|
||||
Route::post('/no_process/{violation}','noProcess')->name('noProcess');
|
||||
Route::get('/{violation}', 'show')->name('show');
|
||||
Route::post('/{violation}', 'update')->name('update');
|
||||
Route::delete('/{violation}', 'destroy')->name('destroy');
|
||||
});
|
||||
Route::prefix('report')
|
||||
->name('reports.')
|
||||
|
||||
Reference in New Issue
Block a user