优化命令
parent
9407d89f23
commit
5bd37b9ce4
|
|
@ -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,12 +44,16 @@ class DeviceLogDailyReportCommand extends Command
|
|||
$sleep = (int) value(fn ($sleep) => is_numeric($sleep) ? $sleep : 300, $this->option('sleep'));
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
/** @var \Illuminate\Database\Eloquent\Collection */
|
||||
$devices = Device::supplierBy("device-supplier-biang")->get();
|
||||
|
||||
foreach ($devices as $device) {
|
||||
$this->createReport($device);
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
|
||||
sleep($sleep);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,12 +42,16 @@ class DeviceLogReportCommand extends Command
|
|||
$sleep = (int) value(fn ($sleep) => is_numeric($sleep) ? $sleep : 300, $this->option('sleep'));
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
/** @var \Illuminate\Database\Eloquent\Collection */
|
||||
$devices = Device::supplierBy("device-supplier-biang")->get();
|
||||
|
||||
foreach ($devices as $device) {
|
||||
$this->createReport($device);
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
|
||||
sleep($sleep);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -39,7 +39,11 @@ class DeviceLogSyncCommand extends Command
|
|||
$sleep = (int) value(fn ($sleep) => is_numeric($sleep) ? $sleep : 60, $this->option('sleep'));
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
$this->sync();
|
||||
} catch (Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
|
||||
sleep($sleep);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,12 +40,16 @@ class DeviceLogDailyReportCommand extends Command
|
|||
$seconds = (int) value(fn ($seconds) => is_numeric($seconds) ? $seconds : 300, $this->option('sleep'));
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
/** @var \Illuminate\Database\Eloquent\Collection */
|
||||
$devices = Device::supplierBy('device-supplier-yunfei')->get();
|
||||
|
||||
foreach ($devices as $device) {
|
||||
$this->createReport($device);
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
|
||||
sleep($seconds);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,12 +40,16 @@ class DeviceLogReportCommand extends Command
|
|||
$seconds = (int) value(fn ($seconds) => is_numeric($seconds) ? $seconds : 300, $this->option('sleep'));
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
/** @var \Illuminate\Database\Eloquent\Collection */
|
||||
$devices = Device::supplierBy('device-supplier-yunfei')->get();
|
||||
|
||||
foreach ($devices as $device) {
|
||||
$this->createReport($device);
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
|
||||
sleep($seconds);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,6 +38,7 @@ class WormReportCommand extends Command
|
|||
$seconds = (int) value(fn ($seconds) => is_numeric($seconds) ? $seconds : 60, $this->option('sleep'));
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
/** @var \Illuminate\Database\Eloquent\Collection */
|
||||
$devices = Device::with(['project'])
|
||||
->supplierBy('device-supplier-yunfei')
|
||||
|
|
@ -47,6 +49,9 @@ class WormReportCommand extends Command
|
|||
$this->info('==================================');
|
||||
$this->createReport($device);
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
|
||||
sleep($seconds);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue