refactor the web services
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use SoapFault;
|
use SoapFault;
|
||||||
use SoapClient;
|
use SoapClient;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
@@ -84,6 +85,7 @@ class RoadObservationProblems extends Command
|
|||||||
$msg .= $e->getMessage();
|
$msg .= $e->getMessage();
|
||||||
// self::sms_sender('09398586633', $msg);
|
// self::sms_sender('09398586633', $msg);
|
||||||
// self::sms_sender('09367487107', $msg);
|
// self::sms_sender('09367487107', $msg);
|
||||||
|
Log::channel('nikarayan')->error($e->getMessage());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$result = serialize($result);
|
$result = serialize($result);
|
||||||
@@ -2723,6 +2725,7 @@ class RoadObservationProblems extends Command
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$affectedRows = 0;
|
||||||
$cities = [];
|
$cities = [];
|
||||||
foreach ($xml as $value) {
|
foreach ($xml as $value) {
|
||||||
// if ($value->fk_FeatureType >= 1 && $value->fk_FeatureType <= 6) { //// code ghabli
|
// if ($value->fk_FeatureType >= 1 && $value->fk_FeatureType <= 6) { //// code ghabli
|
||||||
@@ -2781,6 +2784,7 @@ class RoadObservationProblems extends Command
|
|||||||
'city_fa' => $cityModel ? $cityModel->name_fa : null,
|
'city_fa' => $cityModel ? $cityModel->name_fa : null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
$affectedRows += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -2788,9 +2792,11 @@ class RoadObservationProblems extends Command
|
|||||||
$msg = 'rms: error in get data roadobserved babe!!!!' . "\n";
|
$msg = 'rms: error in get data roadobserved babe!!!!' . "\n";
|
||||||
// self::sms_sender('09398586633', $msg);
|
// self::sms_sender('09398586633', $msg);
|
||||||
// self::sms_sender('09367487107', $msg);
|
// self::sms_sender('09367487107', $msg);
|
||||||
|
$this->info('the received body is empty');
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
echo 'done at: ' . date("Y-m-d H:i:s") . "\n";
|
echo 'done at: ' . date("Y-m-d H:i:s") . "\n";
|
||||||
|
$this->info("{$affectedRows} row's affected");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
public function sms_sender($mobile, $msg)
|
public function sms_sender($mobile, $msg)
|
||||||
|
|||||||
@@ -5,29 +5,42 @@ 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;
|
||||||
|
|||||||
@@ -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',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -262,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');
|
||||||
@@ -271,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')
|
||||||
@@ -333,9 +333,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');
|
||||||
|
|||||||
Reference in New Issue
Block a user