diff --git a/app/Console/Commands/BiAng/DeviceLogDailyReportCommand.php b/app/Console/Commands/BiAng/DeviceLogDailyReportCommand.php index 8990b64..53c7611 100644 --- a/app/Console/Commands/BiAng/DeviceLogDailyReportCommand.php +++ b/app/Console/Commands/BiAng/DeviceLogDailyReportCommand.php @@ -12,6 +12,7 @@ use App\Models\SoilMonitoringDailyLog; use App\Models\SoilMonitoringLog; use App\Services\BiAngDeviceService; use Illuminate\Console\Command; +use Throwable; class DeviceLogDailyReportCommand extends Command { @@ -43,11 +44,15 @@ class DeviceLogDailyReportCommand extends Command $sleep = (int) value(fn ($sleep) => is_numeric($sleep) ? $sleep : 300, $this->option('sleep')); while (true) { - /** @var \Illuminate\Database\Eloquent\Collection */ - $devices = Device::supplierBy("device-supplier-biang")->get(); + try { + /** @var \Illuminate\Database\Eloquent\Collection */ + $devices = Device::supplierBy("device-supplier-biang")->get(); - foreach ($devices as $device) { - $this->createReport($device); + foreach ($devices as $device) { + $this->createReport($device); + } + } catch (Throwable $e) { + report($e); } sleep($sleep); diff --git a/app/Console/Commands/BiAng/DeviceLogReportCommand.php b/app/Console/Commands/BiAng/DeviceLogReportCommand.php index 92b1ee9..aa3a110 100644 --- a/app/Console/Commands/BiAng/DeviceLogReportCommand.php +++ b/app/Console/Commands/BiAng/DeviceLogReportCommand.php @@ -10,6 +10,7 @@ use App\Models\MeteorologicalMonitoringLog; use App\Models\SoilMonitoringLog; use App\Services\BiAngDeviceService; use Illuminate\Console\Command; +use Throwable; class DeviceLogReportCommand extends Command { @@ -41,11 +42,15 @@ class DeviceLogReportCommand extends Command $sleep = (int) value(fn ($sleep) => is_numeric($sleep) ? $sleep : 300, $this->option('sleep')); while (true) { - /** @var \Illuminate\Database\Eloquent\Collection */ - $devices = Device::supplierBy("device-supplier-biang")->get(); + try { + /** @var \Illuminate\Database\Eloquent\Collection */ + $devices = Device::supplierBy("device-supplier-biang")->get(); - foreach ($devices as $device) { - $this->createReport($device); + foreach ($devices as $device) { + $this->createReport($device); + } + } catch (Throwable $e) { + report($e); } sleep($sleep); diff --git a/app/Console/Commands/BiAng/DeviceLogSyncCommand.php b/app/Console/Commands/BiAng/DeviceLogSyncCommand.php index 8c48b65..1f93b16 100644 --- a/app/Console/Commands/BiAng/DeviceLogSyncCommand.php +++ b/app/Console/Commands/BiAng/DeviceLogSyncCommand.php @@ -39,7 +39,11 @@ class DeviceLogSyncCommand extends Command $sleep = (int) value(fn ($sleep) => is_numeric($sleep) ? $sleep : 60, $this->option('sleep')); while (true) { - $this->sync(); + try { + $this->sync(); + } catch (Throwable $e) { + report($e); + } sleep($sleep); }; diff --git a/app/Console/Commands/YunFei/DeviceLogDailyReportCommand.php b/app/Console/Commands/YunFei/DeviceLogDailyReportCommand.php index e3b3b72..42203f0 100644 --- a/app/Console/Commands/YunFei/DeviceLogDailyReportCommand.php +++ b/app/Console/Commands/YunFei/DeviceLogDailyReportCommand.php @@ -8,6 +8,7 @@ use App\Models\InsecticidalLampDailyReport; use App\Models\InsecticidalLampReport; use App\Services\YunFeiDeviceService; use Illuminate\Console\Command; +use Throwable; class DeviceLogDailyReportCommand extends Command { @@ -39,11 +40,15 @@ class DeviceLogDailyReportCommand extends Command $seconds = (int) value(fn ($seconds) => is_numeric($seconds) ? $seconds : 300, $this->option('sleep')); while (true) { - /** @var \Illuminate\Database\Eloquent\Collection */ - $devices = Device::supplierBy('device-supplier-yunfei')->get(); + try { + /** @var \Illuminate\Database\Eloquent\Collection */ + $devices = Device::supplierBy('device-supplier-yunfei')->get(); - foreach ($devices as $device) { - $this->createReport($device); + foreach ($devices as $device) { + $this->createReport($device); + } + } catch (Throwable $e) { + report($e); } sleep($seconds); diff --git a/app/Console/Commands/YunFei/DeviceLogReportCommand.php b/app/Console/Commands/YunFei/DeviceLogReportCommand.php index dec4e8c..a872d2c 100644 --- a/app/Console/Commands/YunFei/DeviceLogReportCommand.php +++ b/app/Console/Commands/YunFei/DeviceLogReportCommand.php @@ -8,6 +8,7 @@ use App\Models\DeviceLog; use App\Models\InsecticidalLampReport; use App\Services\YunFeiDeviceService; use Illuminate\Console\Command; +use Throwable; class DeviceLogReportCommand extends Command { @@ -39,11 +40,15 @@ class DeviceLogReportCommand extends Command $seconds = (int) value(fn ($seconds) => is_numeric($seconds) ? $seconds : 300, $this->option('sleep')); while (true) { - /** @var \Illuminate\Database\Eloquent\Collection */ - $devices = Device::supplierBy('device-supplier-yunfei')->get(); + try { + /** @var \Illuminate\Database\Eloquent\Collection */ + $devices = Device::supplierBy('device-supplier-yunfei')->get(); - foreach ($devices as $device) { - $this->createReport($device); + foreach ($devices as $device) { + $this->createReport($device); + } + } catch (Throwable $e) { + report($e); } sleep($seconds); diff --git a/app/Console/Commands/YunFei/WormReportCommand.php b/app/Console/Commands/YunFei/WormReportCommand.php index 4d6b88e..aad89ef 100644 --- a/app/Console/Commands/YunFei/WormReportCommand.php +++ b/app/Console/Commands/YunFei/WormReportCommand.php @@ -11,6 +11,7 @@ use Illuminate\Console\Command; use Illuminate\Support\Arr; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Storage; +use Throwable; class WormReportCommand extends Command { @@ -37,15 +38,19 @@ class WormReportCommand extends Command $seconds = (int) value(fn ($seconds) => is_numeric($seconds) ? $seconds : 60, $this->option('sleep')); while (true) { - /** @var \Illuminate\Database\Eloquent\Collection */ - $devices = Device::with(['project']) - ->supplierBy('device-supplier-yunfei') - ->where('type', DeviceType::Worm) - ->get(); + try { + /** @var \Illuminate\Database\Eloquent\Collection */ + $devices = Device::with(['project']) + ->supplierBy('device-supplier-yunfei') + ->where('type', DeviceType::Worm) + ->get(); - foreach ($devices as $device) { - $this->info('=================================='); - $this->createReport($device); + foreach ($devices as $device) { + $this->info('=================================='); + $this->createReport($device); + } + } catch (Throwable $e) { + report($e); } sleep($seconds);