add daily mode to nikarayan command
This commit is contained in:
@@ -24,7 +24,7 @@ class RoadObservationProblems extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'webservice:roadobserved';
|
||||
protected $signature = 'webservice:roadobserved {--daily-mode}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -63,7 +63,9 @@ class RoadObservationProblems extends Command
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
$result = $nikarayanService->getRoadObservedProblemsByDate();
|
||||
$time = $this->option('daily-mode') ? verta()->subDay() : verta();
|
||||
|
||||
$result = $nikarayanService->getRoadObservedProblemsByDate($time);
|
||||
|
||||
$result = serialize($result);
|
||||
$x = strpos($result, '<Document');
|
||||
@@ -81,7 +83,7 @@ class RoadObservationProblems extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($value->fk_FeatureType >= 1 && $value->fk_FeatureType <= 18) {
|
||||
if ($value->fk_FeatureType >= 1 && $value->fk_FeatureType <= 24) {
|
||||
$mobile = null;
|
||||
|
||||
if ($value->MobileForSendEventSms && (strlen($value->MobileForSendEventSms) == 11)) {
|
||||
@@ -89,7 +91,7 @@ class RoadObservationProblems extends Command
|
||||
}
|
||||
|
||||
$city = findCityFromGeoJson($value->YGeo, $value->XGeo);
|
||||
$cityModel = $city ? City::find($city['city_id']) : null;
|
||||
$cityModel = $city ? City::query()->find($city['city_id']) : City::query()->find(NikarayanComplaints::mapCities((int) $value->fk_Town));
|
||||
$rop = RoadObserved::query()->updateOrCreate(
|
||||
['fk_RegisteredEventMessage' => $value->fk_RegisteredEventMessage],
|
||||
[
|
||||
@@ -130,7 +132,7 @@ class RoadObservationProblems extends Command
|
||||
'province_id' => $city ? $city['province_id'] : null,
|
||||
'city_id' => $city ? $city['city_id'] : null,
|
||||
// 'handler_type' => EdarateShahri::class,
|
||||
'edarate_shahri_id' => $cityModel ? ($cityModel->edarateShahri()->where('is_primary', 1)->exists() ? $cityModel->edarateShahri()->where('is_primary', 1)->first()->id : null) : null,
|
||||
'edarate_shahri_id' => $cityModel->edarateShahri()->first()->id,
|
||||
'province_fa' => (isset($city['province_id']) ? Province::find($city['province_id'])->name_fa : null),
|
||||
'city_fa' => $cityModel ? $cityModel->name_fa : null,
|
||||
]
|
||||
|
||||
@@ -26,7 +26,7 @@ class Kernel extends ConsoleKernel
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('webservice:roadobserved')
|
||||
->everyFiveMinutes()->appendOutputTo(storage_path('logs/roadobser.log'));
|
||||
->everyFiveMinutes()->appendOutputTo(storage_path('logs/nikarayan.log'));
|
||||
|
||||
$schedule->command('command:sendcontractsmsnotification')
|
||||
// ->everyMinute()->appendOutputTo(storage_path('logs/contractSms.log'));
|
||||
@@ -35,7 +35,8 @@ class Kernel extends ConsoleKernel
|
||||
$schedule->command('reports:rms-summary')
|
||||
->dailyAt('00:00')->appendOutputTo(storage_path('logs/report_summary.log'));
|
||||
|
||||
|
||||
$schedule->command("webservice:roadobserved --daily-mode")
|
||||
->dailyAt('00:15')->appendOutputTo(storage_path('logs/nikarayan.log'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,15 +49,14 @@ class NikarayanService
|
||||
/**
|
||||
* @throws SoapFault
|
||||
*/
|
||||
public function getRoadObservedProblemsByDate()
|
||||
public function getRoadObservedProblemsByDate($time)
|
||||
{
|
||||
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;
|
||||
$month = $time->month < 10 ? '0' . $time->month : $time->month;
|
||||
$day = $time->day < 10 ? '0' . $time->day : $time->day;
|
||||
$date = $time->year . $month . $day;
|
||||
|
||||
$soap_client = new SoapClient($url);
|
||||
return $soap_client->Get_RoadObservedProblems_ByDate(array(
|
||||
|
||||
Reference in New Issue
Block a user