Merge branch 'feature/ActivityStatistic' into 'develop'
Feature/activity statistic See merge request witelgroup/rms_v2!90
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -32,15 +32,14 @@ class SendRoadObservationToNikarayanCommand extends Command
|
|||||||
$count = 0;
|
$count = 0;
|
||||||
$this->info("Dispatching jobs with a delay between each...");
|
$this->info("Dispatching jobs with a delay between each...");
|
||||||
|
|
||||||
DB::transaction(function () use ($count) {
|
DB::transaction(function () use (&$count) {
|
||||||
$delay = 0;
|
$delay = 0;
|
||||||
RoadObserved::query()
|
RoadObserved::query()
|
||||||
->whereBetween('StartTime_DateTime_fa', ['1403-01-01 00:00:00', '1403-07-13 23:59:59'])
|
->whereBetween('StartTime_DateTime_fa', ['1403-01-01 00:00:00', '1403-07-13 23:59:59'])
|
||||||
->where('rms_status', '=', 0)
|
->chunkById(50, function ($roads) use (&$delay, &$count) {
|
||||||
->chunkById(50, function ($roads) use ($delay, $count) {
|
|
||||||
foreach ($roads as $road) {
|
foreach ($roads as $road) {
|
||||||
$road->update(['rms_status' => 1]);
|
$road->update(['status' => 1]);
|
||||||
SendRoadObservationToNikarayan::dispatch($road)->delay(now()->addMinutes(10)->addSeconds($delay));
|
SendRoadObservationToNikarayan::dispatch($road)->delay(now()->addSeconds($delay));
|
||||||
Log::channel('road_observation_problem')->info("Job for Road Observed ID {$road->id} scheduled with a {$delay} seconds delay.");
|
Log::channel('road_observation_problem')->info("Job for Road Observed ID {$road->id} scheduled with a {$delay} seconds delay.");
|
||||||
$this->info("Scheduled job for Road ID: {$road->id} {$delay}s");
|
$this->info("Scheduled job for Road ID: {$road->id} {$delay}s");
|
||||||
$delay += 3;
|
$delay += 3;
|
||||||
|
|||||||
2643
app/Enums/NikarayanComplaints.php
Normal file
2643
app/Enums/NikarayanComplaints.php
Normal file
File diff suppressed because it is too large
Load Diff
26
app/Exceptions/ProhibitedAction.php
Normal file
26
app/Exceptions/ProhibitedAction.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class ProhibitedAction extends Exception
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function __construct(public $message = "", int $code = 422, ?Throwable $previous = null)
|
||||||
|
{
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the exception into an HTTP response.
|
||||||
|
*/
|
||||||
|
public function render(): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->errorResponse($this->message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ use App\Models\LogList;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
class LogListController extends Controller
|
class LogListManagementController extends Controller
|
||||||
{
|
{
|
||||||
use ApiResponse;
|
use ApiResponse;
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ class LogListController extends Controller
|
|||||||
|
|
||||||
public function update(UpdateRequest $request, LogList $logList): JsonResponse
|
public function update(UpdateRequest $request, LogList $logList): JsonResponse
|
||||||
{
|
{
|
||||||
LogList::query()->update([
|
$logList->update([
|
||||||
'description' => $request->description,
|
'description' => $request->description,
|
||||||
'log_unique_code' => $request->log_unique_code,
|
'log_unique_code' => $request->log_unique_code,
|
||||||
'action_type' => $request->action_type,
|
'action_type' => $request->action_type,
|
||||||
197
app/Http/Controllers/V3/NotificationController.php
Normal file
197
app/Http/Controllers/V3/NotificationController.php
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3;
|
||||||
|
|
||||||
|
use App\Exceptions\ProhibitedAction;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use App\Models\EdarateOstani;
|
||||||
|
use App\Models\RoadItemsProject;
|
||||||
|
use App\Models\RoadObserved;
|
||||||
|
use App\Models\SafetyAndPrivacy;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class NotificationController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the incoming request.
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
|
public function __invoke(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse([
|
||||||
|
'roadItem' => $this->roadItemNotifications(),
|
||||||
|
'safetyAndPrivacy' => $this->safetyAndPrivacyNotifications(),
|
||||||
|
'roadObserved' => $this->roadObservedNotifications(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
|
private function roadItemNotifications(): JsonResponse|array
|
||||||
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
$road_items = [
|
||||||
|
'total' => 0
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($user->hasPermissionTo('create-road-item')) {
|
||||||
|
$road_items['operation_cnt'] = RoadItemsProject::query()
|
||||||
|
->where('is_new', '=', 1)
|
||||||
|
->where('user_id', '=', $user->id)
|
||||||
|
->where('status', '=', 2)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$road_items['total'] += $road_items['operation_cnt'];
|
||||||
|
}
|
||||||
|
if ($user->hasPermissionTo('supervise-road-item')) {
|
||||||
|
$road_items['supervise_cnt'] = RoadItemsProject::query()
|
||||||
|
->where('is_new', '=', 1)
|
||||||
|
->where('status', '=', 0)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$road_items['total'] += $road_items['supervise_cnt'];
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('supervise-road-item-province')) {
|
||||||
|
throw_if(is_null($user->province_id) || !$user->province_id, new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
|
||||||
|
|
||||||
|
$road_items['supervise_cnt'] = RoadItemsProject::query()
|
||||||
|
->where('is_new', '=', 1)
|
||||||
|
->where('province_id', '=', $user->province_id)
|
||||||
|
->where('status', '=', 0)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$road_items['total'] += $road_items['supervise_cnt'];
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('supervise-road-item-by-edareostani')) {
|
||||||
|
throw_if(is_null($user->edarate_ostani_id) || !$user->edarate_ostani_id, new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!'));
|
||||||
|
|
||||||
|
$confirmableItems = EdarateOstani::query()->where('id', '=', $user->edarate_ostani_id)->value('items_for_confirm');
|
||||||
|
$road_items['supervise_cnt'] = RoadItemsProject::query()
|
||||||
|
->where('is_new', '=', 1)
|
||||||
|
->where('province_id', '=', $user->province_id)
|
||||||
|
->whereIn('item', explode(",", $confirmableItems))
|
||||||
|
->where('status', '=', 0)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$road_items['total'] += $road_items['supervise_cnt'];
|
||||||
|
}
|
||||||
|
return $road_items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
|
private function safetyAndPrivacyNotifications(): JsonResponse|array
|
||||||
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
$safety_and_privacy = array();
|
||||||
|
if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable')) {
|
||||||
|
$activity = SafetyAndPrivacy::query()
|
||||||
|
->selectRaw('count(*) as cnt, step')
|
||||||
|
->groupby('step')
|
||||||
|
->orderBy('step')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-province')) {
|
||||||
|
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
|
||||||
|
|
||||||
|
$activity = SafetyAndPrivacy::query()
|
||||||
|
->where('province_id', '=', $user->province_id)
|
||||||
|
->selectRaw('count(*) as cnt, step')
|
||||||
|
->groupby('step')
|
||||||
|
->orderBy('step')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-edarate-shahri')) {
|
||||||
|
throw_if(is_null($user->edarate_shahri_id), new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!'));
|
||||||
|
|
||||||
|
$activity = SafetyAndPrivacy::query()
|
||||||
|
->where('edare_shahri_id', '=', $user->edarate_shahri_id)
|
||||||
|
->selectRaw('count(*) as cnt, step')
|
||||||
|
->groupby('step')
|
||||||
|
->orderBy('step')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$safety_and_privacy['step_one'] = isset($activity[0]) ? $activity[0]->cnt : 0;
|
||||||
|
$safety_and_privacy['step_two'] = isset($activity[1]) ? $activity[1]->cnt : 0;
|
||||||
|
|
||||||
|
return $safety_and_privacy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
|
private function roadObservedNotifications(): JsonResponse|array
|
||||||
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
$road_observations = [
|
||||||
|
'total' => 0,
|
||||||
|
'operation_cnt' => 0,
|
||||||
|
'complaint_cnt' => 0,
|
||||||
|
'supervise_cnt' => 0
|
||||||
|
];
|
||||||
|
|
||||||
|
$conditions = [];
|
||||||
|
$complaintConditions = [
|
||||||
|
['rms_status', '=', 0],
|
||||||
|
['edarate_shahri_id', '!=', null]
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($user->hasPermissionTo('show-fast-react')) {
|
||||||
|
$conditions[] = ['status', '=', 2];
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('show-fast-react-province')) {
|
||||||
|
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
|
||||||
|
$conditions = [
|
||||||
|
['status', '=', 2],
|
||||||
|
['rms_province_id', '=', $user->province_id]
|
||||||
|
];
|
||||||
|
$complaintConditions[] = ['province_id', '=', $user->province_id];
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('show-fast-react-edarate-shahri')) {
|
||||||
|
throw_if(is_null($user->edarate_shahri_id), new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!'));
|
||||||
|
$conditions = [
|
||||||
|
['status', '=', 2],
|
||||||
|
['edarate_shahri_id', '=', $user->edarate_shahri_id]
|
||||||
|
];
|
||||||
|
$complaintConditions[] = ['edarate_shahri_id', '=', $user->edarate_shahri_id];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($conditions)) {
|
||||||
|
$road_observations['operation_cnt'] = RoadObserved::query()->where($conditions)->count();
|
||||||
|
$road_observations['complaint_cnt'] = RoadObserved::query()->where($complaintConditions)->count();
|
||||||
|
$road_observations['total'] += $road_observations['operation_cnt'] + $road_observations['complaint_cnt'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$superviseConditions = [
|
||||||
|
['status', '=', 0]
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($user->hasPermissionTo('supervise-fast-react')) {
|
||||||
|
$road_observations['supervise_cnt'] = RoadObserved::query()->where($superviseConditions)->count();
|
||||||
|
$road_observations['complaint_cnt'] = RoadObserved::query()->where($complaintConditions)->count();
|
||||||
|
$road_observations['total'] += $road_observations['supervise_cnt'] + $road_observations['complaint_cnt'];
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('supervise-fast-react-province')) {
|
||||||
|
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
|
||||||
|
$superviseConditions[] = ['province_id', '=', $user->province_id];
|
||||||
|
$complaintConditions[] = ['province_id', '=', $user->province_id];
|
||||||
|
|
||||||
|
$road_observations['supervise_cnt'] = RoadObserved::query()->where($superviseConditions)->count();
|
||||||
|
$road_observations['complaint_cnt'] = RoadObserved::query()->where($complaintConditions)->count();
|
||||||
|
$road_observations['total'] += $road_observations['supervise_cnt'] + $road_observations['complaint_cnt'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $road_observations;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ class StoreRequest extends FormRequest
|
|||||||
return [
|
return [
|
||||||
'name' => 'required|string|unique:permissions,name',
|
'name' => 'required|string|unique:permissions,name',
|
||||||
'name_fa' => 'required|string',
|
'name_fa' => 'required|string',
|
||||||
'description' => 'required|string',
|
'description' => 'string',
|
||||||
'type' => 'required|string',
|
'type' => 'required|string',
|
||||||
'type_fa' => 'required|string',
|
'type_fa' => 'required|string',
|
||||||
'need_province' => 'required|in:0,1',
|
'need_province' => 'required|in:0,1',
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class UpdateRequest extends FormRequest
|
|||||||
return [
|
return [
|
||||||
'name' => "required|string|unique:permissions,name,{$this->permission->id}",
|
'name' => "required|string|unique:permissions,name,{$this->permission->id}",
|
||||||
'name_fa' => 'required|string',
|
'name_fa' => 'required|string',
|
||||||
'description' => 'required|string',
|
'description' => 'string',
|
||||||
'type' => 'required|string',
|
'type' => 'required|string',
|
||||||
'type_fa' => 'required|string',
|
'type_fa' => 'required|string',
|
||||||
'need_province' => 'required|in:0,1',
|
'need_province' => 'required|in:0,1',
|
||||||
|
|||||||
@@ -15,6 +15,13 @@ class SendRoadObservationToNikarayan implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of times the job may be attempted.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public int $tries = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,31 +5,71 @@ namespace App\Services;
|
|||||||
use App\Models\RoadObserved;
|
use App\Models\RoadObserved;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use SoapClient;
|
use SoapClient;
|
||||||
|
use SoapFault;
|
||||||
|
|
||||||
class NikarayanService
|
class NikarayanService
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @throws SoapFault
|
||||||
|
*/
|
||||||
public function updateRoadObservedInfoByNikarayan(Request $request, RoadObserved $roadObserved, $files)
|
public function updateRoadObservedInfoByNikarayan(Request $request, RoadObserved $roadObserved, $files)
|
||||||
{
|
{
|
||||||
if (App::isProduction())
|
if (App::isProduction())
|
||||||
{
|
{
|
||||||
$url = "https://riws.rmto.ir/WebServices/NRPTrafficStatus.asmx?wsdl";
|
try {
|
||||||
|
$url = "https://riws.rmto.ir/WebServices/NRPTrafficStatus.asmx?wsdl";
|
||||||
|
|
||||||
$array = array('strUserName' => 'vaytelrop',
|
$array = array('strUserName' => 'vaytelrop',
|
||||||
'strPassword' => 'VaYtelROP*2024',
|
'strPassword' => 'VaYtelROP*2024',
|
||||||
'strAutoID' => $roadObserved->fk_RegisteredEventMessage,
|
'strAutoID' => $roadObserved->fk_RegisteredEventMessage,
|
||||||
'strStateID' => ($request->input('rms-status') == 1) ? '2' : '3',
|
'strStateID' => ($request->input('rms-status') == 1) ? '2' : '3',
|
||||||
'strDescription' => $request->input('rms-description') ?? $roadObserved->rms_description,
|
'strDescription' => $request->input('rms-description') ?? $roadObserved->rms_description,
|
||||||
'strPreviousImageLink' => "https://rms.rmto.ir/".$files,
|
'strPreviousImageLink' => "https://rms.rmto.ir/".$files,
|
||||||
'strNextImageLink' => "https://rms.rmto.ir/".$files,
|
'strNextImageLink' => "https://rms.rmto.ir/".$files,
|
||||||
'strRMSDateAndTime' => $roadObserved->updated_at
|
'strRMSDateAndTime' => $roadObserved->updated_at
|
||||||
);
|
);
|
||||||
|
|
||||||
$soapClient = new SoapClient($url);
|
$soapClient = new SoapClient($url);
|
||||||
|
$result = $soapClient->UpdateInfo_RoadObservedProblems($array);
|
||||||
|
Log::channel('nikarayan')->info($result);
|
||||||
|
|
||||||
return $soapClient->UpdateInfo_RoadObservedProblems($array);
|
return $result;
|
||||||
|
}
|
||||||
|
catch (\Exception $e) {
|
||||||
|
Log::channel('nikarayan')->error($e->getMessage());
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws SoapFault
|
||||||
|
*/
|
||||||
|
public function getRoadObservedProblemsByDate()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$url = "https://riws.rmto.ir/WebServices/NRPTrafficStatus.asmx?wsdl";
|
||||||
|
|
||||||
|
$v = verta();
|
||||||
|
$month = $v->month < 10 ? '0' . $v->month : $v->month;
|
||||||
|
$day = $v->day < 10 ? '0' . $v->day : $v->day;
|
||||||
|
$date = $v->year . $month . $day;
|
||||||
|
|
||||||
|
$soap_client = new SoapClient($url);
|
||||||
|
return $soap_client->Get_RoadObservedProblems_ByDate(array(
|
||||||
|
'strUserName' => 'vaytelrop',
|
||||||
|
'strPassword' => 'VaYtelROP*2024',
|
||||||
|
'strStartDate' => $date,
|
||||||
|
'strEndDate' => $date
|
||||||
|
));
|
||||||
|
}
|
||||||
|
catch (\Exception $e) {
|
||||||
|
Log::channel('nikarayan')->error($e->getMessage());
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,62 +2,82 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class NominatimService
|
class NominatimService
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
public function get_way_id_from_nominatim($lat = null, $lng = null)
|
public function get_way_id_from_nominatim($lat = null, $lng = null)
|
||||||
{
|
{
|
||||||
if (App::isProduction())
|
if (App::isProduction())
|
||||||
{
|
{
|
||||||
$url = "https://testmap.141.ir/nominatim/reverse?format=jsonv2&lat=".$lat."&lon=".$lng."&zoom=16&addressdetails=16";
|
try {
|
||||||
$arrContextOptions=array(
|
$url = "https://testmap.141.ir/nominatim/reverse?format=jsonv2&lat=".$lat."&lon=".$lng."&zoom=16&addressdetails=16";
|
||||||
"ssl"=>array(
|
$arrContextOptions=array(
|
||||||
"verify_peer"=>false,
|
"ssl"=>array(
|
||||||
"verify_peer_name"=>false,
|
"verify_peer"=>false,
|
||||||
),
|
"verify_peer_name"=>false,
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
|
||||||
$result = file_get_contents($url, false, stream_context_create($arrContextOptions));
|
$result = file_get_contents($url, false, stream_context_create($arrContextOptions));
|
||||||
$result = json_decode($result);
|
$result = json_decode($result);
|
||||||
if (isset($result->osm_type)) {
|
if (isset($result->osm_type)) {
|
||||||
if ($result->osm_type == 'way') {
|
if ($result->osm_type == 'way') {
|
||||||
return $result->osm_id;
|
return $result->osm_id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Log::channel('nominatim')->error($e->getMessage());
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
function getIDFromNominatim($s_lng, $s_lat, $d_lng, $d_lat)
|
function getIDFromNominatim($s_lng, $s_lat, $d_lng, $d_lat)
|
||||||
{
|
{
|
||||||
if (App::isProduction())
|
if (App::isProduction())
|
||||||
{
|
{
|
||||||
$url = "https://testmap.141.ir/route/v1/driving/" . $s_lng . "," . $s_lat . ";" . $d_lng . "," . $d_lat . "?overview=full&alternatives=true&steps=true";
|
try {
|
||||||
$arrContextOptions = array(
|
$url = "https://testmap.141.ir/route/v1/driving/" . $s_lng . "," . $s_lat . ";" . $d_lng . "," . $d_lat . "?overview=full&alternatives=true&steps=true";
|
||||||
"ssl" => array(
|
$arrContextOptions = array(
|
||||||
"verify_peer" => false,
|
"ssl" => array(
|
||||||
"verify_peer_name" => false,
|
"verify_peer" => false,
|
||||||
),
|
"verify_peer_name" => false,
|
||||||
);
|
),
|
||||||
$result = file_get_contents($url, false, stream_context_create($arrContextOptions));
|
);
|
||||||
$result = json_decode($result);
|
$result = file_get_contents($url, false, stream_context_create($arrContextOptions));
|
||||||
if (count($result->routes) > 1 && $result->routes[1]->distance < $result->routes[0]->distance) {
|
$result = json_decode($result);
|
||||||
// if(){
|
if (count($result->routes) > 1 && $result->routes[1]->distance < $result->routes[0]->distance) {
|
||||||
$ways = $result->routes[1]->legs[0]->steps;
|
// if(){
|
||||||
// }
|
$ways = $result->routes[1]->legs[0]->steps;
|
||||||
} else
|
// }
|
||||||
$ways = $result->routes[0]->legs[0]->steps;
|
} else
|
||||||
$ids = array();
|
$ways = $result->routes[0]->legs[0]->steps;
|
||||||
foreach ($ways as $key => $value) {
|
$ids = array();
|
||||||
if (!in_array($value->name, $ids)) {
|
foreach ($ways as $key => $value) {
|
||||||
$ids[] = $value->name;
|
if (!in_array($value->name, $ids)) {
|
||||||
|
$ids[] = $value->name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $ids;
|
return $ids;
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Log::channel('nominatim')->error($e->getMessage());
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [1, 2, 3];
|
return [1, 2, 3];
|
||||||
|
|||||||
@@ -117,6 +117,18 @@ return [
|
|||||||
'path' => storage_path('logs/road_observation_problem.log'),
|
'path' => storage_path('logs/road_observation_problem.log'),
|
||||||
'level' => 'info',
|
'level' => 'info',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'nominatim' => [
|
||||||
|
'driver' => 'single',
|
||||||
|
'path' => storage_path('logs/nominatim.log'),
|
||||||
|
'level' => 'info',
|
||||||
|
],
|
||||||
|
|
||||||
|
'nikarayan' => [
|
||||||
|
'driver' => 'single',
|
||||||
|
'path' => storage_path('logs/nikarayan.log'),
|
||||||
|
'level' => 'info',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ use App\Http\Controllers\V3\Dashboard\RoadPatrolProjectController;
|
|||||||
use App\Http\Controllers\V3\Dashboard\SafetyAndPrivacyController;
|
use App\Http\Controllers\V3\Dashboard\SafetyAndPrivacyController;
|
||||||
use App\Http\Controllers\V3\FMSVehicleManagementController;
|
use App\Http\Controllers\V3\FMSVehicleManagementController;
|
||||||
use App\Http\Controllers\V3\Harim\DivarkeshiController;
|
use App\Http\Controllers\V3\Harim\DivarkeshiController;
|
||||||
use App\Http\Controllers\V3\LogListController;
|
use App\Http\Controllers\V3\LogListManagementController;
|
||||||
|
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\RahdaranController;
|
use App\Http\Controllers\V3\RahdaranController;
|
||||||
@@ -261,6 +262,7 @@ Route::prefix('receipts')
|
|||||||
Route::get('/', 'index')->name('index');
|
Route::get('/', 'index')->name('index');
|
||||||
Route::get('/excel_report', 'excelReport')->name('excelReport');
|
Route::get('/excel_report', 'excelReport')->name('excelReport');
|
||||||
Route::post('/', 'store')->name('store');
|
Route::post('/', 'store')->name('store');
|
||||||
|
Route::get('/accident_types', 'accidentTypes')->name('accidentTypes');
|
||||||
Route::get('/{accident}', 'show')->name('show');
|
Route::get('/{accident}', 'show')->name('show');
|
||||||
Route::post('/{accident}', 'update')->name('update');
|
Route::post('/{accident}', 'update')->name('update');
|
||||||
Route::delete('/{accident}', 'destroy')->name('destroy');
|
Route::delete('/{accident}', 'destroy')->name('destroy');
|
||||||
@@ -270,7 +272,6 @@ Route::prefix('receipts')
|
|||||||
Route::get('/check_payment_status/{accident}', 'checkPaymentStatus')->name('checkPaymentStatus');
|
Route::get('/check_payment_status/{accident}', 'checkPaymentStatus')->name('checkPaymentStatus');
|
||||||
Route::get('/generate_police_document/{accident}', 'generatePoliceDocument')->name('generatePoliceDocument');
|
Route::get('/generate_police_document/{accident}', 'generatePoliceDocument')->name('generatePoliceDocument');
|
||||||
Route::get('/send_sms_again/{accident}', 'sendSmsAgain')->name('sendSmsAgain');
|
Route::get('/send_sms_again/{accident}', 'sendSmsAgain')->name('sendSmsAgain');
|
||||||
Route::get('/accident_types', 'accidentTypes')->name('accidentTypes');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('receipt_reports')
|
Route::prefix('receipt_reports')
|
||||||
@@ -320,7 +321,7 @@ Route::prefix('road_observations')
|
|||||||
|
|
||||||
Route::prefix('log_list')
|
Route::prefix('log_list')
|
||||||
->name('logList.')
|
->name('logList.')
|
||||||
->controller(LogListController::class)
|
->controller(LogListManagementController::class)
|
||||||
->group(function () {
|
->group(function () {
|
||||||
Route::get('/', 'index')->name('index');
|
Route::get('/', 'index')->name('index');
|
||||||
Route::get('/list', 'list')->name('list');
|
Route::get('/list', 'list')->name('list');
|
||||||
@@ -337,9 +338,9 @@ Route::prefix('safety_and_privacy')
|
|||||||
Route::get('/', 'index')->name('index')->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province|show-safety-and-privacy-operator-cartable-edarate-shahri');
|
Route::get('/', 'index')->name('index')->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province|show-safety-and-privacy-operator-cartable-edarate-shahri');
|
||||||
Route::get('/excel_report', 'excelReport')->name('excelReport')->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province|show-safety-and-privacy-operator-cartable-edarate-shahri');
|
Route::get('/excel_report', 'excelReport')->name('excelReport')->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province|show-safety-and-privacy-operator-cartable-edarate-shahri');
|
||||||
Route::post('/first_step_store', 'firstStepStore')->name('firstStepStore')->middleware('permission:add-safety-and-privacy');
|
Route::post('/first_step_store', 'firstStepStore')->name('firstStepStore')->middleware('permission:add-safety-and-privacy');
|
||||||
|
Route::get('/sub_items', 'subItems')->name('subItems');
|
||||||
Route::post('/second_step_store/{safetyAndPrivacy}', 'secondStepStore')->name('secondStepStore')->middleware('permission:add-safety-and-privacy');
|
Route::post('/second_step_store/{safetyAndPrivacy}', 'secondStepStore')->name('secondStepStore')->middleware('permission:add-safety-and-privacy');
|
||||||
Route::post('/third_step_store/{safetyAndPrivacy}', 'thirdStepStore')->name('thirdStepStore')->middleware('permission:add-safety-and-privacy');
|
Route::post('/third_step_store/{safetyAndPrivacy}', 'thirdStepStore')->name('thirdStepStore')->middleware('permission:add-safety-and-privacy');
|
||||||
Route::get('/sub_items', 'subItems')->name('subItems');
|
|
||||||
Route::get('/{safetyAndPrivacy}', 'show')->name('show');
|
Route::get('/{safetyAndPrivacy}', 'show')->name('show');
|
||||||
Route::delete('/{safetyAndPrivacy}', 'destroy')->name('destroy')->middleware('permission:delete-safety-and-privacy');
|
Route::delete('/{safetyAndPrivacy}', 'destroy')->name('destroy')->middleware('permission:delete-safety-and-privacy');
|
||||||
Route::get('/deserialize/{safetyAndPrivacy}', 'deserialize')->name('deserialize');
|
Route::get('/deserialize/{safetyAndPrivacy}', 'deserialize')->name('deserialize');
|
||||||
@@ -379,3 +380,5 @@ Route::prefix('permissions')
|
|||||||
Route::post('/{permission}', 'update')->name('update');
|
Route::post('/{permission}', 'update')->name('update');
|
||||||
Route::delete('/{permission}', 'destroy')->name('destroy');
|
Route::delete('/{permission}', 'destroy')->name('destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::get('/notifications', NotificationController::class)->name('notifications');
|
||||||
|
|||||||
Reference in New Issue
Block a user