Merge branch 'feature/DefineProvince' into 'develop'
refactor See merge request witelgroup/rms_v2!171
This commit is contained in:
@@ -86,7 +86,7 @@ class HarimOfficeController extends Controller
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
'is_possible' => true,
|
||||
'need_road_access' => true,
|
||||
'need_access_road' => true,
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
@@ -112,7 +112,7 @@ class HarimOfficeController extends Controller
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
'is_possible' => true,
|
||||
'need_road_access' => false,
|
||||
'need_access_road' => false,
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
@@ -135,7 +135,7 @@ class HarimOfficeController extends Controller
|
||||
$harim ->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
'is_file_good' => true,
|
||||
'access_road_allowed' => true,
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
@@ -158,7 +158,7 @@ class HarimOfficeController extends Controller
|
||||
$harim ->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
'is_file_good' => false,
|
||||
'access_road_allowed' => false,
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
|
||||
@@ -2,24 +2,66 @@
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Harim;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\PanjareVahed\GetAccessRoadRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\City;
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PanjareVahedController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function receiveNewRequests()
|
||||
public function receiveNewRequests(Request $request)
|
||||
{
|
||||
// find city and province by lat,lng
|
||||
Harim::query()->create([
|
||||
try {
|
||||
$city = City::query()
|
||||
->whereRaw("ST_Contains(
|
||||
geometry,
|
||||
ST_SRID(ST_GeomFromText('POINT($request->lng $request->lat)'), 4326))"
|
||||
)
|
||||
->firstOrFail(['id', 'name_fa', 'province_id']);
|
||||
}
|
||||
catch (ModelNotFoundException $exception){
|
||||
$city = City::query()
|
||||
->orderByRaw("ST_Distance(
|
||||
geometry,
|
||||
ST_SRID(ST_GeomFromText('POINT($request->lng $request->lat)'), 4326)
|
||||
) ASC"
|
||||
)
|
||||
->first(['id', 'name_fa', 'province_id']);
|
||||
}
|
||||
|
||||
$state = HarimStates::BARESI_EDARE_SHAHRESTAN->value;
|
||||
|
||||
Harim::query()->create([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
'panjare_vahed_id' => $request->id,
|
||||
'national_id' => $request->national_id,
|
||||
'phone_number' => $request->phone_number,
|
||||
'request_date' => $request->request_date,
|
||||
'province_id' => $city->province_id,
|
||||
'province_name' => $city->province()->first()->name_fa,
|
||||
'city_id' => $city->id,
|
||||
'city_name' => $city->name,
|
||||
'edareh_shahri_id' => $city->edarateShahri()->first()->id,
|
||||
'requested_organization' => $request->organization,
|
||||
'plan_group' => $request->plan_group,
|
||||
'plan_title' => $request->plan_title,
|
||||
'worksheet_id' => $request->worksheet_id,
|
||||
'response_options' => json_encode($request->response_options),
|
||||
'isic' => $request->isic,
|
||||
'primary_area' => $request->primary_area,
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
return $this->successResponse([
|
||||
'city' => $city->edarateShahri()->first()->name_fa,
|
||||
'province' => $city->province()->first()->name_fa,
|
||||
]);
|
||||
}
|
||||
public function getAccessRoad(GetAccessRoadRequest $request, Harim $harim)
|
||||
{
|
||||
|
||||
@@ -72,14 +72,12 @@ class ControlUnitController extends Controller
|
||||
|
||||
public function noProcess(NoProcessRequest $request): JsonResponse
|
||||
{
|
||||
|
||||
DB::transaction(function () use ($request) {
|
||||
$user = auth()->user();
|
||||
$zone= $request->zone;
|
||||
$type= MissionTypes::NO_PROCESS->value;
|
||||
$state = MissionStates::CREATED_NO_PROCESS->value;
|
||||
|
||||
|
||||
$mission = Mission::query()->create([
|
||||
'user_id' => $user->id,
|
||||
'username' => $user->username,
|
||||
@@ -107,6 +105,7 @@ class ControlUnitController extends Controller
|
||||
$mission->machines()->attach($request->machines);
|
||||
$mission->rahdaran()->attach($request->driver, ['is_driver' => true]);
|
||||
});
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,15 @@ class SendDataToFMSListener implements ShouldQueue
|
||||
*/
|
||||
public function handle(SendDataToFMSEvent $event): void
|
||||
{
|
||||
$this->getErrorRateService->run($event->mission);
|
||||
$mission = $event->mission;
|
||||
|
||||
$this->getErrorRateService->setInputParameters([
|
||||
'area' => $mission->area,
|
||||
'start_date' => $mission->start_date,
|
||||
'end_date' => $mission->end_date,
|
||||
'machine_code' => $mission->machines()->first('cmms_machines.machine_code')
|
||||
]);
|
||||
|
||||
$this->getErrorRateService->run();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class City extends Model
|
||||
'geometry',
|
||||
];
|
||||
|
||||
public function province()
|
||||
public function province(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo('App\Models\Province');
|
||||
}
|
||||
@@ -76,7 +76,7 @@ class City extends Model
|
||||
return $this->hasMany('App\Models\RoadConstructionRural');
|
||||
}
|
||||
|
||||
public function edarateShahri()
|
||||
public function edarateShahri(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany('App\Models\EdarateShahri', 'edarate_shahri_be_city')->withPivot('is_primary','id');
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ return new class extends Migration
|
||||
$table->string('payment_amount')->nullable();
|
||||
$table->boolean('need_access_road')->nullable();
|
||||
$table->boolean('access_road_allowed')->nullable();
|
||||
$table->string('lat')->nullable();
|
||||
$table->string('lng')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user