优化命令
parent
9407d89f23
commit
5bd37b9ce4
|
|
@ -12,6 +12,7 @@ use App\Models\SoilMonitoringDailyLog;
|
||||||
use App\Models\SoilMonitoringLog;
|
use App\Models\SoilMonitoringLog;
|
||||||
use App\Services\BiAngDeviceService;
|
use App\Services\BiAngDeviceService;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class DeviceLogDailyReportCommand extends Command
|
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'));
|
$sleep = (int) value(fn ($sleep) => is_numeric($sleep) ? $sleep : 300, $this->option('sleep'));
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
/** @var \Illuminate\Database\Eloquent\Collection */
|
try {
|
||||||
$devices = Device::supplierBy("device-supplier-biang")->get();
|
/** @var \Illuminate\Database\Eloquent\Collection */
|
||||||
|
$devices = Device::supplierBy("device-supplier-biang")->get();
|
||||||
|
|
||||||
foreach ($devices as $device) {
|
foreach ($devices as $device) {
|
||||||
$this->createReport($device);
|
$this->createReport($device);
|
||||||
|
}
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
report($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep($sleep);
|
sleep($sleep);
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ use App\Models\MeteorologicalMonitoringLog;
|
||||||
use App\Models\SoilMonitoringLog;
|
use App\Models\SoilMonitoringLog;
|
||||||
use App\Services\BiAngDeviceService;
|
use App\Services\BiAngDeviceService;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class DeviceLogReportCommand extends Command
|
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'));
|
$sleep = (int) value(fn ($sleep) => is_numeric($sleep) ? $sleep : 300, $this->option('sleep'));
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
/** @var \Illuminate\Database\Eloquent\Collection */
|
try {
|
||||||
$devices = Device::supplierBy("device-supplier-biang")->get();
|
/** @var \Illuminate\Database\Eloquent\Collection */
|
||||||
|
$devices = Device::supplierBy("device-supplier-biang")->get();
|
||||||
|
|
||||||
foreach ($devices as $device) {
|
foreach ($devices as $device) {
|
||||||
$this->createReport($device);
|
$this->createReport($device);
|
||||||
|
}
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
report($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep($sleep);
|
sleep($sleep);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,11 @@ class DeviceLogSyncCommand extends Command
|
||||||
$sleep = (int) value(fn ($sleep) => is_numeric($sleep) ? $sleep : 60, $this->option('sleep'));
|
$sleep = (int) value(fn ($sleep) => is_numeric($sleep) ? $sleep : 60, $this->option('sleep'));
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
$this->sync();
|
try {
|
||||||
|
$this->sync();
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
report($e);
|
||||||
|
}
|
||||||
|
|
||||||
sleep($sleep);
|
sleep($sleep);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use App\Models\InsecticidalLampDailyReport;
|
||||||
use App\Models\InsecticidalLampReport;
|
use App\Models\InsecticidalLampReport;
|
||||||
use App\Services\YunFeiDeviceService;
|
use App\Services\YunFeiDeviceService;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class DeviceLogDailyReportCommand extends Command
|
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'));
|
$seconds = (int) value(fn ($seconds) => is_numeric($seconds) ? $seconds : 300, $this->option('sleep'));
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
/** @var \Illuminate\Database\Eloquent\Collection */
|
try {
|
||||||
$devices = Device::supplierBy('device-supplier-yunfei')->get();
|
/** @var \Illuminate\Database\Eloquent\Collection */
|
||||||
|
$devices = Device::supplierBy('device-supplier-yunfei')->get();
|
||||||
|
|
||||||
foreach ($devices as $device) {
|
foreach ($devices as $device) {
|
||||||
$this->createReport($device);
|
$this->createReport($device);
|
||||||
|
}
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
report($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep($seconds);
|
sleep($seconds);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use App\Models\DeviceLog;
|
||||||
use App\Models\InsecticidalLampReport;
|
use App\Models\InsecticidalLampReport;
|
||||||
use App\Services\YunFeiDeviceService;
|
use App\Services\YunFeiDeviceService;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class DeviceLogReportCommand extends Command
|
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'));
|
$seconds = (int) value(fn ($seconds) => is_numeric($seconds) ? $seconds : 300, $this->option('sleep'));
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
/** @var \Illuminate\Database\Eloquent\Collection */
|
try {
|
||||||
$devices = Device::supplierBy('device-supplier-yunfei')->get();
|
/** @var \Illuminate\Database\Eloquent\Collection */
|
||||||
|
$devices = Device::supplierBy('device-supplier-yunfei')->get();
|
||||||
|
|
||||||
foreach ($devices as $device) {
|
foreach ($devices as $device) {
|
||||||
$this->createReport($device);
|
$this->createReport($device);
|
||||||
|
}
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
report($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep($seconds);
|
sleep($seconds);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class WormReportCommand extends Command
|
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'));
|
$seconds = (int) value(fn ($seconds) => is_numeric($seconds) ? $seconds : 60, $this->option('sleep'));
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
/** @var \Illuminate\Database\Eloquent\Collection */
|
try {
|
||||||
$devices = Device::with(['project'])
|
/** @var \Illuminate\Database\Eloquent\Collection */
|
||||||
->supplierBy('device-supplier-yunfei')
|
$devices = Device::with(['project'])
|
||||||
->where('type', DeviceType::Worm)
|
->supplierBy('device-supplier-yunfei')
|
||||||
->get();
|
->where('type', DeviceType::Worm)
|
||||||
|
->get();
|
||||||
|
|
||||||
foreach ($devices as $device) {
|
foreach ($devices as $device) {
|
||||||
$this->info('==================================');
|
$this->info('==================================');
|
||||||
$this->createReport($device);
|
$this->createReport($device);
|
||||||
|
}
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
report($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep($seconds);
|
sleep($seconds);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue