create permission

This commit is contained in:
2025-12-23 11:00:07 +03:30
parent e8e0f2c724
commit 89a0e1d228
8 changed files with 85 additions and 8 deletions

View File

@@ -204,16 +204,16 @@ class RequestPortalController extends Controller
/**
* @throws Throwable
*/
public function noProcess(NoProcessRequest $request): JsonResponse
public function noProcess(NoProcessRequest $request, GetErrorRateService $getErrorRateService): JsonResponse
{
DB::transaction(function () use ($request) {
DB::transaction(function () use ($request, $getErrorRateService) {
$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('id', '=', $request->machine_id)->first(['id', 'machine_code']);
$machine = CMMSMachine::query()->where('machine_code', '=', $request->machine_code)->first(['id', 'machine_code']);
$mission = Mission::query()->create([
'user_id' => $user->id,
@@ -229,6 +229,7 @@ class RequestPortalController extends Controller
'type' => $type,
'type_fa' => MissionTypes::name($type),
'start_date' => $request->start_date,
'area' => json_encode($request->area),
'end_date' => $request->end_date,
'end_point' => $request->end_point,
'category_id' => $request->category_id,
@@ -247,6 +248,18 @@ class RequestPortalController extends Controller
$mission->rahdaran()->sync($request->rahdaran);
$mission->rahdaran()->attach($request->driver, ['is_driver' => true]);
$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) {
// $rpc = new OperatorController;
// $rpc->store($mission);

View File

@@ -12,7 +12,8 @@ class NoProcessRequest extends FormRequest
*/
public function authorize(): bool
{
return $this->violation->status === 0 && $this->violation->type === 1;
// return $this->violation->status === 0 && $this->violation->type === 1;
return true;
}
/**
@@ -30,9 +31,9 @@ class NoProcessRequest extends FormRequest
'start_date' => 'required|date',
'end_date' => 'required|date|after:start_date|before:now',
'end_point' => 'required|string',
// 'area' => 'required|array',
// 'area.type' => 'required|string',
// 'area.coordinates' => 'required|array',
'area' => 'array',
'area.type' => 'string',
'area.coordinates' => 'array',
'category_id' => 'required|in:1,2,3',
'explanation' => 'required|string',
];